纽威
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
7.2 KiB

3 years ago
  1. var storage, fail, uid; try { uid = new Date; (storage = window.localStorage).setItem(uid, uid); fail = storage.getItem(uid) != uid; storage.removeItem(uid); fail && (storage = false); } catch (e) { }
  2. if (storage) {
  3. var usedSkin = localStorage.getItem('config-skin');
  4. if (usedSkin != '' && usedSkin != null) {
  5. document.body.className = usedSkin;
  6. }
  7. else {
  8. document.body.className = 'theme-blue-gradient';
  9. localStorage.setItem('config-skin', "theme-blue-gradient");
  10. }
  11. }
  12. else {
  13. document.body.className = 'theme-blue';
  14. }
  15. $(function () {
  16. if (storage) {
  17. try {
  18. var usedSkin = localStorage.getItem('config-skin');
  19. if (usedSkin != '') {
  20. $('#skin-colors .skin-changer').removeClass('active'); $('#skin-colors .skin-changer[data-skin="' + usedSkin + '"]').addClass('active');
  21. }
  22. }
  23. catch (e) { console.log(e); }
  24. }
  25. })
  26. $.fn.removeClassPrefix = function (prefix) {
  27. this.each(function (i, el) {
  28. var classes = el.className.split(" ").filter(function (c) {
  29. return c.lastIndexOf(prefix, 0) !== 0;
  30. });
  31. el.className = classes.join(" ");
  32. });
  33. return this;
  34. };
  35. $(function ($) {
  36. $('#config-tool-cog').on('click', function () { $('#config-tool').toggleClass('closed'); }); $('#config-fixed-header').on('change', function () {
  37. var fixedHeader = '';
  38. if ($(this).is(':checked')) {
  39. $('body').addClass('fixed-header'); fixedHeader = 'fixed-header';
  40. }
  41. else {
  42. $('body').removeClass('fixed-header');
  43. if ($('#config-fixed-sidebar').is(':checked')) {
  44. $('#config-fixed-sidebar').prop('checked', false);
  45. $('#config-fixed-sidebar').trigger('change'); location.reload();
  46. }
  47. }
  48. });
  49. $('#skin-colors .skin-changer').on('click', function () {
  50. $('body').removeClassPrefix('theme-');
  51. $('body').addClass($(this).data('skin'));
  52. $('#skin-colors .skin-changer').removeClass('active');
  53. $(this).addClass('active');
  54. writeStorage(storage, 'config-skin', $(this).data('skin'));
  55. });
  56. function writeStorage(storage, key, value) {
  57. if (storage) {
  58. try {
  59. localStorage.setItem(key, value);
  60. }
  61. catch (e) { console.log(e); }
  62. }
  63. }
  64. });
  65. $(function ($) {
  66. $("#content-wrapper").find('.mainContent').height($(window).height() - 100);
  67. $(window).resize(function (e) {
  68. $("#content-wrapper").find('.mainContent').height($(window).height() - 100);
  69. });
  70. $('#sidebar-nav,#nav-col-submenu').on('click', '.dropdown-toggle', function (e) {
  71. e.preventDefault();
  72. var $item = $(this).parent();
  73. if (!$item.hasClass('open')) {
  74. $item.parent().find('.open .submenu').slideUp('fast');
  75. $item.parent().find('.open').toggleClass('open');
  76. }
  77. $item.toggleClass('open');
  78. if ($item.hasClass('open')) {
  79. $item.children('.submenu').slideDown('fast', function () {
  80. var _height1 = $(window).height() - 92 - $item.position().top;
  81. var _height2 = $item.find('ul.submenu').height() + 10;
  82. var _height3 = _height2 > _height1 ? _height1 : _height2;
  83. $item.find('ul.submenu').css({
  84. overflow: "auto",
  85. height: _height3
  86. })
  87. });
  88. }
  89. else {
  90. $item.children('.submenu').slideUp('fast');
  91. }
  92. });
  93. GetLoadNav();
  94. $('body').on('mouseenter', '#page-wrapper.nav-small #sidebar-nav .dropdown-toggle', function (e) {
  95. if ($(document).width() >= 992) {
  96. var $item = $(this).parent();
  97. if ($('body').hasClass('fixed-leftmenu')) {
  98. var topPosition = $item.position().top;
  99. if ((topPosition + 4 * $(this).outerHeight()) >= $(window).height()) {
  100. topPosition -= 6 * $(this).outerHeight();
  101. }
  102. $('#nav-col-submenu').html($item.children('.submenu').clone());
  103. $('#nav-col-submenu > .submenu').css({ 'top': topPosition });
  104. }
  105. $item.addClass('open');
  106. $item.children('.submenu').slideDown('fast');
  107. }
  108. });
  109. $('body').on('mouseleave', '#page-wrapper.nav-small #sidebar-nav > .nav-pills > li', function (e) {
  110. if ($(document).width() >= 992) {
  111. var $item = $(this);
  112. if ($item.hasClass('open')) {
  113. $item.find('.open .submenu').slideUp('fast');
  114. $item.find('.open').removeClass('open');
  115. $item.children('.submenu').slideUp('fast');
  116. }
  117. $item.removeClass('open');
  118. }
  119. });
  120. $('body').on('mouseenter', '#page-wrapper.nav-small #sidebar-nav a:not(.dropdown-toggle)', function (e) {
  121. if ($('body').hasClass('fixed-leftmenu')) {
  122. $('#nav-col-submenu').html('');
  123. }
  124. });
  125. $('body').on('mouseleave', '#page-wrapper.nav-small #nav-col', function (e) {
  126. if ($('body').hasClass('fixed-leftmenu')) {
  127. $('#nav-col-submenu').html('');
  128. }
  129. });
  130. $('body').find('#make-small-nav').click(function (e) {
  131. $('#page-wrapper').toggleClass('nav-small');
  132. if ($('#page-wrapper').hasClass('nav-small')) {
  133. // MenuOverFlow
  134. $("#nav-col").removeClass('MenuOverFlow');
  135. }
  136. else {
  137. $("#nav-col").addClass('MenuOverFlow');
  138. }
  139. });
  140. $('body').find('.mobile-search').click(function (e) {
  141. e.preventDefault();
  142. $('.mobile-search').addClass('active');
  143. $('.mobile-search form input.form-control').focus();
  144. });
  145. $(document).mouseup(function (e) {
  146. var container = $('.mobile-search');
  147. if (!container.is(e.target) && container.has(e.target).length === 0) // ... nor a descendant of the container
  148. {
  149. container.removeClass('active');
  150. }
  151. });
  152. $(window).load(function () {
  153. window.setTimeout(function () {
  154. $('#ajax-loader').fadeOut();
  155. }, 300);
  156. });
  157. });
  158. function GetLoadNav() {
  159. var data = top.clients.authorizeMenu;
  160. var _html = "";
  161. $.each(data, function (i) {
  162. var row = data[i];
  163. if (row.F_ParentId == "0") {
  164. _html += '<li class="">';
  165. _html += '<a data-id="' + row.F_Id + '" href="#" class="dropdown-toggle"><i class="' + row.F_Icon + '"></i><span>' + row.F_FullName + '</span><i class="fa fa-angle-right drop-icon"></i></a>';
  166. var childNodes = row.ChildNodes;
  167. if (childNodes.length > 0) {
  168. var height = data.length * 38;
  169. _html += '<ul class="submenu" style="display: none; overflow: auto; height:' + height+' ;">';
  170. $.each(childNodes, function (i) {
  171. var subrow = childNodes[i];
  172. _html += '<li>';
  173. _html += '<a class="menuItem" data-id="' + subrow.F_Id + '" href="' + subrow.F_UrlAddress + '" data-index="' + subrow.F_SortCode + '">' + subrow.F_FullName + '</a>';
  174. _html += '</li>';
  175. });
  176. _html += '</ul>';
  177. }
  178. _html += '</li>';
  179. }
  180. });
  181. $("#sidebar-nav ul").prepend(_html);
  182. }