base.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. $(function(){
  2. //顶部导航
  3. $(".header-member-login").hover(function(){
  4. $(this).addClass("hover");
  5. },function(){
  6. $(this).removeClass("hover");
  7. });
  8. if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
  9. $('.aside-ctrl').hide()
  10. }
  11. $('.aside-ctrl').click(function(){
  12. if($('.aside').hasClass('aside-collapsed')) {
  13. $('.aside').animate({width:190},200,function(){
  14. $('.aside').removeClass('aside-collapsed');
  15. $('.a-menu-tit').unbind('mouseenter mouseleave');
  16. });
  17. $('.main-header-btns').animate({'margin-right':"230px"},200);
  18. $('.main').animate({marginLeft:190},200);
  19. } else {
  20. $('.aside').animate({width:60},200,function(){
  21. $('.aside').addClass('aside-collapsed');
  22. $('.a-menu').bind('mouseenter',function(){
  23. $(this).addClass('curr').find('.a-menu-list');
  24. })
  25. $('.a-menu').bind('mouseleave',function(e){
  26. $(this).removeClass('curr').find('.a-menu-list');
  27. })
  28. })
  29. $('.main-header-btns').animate({'margin-right':"90px"},200);
  30. $('.main').animate({marginLeft:60},200);
  31. }
  32. $('.logo-wrap a.curr').removeClass('curr').siblings('a').addClass('curr');
  33. });
  34. //表格交互
  35. $('.tb tr:has("td")').hover(function(){
  36. $(this).addClass('hover');
  37. },function(){
  38. $(this).removeClass('hover');
  39. })
  40. //主体高度计算
  41. function wrapAspect(){
  42. var winHeight=$(window).height();
  43. $(".aside .scroll-pane").height(winHeight).jScrollPane({"autoReinitialise": true,"overflow":true});
  44. Commonjs.getJscrollpane=$(".container-wrap>.scroll-pane").height(winHeight-50).jScrollPane({"autoReinitialise": true}).data('jsp');
  45. //if (!($.browser.msie && ($.browser.version == "6.0") && !$.support.style)) {
  46. // $(".container-wrap>.scroll-pane").height(winHeight-111).jScrollPane({"autoReinitialise": true});
  47. //}else{
  48. // $(".container-wrap>.scroll-pane").height(winHeight-111).width($(window).width()-195);
  49. //}
  50. }
  51. function mainframe(){
  52. var winHeight=$(window).height();
  53. $('#main-frame-wrap').height(winHeight);
  54. }
  55. wrapAspect();
  56. mainframe();
  57. $(window).resize(function(){
  58. Throttle(wrapAspect(),50,30);
  59. Throttle(mainframe(),50,30);
  60. });
  61. $('.header-member').hover(function(){
  62. $('.avatar-wrap img').addClass('header-member-img')
  63. },function(){
  64. $('.avatar-wrap img').removeClass('header-member-img')
  65. });
  66. //多选项
  67. $('.custom-checkbox > label').on('click',function(){
  68. $(this).toggleClass('checked');
  69. if($(this).hasClass('checked')){
  70. $(this).prev().attr("checked",true);
  71. }else{
  72. $(this).prev().attr("checked",false);
  73. }
  74. })
  75. //分页
  76. var isAtBtnPageto;
  77. $(".btn-pageto").on("mouseenter",
  78. function() {
  79. isAtBtnPageto = !0
  80. }
  81. );
  82. $(".btn-pageto").on("mouseleave",
  83. function() {
  84. isAtBtnPageto = !1
  85. }
  86. );
  87. $(".pageto").delegate(".input-pageto","focus",function(){$(this).parent().addClass("pageto-focus")}).delegate(".input-pageto","blur",function(e){isAtBtnPageto||$(this).parent().removeClass("pageto-focus");});
  88. //开关
  89. $('.my-switch-box').on('click',function(){
  90. //预约规则展示的开关限制开放
  91. if($(this).attr('id')=="xhgzRuleSwitch"||$(this).attr('id')=="wyxzgzRuleSwitch")return;
  92. if($(this).is('.red')){
  93. $(this).removeClass('red');
  94. }else{
  95. $(this).addClass('red');
  96. }
  97. });
  98. })
  99. function Throttle(fn, delay, mustRunDelay){
  100. var timer = null;
  101. var t_start;
  102. return function(){
  103. var context = this, args = arguments, t_curr = +new Date();
  104. clearTimeout(timer);
  105. if(!t_start){
  106. t_start = t_curr;
  107. }
  108. if(t_curr - t_start >= mustRunDelay){
  109. fn.apply(context, args);
  110. t_start = t_curr;
  111. }
  112. else {
  113. timer = setTimeout(function(){
  114. fn.apply(context, args);
  115. }, delay);
  116. }
  117. };
  118. };