app-menu.js 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId]) {
  10. /******/ return installedModules[moduleId].exports;
  11. /******/ }
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ i: moduleId,
  15. /******/ l: false,
  16. /******/ exports: {}
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.l = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // define getter function for harmony exports
  37. /******/ __webpack_require__.d = function(exports, name, getter) {
  38. /******/ if(!__webpack_require__.o(exports, name)) {
  39. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "/";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = 1);
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./resources/assets/js/core/app-menu.js":
  89. /*!**********************************************!*\
  90. !*** ./resources/assets/js/core/app-menu.js ***!
  91. \**********************************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports) {
  94. /*=========================================================================================
  95. File Name: app-menu.js
  96. Description: Menu navigation, custom scrollbar, hover scroll bar, multilevel menu
  97. initialization and manipulations
  98. ----------------------------------------------------------------------------------------
  99. Item Name: Vusax - Vuejs, HTML & Laravel Admin Dashboard Template
  100. Author: Pixinvent
  101. Author URL: hhttp://www.themeforest.net/user/pixinvent
  102. ==========================================================================================*/
  103. (function (window, document, $) {
  104. 'use strict';
  105. var vh = window.innerHeight * 0.01;
  106. document.documentElement.style.setProperty('--vh', "".concat(vh, "px"));
  107. $.app = $.app || {};
  108. var $body = $('body');
  109. var $window = $(window);
  110. var menuWrapper_el = $('div[data-menu="menu-wrapper"]').html();
  111. var menuWrapperClasses = $('div[data-menu="menu-wrapper"]').attr('class'); // Main menu
  112. $.app.menu = {
  113. expanded: null,
  114. collapsed: null,
  115. hidden: null,
  116. container: null,
  117. horizontalMenu: false,
  118. is_touch_device: function is_touch_device() {
  119. var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
  120. var mq = function mq(query) {
  121. return window.matchMedia(query).matches;
  122. };
  123. if ('ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch) {
  124. return true;
  125. } // include the 'heartz' as a way to have a non matching MQ to help terminate the join
  126. // https://git.io/vznFH
  127. var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
  128. return mq(query);
  129. },
  130. manualScroller: {
  131. obj: null,
  132. init: function init() {
  133. var scroll_theme = $('.main-menu').hasClass('menu-dark') ? 'light' : 'dark';
  134. if (!$.app.menu.is_touch_device()) {
  135. this.obj = new PerfectScrollbar(".main-menu-content", {
  136. suppressScrollX: true,
  137. wheelPropagation: false
  138. });
  139. } else {
  140. $(".main-menu").addClass("menu-native-scroll");
  141. }
  142. },
  143. update: function update() {
  144. if (this.obj) {
  145. // Scroll to currently active menu on page load if data-scroll-to-active is true
  146. if ($('.main-menu').data('scroll-to-active') === true) {
  147. var activeEl, menu, activeElHeight;
  148. activeEl = document.querySelector('.main-menu-content li.active');
  149. if ($body.hasClass('menu-collapsed')) {
  150. if ($('.main-menu-content li.sidebar-group-active').length) {
  151. activeEl = document.querySelector('.main-menu-content li.sidebar-group-active');
  152. }
  153. } else {
  154. menu = document.querySelector('.main-menu-content');
  155. if (activeEl) {
  156. activeElHeight = activeEl.getBoundingClientRect().top + menu.scrollTop;
  157. } // If active element's top position is less than 2/3 (66%) of menu height than do not scroll
  158. if (activeElHeight > parseInt(menu.clientHeight * 2 / 3)) {
  159. var start = menu.scrollTop,
  160. change = activeElHeight - start - parseInt(menu.clientHeight / 2);
  161. }
  162. }
  163. setTimeout(function () {
  164. $.app.menu.container.stop().animate({
  165. scrollTop: change
  166. }, 300);
  167. $('.main-menu').data('scroll-to-active', 'false');
  168. }, 300);
  169. }
  170. this.obj.update();
  171. }
  172. },
  173. enable: function enable() {
  174. if (!$('.main-menu-content').hasClass('ps')) {
  175. this.init();
  176. }
  177. },
  178. disable: function disable() {
  179. if (this.obj) {
  180. this.obj.destroy();
  181. }
  182. },
  183. updateHeight: function updateHeight() {
  184. if (($body.data('menu') == 'vertical-menu' || $body.data('menu') == 'vertical-menu-modern' || $body.data('menu') == 'vertical-overlay-menu') && $('.main-menu').hasClass('menu-fixed')) {
  185. $('.main-menu-content').css('height', $(window).height() - $('.header-navbar').height() - $('.main-menu-header').outerHeight() - $('.main-menu-footer').outerHeight());
  186. this.update();
  187. }
  188. }
  189. },
  190. init: function init(compactMenu) {
  191. if ($('.main-menu-content').length > 0) {
  192. this.container = $('.main-menu-content');
  193. var menuObj = this;
  194. var defMenu = '';
  195. if (compactMenu === true) {
  196. defMenu = 'collapsed';
  197. }
  198. if ($body.data('menu') == 'vertical-menu-modern') {
  199. var menuToggle = '';
  200. if (menuToggle === "false") {
  201. this.change('collapsed');
  202. } else {
  203. this.change(defMenu);
  204. }
  205. } else {
  206. this.change(defMenu);
  207. }
  208. }
  209. },
  210. drillDownMenu: function drillDownMenu(screenSize) {
  211. if ($('.drilldown-menu').length) {
  212. if (screenSize == 'sm' || screenSize == 'xs') {
  213. if ($('#navbar-mobile').attr('aria-expanded') == 'true') {
  214. $('.drilldown-menu').slidingMenu({
  215. backLabel: true
  216. });
  217. }
  218. } else {
  219. $('.drilldown-menu').slidingMenu({
  220. backLabel: true
  221. });
  222. }
  223. }
  224. },
  225. change: function change(defMenu) {
  226. var currentBreakpoint = Unison.fetch.now(); // Current Breakpoint
  227. this.reset();
  228. var menuType = $body.data('menu');
  229. if (currentBreakpoint) {
  230. switch (currentBreakpoint.name) {
  231. case 'xl':
  232. if (menuType === 'vertical-overlay-menu') {
  233. this.hide();
  234. } else {
  235. if (defMenu === 'collapsed') this.collapse(defMenu);else this.expand();
  236. }
  237. break;
  238. case 'lg':
  239. if (menuType === 'vertical-overlay-menu' || menuType === 'vertical-menu-modern' || menuType === 'horizontal-menu') {
  240. this.hide();
  241. } else {
  242. this.collapse();
  243. }
  244. break;
  245. case 'md':
  246. case 'sm':
  247. this.hide();
  248. break;
  249. case 'xs':
  250. this.hide();
  251. break;
  252. }
  253. } // On the small and extra small screen make them overlay menu
  254. if (menuType === 'vertical-menu' || menuType === 'vertical-menu-modern') {
  255. this.toOverlayMenu(currentBreakpoint.name, menuType);
  256. }
  257. if ($body.is('.horizontal-layout') && !$body.hasClass('.horizontal-menu-demo')) {
  258. this.changeMenu(currentBreakpoint.name);
  259. $('.menu-toggle').removeClass('is-active');
  260. } // Initialize drill down menu for vertical layouts, for horizontal layouts drilldown menu is intitialized in changemenu function
  261. if (menuType != 'horizontal-menu') {
  262. // Drill down menu
  263. // ------------------------------
  264. this.drillDownMenu(currentBreakpoint.name);
  265. } // Dropdown submenu on large screen on hover For Large screen only
  266. // ---------------------------------------------------------------
  267. if (currentBreakpoint.name == 'xl') {
  268. $('body[data-open="hover"] .header-navbar .dropdown').on('mouseenter', function () {
  269. if (!$(this).hasClass('show')) {
  270. $(this).addClass('show');
  271. } else {
  272. $(this).removeClass('show');
  273. }
  274. }).on('mouseleave', function (event) {
  275. $(this).removeClass('show');
  276. });
  277. $('body[data-open="hover"] .dropdown a').on('click', function (e) {
  278. if (menuType == 'horizontal-menu') {
  279. var $this = $(this);
  280. if ($this.hasClass('dropdown-toggle')) {
  281. return false;
  282. }
  283. }
  284. });
  285. } // Added data attribute brand-center for navbar-brand-center
  286. // TODO:AJ: Shift this feature in JADE.
  287. if ($('.header-navbar').hasClass('navbar-brand-center')) {
  288. $('.header-navbar').attr('data-nav', 'brand-center');
  289. }
  290. if (currentBreakpoint.name == 'sm' || currentBreakpoint.name == 'xs') {
  291. $('.header-navbar[data-nav=brand-center]').removeClass('navbar-brand-center');
  292. } else {
  293. $('.header-navbar[data-nav=brand-center]').addClass('navbar-brand-center');
  294. } // On screen width change, current active menu in horizontal
  295. if (currentBreakpoint.name == 'xl' && menuType == 'horizontal-menu') {
  296. $(".main-menu-content").find('li.active').parents('li').addClass('sidebar-group-active active');
  297. }
  298. if (currentBreakpoint.name !== 'xl' && menuType == 'horizontal-menu') {
  299. $("#navbar-type").toggleClass('d-none d-xl-block');
  300. } // Dropdown submenu on small screen on click
  301. // --------------------------------------------------
  302. $('ul.dropdown-menu [data-toggle=dropdown]').on('click', function (event) {
  303. if ($(this).siblings('ul.dropdown-menu').length > 0) {
  304. event.preventDefault();
  305. }
  306. event.stopPropagation();
  307. $(this).parent().siblings().removeClass('show');
  308. $(this).parent().toggleClass('show');
  309. }); // Horizontal layout submenu drawer scrollbar
  310. if (menuType == 'horizontal-menu') {
  311. $('li.dropdown-submenu').on('mouseenter', function () {
  312. if (!$(this).parent('.dropdown').hasClass('show')) {
  313. $(this).removeClass('openLeft');
  314. }
  315. var dd = $(this).find('.dropdown-menu');
  316. if (dd.length > 0) {
  317. var pageHeight = $(window).height(),
  318. ddTop = $(this).position().top,
  319. ddLeft = dd.offset().left,
  320. ddWidth = dd.width(),
  321. ddHeight = dd.height();
  322. if (pageHeight - ddTop - ddHeight - 28 < 1) {
  323. var maxHeight = pageHeight - ddTop - 170;
  324. $(this).find('.dropdown-menu').css({
  325. 'max-height': maxHeight + 'px',
  326. 'overflow-y': 'auto',
  327. 'overflow-x': 'hidden'
  328. });
  329. var menu_content = new PerfectScrollbar('li.dropdown-submenu.show .dropdown-menu', {
  330. wheelPropagation: false
  331. });
  332. } // Add class to horizontal sub menu if screen width is small
  333. if (ddLeft + ddWidth - (window.innerWidth - 16) >= 0) {
  334. $(this).addClass('openLeft');
  335. }
  336. }
  337. });
  338. $('.theme-layouts').find('.semi-dark').hide();
  339. $('#customizer-navbar-colors').hide();
  340. }
  341. /********************************************
  342. * Searchable Menu *
  343. ********************************************/
  344. function searchMenu(list) {
  345. var input = $(".menu-search");
  346. $(input).change(function () {
  347. var filter = $(this).val();
  348. if (filter) {
  349. // Hide Main Navigation Headers
  350. $('.navigation-header').hide(); // this finds all links in a list that contain the input,
  351. // and hide the ones not containing the input while showing the ones that do
  352. $(list).find("li a:not(:Contains(" + filter + "))").hide().parent().hide(); // $(list).find("li a:Contains(" + filter + ")").show().parents('li').show().addClass('open').closest('li').children('a').show();
  353. var searchFilter = $(list).find("li a:Contains(" + filter + ")");
  354. if (searchFilter.parent().hasClass('has-sub')) {
  355. searchFilter.show().parents('li').show().addClass('open').closest('li').children('a').show().children('li').show(); // searchFilter.parents('li').find('li').show().children('a').show();
  356. if (searchFilter.siblings('ul').length > 0) {
  357. searchFilter.siblings('ul').children('li').show().children('a').show();
  358. }
  359. } else {
  360. searchFilter.show().parents('li').show().addClass('open').closest('li').children('a').show();
  361. }
  362. } else {
  363. // return to default
  364. $('.navigation-header').show();
  365. $(list).find("li a").show().parent().show().removeClass('open');
  366. }
  367. $.app.menu.manualScroller.update();
  368. return false;
  369. }).keyup(function () {
  370. // fire the above change event after every letter
  371. $(this).change();
  372. });
  373. }
  374. if (menuType === 'vertical-menu' || menuType === 'vertical-overlay-menu') {
  375. // custom css expression for a case-insensitive contains()
  376. jQuery.expr[':'].Contains = function (a, i, m) {
  377. return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
  378. };
  379. searchMenu($("#main-menu-navigation"));
  380. }
  381. },
  382. transit: function transit(callback1, callback2) {
  383. var menuObj = this;
  384. $body.addClass('changing-menu');
  385. callback1.call(menuObj);
  386. if ($body.hasClass('vertical-layout')) {
  387. if ($body.hasClass('menu-open') || $body.hasClass('menu-expanded')) {
  388. $('.menu-toggle').addClass('is-active'); // Show menu header search when menu is normally visible
  389. if ($body.data('menu') === 'vertical-menu') {
  390. if ($('.main-menu-header')) {
  391. $('.main-menu-header').show();
  392. }
  393. }
  394. } else {
  395. $('.menu-toggle').removeClass('is-active'); // Hide menu header search when only menu icons are visible
  396. if ($body.data('menu') === 'vertical-menu') {
  397. if ($('.main-menu-header')) {
  398. $('.main-menu-header').hide();
  399. }
  400. }
  401. }
  402. }
  403. setTimeout(function () {
  404. callback2.call(menuObj);
  405. $body.removeClass('changing-menu');
  406. menuObj.update();
  407. }, 500);
  408. },
  409. open: function open() {
  410. this.transit(function () {
  411. $body.removeClass('menu-hide menu-collapsed').addClass('menu-open');
  412. this.hidden = false;
  413. this.expanded = true;
  414. if ($body.hasClass('vertical-overlay-menu')) {
  415. $('.sidenav-overlay').removeClass('d-none').addClass('d-block');
  416. $('body').css('overflow', 'hidden');
  417. }
  418. }, function () {
  419. if (!$('.main-menu').hasClass('menu-native-scroll') && $('.main-menu').hasClass('menu-fixed')) {
  420. this.manualScroller.enable();
  421. $('.main-menu-content').css('height', $(window).height() - $('.header-navbar').height() - $('.main-menu-header').outerHeight() - $('.main-menu-footer').outerHeight()); // this.manualScroller.update();
  422. }
  423. if (!$body.hasClass('vertical-overlay-menu')) {
  424. $('.sidenav-overlay').removeClass('d-block d-none');
  425. $('body').css('overflow', 'auto');
  426. }
  427. });
  428. },
  429. hide: function hide() {
  430. this.transit(function () {
  431. $body.removeClass('menu-open menu-expanded').addClass('menu-hide');
  432. this.hidden = true;
  433. this.expanded = false;
  434. if ($body.hasClass('vertical-overlay-menu')) {
  435. $('.sidenav-overlay').removeClass('d-block').addClass('d-none');
  436. $('body').css('overflow', 'auto');
  437. }
  438. }, function () {
  439. if (!$('.main-menu').hasClass('menu-native-scroll') && $('.main-menu').hasClass('menu-fixed')) {
  440. this.manualScroller.enable();
  441. }
  442. if (!$body.hasClass('vertical-overlay-menu')) {
  443. $('.sidenav-overlay').removeClass('d-block d-none');
  444. $('body').css('overflow', 'auto');
  445. }
  446. });
  447. },
  448. expand: function expand() {
  449. if (this.expanded === false) {
  450. if ($body.data('menu') == 'vertical-menu-modern') {
  451. $('.modern-nav-toggle').find('.toggle-icon').removeClass('feather icon-circle').addClass('feather icon-disc');
  452. }
  453. this.transit(function () {
  454. $body.removeClass('menu-collapsed').addClass('menu-expanded');
  455. this.collapsed = false;
  456. this.expanded = true;
  457. $('.sidenav-overlay').removeClass('d-block d-none');
  458. }, function () {
  459. if ($('.main-menu').hasClass('menu-native-scroll') || $body.data('menu') == 'horizontal-menu') {
  460. this.manualScroller.disable();
  461. } else {
  462. if ($('.main-menu').hasClass('menu-fixed')) this.manualScroller.enable();
  463. }
  464. if (($body.data('menu') == 'vertical-menu' || $body.data('menu') == 'vertical-menu-modern') && $('.main-menu').hasClass('menu-fixed')) {
  465. $('.main-menu-content').css('height', $(window).height() - $('.header-navbar').height() - $('.main-menu-header').outerHeight() - $('.main-menu-footer').outerHeight()); // this.manualScroller.update();
  466. }
  467. });
  468. }
  469. },
  470. collapse: function collapse(defMenu) {
  471. if (this.collapsed === false) {
  472. if ($body.data('menu') == 'vertical-menu-modern') {
  473. $('.modern-nav-toggle').find('.toggle-icon').removeClass('feather icon-disc').addClass('feather icon-circle');
  474. }
  475. this.transit(function () {
  476. $body.removeClass('menu-expanded').addClass('menu-collapsed');
  477. this.collapsed = true;
  478. this.expanded = false;
  479. $('.content-overlay').removeClass('d-block d-none');
  480. }, function () {
  481. if ($body.data('menu') == 'horizontal-menu' && $body.hasClass('vertical-overlay-menu')) {
  482. if ($('.main-menu').hasClass('menu-fixed')) this.manualScroller.enable();
  483. }
  484. if (($body.data('menu') == 'vertical-menu' || $body.data('menu') == 'vertical-menu-modern') && $('.main-menu').hasClass('menu-fixed')) {
  485. $('.main-menu-content').css('height', $(window).height() - $('.header-navbar').height()); // this.manualScroller.update();
  486. }
  487. if ($body.data('menu') == 'vertical-menu-modern') {
  488. if ($('.main-menu').hasClass('menu-fixed')) this.manualScroller.enable();
  489. }
  490. });
  491. }
  492. },
  493. toOverlayMenu: function toOverlayMenu(screen, menuType) {
  494. var menu = $body.data('menu');
  495. if (menuType == 'vertical-menu-modern') {
  496. if (screen == 'lg' || screen == 'md' || screen == 'sm' || screen == 'xs') {
  497. if ($body.hasClass(menu)) {
  498. $body.removeClass(menu).addClass('vertical-overlay-menu');
  499. }
  500. } else {
  501. if ($body.hasClass('vertical-overlay-menu')) {
  502. $body.removeClass('vertical-overlay-menu').addClass(menu);
  503. }
  504. }
  505. } else {
  506. if (screen == 'sm' || screen == 'xs') {
  507. if ($body.hasClass(menu)) {
  508. $body.removeClass(menu).addClass('vertical-overlay-menu');
  509. }
  510. } else {
  511. if ($body.hasClass('vertical-overlay-menu')) {
  512. $body.removeClass('vertical-overlay-menu').addClass(menu);
  513. }
  514. }
  515. }
  516. },
  517. changeMenu: function changeMenu(screen) {
  518. // Replace menu html
  519. $('div[data-menu="menu-wrapper"]').html('');
  520. $('div[data-menu="menu-wrapper"]').html(menuWrapper_el);
  521. var menuWrapper = $('div[data-menu="menu-wrapper"]'),
  522. menuContainer = $('div[data-menu="menu-container"]'),
  523. menuNavigation = $('ul[data-menu="menu-navigation"]'),
  524. /*megaMenu = $('li[data-menu="megamenu"]'),
  525. megaMenuCol = $('li[data-mega-col]'),*/
  526. dropdownMenu = $('li[data-menu="dropdown"]'),
  527. dropdownSubMenu = $('li[data-menu="dropdown-submenu"]');
  528. if (screen === 'xl') {
  529. // Change body classes
  530. $body.removeClass('vertical-layout vertical-overlay-menu fixed-navbar').addClass($body.data('menu')); // Remove navbar-fix-top class on large screens
  531. $('nav.header-navbar').removeClass('fixed-top'); // Change menu wrapper, menu container, menu navigation classes
  532. menuWrapper.removeClass().addClass(menuWrapperClasses); // Intitialize drill down menu for horizontal layouts
  533. // --------------------------------------------------
  534. this.drillDownMenu(screen);
  535. $('a.dropdown-item.nav-has-children').on('click', function () {
  536. event.preventDefault();
  537. event.stopPropagation();
  538. });
  539. $('a.dropdown-item.nav-has-parent').on('click', function () {
  540. event.preventDefault();
  541. event.stopPropagation();
  542. });
  543. } else {
  544. // Change body classes
  545. $body.removeClass($body.data('menu')).addClass('vertical-layout vertical-overlay-menu fixed-navbar'); // Add navbar-fix-top class on small screens
  546. $('nav.header-navbar').addClass('fixed-top'); // Change menu wrapper, menu container, menu navigation classes
  547. menuWrapper.removeClass().addClass('main-menu menu-light menu-fixed menu-shadow'); // menuContainer.removeClass().addClass('main-menu-content');
  548. menuNavigation.removeClass().addClass('navigation navigation-main'); // If Dropdown Menu
  549. dropdownMenu.removeClass('dropdown').addClass('has-sub');
  550. dropdownMenu.find('a').removeClass('dropdown-toggle nav-link');
  551. dropdownMenu.children('ul').find('a').removeClass('dropdown-item');
  552. dropdownMenu.find('ul').removeClass('dropdown-menu');
  553. dropdownSubMenu.removeClass().addClass('has-sub');
  554. $.app.nav.init(); // Dropdown submenu on small screen on click
  555. // --------------------------------------------------
  556. $('ul.dropdown-menu [data-toggle=dropdown]').on('click', function (event) {
  557. event.preventDefault();
  558. event.stopPropagation();
  559. $(this).parent().siblings().removeClass('open');
  560. $(this).parent().toggleClass('open');
  561. });
  562. $(".main-menu-content").find('li.active').parents('li').addClass('sidebar-group-active');
  563. $(".main-menu-content").find("li.active").closest("li.nav-item").addClass("open");
  564. }
  565. },
  566. toggle: function toggle() {
  567. var currentBreakpoint = Unison.fetch.now(); // Current Breakpoint
  568. var collapsed = this.collapsed;
  569. var expanded = this.expanded;
  570. var hidden = this.hidden;
  571. var menu = $body.data('menu');
  572. switch (currentBreakpoint.name) {
  573. case 'xl':
  574. if (expanded === true) {
  575. if (menu == 'vertical-overlay-menu') {
  576. this.hide();
  577. } else {
  578. this.collapse();
  579. }
  580. } else {
  581. if (menu == 'vertical-overlay-menu') {
  582. this.open();
  583. } else {
  584. this.expand();
  585. }
  586. }
  587. break;
  588. case 'lg':
  589. if (expanded === true) {
  590. if (menu == 'vertical-overlay-menu' || menu == 'vertical-menu-modern' || menu == 'horizontal-menu') {
  591. this.hide();
  592. } else {
  593. this.collapse();
  594. }
  595. } else {
  596. if (menu == 'vertical-overlay-menu' || menu == 'vertical-menu-modern' || menu == 'horizontal-menu') {
  597. this.open();
  598. } else {
  599. this.expand();
  600. }
  601. }
  602. break;
  603. case 'md':
  604. case 'sm':
  605. if (hidden === true) {
  606. this.open();
  607. } else {
  608. this.hide();
  609. }
  610. break;
  611. case 'xs':
  612. if (hidden === true) {
  613. this.open();
  614. } else {
  615. this.hide();
  616. }
  617. break;
  618. } // Re-init sliding menu to update width
  619. this.drillDownMenu(currentBreakpoint.name);
  620. },
  621. update: function update() {
  622. this.manualScroller.update();
  623. },
  624. reset: function reset() {
  625. this.expanded = false;
  626. this.collapsed = false;
  627. this.hidden = false;
  628. $body.removeClass('menu-hide menu-open menu-collapsed menu-expanded');
  629. }
  630. }; // Navigation Menu
  631. $.app.nav = {
  632. container: $('.navigation-main'),
  633. initialized: false,
  634. navItem: $('.navigation-main').find('li').not('.navigation-category'),
  635. config: {
  636. speed: 300
  637. },
  638. init: function init(config) {
  639. this.initialized = true; // Set to true when initialized
  640. $.extend(this.config, config);
  641. this.bind_events();
  642. },
  643. bind_events: function bind_events() {
  644. var menuObj = this;
  645. $('.navigation-main').on('mouseenter.app.menu', 'li', function () {
  646. var $this = $(this);
  647. $('.hover', '.navigation-main').removeClass('hover');
  648. if ($body.hasClass('menu-collapsed') && $body.data('menu') != 'vertical-menu-modern') {
  649. $('.main-menu-content').children('span.menu-title').remove();
  650. $('.main-menu-content').children('a.menu-title').remove();
  651. $('.main-menu-content').children('ul.menu-content').remove(); // Title
  652. var menuTitle = $this.find('span.menu-title').clone(),
  653. tempTitle,
  654. tempLink;
  655. if (!$this.hasClass('has-sub')) {
  656. tempTitle = $this.find('span.menu-title').text();
  657. tempLink = $this.children('a').attr('href');
  658. if (tempTitle !== '') {
  659. menuTitle = $("<a>");
  660. menuTitle.attr("href", tempLink);
  661. menuTitle.attr("title", tempTitle);
  662. menuTitle.text(tempTitle);
  663. menuTitle.addClass("menu-title");
  664. }
  665. } // menu_header_height = ($('.main-menu-header').length) ? $('.main-menu-header').height() : 0,
  666. // fromTop = menu_header_height + $this.position().top + parseInt($this.css( "border-top" ),10);
  667. var fromTop;
  668. if ($this.css("border-top")) {
  669. fromTop = $this.position().top + parseInt($this.css("border-top"), 10);
  670. } else {
  671. fromTop = $this.position().top;
  672. }
  673. if ($body.data('menu') !== 'vertical-compact-menu') {
  674. menuTitle.appendTo('.main-menu-content').css({
  675. position: 'fixed',
  676. top: fromTop
  677. });
  678. } // Content
  679. if ($this.hasClass('has-sub') && $this.hasClass('nav-item')) {
  680. var menuContent = $this.children('ul:first');
  681. menuObj.adjustSubmenu($this);
  682. }
  683. }
  684. $this.addClass('hover');
  685. }).on('mouseleave.app.menu', 'li', function () {// $(this).removeClass('hover');
  686. }).on('active.app.menu', 'li', function (e) {
  687. $(this).addClass('active');
  688. e.stopPropagation();
  689. }).on('deactive.app.menu', 'li.active', function (e) {
  690. $(this).removeClass('active');
  691. e.stopPropagation();
  692. }).on('open.app.menu', 'li', function (e) {
  693. var $listItem = $(this);
  694. $listItem.addClass('open');
  695. menuObj.expand($listItem); // If menu collapsible then do not take any action
  696. if ($('.main-menu').hasClass('menu-collapsible')) {
  697. return false;
  698. } // If menu accordion then close all except clicked once
  699. else {
  700. $listItem.siblings('.open').find('li.open').trigger('close.app.menu');
  701. $listItem.siblings('.open').trigger('close.app.menu');
  702. }
  703. e.stopPropagation();
  704. }).on('close.app.menu', 'li.open', function (e) {
  705. var $listItem = $(this);
  706. $listItem.removeClass('open');
  707. menuObj.collapse($listItem);
  708. e.stopPropagation();
  709. }).on('click.app.menu', 'li', function (e) {
  710. var $listItem = $(this);
  711. if ($listItem.is('.disabled')) {
  712. e.preventDefault();
  713. } else {
  714. if ($body.hasClass('menu-collapsed') && $body.data('menu') != 'vertical-menu-modern') {
  715. e.preventDefault();
  716. } else {
  717. if ($listItem.has('ul').length) {
  718. if ($listItem.is('.open')) {
  719. $listItem.trigger('close.app.menu');
  720. } else {
  721. $listItem.trigger('open.app.menu');
  722. }
  723. } else {
  724. if (!$listItem.is('.active')) {
  725. $listItem.siblings('.active').trigger('deactive.app.menu');
  726. $listItem.trigger('active.app.menu');
  727. }
  728. }
  729. }
  730. }
  731. e.stopPropagation();
  732. });
  733. $('.navbar-header, .main-menu').on('mouseenter', modernMenuExpand).on('mouseleave', modernMenuCollapse);
  734. function modernMenuExpand() {
  735. if ($body.data('menu') == 'vertical-menu-modern') {
  736. $('.main-menu, .navbar-header').addClass('expanded');
  737. if ($body.hasClass('menu-collapsed')) {
  738. if ($('.main-menu li.open').length === 0) {
  739. $(".main-menu-content").find('li.active').parents('li').addClass('open');
  740. }
  741. var $listItem = $('.main-menu li.menu-collapsed-open'),
  742. $subList = $listItem.children('ul');
  743. $subList.hide().slideDown(200, function () {
  744. $(this).css('display', '');
  745. });
  746. $listItem.addClass('open').removeClass('menu-collapsed-open'); // $.app.menu.changeLogo('expand');
  747. }
  748. }
  749. }
  750. function modernMenuCollapse() {
  751. if ($body.hasClass('menu-collapsed') && $body.data('menu') == 'vertical-menu-modern') {
  752. setTimeout(function () {
  753. if ($('.main-menu:hover').length === 0 && $('.navbar-header:hover').length === 0) {
  754. $('.main-menu, .navbar-header').removeClass('expanded');
  755. if ($body.hasClass('menu-collapsed')) {
  756. var $listItem = $('.main-menu li.open'),
  757. $subList = $listItem.children('ul');
  758. $listItem.addClass('menu-collapsed-open');
  759. $subList.show().slideUp(200, function () {
  760. $(this).css('display', '');
  761. });
  762. $listItem.removeClass('open'); // $.app.menu.changeLogo();
  763. }
  764. }
  765. }, 1);
  766. }
  767. }
  768. $('.main-menu-content').on('mouseleave', function () {
  769. if ($body.hasClass('menu-collapsed')) {
  770. $('.main-menu-content').children('span.menu-title').remove();
  771. $('.main-menu-content').children('a.menu-title').remove();
  772. $('.main-menu-content').children('ul.menu-content').remove();
  773. }
  774. $('.hover', '.navigation-main').removeClass('hover');
  775. }); // If list item has sub menu items then prevent redirection.
  776. $('.navigation-main li.has-sub > a').on('click', function (e) {
  777. e.preventDefault();
  778. });
  779. $('ul.menu-content').on('click', 'li', function (e) {
  780. var $listItem = $(this);
  781. if ($listItem.is('.disabled')) {
  782. e.preventDefault();
  783. } else {
  784. if ($listItem.has('ul')) {
  785. if ($listItem.is('.open')) {
  786. $listItem.removeClass('open');
  787. menuObj.collapse($listItem);
  788. } else {
  789. $listItem.addClass('open');
  790. menuObj.expand($listItem); // If menu collapsible then do not take any action
  791. if ($('.main-menu').hasClass('menu-collapsible')) {
  792. return false;
  793. } // If menu accordion then close all except clicked once
  794. else {
  795. $listItem.siblings('.open').find('li.open').trigger('close.app.menu');
  796. $listItem.siblings('.open').trigger('close.app.menu');
  797. }
  798. e.stopPropagation();
  799. }
  800. } else {
  801. if (!$listItem.is('.active')) {
  802. $listItem.siblings('.active').trigger('deactive.app.menu');
  803. $listItem.trigger('active.app.menu');
  804. }
  805. }
  806. }
  807. e.stopPropagation();
  808. });
  809. },
  810. /**
  811. * Ensure an admin submenu is within the visual viewport.
  812. * @param {jQuery} $menuItem The parent menu item containing the submenu.
  813. */
  814. adjustSubmenu: function adjustSubmenu($menuItem) {
  815. var menuHeaderHeight,
  816. menutop,
  817. topPos,
  818. winHeight,
  819. bottomOffset,
  820. subMenuHeight,
  821. popOutMenuHeight,
  822. borderWidth,
  823. scroll_theme,
  824. $submenu = $menuItem.children('ul:first'),
  825. ul = $submenu.clone(true);
  826. menuHeaderHeight = $('.main-menu-header').height();
  827. menutop = $menuItem.position().top;
  828. winHeight = $window.height() - $('.header-navbar').height();
  829. borderWidth = 0;
  830. subMenuHeight = $submenu.height();
  831. if (parseInt($menuItem.css("border-top"), 10) > 0) {
  832. borderWidth = parseInt($menuItem.css("border-top"), 10);
  833. }
  834. popOutMenuHeight = winHeight - menutop - $menuItem.height() - 30;
  835. scroll_theme = $('.main-menu').hasClass('menu-dark') ? 'light' : 'dark';
  836. topPos = menutop + $menuItem.height() + borderWidth;
  837. ul.addClass('menu-popout').appendTo('.main-menu-content').css({
  838. 'top': topPos,
  839. 'position': 'fixed',
  840. 'max-height': popOutMenuHeight
  841. });
  842. var menu_content = new PerfectScrollbar('.main-menu-content > ul.menu-content', {
  843. wheelPropagation: false
  844. });
  845. },
  846. collapse: function collapse($listItem, callback) {
  847. var $subList = $listItem.children('ul');
  848. $subList.show().slideUp($.app.nav.config.speed, function () {
  849. $(this).css('display', '');
  850. $(this).find('> li').removeClass('is-shown');
  851. if (callback) {
  852. callback();
  853. }
  854. $.app.nav.container.trigger('collapsed.app.menu');
  855. });
  856. },
  857. expand: function expand($listItem, callback) {
  858. var $subList = $listItem.children('ul');
  859. var $children = $subList.children('li').addClass('is-hidden');
  860. $subList.hide().slideDown($.app.nav.config.speed, function () {
  861. $(this).css('display', '');
  862. if (callback) {
  863. callback();
  864. }
  865. $.app.nav.container.trigger('expanded.app.menu');
  866. });
  867. setTimeout(function () {
  868. $children.addClass('is-shown');
  869. $children.removeClass('is-hidden');
  870. }, 0);
  871. },
  872. refresh: function refresh() {
  873. $.app.nav.container.find('.open').removeClass('open');
  874. }
  875. };
  876. })(window, document, jQuery); // We listen to the resize event
  877. window.addEventListener('resize', function () {
  878. // We execute the same script as before
  879. var vh = window.innerHeight * 0.01;
  880. document.documentElement.style.setProperty('--vh', "".concat(vh, "px"));
  881. });
  882. /***/ }),
  883. /***/ 1:
  884. /*!****************************************************!*\
  885. !*** multi ./resources/assets/js/core/app-menu.js ***!
  886. \****************************************************/
  887. /*! no static exports found */
  888. /***/ (function(module, exports, __webpack_require__) {
  889. module.exports = __webpack_require__(/*! F:\p\dcat-admin-github\dcat-admin\resources\assets\js\core\app-menu.js */"./resources/assets/js/core/app-menu.js");
  890. /***/ })
  891. /******/ });