纽威
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.

183 lines
7.1 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. });
  133. $('body').find('.mobile-search').click(function (e) {
  134. e.preventDefault();
  135. $('.mobile-search').addClass('active');
  136. $('.mobile-search form input.form-control').focus();
  137. });
  138. $(document).mouseup(function (e) {
  139. var container = $('.mobile-search');
  140. if (!container.is(e.target) && container.has(e.target).length === 0) // ... nor a descendant of the container
  141. {
  142. container.removeClass('active');
  143. }
  144. });
  145. $(window).load(function () {
  146. window.setTimeout(function () {
  147. $('#ajax-loader').fadeOut();
  148. }, 300);
  149. });
  150. });
  151. function GetLoadNav() {
  152. var data = top.clients.authorizeMenu;
  153. var _html = "";
  154. $.each(data, function (i) {
  155. var row = data[i];
  156. if (row.F_ParentId == "0") {
  157. if (row.F_FullName == "SRM")
  158. _html += '<li class="open">';
  159. else
  160. _html += '<li>';
  161. _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>';
  162. var childNodes = row.ChildNodes;
  163. if (childNodes.length > 0) {
  164. if (row.F_FullName == "SRM")
  165. _html += '<ul class="submenu" style="display: block;">';
  166. else
  167. _html += '<ul class="submenu">';
  168. $.each(childNodes, function (i) {
  169. var subrow = childNodes[i];
  170. _html += '<li>';
  171. _html += '<a class="menuItem" data-id="' + subrow.F_Id + '" href="' + subrow.F_UrlAddress + '" data-index="' + subrow.F_SortCode + '">' + subrow.F_FullName + '</a>';
  172. _html += '</li>';
  173. });
  174. _html += '</ul>';
  175. }
  176. _html += '</li>';
  177. }
  178. });
  179. $("#sidebar-nav ul").prepend(_html);
  180. }