portal html css js resource

index.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. $(function(){
  2. /*向下滚动时,header背景变半透明*/
  3. $(document).scroll(function() {
  4. var top = $(document).scrollTop();
  5. if (top == 0) {
  6. $("#header").css("background", "rgba(255,153,0,1)");
  7. $(".personal-infor").css("opacity", "1");
  8. } else {
  9. $("#header").css("background", "rgba(255,153,0,0.8)");
  10. $(".personal-infor").css("opacity", "0.8");
  11. }
  12. if (top != 0) {
  13. $(".searchbox").fadeIn(1000);
  14. } else {
  15. $(".searchbox").fadeOut(1000);
  16. }
  17. //小搜索框滚动大于等于350,显示在头部
  18. if (top >= 350) {
  19. $("#serc-index").fadeIn(1000);
  20. } else {
  21. $("#serc-index").fadeOut(1000);
  22. }
  23. if (top >= 300) {
  24. $(".content-left").css({
  25. "position": "fixed",
  26. "top": "80px"
  27. })
  28. } else {
  29. $(".content-left").css({
  30. "position": "static"
  31. })
  32. }
  33. });
  34. //加载页面时,判断是否登陆
  35. //
  36. var userid = $.cookie("userid");
  37. if (userid && userid != "null" && userid != null) {
  38. $(".myWorkspace").attr("href","workspaces.html?"+userid);
  39. loginStatus();
  40. }
  41. //登陆个人信息下拉菜单
  42. $('.head-portrait').hover(function() {
  43. $(".personal-infor").stop(true, false).slideDown(500);
  44. }, function() {
  45. $(".personal-infor").stop(true, false).slideUp(500);
  46. });
  47. //搜索框跳转页面
  48. function synContent(type) {
  49. if (type == 1) {
  50. $("#searchContent").val($("#hsearchContent").val());
  51. } else {
  52. $("#hsearchContent").val($("#searchContent").val());
  53. }
  54. }
  55. $("#hsearchContent").blur(function() {
  56. synContent(1);
  57. });
  58. $("#searchContent").blur(function() {
  59. synContent(2);
  60. });
  61. var lookFor = 0;
  62. $("#lookFor ul li").on("click",function(){
  63. lookFor=$(this).index();
  64. console.log(lookFor);
  65. });
  66. $("#search").on("click", function() {
  67. var searchContent = $("#searchContent").val();
  68. location.href = "search.html?searchContent=" + encodeURI(searchContent)+"&lookFor=" + lookFor;
  69. });
  70. //enter绑定时间
  71. $("#searchContent").keydown(function(e){
  72. if(e.which==13) {
  73. synContent(2);
  74. var searchContent = $("#searchContent").val();
  75. console.log(searchContent);
  76. location.href = "search.html?searchContent=" + encodeURI(searchContent)+"&lookFor=" + lookFor;
  77. }
  78. })
  79. $("#hsearchContent").keydown(function(e){
  80. if(e.which==13) {
  81. synContent(1);
  82. var searchContent = $("#hsearchContent").val();
  83. console.log(searchContent);
  84. location.href = "search.html?searchContent=" + encodeURI(searchContent);
  85. }
  86. })
  87. $("#hsearch").on("click", function() {
  88. var searchContent = $("#hsearchContent").val();
  89. location.href = "search.html?searchContent=" + encodeURI(searchContent);
  90. });
  91. //热门领域
  92. $(".field").bind("click",function(){
  93. location.href = "search.html?subject=" + encodeURI($(this).text());
  94. })
  95. //热门专家
  96. $('.professor').hover(function() {
  97. $(this).find(".professor-data").stop(true, false).animate({
  98. "padding": "94px 0",
  99. "top": "-50px"
  100. })
  101. }, function() {
  102. $(this).find(".professor-data").stop(true, false).animate({
  103. "padding": "25px 0",
  104. "top": "58%"
  105. })
  106. })
  107. })