inspinia.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. //自定义js
  2. var smallNavWidth= 70;
  3. var expandNavWidth = 220;
  4. var navDiffer = 150;
  5. //公共配置
  6. layer.config({
  7. extend: ['skin/moon/style.css']
  8. });
  9. function changeLeftNavImg(){
  10. var img = $("#l-nav-img").attr("src");
  11. var index = img.lastIndexOf("/");
  12. if(index == -1)
  13. return;
  14. var flag = img.substr(index + 1);
  15. if( $(document.body).hasClass("mini-navbar") == true) {
  16. $("#l-nav-img").parent().removeClass("l-nav-div-offsetl");
  17. $("#l-nav-img").parent().addClass("l-nav-div-offsets");
  18. $("#l-nav-img").attr("src", img.substr(0, index + 1) + "l-nav-close.png");
  19. }
  20. else
  21. {
  22. $("#l-nav-img").parent().addClass("l-nav-div-offsetl");
  23. $("#l-nav-img").parent().removeClass("l-nav-div-offsets");
  24. $("#l-nav-img").attr("src",img.substr(0,index + 1) + "l-nav-open.png");
  25. }
  26. }
  27. var lastLevelNavActive = null;
  28. function getLastLevelNavActive()
  29. {
  30. return lastLevelNavActive;
  31. }
  32. function setLastLevelNavActive(elem){
  33. lastLevelNavActive = elem;
  34. }
  35. $(document).ready(function () {
  36. // MetsiMenu
  37. $('#side-menu').metisMenu();
  38. // 打开右侧边栏
  39. $('.right-sidebar-toggle').click(function () {
  40. $('#right-sidebar').toggleClass('sidebar-open');
  41. });
  42. // 右侧边栏使用slimscroll
  43. $('.sidebar-container').slimScroll({
  44. height: '100%',
  45. railOpacity: 0.4,
  46. wheelStep: 10
  47. });
  48. // 打开聊天窗口
  49. $('.open-small-chat').click(function () {
  50. $(this).children().toggleClass('fa-comments').toggleClass('fa-remove');
  51. $('.small-chat-box').toggleClass('active');
  52. });
  53. // 聊天窗口使用slimscroll
  54. $('.small-chat-box .content').slimScroll({
  55. height: '234px',
  56. railOpacity: 0.4
  57. });
  58. // Small todo handler
  59. $('.check-link').click(function () {
  60. var button = $(this).find('i');
  61. var label = $(this).next('span');
  62. button.toggleClass('fa-check-square').toggleClass('fa-square-o');
  63. label.toggleClass('todo-completed');
  64. return false;
  65. });
  66. //固定菜单栏
  67. $(function () {
  68. $('.sidebar-collapse').slimScroll({
  69. height: '100%',
  70. railOpacity: 0.9,
  71. alwaysVisible: false
  72. });
  73. });
  74. // 菜单切换
  75. $('.navbar-minimalize').click(function () {
  76. $("body").toggleClass("mini-navbar");
  77. changeLeftNavImg();
  78. SmoothlyMenu();
  79. });
  80. // 侧边栏高度
  81. function fix_height() {
  82. var heightWithoutNavbar = $("body > #wrapper").height() - 61;
  83. $(".sidebard-panel").css("min-height", heightWithoutNavbar + "px");
  84. }
  85. fix_height();
  86. $(window).bind("load resize click scroll", function () {
  87. if (!$("body").hasClass('body-small')) {
  88. fix_height();
  89. }
  90. });
  91. //侧边栏滚动
  92. $(window).scroll(function () {
  93. if ($(window).scrollTop() > 0 && !$('body').hasClass('fixed-nav')) {
  94. $('#right-sidebar').addClass('sidebar-top');
  95. } else {
  96. $('#right-sidebar').removeClass('sidebar-top');
  97. }
  98. });
  99. $('.full-height-scroll').slimScroll({
  100. height: '100%'
  101. });
  102. $('#side-menu>li').click(function () {
  103. if ($('body').hasClass('mini-navbar')) {
  104. NavToggle();
  105. }
  106. });
  107. $('#side-menu>li li a').click(function(){
  108. var href = $(this).attr("href");
  109. if( href != undefined && href != "" )///末端菜单,取消上一激活状态,加载激活状态
  110. {
  111. if(lastLevelNavActive != null)
  112. {
  113. $(lastLevelNavActive).parent().removeClass("last-nav-activel");
  114. }
  115. $(this).parent().addClass("last-nav-activel");
  116. lastLevelNavActive = this;
  117. }
  118. if ($(window).width() < 769) {
  119. NavToggle();
  120. }
  121. });
  122. $('.nav-close').click(NavToggle);
  123. });
  124. $(window).bind("load resize", function () {
  125. if ($(this).width() < 769) {
  126. $('body').addClass('mini-navbar');
  127. $('.navbar-static-side').fadeIn();
  128. changeLeftNavImg();
  129. }
  130. });
  131. function NavToggle(){
  132. $('.navbar-minimalize').trigger('click');
  133. }
  134. function SmoothlyMenu() {
  135. if (!$('body').hasClass('mini-navbar')) {
  136. $('#side-menu').hide();
  137. setTimeout(
  138. function () {
  139. $('#side-menu').fadeIn(500);
  140. }, 100);
  141. } else if ($('body').hasClass('fixed-sidebar')) {
  142. $('#side-menu').hide();
  143. setTimeout(
  144. function () {
  145. $('#side-menu').fadeIn(500);
  146. }, 300);
  147. } else {
  148. $('#side-menu').removeAttr('style');
  149. }
  150. }
  151. //主题设置
  152. $(function () {
  153. var webroot=document.location.href;
  154. webroot=webroot.substring(webroot.indexOf('//')+2,webroot.length);
  155. webroot=webroot.substring(webroot.indexOf('/')+1,webroot.length);
  156. webroot=webroot.substring(0,webroot.indexOf('/'));
  157. rootpath="/"+webroot;
  158. //设置皮肤
  159. // $.get(rootpath+"/static/common/skin-config.jsp", function (data) {
  160. // $('body').append(data);
  161. // });
  162. if (localStorageSupport) {
  163. var collapse = localStorage.getItem("collapse_menu");
  164. var fixednavbar = localStorage.getItem("fixednavbar");
  165. var boxedlayout = localStorage.getItem("boxedlayout");
  166. var body = $('body');
  167. if (collapse == 'on') {
  168. if (!body.hasClass('body-small')) {
  169. body.addClass('mini-navbar');
  170. }
  171. }
  172. if (fixednavbar == 'on') {
  173. $(".navbar-static-top").removeClass('navbar-static-top').addClass('navbar-fixed-top');
  174. body.addClass('fixed-nav');
  175. }
  176. if (boxedlayout == 'on') {
  177. body.addClass('boxed-layout');
  178. }
  179. }
  180. });
  181. //判断浏览器是否支持html5本地存储
  182. function localStorageSupport() {
  183. return (('localStorage' in window) && window['localStorage'] !== null)
  184. }