2022-04-13 13:51:55 +07:00

341 lines
15 KiB
JavaScript

/*!
* metismenu https://github.com/onokumus/metismenu#readme
* A jQuery menu plugin
* @version 3.0.3
* @author Osman Nuri Okumus <onokumus@gmail.com> (https://github.com/onokumus)
* @license: MIT
*/
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],n):e.metisMenu=n(e.jQuery)}(this,function(o){"use strict";function a(r){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{},n=Object.keys(a);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(a).filter(function(e){return Object.getOwnPropertyDescriptor(a,e).enumerable}))),n.forEach(function(e){var n,t,i;n=r,i=a[t=e],t in n?Object.defineProperty(n,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[t]=i})}return r}var s=function(i){var n="transitionend",r={TRANSITION_END:"mmTransitionEnd",triggerTransitionEnd:function(e){i(e).trigger(n)},supportsTransitionEnd:function(){return Boolean(n)}};function e(e){var n=this,t=!1;return i(this).one(r.TRANSITION_END,function(){t=!0}),setTimeout(function(){t||r.triggerTransitionEnd(n)},e),this}return i.fn.mmEmulateTransitionEnd=e,i.event.special[r.TRANSITION_END]={bindType:n,delegateType:n,handle:function(e){if(i(e.target).is(this))return e.handleObj.handler.apply(this,arguments)}},r}(o=o&&o.hasOwnProperty("default")?o.default:o),e="metisMenu",g="metisMenu",n="."+g,t=o.fn[e],l={toggle:!0,preventDefault:!0,triggerElement:"a",parentTrigger:"li",subMenu:"ul"},u={SHOW:"show"+n,SHOWN:"shown"+n,HIDE:"hide"+n,HIDDEN:"hidden"+n,CLICK_DATA_API:"click"+n+".data-api"},i="metismenu",f="mm-active",h="mm-show",d="mm-collapse",c="mm-collapsing",r=function(){function r(e,n){this.element=e,this.config=a({},l,n),this.transitioning=null,this.init()}var e=r.prototype;return e.init=function(){var a=this,s=this.config;o(this.element).addClass(i),o(this.element).find(s.parentTrigger+"."+f).children(s.triggerElement).attr("aria-expanded","true"),o(this.element).find(s.parentTrigger+"."+f).parents(s.parentTrigger).addClass(f),o(this.element).find(s.parentTrigger+"."+f).parents(s.parentTrigger).children(s.triggerElement).attr("aria-expanded","true"),o(this.element).find(s.parentTrigger+"."+f).has(s.subMenu).children(s.subMenu).addClass(d+" "+h),o(this.element).find(s.parentTrigger).not("."+f).has(s.subMenu).children(s.subMenu).addClass(d),o(this.element).find(s.parentTrigger).has(s.subMenu).children(s.triggerElement).on(u.CLICK_DATA_API,function(e){var n=o(this),t=n.parent(s.parentTrigger),i=t.siblings(s.parentTrigger).children(s.triggerElement),r=t.children(s.subMenu);s.preventDefault&&e.preventDefault(),"true"!==n.attr("aria-disabled")&&(t.hasClass(f)?(n.attr("aria-expanded","false"),a.hide(r)):(a.show(r),n.attr("aria-expanded","true"),s.toggle&&i.attr("aria-expanded","false")),s.onTransitionStart&&s.onTransitionStart(e))})},e.show=function(e){var n=this;if(!this.transitioning&&!o(e).hasClass(c)){var t=o(e),i=o.Event(u.SHOW);if(t.trigger(i),!i.isDefaultPrevented()){if(t.parent(this.config.parentTrigger).addClass(f),this.config.toggle){var r=t.parent(this.config.parentTrigger).siblings().children(this.config.subMenu+"."+h);this.hide(r)}t.removeClass(d).addClass(c).height(0),this.setTransitioning(!0);t.height(e[0].scrollHeight).one(s.TRANSITION_END,function(){n.config&&n.element&&(t.removeClass(c).addClass(d+" "+h).height(""),n.setTransitioning(!1),t.trigger(u.SHOWN))}).mmEmulateTransitionEnd(350)}}},e.hide=function(e){var n=this;if(!this.transitioning&&o(e).hasClass(h)){var t=o(e),i=o.Event(u.HIDE);if(t.trigger(i),!i.isDefaultPrevented()){t.parent(this.config.parentTrigger).removeClass(f),t.height(t.height())[0].offsetHeight,t.addClass(c).removeClass(d).removeClass(h),this.setTransitioning(!0);var r=function(){n.config&&n.element&&(n.transitioning&&n.config.onTransitionEnd&&n.config.onTransitionEnd(),n.setTransitioning(!1),t.trigger(u.HIDDEN),t.removeClass(c).addClass(d))};0===t.height()||"none"===t.css("display")?r():t.height(0).one(s.TRANSITION_END,r).mmEmulateTransitionEnd(350)}}},e.setTransitioning=function(e){this.transitioning=e},e.dispose=function(){o.removeData(this.element,g),o(this.element).find(this.config.parentTrigger).has(this.config.subMenu).children(this.config.triggerElement).off("click"),this.transitioning=null,this.config=null,this.element=null},r.jQueryInterface=function(i){return this.each(function(){var e=o(this),n=e.data(g),t=a({},l,e.data(),"object"==typeof i&&i?i:{});if(n||(n=new r(this,t),e.data(g,n)),"string"==typeof i){if(void 0===n[i])throw new Error('No method named "'+i+'"');n[i]()}})},r}();return o.fn[e]=r.jQueryInterface,o.fn[e].Constructor=r,o.fn[e].noConflict=function(){return o.fn[e]=t,r.jQueryInterface},r});
//# sourceMappingURL=metisMenu.min.js.map
var body = $('body');
var html = $('html');
function dezSettings({typography, version, layout, navheaderBg, headerBg, sidebarStyle, sidebarBg, sidebarPosition, headerPosition, containerLayout, direction}) {
this.typography = typography || "poppins";
this.version = version || "light";
this.layout = layout || "vertical";
this.navheaderBg = navheaderBg || "color_1";
this.headerBg = headerBg || "color_1";
this.sidebarStyle = sidebarStyle || "full";
this.sidebarBg = sidebarBg || "color_1";
this.sidebarPosition = sidebarPosition || "static";
this.headerPosition = headerPosition || "static";
this.containerLayout = containerLayout || "wide";
this.direction = direction || "ltr";
this.manageTypography();
this.manageVersion();
this.manageLayout();
this.manageNavHeaderBg();
this.manageHeaderBg();
this.manageSidebarStyle();
this.manageSidebarBg();
this.manageSidebarPosition();
this.manageHeaderPosition();
this.manageContainerLayout();
this.manageRtlLayout();
this.manageResponsiveSidebar();
}
dezSettings.prototype.manageVersion = function() {
switch(this.version) {
case "light":
body.attr("data-theme-version", "light");
break;
case "dark":
body.attr("data-theme-version", "dark");
break;
case "transparent":
body.attr("data-theme-version", "transparent");
break;
default:
body.attr("data-theme-version", "light");
}
}
dezSettings.prototype.manageTypography = function() {
switch(this.version) {
case "poppins":
body.attr("data-typography", "poppins");
break;
case "roboto":
body.attr("data-typography", "roboto");
break;
case "opensans":
body.attr("data-typography", "opensans");
break;
default:
body.attr("data-typography", "poppins");
}
}
dezSettings.prototype.manageLayout = function() {
switch(this.layout) {
case "horizontal":
this.sidebarStyle === "overlay" ? body.attr("data-sidebar-style", "full") : body.attr("data-sidebar-style", `${this.sidebarStyle}`);
body.attr("data-layout", "horizontal");
break;
case "vertical":
body.attr("data-layout", "vertical");
break;
default:
body.attr("data-layout", "vertical");
}
}
dezSettings.prototype.manageNavHeaderBg = function() {
switch(this.navheaderBg) {
case "color_1":
body.attr("data-nav-headerbg", "color_1");
break;
case "color_2":
body.attr("data-nav-headerbg", "color_2");
break;
case "color_3":
body.attr("data-nav-headerbg", "color_3");
break;
case "color_4":
body.attr("data-nav-headerbg", "color_4");
break;
case "color_5":
body.attr("data-nav-headerbg", "color_5");
break;
case "color_6":
body.attr("data-nav-headerbg", "color_6");
break;
case "color_7":
body.attr("data-nav-headerbg", "color_7");
break;
case "color_8":
body.attr("data-nav-headerbg", "color_8");
break;
case "color_9":
body.attr("data-nav-headerbg", "color_9");
break;
case "color_10":
body.attr("data-nav-headerbg", "color_10");
break;
case "image_1":
body.attr("data-nav-headerbg", "image_1");
break;
case "image_2":
body.attr("data-nav-headerbg", "image_2");
break;
case "image_3":
body.attr("data-nav-headerbg", "image_3");
break;
default:
body.attr("data-nav-headerbg", "color_1");
}
}
dezSettings.prototype.manageHeaderBg = function() {
switch(this.headerBg) {
case "color_1":
body.attr("data-headerbg", "color_1");
break;
case "color_2":
body.attr("data-headerbg", "color_2");
break;
case "color_3":
body.attr("data-headerbg", "color_3");
break;
case "color_4":
body.attr("data-headerbg", "color_4");
break;
case "color_5":
body.attr("data-headerbg", "color_5");
break;
case "color_6":
body.attr("data-headerbg", "color_6");
break;
case "color_7":
body.attr("data-headerbg", "color_7");
break;
case "color_8":
body.attr("data-headerbg", "color_8");
break;
case "color_9":
body.attr("data-headerbg", "color_9");
break;
case "color_10":
body.attr("data-headerbg", "color_10");
break;
case "transparent":
body.attr("data-headerbg", "transparent");
break;
case "gradient_1":
body.attr("data-headerbg", "gradient_1");
break;
case "gradient_2":
body.attr("data-headerbg", "gradient_2");
break;
case "gradient_3":
body.attr("data-headerbg", "gradient_3");
break;
default:
body.attr("data-headerbg", "color_1");
}
}
dezSettings.prototype.manageSidebarStyle = function() {
switch(this.sidebarStyle) {
case "full":
body.attr("data-sidebar-style", "full");
break;
case "mini":
body.attr("data-sidebar-style", "mini");
break;
case "compact":
body.attr("data-sidebar-style", "compact");
break;
case "modern":
body.attr("data-sidebar-style", "modern");
break;
case "icon-hover":
body.attr("data-sidebar-style", "icon-hover");
$('.deznav').hover(function() {
$('#main-wrapper').addClass('icon-hover-toggle');
}, function() {
$('#main-wrapper').removeClass('icon-hover-toggle');
});
break;
case "overlay":
this.layout === "horizontal" ? body.attr("data-sidebar-style", "full") : body.attr("data-sidebar-style", "overlay");
break;
default:
body.attr("data-sidebar-style", "full");
}
}
dezSettings.prototype.manageSidebarBg = function() {
switch(this.sidebarBg) {
case "color_1":
body.attr("data-sibebarbg", "color_1");
break;
case "color_2":
body.attr("data-sibebarbg", "color_2");
break;
case "color_3":
body.attr("data-sibebarbg", "color_3");
break;
case "color_4":
body.attr("data-sibebarbg", "color_4");
break;
case "color_5":
body.attr("data-sibebarbg", "color_5");
break;
case "color_6":
body.attr("data-sibebarbg", "color_6");
break;
case "color_7":
body.attr("data-sibebarbg", "color_7");
break;
case "color_8":
body.attr("data-sibebarbg", "color_8");
break;
case "color_9":
body.attr("data-sibebarbg", "color_9");
break;
case "color_10":
body.attr("data-sibebarbg", "color_10");
break;
case "image_1":
body.attr("data-sibebarbg", "image_1");
break;
case "image_2":
body.attr("data-sibebarbg", "image_2");
break;
case "image_3":
body.attr("data-sibebarbg", "image_3");
break;
default:
body.attr("data-sibebarbg", "color_1");
}
}
dezSettings.prototype.manageSidebarPosition = function() {
switch(this.sidebarPosition) {
case "fixed":
this.sidebarStyle === "overlay" && this.layout === "vertical" || this.sidebarStyle === "modern" ? body.attr("data-sidebar-position", "static") : body.attr("data-sidebar-position", "fixed");
break;
case "static":
body.attr("data-sidebar-position", "static");
break;
default:
body.attr("data-sidebar-position", "static");
}
}
dezSettings.prototype.manageHeaderPosition = function() {
switch(this.headerPosition) {
case "fixed":
body.attr("data-header-position", "fixed");
break;
case "static":
body.attr("data-header-position", "static");
break;
default:
body.attr("data-header-position", "static");
}
}
dezSettings.prototype.manageContainerLayout = function() {
switch(this.containerLayout) {
case "boxed":
if(this.layout === "vertical" && this.sidebarStyle === "full") {
body.attr("data-sidebar-style", "overlay");
}
body.attr("data-container", "boxed");
break;
case "wide":
body.attr("data-container", "wide");
break;
case "wide-boxed":
body.attr("data-container", "wide-boxed");
break;
default:
body.attr("data-container", "wide");
}
}
dezSettings.prototype.manageRtlLayout = function() {
switch(this.direction) {
case "rtl":
html.attr("dir", "rtl");
html.addClass('rtl');
body.attr("direction", "rtl");
break;
case "ltr":
html.attr("dir", "ltr");
html.removeClass('rtl');
body.attr("direction", "ltr");
break;
default:
html.attr("dir", "ltr");
body.attr("direction", "ltr");
}
}
dezSettings.prototype.manageResponsiveSidebar = function() {
const innerWidth = $(window).innerWidth();
if(innerWidth < 1200) {
body.attr("data-layout", "vertical");
body.attr("data-container", "wide");
}
if(innerWidth > 767 && innerWidth < 1200) {
body.attr("data-sidebar-style", "mini");
}
if(innerWidth < 768) {
body.attr("data-sidebar-style", "overlay");
}
}