agile-admin.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. require('metismenu');
  2. require('jquery-slimscroll');
  3. require('./waves');
  4. let aaSettings = undefined;
  5. function loadSettings() {
  6. const settingsStr = sessionStorage.getItem('agile-admin') || '{}';
  7. aaSettings = JSON.parse(settingsStr);
  8. }
  9. function saveSettings() {
  10. sessionStorage.setItem('agile-admin', JSON.stringify(aaSettings));
  11. }
  12. // load settings from sessionStorage
  13. loadSettings();
  14. //Loads the correct sidebar on window load,
  15. //collapses the sidebar on window resize.
  16. // Sets the min-height of #page-wrapper to window size
  17. $(window).on("load resize", function () {
  18. let topOffset = 60;
  19. const width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
  20. if (width < 768) {
  21. $('div.navbar-collapse').addClass('collapse');
  22. topOffset = 100; // 2-row-menu
  23. }
  24. else {
  25. $('div.navbar-collapse').removeClass('collapse');
  26. }
  27. let height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
  28. height = height - topOffset;
  29. if (height < 1) height = 1;
  30. if (height > topOffset) {
  31. $("#page-wrapper").css("min-height", (height) + "px");
  32. }
  33. });
  34. // This is for resize window
  35. $(window).on("load resize", function () {
  36. const width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
  37. if (!aaSettings.isSidebarOpened || width < 1170) {
  38. $('body').addClass('content-wrapper');
  39. $(".open-close i").addClass('ti-menu');
  40. $(".open-close i").removeClass('ti-angle-left');
  41. $(".sidebar-nav, .slimScrollDiv").css("overflow-x", "visible").parent().css("overflow", "visible");
  42. }
  43. else {
  44. $('body').removeClass('content-wrapper');
  45. $(".open-close i").addClass('ti-angle-left');
  46. $(".open-close i").removeClass('ti-menu');
  47. }
  48. });
  49. $(document).ready(function () {
  50. $(function () {
  51. $(".preloader").fadeOut();
  52. $('#side-menu').metisMenu();
  53. });
  54. // Theme settings
  55. //Open-Close-right sidebar
  56. $(".right-side-toggle").click(function () {
  57. $(".right-sidebar").slideDown(50);
  58. $(".right-sidebar").toggleClass("shw-rside");
  59. // Fix header
  60. $(".fxhdr").click(function () {
  61. $("body").toggleClass("fix-header");
  62. });
  63. // Fix sidebar
  64. $(".fxsdr").click(function () {
  65. $("body").toggleClass("fix-sidebar");
  66. });
  67. // Service panel js
  68. if ($("body").hasClass("fix-header")) {
  69. $('.fxhdr').attr('checked', true);
  70. }
  71. else {
  72. $('.fxhdr').attr('checked', false);
  73. }
  74. if ($("body").hasClass("fix-sidebar")) {
  75. $('.fxsdr').attr('checked', true);
  76. }
  77. else {
  78. $('.fxsdr').attr('checked', false);
  79. }
  80. });
  81. $(function () {
  82. var url = window.location;
  83. var element = $('ul.nav a').filter(function () {
  84. return this.href == url || url.href.indexOf(this.href) == 0;
  85. }).addClass('active').parent().parent().addClass('in').parent();
  86. if (element.is('li')) {
  87. element.addClass('active');
  88. }
  89. });
  90. // This is for click on open close button
  91. // Sidebar open close
  92. $(".open-close").on('click', function () {
  93. if ($("body").hasClass("content-wrapper")) {
  94. aaSettings.isSidebarOpened = true;
  95. saveSettings();
  96. $("body").trigger("resize");
  97. $(".sidebar-nav, .slimScrollDiv").css("overflow", "hidden").parent().css("overflow", "visible");
  98. $("body").removeClass("content-wrapper");
  99. $(".open-close i").addClass("ti-angle-left");
  100. $(".open-close i").removeClass("ti-menu");
  101. $(".logo span").show();
  102. }
  103. else {
  104. aaSettings.isSidebarOpened = false;
  105. saveSettings();
  106. $("body").trigger("resize");
  107. $(".sidebar-nav, .slimScrollDiv").css("overflow-x", "visible").parent().css("overflow", "visible");
  108. $("body").addClass("content-wrapper");
  109. $(".open-close i").addClass("ti-menu");
  110. $(".open-close i").removeClass("ti-angle-left");
  111. $(".logo span").hide();
  112. }
  113. });
  114. /*
  115. // Collapse Panels
  116. (function ($, window, document) {
  117. var panelSelector = '[data-perform="panel-collapse"]';
  118. $(panelSelector).each(function () {
  119. var $this = $(this)
  120. , parent = $this.closest('.panel')
  121. , wrapper = parent.find('.panel-wrapper')
  122. , collapseOpts = {
  123. toggle: false
  124. };
  125. if (!wrapper.length) {
  126. wrapper = parent.children('.panel-heading').nextAll().wrapAll('<div/>').parent().addClass('panel-wrapper');
  127. collapseOpts = {};
  128. }
  129. wrapper.collapse(collapseOpts).on('hide.bs.collapse', function () {
  130. $this.children('i').removeClass('ti-minus').addClass('ti-plus');
  131. }).on('show.bs.collapse', function () {
  132. $this.children('i').removeClass('ti-plus').addClass('ti-minus');
  133. });
  134. });
  135. $(document).on('click', panelSelector, function (e) {
  136. e.preventDefault();
  137. var parent = $(this).closest('.panel');
  138. var wrapper = parent.find('.panel-wrapper');
  139. wrapper.collapse('toggle');
  140. });
  141. }(jQuery, window, document));
  142. // Remove Panels
  143. (function ($, window, document) {
  144. var panelSelector = '[data-perform="panel-dismiss"]';
  145. $(document).on('click', panelSelector, function (e) {
  146. e.preventDefault();
  147. var parent = $(this).closest('.panel');
  148. removeElement();
  149. function removeElement() {
  150. var col = parent.parent();
  151. parent.remove();
  152. col.filter(function () {
  153. var el = $(this);
  154. return (el.is('[class*="col-"]') && el.children('*').length === 0);
  155. }).remove();
  156. }
  157. });
  158. }(jQuery, window, document));
  159. */
  160. //tooltip
  161. $(function () {
  162. $('[data-toggle="tooltip"]').tooltip()
  163. })
  164. //Popover
  165. $(function () {
  166. $('[data-toggle="popover"]').popover()
  167. })
  168. // Task
  169. $(".list-task li label").click(function () {
  170. $(this).toggleClass("task-done");
  171. });
  172. $(".settings_box a").click(function () {
  173. $("ul.theme_color").toggleClass("theme_block");
  174. });
  175. });
  176. //Colepsible toggle
  177. $(".collapseble").click(function () {
  178. $(".collapseblebox").fadeToggle(350);
  179. });
  180. // Sidebar
  181. $('.slimscrollright').slimScroll({
  182. height: '100%'
  183. , position: 'right'
  184. , size: "5px"
  185. , color: '#dcdcdc'
  186. , });
  187. $('.slimscrollsidebar').slimScroll({
  188. height: '100%'
  189. , position: 'right'
  190. , size: "0px"
  191. , color: '#dcdcdc'
  192. , });
  193. $('.chat-list').slimScroll({
  194. height: '100%'
  195. , position: 'right'
  196. , size: "0px"
  197. , color: '#dcdcdc'
  198. , });
  199. // Resize all elements
  200. $("body").trigger("resize");
  201. // visited ul li
  202. $('.visited li a').click(function (e) {
  203. $('.visited li').removeClass('active');
  204. var $parent = $(this).parent();
  205. if (!$parent.hasClass('active')) {
  206. $parent.addClass('active');
  207. }
  208. e.preventDefault();
  209. });
  210. // Login and recover password
  211. $('#to-recover').click(function () {
  212. $("#loginform").slideUp();
  213. $("#recoverform").fadeIn();
  214. });
  215. // Update 1.5
  216. // this is for close icon when navigation open in mobile view
  217. $(".navbar-toggle").click(function () {
  218. $(".navbar-toggle i").toggleClass("ti-menu");
  219. $(".navbar-toggle i").addClass("ti-close");
  220. });
  221. // Update 1.6