Skip to content
Snippets Groups Projects
Unverified Commit 1e01a708 authored by Mykola Balabash's avatar Mykola Balabash Committed by GitHub
Browse files

Fixed #444: Added support for different menus (#445)

parent ff339b6b
No related branches found
No related tags found
No related merge requests found
......@@ -104,7 +104,7 @@
$(window).resize(
_.debounce(() => {
if ($("#dxpr-theme-main-menu .menu").length > 0) {
if ($("#dxpr-theme-main-menu .nav").length > 0) {
dxpr_themeMenuGovernorBodyClass();
dxpr_themeMenuGovernor(document);
}
......@@ -453,7 +453,7 @@
}
$(document).ready(() => {
if ($("#dxpr-theme-main-menu .menu").length > 0) {
if ($("#dxpr-theme-main-menu .nav").length > 0) {
dxpr_themeMenuGovernorBodyClass();
dxpr_themeMenuGovernor(document);
}
......
"use strict";!function(e,t,n){var a="";if("function"!=typeof _){window._={},window._.debounce=function(e,t,n){var a,d,i=function(t,n){a=null,n&&(d=e.apply(t,n))},m=r((function(r){var m=n&&!a;return a&&clearTimeout(a),m?(a=setTimeout(i,t),d=e.apply(this,r)):n||(a=_.delay(i,t,this,r)),d}));return m.cancel=function(){clearTimeout(a),a=null},m};var r=function(e,t){return t=null==t?e.length-1:+t,function(){for(var n=Math.max(arguments.length-t,0),a=Array(n),r=0;r<n;r++)a[r]=arguments[r+t];switch(t){case 0:return e.call(this,a);case 1:return e.call(this,arguments[0],a);case 2:return e.call(this,arguments[0],arguments[1],a)}var d=Array(t+1);for(r=0;r<t;r++)d[r]=arguments[r];return d[t]=a,e.apply(this,d)}};_.delay=r((function(e,t,n){return setTimeout((function(){return e.apply(null,n)}),t)})),window._.throttle=function(e,t,n){var a,r,d,i=null,m=0;n||(n={});var o=function(){m=!1===n.leading?0:_.now(),i=null,d=e.apply(a,r),i||(a=r=null)};return function(){var s=_.now();m||!1!==n.leading||(m=s);var l=t-(s-m);return a=this,r=arguments,l<=0||l>t?(i&&(clearTimeout(i),i=null),m=s,d=e.apply(a,r),i||(a=r=null)):i||!1===n.trailing||(i=setTimeout(o,l)),d}}}e(window).resize(_.debounce((function(){e("#dxpr-theme-main-menu .menu").length>0&&(h(),s(document)),u()}),50)),u();var d="dxpr_themeNavBreakpoint"in window?window.dxpr_themeNavBreakpoint:1200;if(e(".dxpr-theme-header--sticky").length>0&&!e(".dxpr-theme-header--overlay").length&&e(window).width()>d){var i=drupalSettings.dxpr_themeSettings.headerHeight,m=drupalSettings.dxpr_themeSettings.headerOffset,o=0;i&&m&&_.throttle(e(window).scroll((function(){if((o=e(window).scrollTop())>=m?(document.querySelector(".dxpr-theme-header--sticky").classList.add("affix"),document.querySelector(".dxpr-theme-header--sticky").classList.remove("affix-top")):(document.querySelector(".dxpr-theme-header--sticky").classList.add("affix-top"),document.querySelector(".dxpr-theme-header--sticky").classList.remove("affix")),o>=m&&o<=2*m){var t=document.documentElement.scrollHeight>window.innerHeight?Number(i)+Number(m):Number(i);document.getElementsByClassName("wrap-containers")[0].style.cssText="margin-top:".concat(t,"px")}else o<m&&(document.getElementsByClassName("wrap-containers")[0].style.cssText="margin-top:0")})),100)}function s(t){var r=1200;if("dxpr_themeNavBreakpoint"in window&&(r=window.dxpr_themeNavBreakpoint),0==e(".body--dxpr-theme-header-side").length&&e(window).width()>r){if("top"==a)return!1;e(".html--dxpr-theme-nav-mobile--open").removeClass("html--dxpr-theme-nav-mobile--open"),e(".dxpr-theme-header--side").removeClass("dxpr-theme-header--side").addClass("dxpr-theme-header--top"),e("#dxpr-theme-main-menu .menu__breadcrumbs").remove(),e(".menu__level").removeClass("menu__level").css("top","100%").css("margin-top",0).css("height","auto"),e(".menu__item").removeClass("menu__item"),e("[data-submenu]").removeAttr("data-submenu"),e("[data-menu]").removeAttr("data-menu");var d=e("body").innerWidth();if(e("#dxpr-theme-main-menu .menu .dropdown-menu",t).each((function(){var t=e(this).width();if(e(this).find(".dxpr-theme-megamenu__heading").length>0)var n=e(this).find(".dxpr-theme-megamenu__heading").length;else n=Math.floor(e(this).find("li").length/8)+1;if(n>2)e(this).css({width:"100%","left:":"0"}).parent().css({position:"static"}).find(".dropdown-menu >li").css({width:"".concat(100/n,"%")});else{var a=e(this);n>1&&a.css("min-width",t*n+2).find(">li").css("width",t);var r=a.parent();setTimeout((function(){var e=Math.round(d-r.offset().left-a.outerWidth()-10);e<0&&a.css("left","".concat(e,"px"))}),0)}})),a="top",e(".tabs--primary").length>0&&e("#navbar").length>0){var i=e(".tabs--primary")[0].getBoundingClientRect();if(e(".dxpr-theme-header--navbar-pull-down").length>0&&e("#navbar .container-col").length>0){var m=e("#navbar .container-col")[0].getBoundingClientRect();p(m,i)&&e(".tabs--primary").css("margin-top",m.bottom-i.top+6)}else{var o=e("#navbar")[0].getBoundingClientRect();p(o,i)&&e(".tabs--primary").css("margin-top",o.bottom-i.top+6)}}if(e("#secondary-header").length>0&&e("#navbar.dxpr-theme-header--overlay").length>0){var s=e("#secondary-header")[0].getBoundingClientRect();p(e("#navbar.dxpr-theme-header--overlay")[0].getBoundingClientRect(),s)&&(drupalSettings.dxpr_themeSettings.secondHeaderSticky?(e("#navbar.dxpr-theme-header--overlay").css("cssText","top:".concat(s.bottom,"px !important;")),e("#secondary-header").addClass("dxpr-theme-secondary-header--sticky")):(e("#toolbar-bar").length>0?e("#navbar.dxpr-theme-header--overlay").css("top",s.bottom):e("#navbar.dxpr-theme-header--overlay").css("top",""),e("#secondary-header").removeClass("dxpr-theme-secondary-header--sticky")))}}else{if("side"==a)return!1;e("#dxpr-theme-main-menu").hide(),e(".dxpr-theme-header--top").removeClass("dxpr-theme-header--top").addClass("dxpr-theme-header--side"),e("#dxpr-theme-main-menu .menu .dropdown-menu, #dxpr-theme-main-menu .menu .dropdown-menu li").removeAttr("style"),e("#dxpr-theme-main-menu .menu").addClass("menu__level"),e("#dxpr-theme-main-menu .menu .dropdown-menu").addClass("menu__level"),e("#dxpr-theme-main-menu .menu .dxpr-theme-megamenu").addClass("menu__level"),e("#dxpr-theme-main-menu .menu a").addClass("menu__link"),e("#dxpr-theme-main-menu .menu li").addClass("menu__item"),e("#dxpr-theme-main-menu .menu a.dropdown-toggle").each((function(t){e(this).attr("data-submenu",e(this).text()).next().attr("data-menu",e(this).text())})),e("#dxpr-theme-main-menu .menu a.dxpr-theme-megamenu__heading").each((function(t){e(this).attr("data-submenu",e(this).text()).next().attr("data-menu",e(this).text())}));var l=e("#dxpr-theme-main-menu .menu .dropdown-menu").length>0,h=document.getElementById("dxpr-theme-main-menu"),u=(new MLMenu(h,{breadcrumbsCtrl:l,initialBreadcrumb:"menu",backCtrl:!1,itemsDelayInterval:10}),function(){"cross"===drupalSettings.dxpr_themeSettings.hamburgerAnimation&&e("#dxpr-theme-menu-toggle").toggleClass("navbar-toggle--active"),e(h).toggleClass("menu--open"),e("html").toggleClass("html--dxpr-theme-nav-mobile--open")});if(e(n("dxpr_themeMenuToggle","#dxpr-theme-menu-toggle")).click((function(){u()})),e("#dxpr-theme-main-menu").css("position","fixed").show(),e(".menu__link").click((function(){e(this).attr("data-submenu")||u()})),e(".wrap-branding").length>0)var c=e(".wrap-branding")[0].getBoundingClientRect().bottom;else c=0;var x=e("#dxpr-theme-main-menu .block:not(.block-menu)").last();if(e(".body--dxpr-theme-header-side").length>0&&e(window).width()>r&&x.length>0&&c>0&&e("#dxpr-theme-main-menu").css("padding-top",c+40),x.length>0){var g=x[0].getBoundingClientRect().bottom;e(".menu__breadcrumbs").css("top",g+20),e(".menu__level").css("top",g+40);var v=40+g;e(".dxpr-theme-header--side .menu__level").css("height","calc(100vh - ".concat(v,"px)"))}else if(e(".body--dxpr-theme-header-side").length>0&&e(".wrap-branding").length>0&&c>120){e(".menu__breadcrumbs").css("top",c+20),e(".menu__level").css("top",c+40);v=40+c;e(".dxpr-theme-header--side .menu__level").css("height","calc(100vh - ".concat(v,"px)"))}a="side"}}i=drupalSettings.dxpr_themeSettings.headerMobileHeight;var l=drupalSettings.dxpr_themeSettings.headerMobileFixed;d="dxpr_themeNavBreakpoint"in window?window.dxpr_themeNavBreakpoint:1200;function h(){var t=1200;"dxpr_themeNavBreakpoint"in window&&(t=window.dxpr_themeNavBreakpoint),e(window).width()>t?e(".body--dxpr-theme-nav-mobile").removeClass("body--dxpr-theme-nav-mobile").addClass("body--dxpr-theme-nav-desktop"):e(".body--dxpr-theme-nav-desktop").removeClass("body--dxpr-theme-nav-desktop").addClass("body--dxpr-theme-nav-mobile")}function u(){"right"===drupalSettings.dxpr_themeSettings.headerSideDirection&&e(window).width()<=window.dxpr_themeNavBreakpoint?e("#dxpr-theme-main-menu").addClass("dxpr-theme-main-menu--to-left"):e("#dxpr-theme-main-menu").removeClass("dxpr-theme-main-menu--to-left"),e(window).width()>window.dxpr_themeNavBreakpoint&&0===e(".dxpr-theme-header--side").length&&e("#dxpr-theme-main-menu").css("position","relative")}function p(e,t){return!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}l&&e(".dxpr-theme-header").length>0&&e(window).width()<=d&&(e("#toolbar-bar").length>0&&e("#navbar").addClass("header-mobile-admin-fixed"),e(window).width()>=975?e("#navbar").addClass("header-mobile-admin-fixed-active"):e("#navbar").removeClass("header-mobile-admin-fixed-active"),e(".dxpr-theme-boxed-container").css("overflow","hidden"),e("#toolbar-bar").addClass("header-mobile-fixed"),e("#navbar").addClass("header-mobile-fixed"),e("#secondary-header").css("margin-top",+i)),e(document).ready((function(){e("#dxpr-theme-main-menu .menu").length>0&&(h(),s(document))}))}(jQuery,Drupal,once);
\ No newline at end of file
"use strict";!function(e,t,n){var a="";if("function"!=typeof _){window._={},window._.debounce=function(e,t,n){var a,d,i=function(t,n){a=null,n&&(d=e.apply(t,n))},m=r((function(r){var m=n&&!a;return a&&clearTimeout(a),m?(a=setTimeout(i,t),d=e.apply(this,r)):n||(a=_.delay(i,t,this,r)),d}));return m.cancel=function(){clearTimeout(a),a=null},m};var r=function(e,t){return t=null==t?e.length-1:+t,function(){for(var n=Math.max(arguments.length-t,0),a=Array(n),r=0;r<n;r++)a[r]=arguments[r+t];switch(t){case 0:return e.call(this,a);case 1:return e.call(this,arguments[0],a);case 2:return e.call(this,arguments[0],arguments[1],a)}var d=Array(t+1);for(r=0;r<t;r++)d[r]=arguments[r];return d[t]=a,e.apply(this,d)}};_.delay=r((function(e,t,n){return setTimeout((function(){return e.apply(null,n)}),t)})),window._.throttle=function(e,t,n){var a,r,d,i=null,m=0;n||(n={});var o=function(){m=!1===n.leading?0:_.now(),i=null,d=e.apply(a,r),i||(a=r=null)};return function(){var s=_.now();m||!1!==n.leading||(m=s);var l=t-(s-m);return a=this,r=arguments,l<=0||l>t?(i&&(clearTimeout(i),i=null),m=s,d=e.apply(a,r),i||(a=r=null)):i||!1===n.trailing||(i=setTimeout(o,l)),d}}}e(window).resize(_.debounce((function(){e("#dxpr-theme-main-menu .nav").length>0&&(h(),s(document)),u()}),50)),u();var d="dxpr_themeNavBreakpoint"in window?window.dxpr_themeNavBreakpoint:1200;if(e(".dxpr-theme-header--sticky").length>0&&!e(".dxpr-theme-header--overlay").length&&e(window).width()>d){var i=drupalSettings.dxpr_themeSettings.headerHeight,m=drupalSettings.dxpr_themeSettings.headerOffset,o=0;i&&m&&_.throttle(e(window).scroll((function(){if((o=e(window).scrollTop())>=m?(document.querySelector(".dxpr-theme-header--sticky").classList.add("affix"),document.querySelector(".dxpr-theme-header--sticky").classList.remove("affix-top")):(document.querySelector(".dxpr-theme-header--sticky").classList.add("affix-top"),document.querySelector(".dxpr-theme-header--sticky").classList.remove("affix")),o>=m&&o<=2*m){var t=document.documentElement.scrollHeight>window.innerHeight?Number(i)+Number(m):Number(i);document.getElementsByClassName("wrap-containers")[0].style.cssText="margin-top:".concat(t,"px")}else o<m&&(document.getElementsByClassName("wrap-containers")[0].style.cssText="margin-top:0")})),100)}function s(t){var r=1200;if("dxpr_themeNavBreakpoint"in window&&(r=window.dxpr_themeNavBreakpoint),0==e(".body--dxpr-theme-header-side").length&&e(window).width()>r){if("top"==a)return!1;e(".html--dxpr-theme-nav-mobile--open").removeClass("html--dxpr-theme-nav-mobile--open"),e(".dxpr-theme-header--side").removeClass("dxpr-theme-header--side").addClass("dxpr-theme-header--top"),e("#dxpr-theme-main-menu .menu__breadcrumbs").remove(),e(".menu__level").removeClass("menu__level").css("top","100%").css("margin-top",0).css("height","auto"),e(".menu__item").removeClass("menu__item"),e("[data-submenu]").removeAttr("data-submenu"),e("[data-menu]").removeAttr("data-menu");var d=e("body").innerWidth();if(e("#dxpr-theme-main-menu .menu .dropdown-menu",t).each((function(){var t=e(this).width();if(e(this).find(".dxpr-theme-megamenu__heading").length>0)var n=e(this).find(".dxpr-theme-megamenu__heading").length;else n=Math.floor(e(this).find("li").length/8)+1;if(n>2)e(this).css({width:"100%","left:":"0"}).parent().css({position:"static"}).find(".dropdown-menu >li").css({width:"".concat(100/n,"%")});else{var a=e(this);n>1&&a.css("min-width",t*n+2).find(">li").css("width",t);var r=a.parent();setTimeout((function(){var e=Math.round(d-r.offset().left-a.outerWidth()-10);e<0&&a.css("left","".concat(e,"px"))}),0)}})),a="top",e(".tabs--primary").length>0&&e("#navbar").length>0){var i=e(".tabs--primary")[0].getBoundingClientRect();if(e(".dxpr-theme-header--navbar-pull-down").length>0&&e("#navbar .container-col").length>0){var m=e("#navbar .container-col")[0].getBoundingClientRect();p(m,i)&&e(".tabs--primary").css("margin-top",m.bottom-i.top+6)}else{var o=e("#navbar")[0].getBoundingClientRect();p(o,i)&&e(".tabs--primary").css("margin-top",o.bottom-i.top+6)}}if(e("#secondary-header").length>0&&e("#navbar.dxpr-theme-header--overlay").length>0){var s=e("#secondary-header")[0].getBoundingClientRect();p(e("#navbar.dxpr-theme-header--overlay")[0].getBoundingClientRect(),s)&&(drupalSettings.dxpr_themeSettings.secondHeaderSticky?(e("#navbar.dxpr-theme-header--overlay").css("cssText","top:".concat(s.bottom,"px !important;")),e("#secondary-header").addClass("dxpr-theme-secondary-header--sticky")):(e("#toolbar-bar").length>0?e("#navbar.dxpr-theme-header--overlay").css("top",s.bottom):e("#navbar.dxpr-theme-header--overlay").css("top",""),e("#secondary-header").removeClass("dxpr-theme-secondary-header--sticky")))}}else{if("side"==a)return!1;e("#dxpr-theme-main-menu").hide(),e(".dxpr-theme-header--top").removeClass("dxpr-theme-header--top").addClass("dxpr-theme-header--side"),e("#dxpr-theme-main-menu .menu .dropdown-menu, #dxpr-theme-main-menu .menu .dropdown-menu li").removeAttr("style"),e("#dxpr-theme-main-menu .menu").addClass("menu__level"),e("#dxpr-theme-main-menu .menu .dropdown-menu").addClass("menu__level"),e("#dxpr-theme-main-menu .menu .dxpr-theme-megamenu").addClass("menu__level"),e("#dxpr-theme-main-menu .menu a").addClass("menu__link"),e("#dxpr-theme-main-menu .menu li").addClass("menu__item"),e("#dxpr-theme-main-menu .menu a.dropdown-toggle").each((function(t){e(this).attr("data-submenu",e(this).text()).next().attr("data-menu",e(this).text())})),e("#dxpr-theme-main-menu .menu a.dxpr-theme-megamenu__heading").each((function(t){e(this).attr("data-submenu",e(this).text()).next().attr("data-menu",e(this).text())}));var l=e("#dxpr-theme-main-menu .menu .dropdown-menu").length>0,h=document.getElementById("dxpr-theme-main-menu"),u=(new MLMenu(h,{breadcrumbsCtrl:l,initialBreadcrumb:"menu",backCtrl:!1,itemsDelayInterval:10}),function(){"cross"===drupalSettings.dxpr_themeSettings.hamburgerAnimation&&e("#dxpr-theme-menu-toggle").toggleClass("navbar-toggle--active"),e(h).toggleClass("menu--open"),e("html").toggleClass("html--dxpr-theme-nav-mobile--open")});if(e(n("dxpr_themeMenuToggle","#dxpr-theme-menu-toggle")).click((function(){u()})),e("#dxpr-theme-main-menu").css("position","fixed").show(),e(".menu__link").click((function(){e(this).attr("data-submenu")||u()})),e(".wrap-branding").length>0)var c=e(".wrap-branding")[0].getBoundingClientRect().bottom;else c=0;var x=e("#dxpr-theme-main-menu .block:not(.block-menu)").last();if(e(".body--dxpr-theme-header-side").length>0&&e(window).width()>r&&x.length>0&&c>0&&e("#dxpr-theme-main-menu").css("padding-top",c+40),x.length>0){var v=x[0].getBoundingClientRect().bottom;e(".menu__breadcrumbs").css("top",v+20),e(".menu__level").css("top",v+40);var g=40+v;e(".dxpr-theme-header--side .menu__level").css("height","calc(100vh - ".concat(g,"px)"))}else if(e(".body--dxpr-theme-header-side").length>0&&e(".wrap-branding").length>0&&c>120){e(".menu__breadcrumbs").css("top",c+20),e(".menu__level").css("top",c+40);g=40+c;e(".dxpr-theme-header--side .menu__level").css("height","calc(100vh - ".concat(g,"px)"))}a="side"}}i=drupalSettings.dxpr_themeSettings.headerMobileHeight;var l=drupalSettings.dxpr_themeSettings.headerMobileFixed;d="dxpr_themeNavBreakpoint"in window?window.dxpr_themeNavBreakpoint:1200;function h(){var t=1200;"dxpr_themeNavBreakpoint"in window&&(t=window.dxpr_themeNavBreakpoint),e(window).width()>t?e(".body--dxpr-theme-nav-mobile").removeClass("body--dxpr-theme-nav-mobile").addClass("body--dxpr-theme-nav-desktop"):e(".body--dxpr-theme-nav-desktop").removeClass("body--dxpr-theme-nav-desktop").addClass("body--dxpr-theme-nav-mobile")}function u(){"right"===drupalSettings.dxpr_themeSettings.headerSideDirection&&e(window).width()<=window.dxpr_themeNavBreakpoint?e("#dxpr-theme-main-menu").addClass("dxpr-theme-main-menu--to-left"):e("#dxpr-theme-main-menu").removeClass("dxpr-theme-main-menu--to-left"),e(window).width()>window.dxpr_themeNavBreakpoint&&0===e(".dxpr-theme-header--side").length&&e("#dxpr-theme-main-menu").css("position","relative")}function p(e,t){return!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom)}l&&e(".dxpr-theme-header").length>0&&e(window).width()<=d&&(e("#toolbar-bar").length>0&&e("#navbar").addClass("header-mobile-admin-fixed"),e(window).width()>=975?e("#navbar").addClass("header-mobile-admin-fixed-active"):e("#navbar").removeClass("header-mobile-admin-fixed-active"),e(".dxpr-theme-boxed-container").css("overflow","hidden"),e("#toolbar-bar").addClass("header-mobile-fixed"),e("#navbar").addClass("header-mobile-fixed"),e("#secondary-header").css("margin-top",+i)),e(document).ready((function(){e("#dxpr-theme-main-menu .nav").length>0&&(h(),s(document))}))}(jQuery,Drupal,once);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment