global.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*全局自适应高度*/
  2. function autoFlashHeight(){
  3. var cHeader = $(".c-header").height();
  4. var sBar = $(".sjs-bar").height();
  5. var sBarz = $(".side-bar").height();
  6. $(".sjs-height-1").height($(window).height()-cHeader-160);
  7. $(".sjs-height-2").height($(window).height()-cHeader-sBarz-160);
  8. $(".sjs-height-3").height($(window).height()-cHeader-sBar-560);
  9. };
  10. $(window).resize(autoFlashHeight);
  11. /*全局自适应高度结束*/
  12. $(function(){
  13. /*侧滑*/
  14. $(".open-sidebar").click(function(){
  15. $(".slide-sidebar").animate({width:"800"}).addClass("open");
  16. });
  17. $("body").click(function(event){
  18. var e = event || window.event; //浏览器兼容性
  19. if(!$(event.target).is('a')) {
  20. var elem = event.target || e.srcElement;
  21. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  22. if (elem.className == "open-sidebar" || elem.className == 'slide-sidebar open') {
  23. return false;
  24. }
  25. elem = elem.parentNode;
  26. }
  27. $(".slide-sidebar").animate({width:"0"}).removeClass("open")// 关闭处理
  28. }
  29. });
  30. /*侧滑*/
  31. /*工具提示*/
  32. $(function () {
  33. $('[data-toggle="tooltip"]').tooltip()
  34. });
  35. /*侧栏菜单*/
  36. $(".bg-nav > li > a").click(function() {
  37. var self = $(this);
  38. var subMenu = $(this).siblings('ul.sub-menu');
  39. if(subMenu.length > 0) {
  40. if(subMenu.is(":visible")) {
  41. self.find('.menu-arrow').removeClass('fa-angle-up').addClass('fa-angle-down');
  42. subMenu.slideUp('fast');
  43. self.parent().removeClass('active');
  44. }else{
  45. self.parent().addClass('active');
  46. self.find('.menu-arrow').removeClass('fa-angle-down').addClass('fa-angle-up');
  47. subMenu.slideDown('fast');
  48. }
  49. }
  50. });
  51. });