global.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*全局自适应高度*/
  2. function autoFlashHeight(){
  3. var headerHeight = $(".header").height();
  4. var toolsbarHeight = $(".toolsbar").height();
  5. var ftoolsbarHeight = $(".toolsbar-f").height();
  6. var bottomContentHeight = $(".bottom-content").height();
  7. var toolsBarHeightQ = $(".tools-bar-height-q").height();
  8. var toolsBarHeightD = $(".tools-bar-height-d").height();
  9. $(".main-data-side-q").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightQ-202);
  10. $(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-202);
  11. $(".main-data-top").height($(window).height()-headerHeight-toolsbarHeight-bottomContentHeight-1);
  12. $(".main-data-full").height($(window).height()-headerHeight-toolsbarHeight-1);
  13. $(".main-data-full-fl").height($(window).height()-headerHeight-toolsbarHeight-37);
  14. $(".main-data-not").height($(window).height()-headerHeight-1);
  15. $(".main-data-side-search").height($(window).height()-headerHeight-toolsbarHeight-64);
  16. $(".side-content").height($(window).height()-headerHeight );
  17. $(".poj-list").height($(window).height()-headerHeight-toolsbarHeight);
  18. $(".form-view").height($(window).height()-headerHeight-ftoolsbarHeight);
  19. $(".form-list").height($(window).height()-headerHeight-50 );
  20. };
  21. $(window).resize(autoFlashHeight);
  22. /*全局自适应高度结束*/
  23. $(function(){
  24. /*侧滑*/
  25. $(".open-sidebar").click(function(){
  26. $(".slide-sidebar").animate({width:"800"}).addClass("open");
  27. });
  28. $("body").click(function(event){
  29. var e = event || window.event; //浏览器兼容性
  30. if(!$(event.target).is('a')) {
  31. var elem = event.target || e.srcElement;
  32. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  33. if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
  34. return false;
  35. }
  36. elem = elem.parentNode;
  37. }
  38. $(".slide-sidebar").animate({width:"0"}).removeClass("open")// 关闭处理
  39. }
  40. });
  41. /*侧滑*/
  42. /*工具提示*/
  43. $(function () {
  44. $('[data-toggle="tooltip"]').tooltip()
  45. });
  46. /*侧栏菜单*/
  47. $(".bg-nav > li > a").click(function() {
  48. var self = $(this);
  49. var subMenu = $(this).siblings('ul.sub-menu');
  50. if(subMenu.length > 0) {
  51. if(subMenu.is(":visible")) {
  52. self.find('.menu-arrow').removeClass('fa-angle-up').addClass('fa-angle-down');
  53. subMenu.slideUp('fast');
  54. self.parent().removeClass('active');
  55. }else{
  56. self.parent().addClass('active');
  57. self.find('.menu-arrow').removeClass('fa-angle-down').addClass('fa-angle-up');
  58. subMenu.slideDown('fast');
  59. }
  60. }
  61. });
  62. // 数据提交
  63. $("#submit-form").click(function() {
  64. $("#save-form").submit();
  65. });
  66. });
  67. /**
  68. * 提示框
  69. *
  70. * @param string message
  71. * @param string type
  72. * @param string icon
  73. * @return void
  74. */
  75. function toast(message, type, icon)
  76. {
  77. var toast = $(".toast");
  78. toast.addClass(type);
  79. toast.children('.message').html(message);
  80. var iconClass = 'fa-' + icon;
  81. toast.children('.icon').addClass(iconClass);
  82. toast.fadeIn(500);
  83. setTimeout(function() {
  84. toast.fadeOut('fast');
  85. toast.children('.message').text('');
  86. toast.children('.icon').removeClass(iconClass);
  87. }, 3000);
  88. }