! function(window, document, $) {
"use strict";
$.app = $.app || {};
var $body = $("body"),
$window = $(window),
menuWrapper_el = $('div[data-menu="menu-wrapper"]').html(),
menuWrapperClasses = $('div[data-menu="menu-wrapper"]').attr("class");
$.app.menu = {
expanded: null,
collapsed: null,
hidden: null,
container: null,
horizontalMenu: !1,
manualScroller: {
obj: null,
init: function() {
var scroll_theme = $(".main-menu").hasClass("menu-dark") ? "light" : "dark";
this.obj = $(".main-menu-content").perfectScrollbar({
suppressScrollX: !0,
theme: scroll_theme
})
},
update: function() {
if (this.obj) {
if ($(".main-menu").data("scroll-to-active") === !0) {
var position;
position = $(".main-menu-content").find("li.active").parents("li").length > 0 ? $(".main-menu-content").find("li.active").parents("li").last().position() : $(".main-menu-content").find("li.active").position(), setTimeout(function() {
void 0 !== position && $.app.menu.container.stop().animate({
scrollTop: position.top
}, 300), $(".main-menu").data("scroll-to-active", "false")
}, 300)
}
$(".main-menu-content").perfectScrollbar("update")
}
},
enable: function() {
this.init()
},
disable: function() {
this.obj && $(".main-menu-content").perfectScrollbar("destroy")
},
updateHeight: function() {
"vertical-menu" != $body.data("menu") && "vertical-menu-modern" != $body.data("menu") && "vertical-overlay-menu" != $body.data("menu") || !$(".main-menu").hasClass("menu-fixed") || ($(".main-menu-content").css("height", $(window).height() - $(".header-navbar").height() - $(".main-menu-header").outerHeight() - $(".main-menu-footer").outerHeight()), this.update())
}
},
init: function(compactMenu) {
if ($(".main-menu-content").length > 0) {
this.container = $(".main-menu-content");
var defMenu = "";
if (compactMenu === !0 && (defMenu = "collapsed"), "vertical-menu-modern" == $body.data("menu")) {
var menuToggle = "";
"undefined" != typeof Storage && (menuToggle = localStorage.getItem("menuLocked")), "false" === menuToggle ? this.change("collapsed") : this.change()
} else this.change(defMenu)
} else this.drillDownMenu()
},
drillDownMenu: function(screenSize) {
$(".drilldown-menu").length && ("sm" == screenSize || "xs" == screenSize ? "true" == $("#navbar-mobile").attr("aria-expanded") && $(".drilldown-menu").slidingMenu({
backLabel: !0
}) : $(".drilldown-menu").slidingMenu({
backLabel: !0
}))
},
change: function(defMenu) {
function searchMenu(list) {
var input = $(".menu-search");
$(input).change(function() {
var filter = $(this).val();
if (filter) {
$(".navigation-header").hide(), $(list).find("li a:not(:Contains(" + filter + "))").hide().parent().hide();
var searchFilter = $(list).find("li a:Contains(" + filter + ")");
searchFilter.parent().hasClass("has-sub") ? (searchFilter.show().parents("li").show().addClass("open").closest("li").children("a").show().children("li").show(), searchFilter.siblings("ul").length > 0 && searchFilter.siblings("ul").children("li").show().children("a").show()) : searchFilter.show().parents("li").show().addClass("open").closest("li").children("a").show()
} else $(".navigation-header").show(), $(list).find("li a").show().parent().show().removeClass("open");
return $.app.menu.manualScroller.update(), !1
}).keyup(function() {
$(this).change()
})
}
var currentBreakpoint = Unison.fetch.now();
this.reset();
var menuType = $body.data("menu");
if (currentBreakpoint) switch (currentBreakpoint.name) {
case "xl":
case "lg":
"vertical-overlay-menu" === menuType ? this.hide() : "collapsed" === defMenu ? this.collapse(defMenu) : this.expand();
break;
case "md":
"vertical-overlay-menu" === menuType ? this.hide() : this.collapse();
break;
case "sm":
this.hide();
break;
case "xs":
this.hide()
}
"vertical-menu" !== menuType && "vertical-menu-modern" !== menuType || this.toOverlayMenu(currentBreakpoint.name), $body.is(".horizontal-layout") && !$body.hasClass(".horizontal-menu-demo") && (this.changeMenu(currentBreakpoint.name), $(".menu-toggle").removeClass("is-active")), "horizontal-menu" != menuType && this.drillDownMenu(currentBreakpoint.name), "xl" == currentBreakpoint.name && ($('body[data-open="hover"] .dropdown').on("mouseenter", function() {
$(this).hasClass("open") ? $(this).removeClass("open") : $(this).addClass("open")
}).on("mouseleave", function(event) {
$(this).removeClass("open")
}), $('body[data-open="hover"] .dropdown a').on("click", function(e) {
if ("horizontal-menu" == menuType) {
var $this = $(this);
if ($this.hasClass("dropdown-toggle")) return !1
}
})), $(".header-navbar").hasClass("navbar-brand-center") && $(".header-navbar").attr("data-nav", "brand-center"), "sm" == currentBreakpoint.name || "xs" == currentBreakpoint.name ? $(".header-navbar[data-nav=brand-center]").removeClass("navbar-brand-center") : $(".header-navbar[data-nav=brand-center]").addClass("navbar-brand-center"), $("ul.dropdown-menu [data-toggle=dropdown]").on("click", function(event) {
$(this).siblings("ul.dropdown-menu").length > 0 && event.preventDefault(), event.stopPropagation(), $(this).parent().siblings().removeClass("open"), $(this).parent().toggleClass("open")
}), "horizontal-menu" == menuType && ("sm" == currentBreakpoint.name || "xs" == currentBreakpoint.name ? $(".menu-fixed").length && $(".menu-fixed").unstick() : $(".navbar-fixed").length && $(".navbar-fixed").sticky()), "vertical-menu" !== menuType && "vertical-overlay-menu" !== menuType || (jQuery.expr[":"].Contains = function(a, i, m) {
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase()) >= 0
}, searchMenu($("#main-menu-navigation")))
},
transit: function(callback1, callback2) {
var menuObj = this;
$body.addClass("changing-menu"), callback1.call(menuObj), $body.hasClass("vertical-layout") && ($body.hasClass("menu-open") || $body.hasClass("menu-expanded") ? ($(".menu-toggle").addClass("is-active"), "vertical-menu" === $body.data("menu") && $(".main-menu-header") && $(".main-menu-header").show()) : ($(".menu-toggle").removeClass("is-active"), "vertical-menu" === $body.data("menu") && $(".main-menu-header") && $(".main-menu-header").hide())), setTimeout(function() {
callback2.call(menuObj), $body.removeClass("changing-menu"), menuObj.update()
}, 500)
},
open: function() {
this.transit(function() {
$body.removeClass("menu-hide menu-collapsed").addClass("menu-open"), this.hidden = !1, this.expanded = !0
}, function() {
!$(".main-menu").hasClass("menu-native-scroll") && $(".main-menu").hasClass("menu-fixed") && (this.manualScroller.enable(), $(".main-menu-content").css("height", $(window).height() - $(".header-navbar").height() - $(".main-menu-header").outerHeight() - $(".main-menu-footer").outerHeight()))
})
},
hide: function() {
this.transit(function() {
$body.removeClass("menu-open menu-expanded").addClass("menu-hide"), this.hidden = !0, this.expanded = !1
}, function() {
!$(".main-menu").hasClass("menu-native-scroll") && $(".main-menu").hasClass("menu-fixed") && this.manualScroller.enable()
})
},
expand: function() {
this.expanded === !1 && ("vertical-menu-modern" == $body.data("menu") && ($(".modern-nav-toggle").find(".toggle-icon").removeClass("ft-toggle-left").addClass("ft-toggle-right"), "undefined" != typeof Storage && localStorage.setItem("menuLocked", "true")), this.transit(function() {
$body.removeClass("menu-collapsed").addClass("menu-expanded"), this.collapsed = !1, this.expanded = !0
}, function() {
$(".main-menu").hasClass("menu-native-scroll") || "horizontal-menu" == $body.data("menu") ? this.manualScroller.disable() : $(".main-menu").hasClass("menu-fixed") && this.manualScroller.enable(), "vertical-menu" != $body.data("menu") && "vertical-menu-modern" != $body.data("menu") || !$(".main-menu").hasClass("menu-fixed") || $(".main-menu-content").css("height", $(window).height() - $(".header-navbar").height() - $(".main-menu-header").outerHeight() - $(".main-menu-footer").outerHeight())
}))
},
collapse: function(defMenu) {
this.collapsed === !1 && ("vertical-menu-modern" == $body.data("menu") && ($(".modern-nav-toggle").find(".toggle-icon").removeClass("ft-toggle-right").addClass("ft-toggle-left"), "undefined" != typeof Storage && localStorage.setItem("menuLocked", "false")), this.transit(function() {
$body.removeClass("menu-expanded").addClass("menu-collapsed"), this.collapsed = !0, this.expanded = !1
}, function() {
"horizontal-menu" == $body.data("menu") && $body.hasClass("vertical-overlay-menu") && $(".main-menu").hasClass("menu-fixed") && this.manualScroller.enable(), "vertical-menu" != $body.data("menu") && "vertical-menu-modern" != $body.data("menu") || !$(".main-menu").hasClass("menu-fixed") || $(".main-menu-content").css("height", $(window).height() - $(".header-navbar").height())
}))
},
toOverlayMenu: function(screen) {
var menu = $body.data("menu");
"sm" == screen || "xs" == screen ? $body.hasClass(menu) && $body.removeClass(menu).addClass("vertical-overlay-menu") : $body.hasClass("vertical-overlay-menu") && $body.removeClass("vertical-overlay-menu").addClass(menu)
},
changeMenu: function(screen) {
$('div[data-menu="menu-wrapper"]').html(""), $('div[data-menu="menu-wrapper"]').html(menuWrapper_el);
var menuWrapper = $('div[data-menu="menu-wrapper"]'),
menuNavigation = ($('div[data-menu="menu-container"]'), $('ul[data-menu="menu-navigation"]')),
megaMenu = $('li[data-menu="megamenu"]'),
megaMenuCol = $("li[data-mega-col]"),
dropdownMenu = $('li[data-menu="dropdown"]'),
dropdownSubMenu = $('li[data-menu="dropdown-submenu"]');
"sm" == screen || "xs" == screen ? ($body.removeClass($body.data("menu")).addClass("vertical-layout vertical-overlay-menu fixed-navbar"), $("nav.header-navbar").addClass("navbar-fixed-top"), menuWrapper.removeClass().addClass("main-menu menu-light menu-fixed menu-shadow"), menuNavigation.removeClass().addClass("navigation navigation-main"), megaMenu.removeClass("dropdown mega-dropdown").addClass("has-sub"), megaMenu.children("ul").removeClass(), megaMenuCol.each(function(index, el) {
var megaMenuSub = $(el).find(".mega-menu-sub");
megaMenuSub.find("li").has("ul").addClass("has-sub");
var first_child = $(el).children().first(),
first_child_text = "";
first_child.is("h6") && (first_child_text = first_child.html(), first_child.remove(), $(el).prepend('<a href="#">' + first_child_text + "</a>").addClass("has-sub mega-menu-title"))
}), megaMenu.find("a").removeClass("dropdown-toggle"), megaMenu.find("a").removeClass("dropdown-item"), dropdownMenu.removeClass("dropdown").addClass("has-sub"), dropdownMenu.find("a").removeClass("dropdown-toggle nav-link"), dropdownMenu.children("ul").find("a").removeClass("dropdown-item"), dropdownMenu.find("ul").removeClass("dropdown-menu"), dropdownSubMenu.removeClass().addClass("has-sub"), $.app.nav.init(), $("ul.dropdown-menu [data-toggle=dropdown]").on("click", function(event) {
event.preventDefault(), event.stopPropagation(), $(this).parent().siblings().removeClass("open"), $(this).parent().toggleClass("open")
})) : ($body.removeClass("vertical-layout vertical-overlay-menu fixed-navbar").addClass($body.data("menu")), $("nav.header-navbar").removeClass("navbar-fixed-top"), menuWrapper.removeClass().addClass(menuWrapperClasses), this.drillDownMenu(screen), $("a.dropdown-item.nav-has-children").on("click", function() {
event.preventDefault(), event.stopPropagation()
}), $("a.dropdown-item.nav-has-parent").on("click", function() {
event.preventDefault(), event.stopPropagation()
}))
},
toggle: function() {
var currentBreakpoint = Unison.fetch.now(),
expanded = (this.collapsed, this.expanded),
hidden = this.hidden,
menu = $body.data("menu");
switch (currentBreakpoint.name) {
case "xl":
case "lg":
case "md":
expanded === !0 ? "vertical-overlay-menu" == menu ? this.hide() : this.collapse() : "vertical-overlay-menu" == menu ? this.open() : this.expand();
break;
case "sm":
hidden === !0 ? this.open() : this.hide();
break;
case "xs":
hidden === !0 ? this.open() : this.hide()
}
this.drillDownMenu(currentBreakpoint.name)
},
update: function() {
this.manualScroller.update()
},
reset: function() {
this.expanded = !1, this.collapsed = !1, this.hidden = !1, $body.removeClass("menu-hide menu-open menu-collapsed menu-expanded")
}
}, $.app.nav = {
container: $(".navigation-main"),
initialized: !1,
navItem: $(".navigation-main").find("li").not(".navigation-category"),
config: {
speed: 300
},
init: function(config) {
this.initialized = !0, $.extend(this.config, config), this.bind_events()
},
bind_events: function() {
function modernMenuExpand() {
if ("vertical-menu-modern" == $body.data("menu") && ($(".main-menu, .navbar-header").addClass("expanded"), $body.hasClass("menu-collapsed"))) {
var $listItem = $(".main-menu li.menu-collapsed-open"),
$subList = $listItem.children("ul");
$subList.hide().slideDown(200, function() {
$(this).css("display", "")
}), $listItem.addClass("open").removeClass("menu-collapsed-open")
}
}
function modernMenuCollapse() {
if ($body.hasClass("menu-collapsed") && "vertical-menu-modern" == $body.data("menu") && 0 === $(".main-menu:hover").length && 0 === $(".navbar-header:hover").length && ($(".main-menu, .navbar-header").removeClass("expanded"), $body.hasClass("menu-collapsed"))) {
var $listItem = $(".main-menu li.open"),
$subList = $listItem.children("ul");
$listItem.addClass("menu-collapsed-open"), $subList.show().slideUp(200, function() {
$(this).css("display", "")
}), $listItem.removeClass("open")
}
}
var menuObj = this;
$(".navigation-main").on("mouseenter.app.menu", "li", function() {
var $this = $(this);
if ($(".hover", ".navigation-main").removeClass("hover"), $body.hasClass("menu-collapsed") && "vertical-menu-modern" != $body.data("menu")) {
$(".main-menu-content").children("span.menu-title").remove(), $(".main-menu-content").children("a.menu-title").remove(), $(".main-menu-content").children("ul.menu-content").remove();
var tempTitle, tempLink, menuTitle = $this.find("span.menu-title").clone();
$this.hasClass("has-sub") || (tempTitle = $this.find("span.menu-title").text(), tempLink = $this.children("a").attr("href"), "" !== tempTitle && (menuTitle = $("<a>"), menuTitle.attr("href", tempLink), menuTitle.attr("title", tempTitle), menuTitle.text(tempTitle), menuTitle.addClass("menu-title")));
var fromTop;
if (fromTop = $this.css("border-top") ? $this.position().top + parseInt($this.css("border-top"), 10) : $this.position().top, "vertical-compact-menu" !== $body.data("menu") && menuTitle.appendTo(".main-menu-content").css({
position: "fixed",
top: fromTop
}), $this.hasClass("has-sub") && $this.hasClass("nav-item")) {
$this.children("ul:first");
menuObj.adjustSubmenu($this)
}
}
$this.addClass("hover")
}).on("mouseleave.app.menu", "li", function() {}).on("active.app.menu", "li", function(e) {
$(this).addClass("active"), e.stopPropagation()
}).on("deactive.app.menu", "li.active", function(e) {
$(this).removeClass("active"), e.stopPropagation()
}).on("open.app.menu", "li", function(e) {
var $listItem = $(this);
return $listItem.addClass("open"), menuObj.expand($listItem), !$(".main-menu").hasClass("menu-collapsible") && ($listItem.siblings(".open").find("li.open").trigger("close.app.menu"), $listItem.siblings(".open").trigger("close.app.menu"), void e.stopPropagation())
}).on("close.app.menu", "li.open", function(e) {
var $listItem = $(this);
$listItem.removeClass("open"), menuObj.collapse($listItem), e.stopPropagation()
}).on("click.app.menu", "li", function(e) {
var $listItem = $(this);
$listItem.is(".disabled") ? e.preventDefault() : $body.hasClass("menu-collapsed") && "vertical-menu-modern" != $body.data("menu") ? e.preventDefault() : $listItem.has("ul") ? $listItem.is(".open") ? $listItem.trigger("close.app.menu") : $listItem.trigger("open.app.menu") : $listItem.is(".active") || ($listItem.siblings(".active").trigger("deactive.app.menu"), $listItem.trigger("active.app.menu")), e.stopPropagation()
}), $(".navbar-header, .main-menu").on("mouseenter", modernMenuExpand).on("mouseleave", modernMenuCollapse), $(".main-menu-content").on("mouseleave", function() {
$body.hasClass("menu-collapsed") && ($(".main-menu-content").children("span.menu-title").remove(), $(".main-menu-content").children("a.menu-title").remove(), $(".main-menu-content").children("ul.menu-content").remove()), $(".hover", ".navigation-main").removeClass("hover")
}), $(".navigation-main li.has-sub > a").on("click", function(e) {
e.preventDefault()
}), $("ul.menu-content").on("click", "li", function(e) {
var $listItem = $(this);
if ($listItem.is(".disabled")) e.preventDefault();
else if ($listItem.has("ul"))
if ($listItem.is(".open")) $listItem.removeClass("open"), menuObj.collapse($listItem);
else {
if ($listItem.addClass("open"), menuObj.expand($listItem), $(".main-menu").hasClass("menu-collapsible")) return !1;
$listItem.siblings(".open").find("li.open").trigger("close.app.menu"), $listItem.siblings(".open").trigger("close.app.menu"), e.stopPropagation()
}
else $listItem.is(".active") || ($listItem.siblings(".active").trigger("deactive.app.menu"), $listItem.trigger("active.app.menu"));
e.stopPropagation()
})
},
adjustSubmenu: function($menuItem) {
var menuHeaderHeight, menutop, topPos, winHeight, subMenuHeight, popOutMenuHeight, borderWidth, scroll_theme, $submenu = $menuItem.children("ul:first"),
ul = $submenu.clone(!0);
menuHeaderHeight = $(".main-menu-header").height(), menutop = $menuItem.position().top, winHeight = $window.height() - $(".header-navbar").height(), borderWidth = 0, subMenuHeight = $submenu.height(), parseInt($menuItem.css("border-top"), 10) > 0 && (borderWidth = parseInt($menuItem.css("border-top"), 10)), popOutMenuHeight = winHeight - menutop - $menuItem.height() - 30, scroll_theme = $(".main-menu").hasClass("menu-dark") ? "light" : "dark", topPos = menutop + $menuItem.height() + borderWidth, ul.addClass("menu-popout").appendTo(".main-menu-content").css({
top: topPos,
position: "fixed",
"max-height": popOutMenuHeight
}), $(".main-menu-content > ul.menu-content").perfectScrollbar({
theme: scroll_theme
})
},
collapse: function($listItem, callback) {
var $subList = $listItem.children("ul");
$subList.show().slideUp($.app.nav.config.speed, function() {
$(this).css("display", ""), $(this).find("> li").removeClass("is-shown"), callback && callback(), $.app.nav.container.trigger("collapsed.app.menu")
})
},
expand: function($listItem, callback) {
var $subList = $listItem.children("ul"),
$children = $subList.children("li").addClass("is-hidden");
$subList.hide().slideDown($.app.nav.config.speed, function() {
$(this).css("display", ""), callback && callback(), $.app.nav.container.trigger("expanded.app.menu")
}), setTimeout(function() {
$children.addClass("is-shown"), $children.removeClass("is-hidden")
}, 0)
},
refresh: function() {
$.app.nav.container.find(".open").removeClass("open")
}
}
}(window, document, jQuery);