diff --git a/composer.json b/composer.json index 45260a8..93d7950 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "sschreier/sschreierstickymenu", "description": "Sticky MenĂ¼", - "version": "1.1.0", + "version": "1.2.0", "type": "shopware-platform-plugin", "license": "proprietary", "authors": [ @@ -11,8 +11,8 @@ } ], "require": { - "shopware/core": "~6.5.0", - "shopware/storefront": "~6.5.0" + "shopware/core": "~6.6.0", + "shopware/storefront": "~6.6.0" }, "extra": { "shopware-plugin-class": "Sschreier\\StickyMenu\\SschreierStickyMenu", diff --git a/src/Resources/app/storefront/dist/storefront/js/sschreier-sticky-menu.js b/src/Resources/app/storefront/dist/storefront/js/sschreier-sticky-menu.js deleted file mode 100644 index 5269d54..0000000 --- a/src/Resources/app/storefront/dist/storefront/js/sschreier-sticky-menu.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["sschreier-sticky-menu"],{9057:(i,t,e)=>{var n,s,o,a=e(6285),r=e(3206),l=e(7474);class u extends a.Z{init(){this.PluginManager=window.PluginManager,this.subscribeViewportEvent(),this.pluginShouldBeActive()&&this.initializePlugin()}createElement(){this._mainNavigationClone=this.el.cloneNode(!0),this._mainNavigationClone.classList.add(this.options.cloneMainNavigationStickyClass),r.Z.querySelector(this._mainNavigationClone,".main-navigation").removeAttribute("id"),document.body.appendChild(this._mainNavigationClone)}addEventListener(){document.addEventListener("scroll",this.onScroll.bind(this))}removeEventListener(){document.removeEventListener("scroll",this.onScroll.bind(this))}onScroll(){document.documentElement.scrollTop>this.options.positionStickyMenuIsActive?this._mainNavigationClone.classList.contains("is--active")||this._mainNavigationClone.classList.add("is--active"):this._mainNavigationClone.classList.remove("is--active")}reinitializePlugin(){this.PluginManager.initializePlugin("FlyoutMenu",'[data-flyout-menu="true"]',{})}subscribeViewportEvent(){document.$emitter.subscribe("Viewport/hasChanged",this.update,{scope:this})}update(){if(this.pluginShouldBeActive()){if(this.initialized)return;this.initializePlugin()}else{if(!this.initialized)return;this.destroy()}}pluginShouldBeActive(){return!this.options.notActiveViewportsStickyMenu.includes(l.Z.getCurrentViewport())}initializePlugin(){this.createElement(),this.addEventListener(),this.reinitializePlugin(),this.initialized=!0}destroy(){this._mainNavigationClone.remove(),this.removeEventListener(),this.initialized=!1}}n=u,o={cloneMainNavigationStickyClass:"main-navigation-sticky",positionStickyMenuIsActive:120,notActiveViewportsStickyMenu:"'XS', 'SM', 'MD'"},(s=function(i){var t=function(i,t){if("object"!=typeof i||null===i)return i;var e=i[Symbol.toPrimitive];if(void 0!==e){var n=e.call(i,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(i)}(i,"string");return"symbol"==typeof t?t:String(t)}(s="options"))in n?Object.defineProperty(n,s,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[s]=o;window.PluginManager.register("StickyMenuPlugin",u,"[data-sticky-menu]",{positionStickyMenuIsActive:120,notActiveViewportsStickyMenu:"'XS', 'SM', 'MD'"})}},i=>{i.O(0,["vendor-node","vendor-shared"],(()=>{return t=9057,i(i.s=t);var t}));i.O()}]); \ No newline at end of file diff --git a/src/Resources/app/storefront/dist/storefront/js/sschreier-sticky-menu/sschreier-sticky-menu.js b/src/Resources/app/storefront/dist/storefront/js/sschreier-sticky-menu/sschreier-sticky-menu.js new file mode 100644 index 0000000..fa13443 --- /dev/null +++ b/src/Resources/app/storefront/dist/storefront/js/sschreier-sticky-menu/sschreier-sticky-menu.js @@ -0,0 +1 @@ +(()=>{"use strict";var t={857:t=>{var e=function(t){var e;return!!t&&"object"==typeof t&&"[object RegExp]"!==(e=Object.prototype.toString.call(t))&&"[object Date]"!==e&&t.$$typeof!==i},i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function r(t,e){return!1!==e.clone&&e.isMergeableObject(t)?a(Array.isArray(t)?[]:{},t,e):t}function n(t,e,i){return t.concat(e).map(function(t){return r(t,i)})}function s(t){return Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[])}function o(t,e){try{return e in t}catch(t){return!1}}function a(t,i,c){(c=c||{}).arrayMerge=c.arrayMerge||n,c.isMergeableObject=c.isMergeableObject||e,c.cloneUnlessOtherwiseSpecified=r;var l,u,h=Array.isArray(i);return h!==Array.isArray(t)?r(i,c):h?c.arrayMerge(t,i,c):(u={},(l=c).isMergeableObject(t)&&s(t).forEach(function(e){u[e]=r(t[e],l)}),s(i).forEach(function(e){(!o(t,e)||Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))&&(o(t,e)&&l.isMergeableObject(i[e])?u[e]=(function(t,e){if(!e.customMerge)return a;var i=e.customMerge(t);return"function"==typeof i?i:a})(e,l)(t[e],i[e],l):u[e]=r(i[e],l))}),u)}a.all=function(t,e){if(!Array.isArray(t))throw Error("first argument should be an array");return t.reduce(function(t,i){return a(t,i,e)},{})},t.exports=a}},e={};function i(r){var n=e[r];if(void 0!==n)return n.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,i),s.exports}(()=>{i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e}})(),(()=>{i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})}})(),(()=>{i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e)})(),(()=>{var t=i(857),e=i.n(t);class r{static ucFirst(t){return t.charAt(0).toUpperCase()+t.slice(1)}static lcFirst(t){return t.charAt(0).toLowerCase()+t.slice(1)}static toDashCase(t){return t.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(t,e){let i=r.toUpperCamelCase(t,e);return r.lcFirst(i)}static toUpperCamelCase(t,e){return e?t.split(e).map(t=>r.ucFirst(t.toLowerCase())).join(""):r.ucFirst(t.toLowerCase())}static parsePrimitive(t){try{return/^\d+(.|,)\d+$/.test(t)&&(t=t.replace(",",".")),JSON.parse(t)}catch(e){return t.toString()}}}class n{static isNode(t){return"object"==typeof t&&null!==t&&(t===document||t===window||t instanceof Node)}static hasAttribute(t,e){if(!n.isNode(t))throw Error("The element must be a valid HTML Node!");return"function"==typeof t.hasAttribute&&t.hasAttribute(e)}static getAttribute(t,e){let i=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(i&&!1===n.hasAttribute(t,e))throw Error('The required property "'.concat(e,'" does not exist!'));if("function"!=typeof t.getAttribute){if(i)throw Error("This node doesn't support the getAttribute function!");return}return t.getAttribute(e)}static getDataAttribute(t,e){let i=!(arguments.length>2)||void 0===arguments[2]||arguments[2],s=e.replace(/^data(|-)/,""),o=r.toLowerCamelCase(s,"-");if(!n.isNode(t)){if(i)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===t.dataset){if(i)throw Error("This node doesn't support the dataset attribute!");return}let a=t.dataset[o];if(void 0===a){if(i)throw Error('The required data attribute "'.concat(e,'" does not exist on ').concat(t,"!"));return a}return r.parsePrimitive(a)}static querySelector(t,e){let i=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(i&&!n.isNode(t))throw Error("The parent node is not a valid HTML Node!");let r=t.querySelector(e)||!1;if(i&&!1===r)throw Error('The required element "'.concat(e,'" does not exist in parent node!'));return r}static querySelectorAll(t,e){let i=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(i&&!n.isNode(t))throw Error("The parent node is not a valid HTML Node!");let r=t.querySelectorAll(e);if(0===r.length&&(r=!1),i&&!1===r)throw Error('At least one item of "'.concat(e,'" must exist in parent node!'));return r}}class s{publish(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=new CustomEvent(t,{detail:e,cancelable:i});return this.el.dispatchEvent(r),r}subscribe(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=this,n=t.split("."),s=i.scope?e.bind(i.scope):e;if(i.once&&!0===i.once){let e=s;s=function(i){r.unsubscribe(t),e(i)}}return this.el.addEventListener(n[0],s),this.listeners.push({splitEventName:n,opts:i,cb:s}),!0}unsubscribe(t){let e=t.split(".");return this.listeners=this.listeners.reduce((t,i)=>([...i.splitEventName].sort().toString()===e.sort().toString()?this.el.removeEventListener(i.splitEventName[0],i.cb):t.push(i),t),[]),!0}reset(){return this.listeners.forEach(t=>{this.el.removeEventListener(t.splitEventName[0],t.cb)}),this.listeners=[],!0}get el(){return this._el}set el(t){this._el=t}get listeners(){return this._listeners}set listeners(t){this._listeners=t}constructor(t=document){this._el=t,t.$emitter=this,this._listeners=[]}}class o{init(){throw Error('The "init" method for the plugin "'.concat(this._pluginName,'" is not defined.'))}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(t){let i=r.toDashCase(this._pluginName),s=n.getDataAttribute(this.el,"data-".concat(i,"-config"),!1),o=n.getAttribute(this.el,"data-".concat(i,"-options"),!1),a=[this.constructor.options,this.options,t];s&&a.push(window.PluginConfigManager.get(this._pluginName,s));try{o&&a.push(JSON.parse(o))}catch(t){throw console.error(this.el),Error('The data attribute "data-'.concat(i,'-options" could not be parsed to json: ').concat(t.message))}return e().all(a.filter(t=>t instanceof Object&&!(t instanceof Array)).map(t=>t||{}))}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(t){return t||(t=this.constructor.name),t}constructor(t,e={},i=!1){if(!n.isNode(t))throw Error("There is no valid element given.");this.el=t,this.$emitter=new s(this.el),this._pluginName=this._getPluginName(i),this.options=this._mergeOptions(e),this._initialized=!1,this._registerInstance(),this._init()}}class a{static debounce(t,e){let i,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function(){for(var n=arguments.length,s=Array(n),o=0;othis.options.positionStickyMenuIsActive?this._mainNavigationClone.classList.contains("is--active")||this._mainNavigationClone.classList.add("is--active"):this._mainNavigationClone.classList.remove("is--active")}reinitializePlugin(){this.PluginManager.initializePlugin("FlyoutMenu",'[data-flyout-menu="true"]',{})}subscribeViewportEvent(){document.$emitter.subscribe("Viewport/hasChanged",this.update,{scope:this})}update(){if(this.pluginShouldBeActive())this.initialized||this.initializePlugin();else{if(!this.initialized)return;this.destroy()}}pluginShouldBeActive(){return!this.options.notActiveViewportsStickyMenu.includes(c.getCurrentViewport())}initializePlugin(){this.createElement(),this.addEventListener(),this.reinitializePlugin(),this.initialized=!0}destroy(){this._mainNavigationClone.remove(),this.removeEventListener(),this.initialized=!1}}l.options={cloneMainNavigationStickyClass:"main-navigation-sticky",positionStickyMenuIsActive:120,notActiveViewportsStickyMenu:"'XS', 'SM', 'MD'"},window.PluginManager.register("StickyMenuPlugin",l,"[data-sticky-menu]",{positionStickyMenuIsActive:120,notActiveViewportsStickyMenu:"'XS', 'SM', 'MD'"})})()})(); \ No newline at end of file diff --git a/src/Resources/config/config.xml b/src/Resources/config/config.xml old mode 100755 new mode 100644