diff --git a/assets/universalTheme.js.min.php b/assets/universalTheme.js.min.php index f8217b6..02d5f82 100644 --- a/assets/universalTheme.js.min.php +++ b/assets/universalTheme.js.min.php @@ -8,5 +8,5 @@ */ return <<<'EOT' -var bearCMS=bearCMS||{};bearCMS.universalTheme=bearCMS.universalTheme||{initializeNavigation:function(){try{responsiveAttributes.run()}catch(t){}var t=document.querySelector(".template-navigation"),e=document.querySelector(".template-navigation-container"),i=null,n=document.querySelector(".template-navigation-items"),a=document.querySelector(".template-navigation-additional-buttons"),o=null!==a,l=document.createDocumentFragment();function r(){var r=e.getAttribute("data-bearcms-universal-theme-navigation-type"),d="horizontal";"buttonBlock"===r?d="button-block":"buttonDropDown"===r?d="button-drop-down":"buttonOverlay"===r&&(d="button-overlay");var s,v=e.getAttribute("data-bearcms-universal-theme-navigation-buttons-layout-"+d),u=r+"/"+v+"/"+(null!==(s=t.querySelector("ul"))?s.getAttribute("data-nm-type"):null);if(i!==u){l.appendChild(n),o&&l.appendChild(a);var c=function(t,e,i,n){var a="data-bearcms-template-visibility",o=function(){"visible"!==e.getAttribute(a)?(e.setAttribute(a,"visible"),void 0!==i&&i()):(e.removeAttribute(a),void 0!==n&&n())};t.addEventListener("click",(function(){o()})),t.toggle=o},g=null;if("horizontal"===r)t.innerHTML="",g="horizontal-down",t.appendChild(n),o&&t.appendChild(a);else if("buttonBlock"===r){var p="toggleLeft"===v;t.innerHTML='
';var m=t.lastChild,b=(L=(w=t.firstChild).firstChild).firstChild;m.appendChild(n),o&&(p?w.appendChild(a):w.insertBefore(a,L)),g="none",c(b,m)}else if("buttonOverlay"===r){var f="toggleLeft"===v;p="toggleLeft"===v,t.innerHTML='
';var h=t.firstChild,C=(m=h.lastChild,b=(L=(w=t.lastChild).firstChild).firstChild,m.firstChild.firstChild);m.appendChild(n),o&&(p?w.appendChild(a):w.insertBefore(a,L)),g=f?"vertical-right":"vertical-left",c(b,h),m.addEventListener("mousedown",(function(t){t.stopPropagation()})),m.addEventListener("click",(function(t){t.stopPropagation()})),h.addEventListener("click",(function(t){t.stopPropagation(),b.toggle()})),C.addEventListener("click",(function(t){t.stopPropagation(),b.toggle()}))}else if("buttonDropDown"===r){var w,L,y="toggleLeft"===v;p="toggleLeft"===v,t.innerHTML='
',m=t.firstChild,b=(L=(w=t.lastChild).firstChild).firstChild,m.appendChild(n),o&&(p?w.appendChild(a):w.insertBefore(a,L)),g=y?"vertical-right":"vertical-left";var E=function(){var t=m.getBoundingClientRect().width,i=b.getBoundingClientRect(),n=e.getBoundingClientRect(),a=Math.ceil(i.height+i.top-n.top),o=i.left-n.left+(y?0:-t+i.width);o<0&&(o=0);var l=document.body.clientWidth;o+t>l&&(o=l-t),m.style.top=a+"px",m.style.left=o+"px"},M=null;"undefined"!=typeof ResizeObserver&&(M=new ResizeObserver(()=>{E()})),c(b,m,(function(){E(),window.addEventListener("resize",E),window.addEventListener("scroll",E),document.body.addEventListener("mousedown",b.toggle),null!==M&&M.observe(m,{box:"border-box"})}),(function(){window.removeEventListener("resize",E),window.removeEventListener("scroll",E),document.body.removeEventListener("mousedown",b.toggle),null!==M&&M.unobserve(m)})),b.addEventListener("mousedown",(function(t){t.stopPropagation()})),m.addEventListener("mousedown",(function(t){t.stopPropagation()}))}!function(e){var i=t.querySelector("ul");null!==i&&i.setAttribute("data-nm-type",e)}(g),i=r+"/"+v+"/"+g}}window.addEventListener("resize",r),window.addEventListener("orientationchange",r),r(),new MutationObserver(r).observe(e,{attributes:!0,childList:!0,subtree:!0})}}; +var bearCMS=bearCMS||{};bearCMS.universalTheme=bearCMS.universalTheme||{initializeNavigation:function(){try{responsiveAttributes.run()}catch(t){}var t=document.querySelector(".template-navigation"),e=document.querySelector(".template-navigation-container"),i=null,n=document.querySelector(".template-navigation-items"),a=document.querySelector(".template-navigation-additional-buttons"),o=null!==a,l=document.createDocumentFragment();function r(){var r=e.getAttribute("data-bearcms-universal-theme-navigation-type");if(null!==r){var d="horizontal";"buttonBlock"===r?d="button-block":"buttonDropDown"===r?d="button-drop-down":"buttonOverlay"===r&&(d="button-overlay");var s,v=e.getAttribute("data-bearcms-universal-theme-navigation-buttons-layout-"+d),u=r+"/"+v+"/"+(null!==(s=t.querySelector("ul"))?s.getAttribute("data-nm-type"):null);if(i!==u){l.appendChild(n),o&&l.appendChild(a);var c=function(t,e,i,n){var a="data-bearcms-template-visibility",o=function(){"visible"!==e.getAttribute(a)?(e.setAttribute(a,"visible"),void 0!==i&&i()):(e.removeAttribute(a),void 0!==n&&n())};t.addEventListener("click",(function(){o()})),t.toggle=o},g=null;if("horizontal"===r)t.innerHTML="",g="horizontal-down",t.appendChild(n),o&&t.appendChild(a);else if("buttonBlock"===r){var p="toggleLeft"===v;t.innerHTML='
';var m=t.lastChild,b=(L=(w=t.firstChild).firstChild).firstChild;m.appendChild(n),o&&(p?w.appendChild(a):w.insertBefore(a,L)),g="none",c(b,m)}else if("buttonOverlay"===r){var f="toggleLeft"===v;p="toggleLeft"===v,t.innerHTML='
';var h=t.firstChild,C=(m=h.lastChild,b=(L=(w=t.lastChild).firstChild).firstChild,m.firstChild.firstChild);m.appendChild(n),o&&(p?w.appendChild(a):w.insertBefore(a,L)),g=f?"vertical-right":"vertical-left",c(b,h),m.addEventListener("mousedown",(function(t){t.stopPropagation()})),m.addEventListener("click",(function(t){t.stopPropagation()})),h.addEventListener("click",(function(t){t.stopPropagation(),b.toggle()})),C.addEventListener("click",(function(t){t.stopPropagation(),b.toggle()}))}else if("buttonDropDown"===r){var w,L,y="toggleLeft"===v;p="toggleLeft"===v,t.innerHTML='
',m=t.firstChild,b=(L=(w=t.lastChild).firstChild).firstChild,m.appendChild(n),o&&(p?w.appendChild(a):w.insertBefore(a,L)),g=y?"vertical-right":"vertical-left";var E=function(){var t=m.getBoundingClientRect().width,i=b.getBoundingClientRect(),n=e.getBoundingClientRect(),a=Math.ceil(i.height+i.top-n.top),o=i.left-n.left+(y?0:-t+i.width);o<0&&(o=0);var l=document.body.clientWidth;o+t>l&&(o=l-t),m.style.top=a+"px",m.style.left=o+"px"},M=null;"undefined"!=typeof ResizeObserver&&(M=new ResizeObserver(()=>{E()})),c(b,m,(function(){E(),window.addEventListener("resize",E),window.addEventListener("scroll",E),document.body.addEventListener("mousedown",b.toggle),null!==M&&M.observe(m,{box:"border-box"})}),(function(){window.removeEventListener("resize",E),window.removeEventListener("scroll",E),document.body.removeEventListener("mousedown",b.toggle),null!==M&&M.unobserve(m)})),b.addEventListener("mousedown",(function(t){t.stopPropagation()})),m.addEventListener("mousedown",(function(t){t.stopPropagation()}))}!function(e){var i=t.querySelector("ul");null!==i&&i.setAttribute("data-nm-type",e)}(g),i=r+"/"+v+"/"+g}}}window.addEventListener("resize",r),window.addEventListener("orientationchange",r),window.addEventListener("orientationchange",r),window.addEventListener("css-to-attributes-change",(function(t){-1!==t.elements.indexOf(e)&&r()})),r(),new MutationObserver(r).observe(e,{attributes:!0,childList:!0,subtree:!0})}}; EOT; diff --git a/dev/universalTheme.js b/dev/universalTheme.js index fbd1cb0..2cbaeb8 100644 --- a/dev/universalTheme.js +++ b/dev/universalTheme.js @@ -31,6 +31,9 @@ bearCMS.universalTheme = bearCMS.universalTheme || (function () { var fragment = document.createDocumentFragment(); function update() { var navType = containerElement.getAttribute('data-bearcms-universal-theme-navigation-type'); + if (navType === null) { + return; + } var buttonsLayoutSuffix = 'horizontal'; if (navType === 'buttonBlock') { buttonsLayoutSuffix = 'button-block'; @@ -208,6 +211,12 @@ bearCMS.universalTheme = bearCMS.universalTheme || (function () { window.addEventListener('resize', update); window.addEventListener('orientationchange', update); + window.addEventListener('orientationchange', update); + window.addEventListener('css-to-attributes-change', function (event) { + if (event.elements.indexOf(containerElement) !== -1) { + update(); + } + }); update(); (new MutationObserver(update)).observe(containerElement, { attributes: true, childList: true, subtree: true }); };