@perevorot/shop 2.0.149 → 2.0.151

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=e.defineComponent({name:"catalog",setup:function(){var t=e.ref(null),n=[],o=function(){document.querySelectorAll("#subcategory > div").forEach((function(e){e.remove()}))},a=function(){window.disableScrollTopAfterCatalogLoad||window.scrollTo({top:0,left:0,behavior:"smooth"}),window.lazyImages&&window.lazyImages.update(),window.catalogFilterCallback&&window.catalogFilterCallback(),document.documentElement.classList.remove("is-catalog-loading"),r()},c=function(c,r){var i=function(e){var t=e.hash?e.hash.substring(1):"",n=e.pathname.replace(/\/$/,"");return n=t?-1!==e.pathname.indexOf(":")?n+";"+t:n+"/"+t:n,$env.shop.isTrailingSlash&&(n+="/"),e.origin+n+(e.search?e.search+"&filter":"?filter")}(c),l=function(e){return e.replace(/[^a-z0-9]/g,"")}(i);-1===n.indexOf(l)?(document.documentElement.classList.add("is-catalog-loading"),$http.get(i).then((function(i){var u=document.createElement("html");u.innerHTML=i.data.page,window.app.component(l,{template:u.querySelector("#subcategory").innerHTML}),o(),n.push(l),t.value=l;var d={event:"applied_filter"};window.custom_page_type&&(d.custom_page_type=window.custom_page_type),$env.debug.ecommerce&&console.log(d),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(d)),r||history.pushState({urlPath:c.href,source:"catalog"},document.title,c.href),e.nextTick(a)})).catch((function(e){console.error(e)})).finally((function(){document.documentElement.classList.remove("is-catalog-loading")}))):(o(),t.value=l,r||history.pushState({urlPath:c.href,source:"catalog"},document.title,c.href),e.nextTick(a))},r=function(){document.querySelectorAll("[shop-filter] a").forEach((function(e){e.addEventListener("click",(function(t){t.preventDefault(),c(e)}))}))},i=function(){var e=document.createElement("a");e.href=window.location.href,c(e,!0)};return window.onpageshow=function(e){e.persisted&&window.location.reload()},window.addEventListener("DOMContentLoaded",(function(){r(),window.addEventListener("popstate",(function(e){e.state&&"catalog"==e.state.source&&i()})),window.location.hash&&i()})),{page:t}}});t.render=function(t,n,o,a,c,r){return e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.page))},module.exports=t;
1
+ "use strict";var e=require("vue"),t=e.defineComponent({name:"catalog",setup:function(){var t=e.ref(null),n=[],o=function(){document.querySelectorAll("#subcategory > div").forEach((function(e){e.remove()}))},a=function(){window.disableScrollTopAfterCatalogLoad||window.scrollTo({top:0,left:0,behavior:"smooth"}),window.lazyImages&&window.lazyImages.update(),window.catalogFilterCallback&&window.catalogFilterCallback(),document.documentElement.classList.remove("is-catalog-loading"),r()},c=function(c,r){var i=function(e){var t=e.hash?e.hash.substring(1):"",n=e.pathname.replace(/\/$/,"");return n=t?-1!==e.pathname.indexOf(":")?n+";"+t:n+"/"+t:n,$env.shop.isTrailingSlash&&(n+="/"),e.origin+n+(e.search?e.search+"&filter":"?filter")}(c),l=function(e){return e.replace(/[^a-z0-9]/g,"")}(i);-1===n.indexOf(l)?(document.documentElement.classList.add("is-catalog-loading"),$http.get(i).then((function(i){var u=document.createElement("html");if(u.innerHTML=i.data.page,window.app.component(l,{template:u.querySelector("#subcategory").innerHTML}),o(),n.push(l),t.value=l,!window.prevent_applied_filter_track){var d={event:"applied_filter"};window.custom_page_type&&(d.custom_page_type=window.custom_page_type),$env.debug.ecommerce&&console.log(d),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(d))}r||history.pushState({urlPath:c.href,source:"catalog"},document.title,c.href),e.nextTick(a)})).catch((function(e){console.error(e)})).finally((function(){document.documentElement.classList.remove("is-catalog-loading")}))):(o(),t.value=l,r||history.pushState({urlPath:c.href,source:"catalog"},document.title,c.href),e.nextTick(a))},r=function(){document.querySelectorAll("[shop-filter] a").forEach((function(e){e.addEventListener("click",(function(t){t.preventDefault(),c(e)}))}))},i=function(){var e=document.createElement("a");e.href=window.location.href,c(e,!0)};return window.onpageshow=function(e){e.persisted&&window.location.reload()},window.addEventListener("DOMContentLoaded",(function(){r(),window.addEventListener("popstate",(function(e){e.state&&"catalog"==e.state.source&&i()})),window.location.hash&&i()})),{page:t}}});t.render=function(t,n,o,a,c,r){return e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.page))},module.exports=t;
2
2
  //# sourceMappingURL=Catalog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Catalog.js","sources":["../../../src/components/shop/Catalog.vue","../../../src/components/shop/Catalog.vue?vue&type=template&id=e2a58212&lang.js"],"sourcesContent":["<template>\n <component :is=\"page\"></component>\n</template>\n<script>\nimport { ref, defineComponent, nextTick } from 'vue';\n\nexport default defineComponent({\n name: 'catalog',\n setup() {\n const page = ref(null);\n const pages = [];\n\n const getPageName = (href) => {\n return href.replace(/[^a-z0-9]/g, '');\n };\n\n const clearContainer = () => {\n document.querySelectorAll('#subcategory > div').forEach((element) => {\n element.remove();\n });\n };\n\n const after = () => {\n if (!window.disableScrollTopAfterCatalogLoad) {\n window.scrollTo({\n top: 0,\n left: 0,\n behavior: 'smooth'\n });\n }\n\n if (window.lazyImages) {\n window.lazyImages.update();\n }\n\n if (window.catalogFilterCallback) {\n window.catalogFilterCallback();\n }\n\n document.documentElement.classList.remove('is-catalog-loading');\n\n init();\n };\n\n const parseFilterHref = (a) => {\n const hash = a.hash ? a.hash.substring(1) : '';\n\n let pathname = a.pathname.replace(/\\/$/, '');\n\n pathname = hash ? (a.pathname.indexOf(':') !== -1 ? pathname + ';' + hash : pathname + '/' + hash) : pathname;\n\n if ($env.shop.isTrailingSlash) {\n pathname = pathname + '/';\n }\n\n const href = a.origin + pathname + (a.search ? a.search + '&filter' : '?filter');\n\n return href;\n };\n\n const get = (a, ignoreHistory) => {\n const href = parseFilterHref(a);\n\n const componentName = getPageName(href);\n\n if (pages.indexOf(componentName) === -1) {\n document.documentElement.classList.add('is-catalog-loading');\n\n $http\n .get(href)\n .then((response) => {\n let html = document.createElement('html');\n\n html.innerHTML = response.data.page;\n\n window.app.component(componentName, {\n template: html.querySelector('#subcategory').innerHTML\n });\n\n clearContainer();\n\n pages.push(componentName);\n\n page.value = componentName;\n\n let object = {\n 'event': 'applied_filter',\n };\n\n if (window.custom_page_type) {\n object.custom_page_type = window.custom_page_type;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n\n if (!ignoreHistory) {\n history.pushState({ urlPath: a.href, source: 'catalog' }, document.title, a.href);\n }\n\n nextTick(after);\n })\n .catch((error) => {\n console.error(error);\n })\n .finally(() => {\n document.documentElement.classList.remove('is-catalog-loading');\n });\n } else {\n clearContainer();\n\n page.value = componentName;\n\n if (!ignoreHistory) {\n history.pushState({ urlPath: a.href, source: 'catalog' }, document.title, a.href);\n }\n\n nextTick(after);\n }\n };\n\n const init = () => {\n document.querySelectorAll('[shop-filter] a').forEach((a) => {\n a.addEventListener('click', (e) => {\n e.preventDefault();\n\n get(a);\n });\n });\n };\n\n const refresh = () => {\n const a = document.createElement('a');\n a.href = window.location.href;\n\n get(a, true);\n };\n\n window.onpageshow = function (event) {\n if (event.persisted) {\n window.location.reload();\n }\n };\n\n window.addEventListener('DOMContentLoaded', () => {\n init();\n\n window.addEventListener('popstate', (e) => {\n if (e.state && e.state.source == 'catalog') {\n refresh();\n }\n });\n\n if (window.location.hash) {\n refresh();\n }\n });\n\n return {\n page\n };\n }\n});\n</script>","<template>\n <component :is=\"page\"></component>\n</template>\n<script>\nimport { ref, defineComponent, nextTick } from 'vue';\n\nexport default defineComponent({\n name: 'catalog',\n setup() {\n const page = ref(null);\n const pages = [];\n\n const getPageName = (href) => {\n return href.replace(/[^a-z0-9]/g, '');\n };\n\n const clearContainer = () => {\n document.querySelectorAll('#subcategory > div').forEach((element) => {\n element.remove();\n });\n };\n\n const after = () => {\n if (!window.disableScrollTopAfterCatalogLoad) {\n window.scrollTo({\n top: 0,\n left: 0,\n behavior: 'smooth'\n });\n }\n\n if (window.lazyImages) {\n window.lazyImages.update();\n }\n\n if (window.catalogFilterCallback) {\n window.catalogFilterCallback();\n }\n\n document.documentElement.classList.remove('is-catalog-loading');\n\n init();\n };\n\n const parseFilterHref = (a) => {\n const hash = a.hash ? a.hash.substring(1) : '';\n\n let pathname = a.pathname.replace(/\\/$/, '');\n\n pathname = hash ? (a.pathname.indexOf(':') !== -1 ? pathname + ';' + hash : pathname + '/' + hash) : pathname;\n\n if ($env.shop.isTrailingSlash) {\n pathname = pathname + '/';\n }\n\n const href = a.origin + pathname + (a.search ? a.search + '&filter' : '?filter');\n\n return href;\n };\n\n const get = (a, ignoreHistory) => {\n const href = parseFilterHref(a);\n\n const componentName = getPageName(href);\n\n if (pages.indexOf(componentName) === -1) {\n document.documentElement.classList.add('is-catalog-loading');\n\n $http\n .get(href)\n .then((response) => {\n let html = document.createElement('html');\n\n html.innerHTML = response.data.page;\n\n window.app.component(componentName, {\n template: html.querySelector('#subcategory').innerHTML\n });\n\n clearContainer();\n\n pages.push(componentName);\n\n page.value = componentName;\n\n let object = {\n 'event': 'applied_filter',\n };\n\n if (window.custom_page_type) {\n object.custom_page_type = window.custom_page_type;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n\n if (!ignoreHistory) {\n history.pushState({ urlPath: a.href, source: 'catalog' }, document.title, a.href);\n }\n\n nextTick(after);\n })\n .catch((error) => {\n console.error(error);\n })\n .finally(() => {\n document.documentElement.classList.remove('is-catalog-loading');\n });\n } else {\n clearContainer();\n\n page.value = componentName;\n\n if (!ignoreHistory) {\n history.pushState({ urlPath: a.href, source: 'catalog' }, document.title, a.href);\n }\n\n nextTick(after);\n }\n };\n\n const init = () => {\n document.querySelectorAll('[shop-filter] a').forEach((a) => {\n a.addEventListener('click', (e) => {\n e.preventDefault();\n\n get(a);\n });\n });\n };\n\n const refresh = () => {\n const a = document.createElement('a');\n a.href = window.location.href;\n\n get(a, true);\n };\n\n window.onpageshow = function (event) {\n if (event.persisted) {\n window.location.reload();\n }\n };\n\n window.addEventListener('DOMContentLoaded', () => {\n init();\n\n window.addEventListener('popstate', (e) => {\n if (e.state && e.state.source == 'catalog') {\n refresh();\n }\n });\n\n if (window.location.hash) {\n refresh();\n }\n });\n\n return {\n page\n };\n }\n});\n</script>"],"names":["defineComponent","name","setup","page","ref","pages","clearContainer","document","querySelectorAll","forEach","element","remove","after","window","disableScrollTopAfterCatalogLoad","scrollTo","top","left","behavior","lazyImages","update","catalogFilterCallback","documentElement","classList","init","get","a","ignoreHistory","href","hash","substring","pathname","replace","indexOf","$env","shop","isTrailingSlash","origin","search","parseFilterHref","componentName","getPageName","add","$http","then","response","html","createElement","innerHTML","data","app","component","template","querySelector","push","value","object","custom_page_type","debug","ecommerce","console","log","dataLayer","history","pushState","urlPath","source","title","nextTick","error","addEventListener","e","preventDefault","refresh","location","onpageshow","event","persisted","reload","state","_createBlock","_ctx"],"mappings":"oCAMeA,kBAAgB,CAC3BC,KAAM,UACNC,qBACUC,EAAOC,MAAI,MACXC,EAAQ,GAMRC,EAAiB,WACnBC,SAASC,iBAAiB,sBAAsBC,SAAQ,SAACC,GACrDA,EAAQC,aAIVC,EAAQ,WACLC,OAAOC,kCACRD,OAAOE,SAAS,CACZC,IAAK,EACLC,KAAM,EACNC,SAAU,WAIdL,OAAOM,YACPN,OAAOM,WAAWC,SAGlBP,OAAOQ,uBACPR,OAAOQ,wBAGXd,SAASe,gBAAgBC,UAAUZ,OAAO,sBAE1Ca,KAmBEC,EAAM,SAACC,EAAGC,OACNC,EAjBc,SAACF,OACfG,EAAOH,EAAEG,KAAOH,EAAEG,KAAKC,UAAU,GAAK,GAExCC,EAAWL,EAAEK,SAASC,QAAQ,MAAO,WAEzCD,EAAWF,GAAqC,IAA7BH,EAAEK,SAASE,QAAQ,KAAcF,EAAW,IAAMF,EAAOE,EAAW,IAAMF,EAAQE,EAEjGG,KAA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AOf,OAAO6D,SAAS9C,KAEzBH,EAAIC,GAAG,WAGXb,OAAO8D,WAAa,SAAUC,GACtBA,EAAMC,WACNhE,OAAO6D,SAASI,UAIxBjE,OAAOyD,iBAAiB,oBAAoB,WACxC9C,IAEAX,OAAOyD,iBAAiB,YAAY,SAACC,GAC7BA,EAAEQ,OAA2B,WAAlBR,EAAEQ,MAAMb,QACnBO,OAIJ5D,OAAO6D,SAAS7C,MAChB4C,OAID,CACHtE,KAAAA,0DCvKR6E,wCAAgBC"}
1
+ {"version":3,"file":"Catalog.js","sources":["../../../src/components/shop/Catalog.vue","../../../src/components/shop/Catalog.vue?vue&type=template&id=7b55c54e&lang.js"],"sourcesContent":["<template>\n <component :is=\"page\"></component>\n</template>\n<script>\nimport { ref, defineComponent, nextTick } from 'vue';\n\nexport default defineComponent({\n name: 'catalog',\n setup() {\n const page = ref(null);\n const pages = [];\n\n const getPageName = (href) => {\n return href.replace(/[^a-z0-9]/g, '');\n };\n\n const clearContainer = () => {\n document.querySelectorAll('#subcategory > div').forEach((element) => {\n element.remove();\n });\n };\n\n const after = () => {\n if (!window.disableScrollTopAfterCatalogLoad) {\n window.scrollTo({\n top: 0,\n left: 0,\n behavior: 'smooth'\n });\n }\n\n if (window.lazyImages) {\n window.lazyImages.update();\n }\n\n if (window.catalogFilterCallback) {\n window.catalogFilterCallback();\n }\n\n document.documentElement.classList.remove('is-catalog-loading');\n\n init();\n };\n\n const parseFilterHref = (a) => {\n const hash = a.hash ? a.hash.substring(1) : '';\n\n let pathname = a.pathname.replace(/\\/$/, '');\n\n pathname = hash ? (a.pathname.indexOf(':') !== -1 ? pathname + ';' + hash : pathname + '/' + hash) : pathname;\n\n if ($env.shop.isTrailingSlash) {\n pathname = pathname + '/';\n }\n\n const href = a.origin + pathname + (a.search ? a.search + '&filter' : '?filter');\n\n return href;\n };\n\n const get = (a, ignoreHistory) => {\n const href = parseFilterHref(a);\n\n const componentName = getPageName(href);\n\n if (pages.indexOf(componentName) === -1) {\n document.documentElement.classList.add('is-catalog-loading');\n\n $http\n .get(href)\n .then((response) => {\n let html = document.createElement('html');\n\n html.innerHTML = response.data.page;\n\n window.app.component(componentName, {\n template: html.querySelector('#subcategory').innerHTML\n });\n\n clearContainer();\n\n pages.push(componentName);\n\n page.value = componentName;\n\n if (!window.prevent_applied_filter_track) {\n let object = {\n 'event': 'applied_filter',\n };\n\n if (window.custom_page_type) {\n object.custom_page_type = window.custom_page_type;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n if (!ignoreHistory) {\n history.pushState({ urlPath: a.href, source: 'catalog' }, document.title, a.href);\n }\n\n nextTick(after);\n })\n .catch((error) => {\n console.error(error);\n })\n .finally(() => {\n document.documentElement.classList.remove('is-catalog-loading');\n });\n } else {\n clearContainer();\n\n page.value = componentName;\n\n if (!ignoreHistory) {\n history.pushState({ urlPath: a.href, source: 'catalog' }, document.title, a.href);\n }\n\n nextTick(after);\n }\n };\n\n const init = () => {\n document.querySelectorAll('[shop-filter] a').forEach((a) => {\n a.addEventListener('click', (e) => {\n e.preventDefault();\n\n get(a);\n });\n });\n };\n\n const refresh = () => {\n const a = document.createElement('a');\n a.href = window.location.href;\n\n get(a, true);\n };\n\n window.onpageshow = function (event) {\n if (event.persisted) {\n window.location.reload();\n }\n };\n\n window.addEventListener('DOMContentLoaded', () => {\n init();\n\n window.addEventListener('popstate', (e) => {\n if (e.state && e.state.source == 'catalog') {\n refresh();\n }\n });\n\n if (window.location.hash) {\n refresh();\n }\n });\n\n return {\n page\n };\n }\n});\n</script>","<template>\n <component :is=\"page\"></component>\n</template>\n<script>\nimport { ref, defineComponent, nextTick } from 'vue';\n\nexport default defineComponent({\n name: 'catalog',\n setup() {\n const page = ref(null);\n const pages = [];\n\n const getPageName = (href) => {\n return href.replace(/[^a-z0-9]/g, '');\n };\n\n const clearContainer = () => {\n document.querySelectorAll('#subcategory > div').forEach((element) => {\n element.remove();\n });\n };\n\n const after = () => {\n if (!window.disableScrollTopAfterCatalogLoad) {\n window.scrollTo({\n top: 0,\n left: 0,\n behavior: 'smooth'\n });\n }\n\n if (window.lazyImages) {\n window.lazyImages.update();\n }\n\n if (window.catalogFilterCallback) {\n window.catalogFilterCallback();\n }\n\n document.documentElement.classList.remove('is-catalog-loading');\n\n init();\n };\n\n const parseFilterHref = (a) => {\n const hash = a.hash ? a.hash.substring(1) : '';\n\n let pathname = a.pathname.replace(/\\/$/, '');\n\n pathname = hash ? (a.pathname.indexOf(':') !== -1 ? pathname + ';' + hash : pathname + '/' + hash) : pathname;\n\n if ($env.shop.isTrailingSlash) {\n pathname = pathname + '/';\n }\n\n const href = a.origin + pathname + (a.search ? a.search + '&filter' : '?filter');\n\n return href;\n };\n\n const get = (a, ignoreHistory) => {\n const href = parseFilterHref(a);\n\n const componentName = getPageName(href);\n\n if (pages.indexOf(componentName) === -1) {\n document.documentElement.classList.add('is-catalog-loading');\n\n $http\n .get(href)\n .then((response) => {\n let html = document.createElement('html');\n\n html.innerHTML = response.data.page;\n\n window.app.component(componentName, {\n template: html.querySelector('#subcategory').innerHTML\n });\n\n clearContainer();\n\n pages.push(componentName);\n\n page.value = componentName;\n\n if (!window.prevent_applied_filter_track) {\n let object = {\n 'event': 'applied_filter',\n };\n\n if (window.custom_page_type) {\n object.custom_page_type = window.custom_page_type;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n\n if (!ignoreHistory) {\n history.pushState({ urlPath: a.href, source: 'catalog' }, document.title, a.href);\n }\n\n nextTick(after);\n })\n .catch((error) => {\n console.error(error);\n })\n .finally(() => {\n document.documentElement.classList.remove('is-catalog-loading');\n });\n } else {\n clearContainer();\n\n page.value = componentName;\n\n if (!ignoreHistory) {\n history.pushState({ urlPath: a.href, source: 'catalog' }, document.title, a.href);\n }\n\n nextTick(after);\n }\n };\n\n const init = () => {\n document.querySelectorAll('[shop-filter] a').forEach((a) => {\n a.addEventListener('click', (e) => {\n e.preventDefault();\n\n get(a);\n });\n });\n };\n\n const refresh = () => {\n const a = document.createElement('a');\n a.href = window.location.href;\n\n get(a, true);\n };\n\n window.onpageshow = function (event) {\n if (event.persisted) {\n window.location.reload();\n }\n };\n\n window.addEventListener('DOMContentLoaded', () => {\n init();\n\n window.addEventListener('popstate', (e) => {\n if (e.state && e.state.source == 'catalog') {\n refresh();\n }\n });\n\n if (window.location.hash) {\n refresh();\n }\n });\n\n return {\n page\n };\n }\n});\n</script>"],"names":["defineComponent","name","setup","page","ref","pages","clearContainer","document","querySelectorAll","forEach","element","remove","after","window","disableScrollTopAfterCatalogLoad","scrollTo","top","left","behavior","lazyImages","update","catalogFilterCallback","documentElement","classList","init","get","a","ignoreHistory","href","hash","substring","pathname","replace","indexOf","$env","shop","isTrailingSlash","origin","search","parseFilterHref","componentName","getPageName","add","$http","then","response","html","createElement","innerHTML","data","app","component","template","querySelector","push","value","prevent_applied_filter_track","object","custom_page_type","debug","ecommerce","console","log","dataLayer","history","pushState","urlPath","source","title","nextTick","error","addEventListener","e","preventDefault","refresh","location","onpageshow","event","persisted","reload","state","_createBlock","_ctx"],"mappings":"oCAMeA,kBAAgB,CAC3BC,KAAM,UACNC,qBACUC,EAAOC,MAAI,MACXC,EAAQ,GAMRC,EAAiB,WACnBC,SAASC,iBAAiB,sBAAsBC,SAAQ,SAACC,GACrDA,EAAQC,aAIVC,EAAQ,WACLC,OAAOC,kCACRD,OAAOE,SAAS,CACZC,IAAK,EACLC,KAAM,EACNC,SAAU,WAIdL,OAAOM,YACPN,OAAOM,WAAWC,SAGlBP,OAAOQ,uBACPR,OAAOQ,wBAGXd,SAASe,gBAAgBC,UAAUZ,OAAO,sBAE1Ca,KAmBEC,EAAM,SAACC,EAAGC,OACNC,EAjBc,SAACF,OACfG,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AS6D,MAAO1C,EAAEE,MAGhFyC,WAASzD,KAIXY,EAAO,WACTjB,SAASC,iBAAiB,mBAAmBC,SAAQ,SAACiB,GAClDA,EAAE6C,iBAAiB,SAAS,SAACC,GACzBA,EAAEC,iBAEFhD,EAAIC,UAKVgD,EAAU,eACNhD,EAAInB,SAASwC,cAAc,KACjCrB,EAAEE,KAAOf,OAAO8D,SAAS/C,KAEzBH,EAAIC,GAAG,WAGXb,OAAO+D,WAAa,SAAUC,GACtBA,EAAMC,WACNjE,OAAO8D,SAASI,UAIxBlE,OAAO0D,iBAAiB,oBAAoB,WACxC/C,IAEAX,OAAO0D,iBAAiB,YAAY,SAACC,GAC7BA,EAAEQ,OAA2B,WAAlBR,EAAEQ,MAAMb,QACnBO,OAIJ7D,OAAO8D,SAAS9C,MAChB6C,OAID,CACHvE,KAAAA,0DCzKR8E,wCAAgBC"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=require("vuex"),a=require("vue-toastification"),n={setup:function(){return{translate:window.__}}},r={class:"shop-cart-success-message"};n.render=function(t,a,n,o,i,l){return e.openBlock(),e.createElementBlock("div",r,e.toDisplayString(o.translate("shop.cart.message")),1)};var o=a.useToast(),i={name:"cart-add",props:{id:Number,isChangeQuantity:{type:Boolean,default:!0},isAlreadyInCart:{type:Boolean,default:!0},isSimple:{type:Boolean,default:!1},isPlusMinus:{type:Boolean,default:!1},after:{type:String,default:"modal"},property:{type:String,default:null},code:{type:String,default:null},name:{type:String,default:null},price:{type:Number,default:null},cartStorage:{type:String,default:"cart"}},setup:function(a){var r=t.useStore(),i=e.ref(!1),l=e.ref(1),c=e.ref(null),s=a.cartStorage,d=e.computed((function(){return r.getters[s+"/productQuantity"](a.id)})),u=a.isAlreadyInCart,m=a.isChangeQuantity,p=a.isPlusMinus;a.isSimple&&(u=!1,m=!1,p=!1);return{button:c,loading:i,quantity:l,add:function(){var e,t,d,u,m;i.value=!0;var p=[];c.value.closest(".product-main")&&document.querySelectorAll("#options input[type=checkbox]:checked").forEach((function(e){p.push(parseInt(e.value))}));var y={};window.getTrackingIndexProductsList&&"function"==typeof window.getTrackingIndexProductsList&&(y=window.getTrackingIndexProductsList(c.value));var v=Math.max(1,l.value),f=c.value.closest("[shop-product]"),g=a.name?a.name:null===(e=f.querySelector("[shop-product-name]"))||void 0===e?void 0:e.textContent,h=a.price?a.price:null===(t=f.querySelector("[shop-product-price]"))||void 0===t?void 0:t.childNodes[0].nodeValue.replace(/ /g,""),b=a.property?a.property:null===(d=f.querySelector("[shop-product-property]"))||void 0===d?void 0:d.textContent,k=a.code?a.code:f.dataset.code,C=null===(u=f.querySelector("[shop-product-category]"))||void 0===u?void 0:u.textContent,_=null===(m=f.querySelector("[shop-product-brand]"))||void 0===m?void 0:m.textContent;r.dispatch(s+"/add",{cart:s,after:a.after,product:{id:a.id,quantity:v,options:p,extra:{trackingIndex:y}},finally:function(){(i.value=!1,l.value=1,"message"==a.after)&&o({component:n},{type:"success-cart"})},callback:function(){var e={ecommerce:{currency:"UAH",value:parseFloat(h),items:[{item_name:g,item_id:k,price:parseFloat(h),quantity:v}]},event:"add_to_cart"};y.index&&(e.ecommerce.items[0].index=y.index),y.item_list_name&&(e.ecommerce.items[0].item_list_name=y.item_list_name),_&&(e.ecommerce.items[0].item_brand=_),C&&(-1!==C.indexOf("/")?C.split("/").forEach((function(t,a){e.ecommerce.items[0]["item_category"+(a?a+1:"")]=t.trim()})):e.ecommerce.items[0].item_category=C),b&&(e.ecommerce.items[0].item_variant=b),$env.debug.ecommerce&&console.log(e),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(e))}})},remove:function(){i.value=!0,r.dispatch(s+"/remove",{id:a.id,cart:s,finally:function(){i.value=!1}})},cart:d,increase:function(){l.value++},decrease:function(){l.value>1&&l.value--},isAlreadyInCart:u,isChangeQuantity:m,isPlusMinus:p}}},l={class:"cart-add",ref:"button"},c={class:"columns"},s={key:0,class:"column"},d={class:"cart-change-quantity"},u=["disabled"],m=["disabled"],p=["disabled"],y={class:"column is-narrow"},v=["disabled"],f=e.createElementVNode("svg",{class:"icon cart"},[e.createElementVNode("use",{"xlink:href":"#cart-add"})],-1),g={class:"cart-add-button-label"},h={key:0},b=e.createElementVNode("br",null,null,-1),k=["disabled","textContent"];i.render=function(t,a,n,r,o,i){return e.openBlock(),e.createElementBlock("div",l,[e.createElementVNode("div",c,[t.$env.shop.isCustomQuantity&&r.isChangeQuantity?(e.openBlock(),e.createElementBlock("div",s,[e.createElementVNode("div",d,[r.isPlusMinus?(e.openBlock(),e.createElementBlock("button",{key:0,class:"button is-small decrease",onClick:a[0]||(a[0]=function(){return r.decrease&&r.decrease.apply(r,arguments)}),disabled:r.loading||1==r.quantity},"-",8,u)):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("input",{class:"input is-small",type:"number",min:"1","onUpdate:modelValue":a[1]||(a[1]=function(e){return r.quantity=e}),disabled:r.loading},null,8,m),[[e.vModelText,r.quantity]]),r.isPlusMinus?(e.openBlock(),e.createElementBlock("button",{key:1,class:"button is-small increase",onClick:a[2]||(a[2]=function(){return r.increase&&r.increase.apply(r,arguments)}),disabled:r.loading},"+",8,p)):e.createCommentVNode("v-if",!0)])])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",y,[e.createElementVNode("button",{class:"button is-link is-small",onClick:a[3]||(a[3]=function(){return r.add&&r.add.apply(r,arguments)}),disabled:r.loading},[e.renderSlot(t.$slots,"default",{label:t.__("shop.cart.add")},(function(){return[f,e.createElementVNode("span",g,e.toDisplayString(t.__("shop.cart.add")),1)]}))],8,v)])]),t.$env.shop.isAlreadyInCart&&r.isAlreadyInCart&&r.cart>0?(e.openBlock(),e.createElementBlock("div",h,[e.createTextVNode(e.toDisplayString(t.__("shop.cart.already",{quantity:r.cart}))+" ",1),b,e.createElementVNode("a",{onClick:a[4]||(a[4]=e.withModifiers((function(){return r.remove&&r.remove.apply(r,arguments)}),["prevent"])),disabled:r.loading,textContent:e.toDisplayString(t.__("shop.cart.remove"))},null,8,k)])):e.createCommentVNode("v-if",!0)],512)},module.exports=i;
1
+ "use strict";var e=require("vue"),t=require("vuex"),a=require("vue-toastification"),n={setup:function(){return{translate:window.__}}},r={class:"shop-cart-success-message"};n.render=function(t,a,n,o,i,l){return e.openBlock(),e.createElementBlock("div",r,e.toDisplayString(o.translate("shop.cart.message")),1)};var o=a.useToast(),i={name:"cart-add",props:{id:Number,isChangeQuantity:{type:Boolean,default:!0},isAlreadyInCart:{type:Boolean,default:!0},isSimple:{type:Boolean,default:!1},isPlusMinus:{type:Boolean,default:!1},after:{type:String,default:"modal"},property:{type:String,default:null},code:{type:String,default:null},name:{type:String,default:null},price:{type:Number,default:null},cartStorage:{type:String,default:"cart"}},setup:function(a){var r=t.useStore(),i=e.ref(!1),l=e.ref(1),c=e.ref(null),s=a.cartStorage,d=e.computed((function(){return r.getters[s+"/productQuantity"](a.id)})),u=a.isAlreadyInCart,m=a.isChangeQuantity,p=a.isPlusMinus;a.isSimple&&(u=!1,m=!1,p=!1);return{button:c,loading:i,quantity:l,add:function(){var e,t,d,u,m;i.value=!0;var p=[];c.value.closest(".product-main")&&document.querySelectorAll("#options input[type=checkbox]:checked").forEach((function(e){p.push(parseInt(e.value))}));var y={};window.getTrackingIndexProductsList&&"function"==typeof window.getTrackingIndexProductsList&&(y=window.getTrackingIndexProductsList(c.value));var v=Math.max(1,l.value),f=c.value.closest("[shop-product]"),g=a.name?a.name:null===(e=f.querySelector("[shop-product-name]"))||void 0===e?void 0:e.textContent,h=a.price?a.price:null===(t=f.querySelector("[shop-product-price]"))||void 0===t?void 0:t.childNodes[0].nodeValue.replace(/ /g,""),b=a.property?a.property:null===(d=f.querySelector("[shop-product-property]"))||void 0===d?void 0:d.textContent,k=a.code?a.code:f.dataset.code,C=null===(u=f.querySelector("[shop-product-category]"))||void 0===u?void 0:u.textContent,_=null===(m=f.querySelector("[shop-product-brand]"))||void 0===m?void 0:m.textContent;r.dispatch(s+"/add",{cart:s,after:a.after,product:{id:a.id,quantity:v,options:p,extra:{trackingIndex:y}},finally:function(){(i.value=!1,l.value=1,"message"==a.after)&&o({component:n},{type:"success-cart"})},callback:function(){var e={ecommerce:{currency:"UAH",value:parseFloat(h)*v,items:[{item_name:g,item_id:k,price:parseFloat(h),quantity:v}]},event:"add_to_cart"};y.index&&(e.ecommerce.items[0].index=y.index),y.item_list_name&&(e.ecommerce.items[0].item_list_name=y.item_list_name),_&&(e.ecommerce.items[0].item_brand=_),C&&(-1!==C.indexOf("/")?C.split("/").forEach((function(t,a){e.ecommerce.items[0]["item_category"+(a?a+1:"")]=t.trim()})):e.ecommerce.items[0].item_category=C),b&&(e.ecommerce.items[0].item_variant=b),$env.debug.ecommerce&&console.log(e),!$env.debug.ecommerce&&window.dataLayer&&(window.dataLayer.push({ecommerce:null}),window.dataLayer.push(e))}})},remove:function(){i.value=!0,r.dispatch(s+"/remove",{id:a.id,cart:s,finally:function(){i.value=!1}})},cart:d,increase:function(){l.value++},decrease:function(){l.value>1&&l.value--},isAlreadyInCart:u,isChangeQuantity:m,isPlusMinus:p}}},l={class:"cart-add",ref:"button"},c={class:"columns"},s={key:0,class:"column"},d={class:"cart-change-quantity"},u=["disabled"],m=["disabled"],p=["disabled"],y={class:"column is-narrow"},v=["disabled"],f=e.createElementVNode("svg",{class:"icon cart"},[e.createElementVNode("use",{"xlink:href":"#cart-add"})],-1),g={class:"cart-add-button-label"},h={key:0},b=e.createElementVNode("br",null,null,-1),k=["disabled","textContent"];i.render=function(t,a,n,r,o,i){return e.openBlock(),e.createElementBlock("div",l,[e.createElementVNode("div",c,[t.$env.shop.isCustomQuantity&&r.isChangeQuantity?(e.openBlock(),e.createElementBlock("div",s,[e.createElementVNode("div",d,[r.isPlusMinus?(e.openBlock(),e.createElementBlock("button",{key:0,class:"button is-small decrease",onClick:a[0]||(a[0]=function(){return r.decrease&&r.decrease.apply(r,arguments)}),disabled:r.loading||1==r.quantity},"-",8,u)):e.createCommentVNode("v-if",!0),e.withDirectives(e.createElementVNode("input",{class:"input is-small",type:"number",min:"1","onUpdate:modelValue":a[1]||(a[1]=function(e){return r.quantity=e}),disabled:r.loading},null,8,m),[[e.vModelText,r.quantity]]),r.isPlusMinus?(e.openBlock(),e.createElementBlock("button",{key:1,class:"button is-small increase",onClick:a[2]||(a[2]=function(){return r.increase&&r.increase.apply(r,arguments)}),disabled:r.loading},"+",8,p)):e.createCommentVNode("v-if",!0)])])):e.createCommentVNode("v-if",!0),e.createElementVNode("div",y,[e.createElementVNode("button",{class:"button is-link is-small",onClick:a[3]||(a[3]=function(){return r.add&&r.add.apply(r,arguments)}),disabled:r.loading},[e.renderSlot(t.$slots,"default",{label:t.__("shop.cart.add")},(function(){return[f,e.createElementVNode("span",g,e.toDisplayString(t.__("shop.cart.add")),1)]}))],8,v)])]),t.$env.shop.isAlreadyInCart&&r.isAlreadyInCart&&r.cart>0?(e.openBlock(),e.createElementBlock("div",h,[e.createTextVNode(e.toDisplayString(t.__("shop.cart.already",{quantity:r.cart}))+" ",1),b,e.createElementVNode("a",{onClick:a[4]||(a[4]=e.withModifiers((function(){return r.remove&&r.remove.apply(r,arguments)}),["prevent"])),disabled:r.loading,textContent:e.toDisplayString(t.__("shop.cart.remove"))},null,8,k)])):e.createCommentVNode("v-if",!0)],512)},module.exports=i;
2
2
  //# sourceMappingURL=CartAdd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CartAdd.js","sources":["../../../../src/components/shop/cart/SuccessMessage.vue","../../../../src/components/shop/cart/SuccessMessage.vue?vue&type=template&id=75a41ddb&lang.js","../../../../src/components/shop/cart/CartAdd.vue","../../../../src/components/shop/cart/CartAdd.vue?vue&type=template&id=8b686432&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-cart-success-message\">\n {{ translate(\"shop.cart.message\") }}\n </div>\n</template>\n<script>\nexport default {\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"shop-cart-success-message\">\n {{ translate(\"shop.cart.message\") }}\n </div>\n</template>\n<script>\nexport default {\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"cart-add\" ref=\"button\">\n <div class=\"columns\">\n <div class=\"column\" v-if=\"$env.shop.isCustomQuantity && isChangeQuantity\">\n <div class=\"cart-change-quantity\">\n <button class=\"button is-small decrease\" @click=\"decrease\" :disabled=\"loading || quantity == 1\" v-if=\"isPlusMinus\">-</button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"quantity\" :disabled=\"loading\" />\n <button class=\"button is-small increase\" @click=\"increase\" :disabled=\"loading\" v-if=\"isPlusMinus\">+</button>\n </div>\n </div>\n <div class=\"column is-narrow\">\n <button class=\"button is-link is-small\" v-on:click=\"add\" :disabled=\"loading\">\n <slot :label=\"__('shop.cart.add')\">\n <svg class=\"icon cart\">\n <use xlink:href=\"#cart-add\" />\n </svg>\n <span class=\"cart-add-button-label\">\n {{ __('shop.cart.add') }}\n </span>\n </slot>\n </button>\n </div>\n </div>\n <div v-if=\"$env.shop.isAlreadyInCart && isAlreadyInCart && cart > 0\">\n {{ __('shop.cart.already', { quantity: cart }) }}\n <br />\n <a v-on:click.prevent=\"remove\" :disabled=\"loading\" v-text=\"__('shop.cart.remove')\"></a>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { useToast } from 'vue-toastification';\nimport SuccessMessage from './SuccessMessage.vue';\n\nconst toast = useToast();\n\nexport default {\n name: 'cart-add',\n props: {\n id: Number,\n isChangeQuantity: {\n type: Boolean,\n default: true\n },\n isAlreadyInCart: {\n type: Boolean,\n default: true\n },\n isSimple: {\n type: Boolean,\n default: false\n },\n isPlusMinus: {\n type: Boolean,\n default: false\n },\n after: {\n type: String,\n default: 'modal'\n },\n property: {\n type: String,\n default: null\n },\n code: {\n type: String,\n default: null\n },\n name: {\n type: String,\n default: null\n },\n price: {\n type: Number,\n default: null\n },\n cartStorage: {\n type: String,\n default: 'cart'\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const quantity = ref(1);\n const button = ref(null);\n const cartStorage = props.cartStorage;\n\n const cart = computed(() => store.getters[cartStorage + '/productQuantity'](props.id));\n\n let isAlreadyInCart = props.isAlreadyInCart;\n let isChangeQuantity = props.isChangeQuantity;\n let isPlusMinus = props.isPlusMinus;\n\n if (props.isSimple) {\n isAlreadyInCart = false;\n isChangeQuantity = false;\n isPlusMinus = false;\n }\n\n const add = () => {\n loading.value = true;\n\n let options = [];\n\n if (button.value.closest('.product-main')) {\n const checkedOptions = document.querySelectorAll('#options input[type=checkbox]:checked');\n\n checkedOptions.forEach((element) => {\n options.push(parseInt(element.value));\n });\n }\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const q = Math.max(1, quantity.value);\n const product = button.value.closest('[shop-product]');\n const name = props.name ? props.name : product.querySelector('[shop-product-name]')?.textContent;\n const price = props.price ? props.price : product.querySelector('[shop-product-price]')?.childNodes[0].nodeValue.replace(/ /g, '');\n const property = props.property ? props.property : product.querySelector('[shop-product-property]')?.textContent;\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]')?.textContent;\n const brand = product.querySelector('[shop-product-brand]')?.textContent;\n\n store.dispatch(cartStorage + '/add', {\n cart: cartStorage,\n after: props.after,\n product: {\n id: props.id,\n quantity: q,\n options: options,\n extra: {\n trackingIndex: trackingIndex\n }\n },\n finally: () => {\n loading.value = false;\n quantity.value = 1;\n\n if (props.after == 'message') {\n const component = {\n component: SuccessMessage\n };\n\n toast(component, {\n type: 'success-cart'\n });\n }\n },\n callback: () => {\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price),\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch(cartStorage + '/remove', {\n id: props.id,\n cart: cartStorage,\n finally: () => {\n loading.value = false;\n }\n });\n };\n\n const increase = () => {\n quantity.value++;\n };\n\n const decrease = () => {\n if (quantity.value > 1) {\n quantity.value--;\n }\n };\n\n return {\n button,\n loading,\n quantity,\n add,\n remove,\n cart,\n increase,\n decrease,\n isAlreadyInCart,\n isChangeQuantity,\n isPlusMinus\n };\n }\n};\n</script>","<template>\n <div class=\"cart-add\" ref=\"button\">\n <div class=\"columns\">\n <div class=\"column\" v-if=\"$env.shop.isCustomQuantity && isChangeQuantity\">\n <div class=\"cart-change-quantity\">\n <button class=\"button is-small decrease\" @click=\"decrease\" :disabled=\"loading || quantity == 1\" v-if=\"isPlusMinus\">-</button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"quantity\" :disabled=\"loading\" />\n <button class=\"button is-small increase\" @click=\"increase\" :disabled=\"loading\" v-if=\"isPlusMinus\">+</button>\n </div>\n </div>\n <div class=\"column is-narrow\">\n <button class=\"button is-link is-small\" v-on:click=\"add\" :disabled=\"loading\">\n <slot :label=\"__('shop.cart.add')\">\n <svg class=\"icon cart\">\n <use xlink:href=\"#cart-add\" />\n </svg>\n <span class=\"cart-add-button-label\">\n {{ __('shop.cart.add') }}\n </span>\n </slot>\n </button>\n </div>\n </div>\n <div v-if=\"$env.shop.isAlreadyInCart && isAlreadyInCart && cart > 0\">\n {{ __('shop.cart.already', { quantity: cart }) }}\n <br />\n <a v-on:click.prevent=\"remove\" :disabled=\"loading\" v-text=\"__('shop.cart.remove')\"></a>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { useToast } from 'vue-toastification';\nimport SuccessMessage from './SuccessMessage.vue';\n\nconst toast = useToast();\n\nexport default {\n name: 'cart-add',\n props: {\n id: Number,\n isChangeQuantity: {\n type: Boolean,\n default: true\n },\n isAlreadyInCart: {\n type: Boolean,\n default: true\n },\n isSimple: {\n type: Boolean,\n default: false\n },\n isPlusMinus: {\n type: Boolean,\n default: false\n },\n after: {\n type: String,\n default: 'modal'\n },\n property: {\n type: String,\n default: null\n },\n code: {\n type: String,\n default: null\n },\n name: {\n type: String,\n default: null\n },\n price: {\n type: Number,\n default: null\n },\n cartStorage: {\n type: String,\n default: 'cart'\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const quantity = ref(1);\n const button = ref(null);\n const cartStorage = props.cartStorage;\n\n const cart = computed(() => store.getters[cartStorage + '/productQuantity'](props.id));\n\n let isAlreadyInCart = props.isAlreadyInCart;\n let isChangeQuantity = props.isChangeQuantity;\n let isPlusMinus = props.isPlusMinus;\n\n if (props.isSimple) {\n isAlreadyInCart = false;\n isChangeQuantity = false;\n isPlusMinus = false;\n }\n\n const add = () => {\n loading.value = true;\n\n let options = [];\n\n if (button.value.closest('.product-main')) {\n const checkedOptions = document.querySelectorAll('#options input[type=checkbox]:checked');\n\n checkedOptions.forEach((element) => {\n options.push(parseInt(element.value));\n });\n }\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const q = Math.max(1, quantity.value);\n const product = button.value.closest('[shop-product]');\n const name = props.name ? props.name : product.querySelector('[shop-product-name]')?.textContent;\n const price = props.price ? props.price : product.querySelector('[shop-product-price]')?.childNodes[0].nodeValue.replace(/ /g, '');\n const property = props.property ? props.property : product.querySelector('[shop-product-property]')?.textContent;\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]')?.textContent;\n const brand = product.querySelector('[shop-product-brand]')?.textContent;\n\n store.dispatch(cartStorage + '/add', {\n cart: cartStorage,\n after: props.after,\n product: {\n id: props.id,\n quantity: q,\n options: options,\n extra: {\n trackingIndex: trackingIndex\n }\n },\n finally: () => {\n loading.value = false;\n quantity.value = 1;\n\n if (props.after == 'message') {\n const component = {\n component: SuccessMessage\n };\n\n toast(component, {\n type: 'success-cart'\n });\n }\n },\n callback: () => {\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price),\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch(cartStorage + '/remove', {\n id: props.id,\n cart: cartStorage,\n finally: () => {\n loading.value = false;\n }\n });\n };\n\n const increase = () => {\n quantity.value++;\n };\n\n const decrease = () => {\n if (quantity.value > 1) {\n quantity.value--;\n }\n };\n\n return {\n button,\n loading,\n quantity,\n add,\n remove,\n cart,\n increase,\n decrease,\n isAlreadyInCart,\n isChangeQuantity,\n isPlusMinus\n };\n }\n};\n</script>"],"names":["setup","translate","window","__","_createElementBlock","_hoisted_1","$setup","toast","useToast","name","props","id","Number","isChangeQuantity","type","Boolean","isAlreadyInCart","isSimple","isPlusMinus","after","String","property","code","price","cartStorage","store","useStore","loading","ref","quantity","button","cart","computed","getters","add","value","options","closest","document","querySelectorAll","forEach","element","push","parseInt","trackingIndex","getTrackingIndexProductsList","q","Math","max","product","querySelector","_product$querySelecto","textContent","_product$querySelecto2","childNodes","nodeValue","replace","_product$querySelecto3","dataset","category","_product$querySelecto4","brand","_product$querySelecto5","dispatch","extra","component","SuccessMessage","callback","object","ecommerce","currency","parseFloat","items","item_name","item_id","event","index","item_list_name","item_brand","indexOf","split","segment","trim","item_category","item_variant","$env","debug","console","log","dataLayer","remove","increase","decrease","_createElementVNode","_hoisted_2","_ctx","shop","isCustomQuantity","_hoisted_3","_hoisted_4","onClick","disabled","min","_hoisted_8","_renderSlot","label","_hoisted_10","_hoisted_11","_hoisted_13","_toDisplayString"],"mappings":"sFAMe,CACXA,uBAGW,CACHC,UAHcC,OAAOC,eCPlB,iFAAXC,2BAAAC,oBACOC,sCCkCX,IAAMC,EAAQC,eAEC,CACXC,KAAM,WACNC,MAAO,CACHC,GAAIC,OACJC,iBAAkB,CACdC,KAAMC,iBACG,GAEbC,gBAAiB,CACbF,KAAMC,iBACG,GAEbE,SAAU,CACNH,KAAMC,iBACG,GAEbG,YAAa,CACTJ,KAAMC,iBACG,GAEbI,MAAO,CACHL,KAAMM,eACG,SAEbC,SAAU,CACNP,KAAMM,eACG,MAEbE,KAAM,CACFR,KAAMM,eACG,MAEbX,KAAM,CACFK,KAAMM,eACG,MAEbG,MAAO,CACHT,KAAMF,eACG,MAEbY,YAAa,C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AAAA,EACAH,iBAAAA,EACAK,YAAAA,cCrPG,WAAWU,IAAI,mBACX,0BACI,mBACI,8EAMJ,qCAGCiE,kCAAW,cACPA,yCAAgB,4BAER,qCASxBA,yHAxBRzF,2BAAAC,GACIwF,2BAAAC,GAC8BC,OAAKC,KAAKC,kBAAoB3F,kCAAxDF,2BAAA8F,GACIL,2BAAAM,GAC0G7F,6BAAtGF,2CAAc,2BAA4BgG,sCAAO9F,4CAAW+F,SAAU/F,cAAWA,YAAkC,2DACnHuF,oCAAa,iBAAiB/E,KAAK,SAASwF,IAAI,yDAAahG,eAAW+F,SAAU/F,oCAArBA,cACwBA,6BAArFF,2CAAc,2BAA4BgG,sCAAO9F,4CAAW+F,SAAU/F,WAA4B,+EAG1GuF,2BAAAU,GACIV,qCAAc,0BAA+BO,sCAAO9F,kCAAM+F,SAAU/F,YAChEkG,iCAAOC,MAAOV,wBAAd,kBACIW,EAGAb,4BAAAc,oBACOZ,wCAMZA,OAAKC,KAAKhF,iBAAmBV,mBAAmBA,wBAA3DF,kEACO2F,mCAAoCzF,iBACvCsG,EACAf,0BAAQO,uDAAe9F,sDAAS+F,SAAU/F,sBAASuG,kBAAQd"}
1
+ {"version":3,"file":"CartAdd.js","sources":["../../../../src/components/shop/cart/SuccessMessage.vue","../../../../src/components/shop/cart/SuccessMessage.vue?vue&type=template&id=75a41ddb&lang.js","../../../../src/components/shop/cart/CartAdd.vue","../../../../src/components/shop/cart/CartAdd.vue?vue&type=template&id=24a33c02&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-cart-success-message\">\n {{ translate(\"shop.cart.message\") }}\n </div>\n</template>\n<script>\nexport default {\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"shop-cart-success-message\">\n {{ translate(\"shop.cart.message\") }}\n </div>\n</template>\n<script>\nexport default {\n setup() {\n const translate = window.__;\n\n return {\n translate,\n };\n },\n};\n</script>","<template>\n <div class=\"cart-add\" ref=\"button\">\n <div class=\"columns\">\n <div class=\"column\" v-if=\"$env.shop.isCustomQuantity && isChangeQuantity\">\n <div class=\"cart-change-quantity\">\n <button class=\"button is-small decrease\" @click=\"decrease\" :disabled=\"loading || quantity == 1\" v-if=\"isPlusMinus\">-</button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"quantity\" :disabled=\"loading\" />\n <button class=\"button is-small increase\" @click=\"increase\" :disabled=\"loading\" v-if=\"isPlusMinus\">+</button>\n </div>\n </div>\n <div class=\"column is-narrow\">\n <button class=\"button is-link is-small\" v-on:click=\"add\" :disabled=\"loading\">\n <slot :label=\"__('shop.cart.add')\">\n <svg class=\"icon cart\">\n <use xlink:href=\"#cart-add\" />\n </svg>\n <span class=\"cart-add-button-label\">\n {{ __('shop.cart.add') }}\n </span>\n </slot>\n </button>\n </div>\n </div>\n <div v-if=\"$env.shop.isAlreadyInCart && isAlreadyInCart && cart > 0\">\n {{ __('shop.cart.already', { quantity: cart }) }}\n <br />\n <a v-on:click.prevent=\"remove\" :disabled=\"loading\" v-text=\"__('shop.cart.remove')\"></a>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { useToast } from 'vue-toastification';\nimport SuccessMessage from './SuccessMessage.vue';\n\nconst toast = useToast();\n\nexport default {\n name: 'cart-add',\n props: {\n id: Number,\n isChangeQuantity: {\n type: Boolean,\n default: true\n },\n isAlreadyInCart: {\n type: Boolean,\n default: true\n },\n isSimple: {\n type: Boolean,\n default: false\n },\n isPlusMinus: {\n type: Boolean,\n default: false\n },\n after: {\n type: String,\n default: 'modal'\n },\n property: {\n type: String,\n default: null\n },\n code: {\n type: String,\n default: null\n },\n name: {\n type: String,\n default: null\n },\n price: {\n type: Number,\n default: null\n },\n cartStorage: {\n type: String,\n default: 'cart'\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const quantity = ref(1);\n const button = ref(null);\n const cartStorage = props.cartStorage;\n\n const cart = computed(() => store.getters[cartStorage + '/productQuantity'](props.id));\n\n let isAlreadyInCart = props.isAlreadyInCart;\n let isChangeQuantity = props.isChangeQuantity;\n let isPlusMinus = props.isPlusMinus;\n\n if (props.isSimple) {\n isAlreadyInCart = false;\n isChangeQuantity = false;\n isPlusMinus = false;\n }\n\n const add = () => {\n loading.value = true;\n\n let options = [];\n\n if (button.value.closest('.product-main')) {\n const checkedOptions = document.querySelectorAll('#options input[type=checkbox]:checked');\n\n checkedOptions.forEach((element) => {\n options.push(parseInt(element.value));\n });\n }\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const q = Math.max(1, quantity.value);\n const product = button.value.closest('[shop-product]');\n const name = props.name ? props.name : product.querySelector('[shop-product-name]')?.textContent;\n const price = props.price ? props.price : product.querySelector('[shop-product-price]')?.childNodes[0].nodeValue.replace(/ /g, '');\n const property = props.property ? props.property : product.querySelector('[shop-product-property]')?.textContent;\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]')?.textContent;\n const brand = product.querySelector('[shop-product-brand]')?.textContent;\n\n store.dispatch(cartStorage + '/add', {\n cart: cartStorage,\n after: props.after,\n product: {\n id: props.id,\n quantity: q,\n options: options,\n extra: {\n trackingIndex: trackingIndex\n }\n },\n finally: () => {\n loading.value = false;\n quantity.value = 1;\n\n if (props.after == 'message') {\n const component = {\n component: SuccessMessage\n };\n\n toast(component, {\n type: 'success-cart'\n });\n }\n },\n callback: () => {\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch(cartStorage + '/remove', {\n id: props.id,\n cart: cartStorage,\n finally: () => {\n loading.value = false;\n }\n });\n };\n\n const increase = () => {\n quantity.value++;\n };\n\n const decrease = () => {\n if (quantity.value > 1) {\n quantity.value--;\n }\n };\n\n return {\n button,\n loading,\n quantity,\n add,\n remove,\n cart,\n increase,\n decrease,\n isAlreadyInCart,\n isChangeQuantity,\n isPlusMinus\n };\n }\n};\n</script>","<template>\n <div class=\"cart-add\" ref=\"button\">\n <div class=\"columns\">\n <div class=\"column\" v-if=\"$env.shop.isCustomQuantity && isChangeQuantity\">\n <div class=\"cart-change-quantity\">\n <button class=\"button is-small decrease\" @click=\"decrease\" :disabled=\"loading || quantity == 1\" v-if=\"isPlusMinus\">-</button>\n <input class=\"input is-small\" type=\"number\" min=\"1\" v-model=\"quantity\" :disabled=\"loading\" />\n <button class=\"button is-small increase\" @click=\"increase\" :disabled=\"loading\" v-if=\"isPlusMinus\">+</button>\n </div>\n </div>\n <div class=\"column is-narrow\">\n <button class=\"button is-link is-small\" v-on:click=\"add\" :disabled=\"loading\">\n <slot :label=\"__('shop.cart.add')\">\n <svg class=\"icon cart\">\n <use xlink:href=\"#cart-add\" />\n </svg>\n <span class=\"cart-add-button-label\">\n {{ __('shop.cart.add') }}\n </span>\n </slot>\n </button>\n </div>\n </div>\n <div v-if=\"$env.shop.isAlreadyInCart && isAlreadyInCart && cart > 0\">\n {{ __('shop.cart.already', { quantity: cart }) }}\n <br />\n <a v-on:click.prevent=\"remove\" :disabled=\"loading\" v-text=\"__('shop.cart.remove')\"></a>\n </div>\n </div>\n</template>\n<script>\nimport { ref, computed } from 'vue';\nimport { useStore } from 'vuex';\nimport { useToast } from 'vue-toastification';\nimport SuccessMessage from './SuccessMessage.vue';\n\nconst toast = useToast();\n\nexport default {\n name: 'cart-add',\n props: {\n id: Number,\n isChangeQuantity: {\n type: Boolean,\n default: true\n },\n isAlreadyInCart: {\n type: Boolean,\n default: true\n },\n isSimple: {\n type: Boolean,\n default: false\n },\n isPlusMinus: {\n type: Boolean,\n default: false\n },\n after: {\n type: String,\n default: 'modal'\n },\n property: {\n type: String,\n default: null\n },\n code: {\n type: String,\n default: null\n },\n name: {\n type: String,\n default: null\n },\n price: {\n type: Number,\n default: null\n },\n cartStorage: {\n type: String,\n default: 'cart'\n }\n },\n setup(props) {\n const store = useStore();\n const loading = ref(false);\n const quantity = ref(1);\n const button = ref(null);\n const cartStorage = props.cartStorage;\n\n const cart = computed(() => store.getters[cartStorage + '/productQuantity'](props.id));\n\n let isAlreadyInCart = props.isAlreadyInCart;\n let isChangeQuantity = props.isChangeQuantity;\n let isPlusMinus = props.isPlusMinus;\n\n if (props.isSimple) {\n isAlreadyInCart = false;\n isChangeQuantity = false;\n isPlusMinus = false;\n }\n\n const add = () => {\n loading.value = true;\n\n let options = [];\n\n if (button.value.closest('.product-main')) {\n const checkedOptions = document.querySelectorAll('#options input[type=checkbox]:checked');\n\n checkedOptions.forEach((element) => {\n options.push(parseInt(element.value));\n });\n }\n\n let trackingIndex = {};\n\n if (window.getTrackingIndexProductsList && typeof window.getTrackingIndexProductsList === 'function') {\n trackingIndex = window.getTrackingIndexProductsList(button.value);\n }\n\n const q = Math.max(1, quantity.value);\n const product = button.value.closest('[shop-product]');\n const name = props.name ? props.name : product.querySelector('[shop-product-name]')?.textContent;\n const price = props.price ? props.price : product.querySelector('[shop-product-price]')?.childNodes[0].nodeValue.replace(/ /g, '');\n const property = props.property ? props.property : product.querySelector('[shop-product-property]')?.textContent;\n const code = props.code ? props.code : product.dataset.code;\n const category = product.querySelector('[shop-product-category]')?.textContent;\n const brand = product.querySelector('[shop-product-brand]')?.textContent;\n\n store.dispatch(cartStorage + '/add', {\n cart: cartStorage,\n after: props.after,\n product: {\n id: props.id,\n quantity: q,\n options: options,\n extra: {\n trackingIndex: trackingIndex\n }\n },\n finally: () => {\n loading.value = false;\n quantity.value = 1;\n\n if (props.after == 'message') {\n const component = {\n component: SuccessMessage\n };\n\n toast(component, {\n type: 'success-cart'\n });\n }\n },\n callback: () => {\n const object = {\n ecommerce: {\n currency: 'UAH',\n value: parseFloat(price) * q,\n items: [\n {\n item_name: name,\n item_id: code,\n price: parseFloat(price),\n quantity: q,\n }\n ]\n },\n event: 'add_to_cart'\n };\n\n if (trackingIndex.index) {\n object.ecommerce.items[0].index = trackingIndex.index;\n }\n\n if (trackingIndex.item_list_name) {\n object.ecommerce.items[0].item_list_name = trackingIndex.item_list_name;\n }\n\n if (brand) {\n object.ecommerce.items[0].item_brand = brand;\n }\n\n if (category) {\n if (category.indexOf('/') !== -1) {\n category.split('/').forEach((segment, index) => {\n object.ecommerce.items[0]['item_category' + (index ? index + 1 : '')] = segment.trim();\n });\n } else {\n object.ecommerce.items[0].item_category = category;\n }\n }\n\n if (property) {\n object.ecommerce.items[0].item_variant = property;\n }\n\n if ($env.debug.ecommerce) {\n console.log(object);\n }\n\n if (!$env.debug.ecommerce && window.dataLayer) {\n window.dataLayer.push({\n ecommerce: null\n });\n\n window.dataLayer.push(object);\n }\n }\n });\n };\n\n const remove = () => {\n loading.value = true;\n\n store.dispatch(cartStorage + '/remove', {\n id: props.id,\n cart: cartStorage,\n finally: () => {\n loading.value = false;\n }\n });\n };\n\n const increase = () => {\n quantity.value++;\n };\n\n const decrease = () => {\n if (quantity.value > 1) {\n quantity.value--;\n }\n };\n\n return {\n button,\n loading,\n quantity,\n add,\n remove,\n cart,\n increase,\n decrease,\n isAlreadyInCart,\n isChangeQuantity,\n isPlusMinus\n };\n }\n};\n</script>"],"names":["setup","translate","window","__","_createElementBlock","_hoisted_1","$setup","toast","useToast","name","props","id","Number","isChangeQuantity","type","Boolean","isAlreadyInCart","isSimple","isPlusMinus","after","String","property","code","price","cartStorage","store","useStore","loading","ref","quantity","button","cart","computed","getters","add","value","options","closest","document","querySelectorAll","forEach","element","push","parseInt","trackingIndex","getTrackingIndexProductsList","q","Math","max","product","querySelector","_product$querySelecto","textContent","_product$querySelecto2","childNodes","nodeValue","replace","_product$querySelecto3","dataset","category","_product$querySelecto4","brand","_product$querySelecto5","dispatch","extra","component","SuccessMessage","callback","object","ecommerce","currency","parseFloat","items","item_name","item_id","event","index","item_list_name","item_brand","indexOf","split","segment","trim","item_category","item_variant","$env","debug","console","log","dataLayer","remove","increase","decrease","_createElementVNode","_hoisted_2","_ctx","shop","isCustomQuantity","_hoisted_3","_hoisted_4","onClick","disabled","min","_hoisted_8","_renderSlot","label","_hoisted_10","_hoisted_11","_hoisted_13","_toDisplayString"],"mappings":"sFAMe,CACXA,uBAGW,CACHC,UAHcC,OAAOC,eCPlB,iFAAXC,2BAAAC,oBACOC,sCCkCX,IAAMC,EAAQC,eAEC,CACXC,KAAM,WACNC,MAAO,CACHC,GAAIC,OACJC,iBAAkB,CACdC,KAAMC,iBACG,GAEbC,gBAAiB,CACbF,KAAMC,iBACG,GAEbE,SAAU,CACNH,KAAMC,iBACG,GAEbG,YAAa,CACTJ,KAAMC,iBACG,GAEbI,MAAO,CACHL,KAAMM,eACG,SAEbC,SAAU,CACNP,KAAMM,eACG,MAEbE,KAAM,CACFR,KAAMM,eACG,MAEbX,KAAM,CACFK,KAAMM,eACG,MAEbG,MAAO,CACHT,KAAMF,eACG,MAEbY,YAAa,CACTV,KAAMM,eACG,SAGjBpB,eAAMU,OACIe,EAAQC,aACRC,EAAUC,OAAI,GACdC,EAAWD,MAAI,GACfE,EAASF,MAAI,MACbJ,EAAcd,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B,4BAER,qCASxBA,yHAxBRzF,2BAAAC,GACIwF,2BAAAC,GAC8BC,OAAKC,KAAKC,kBAAoB3F,kCAAxDF,2BAAA8F,GACIL,2BAAAM,GAC0G7F,6BAAtGF,2CAAc,2BAA4BgG,sCAAO9F,4CAAW+F,SAAU/F,cAAWA,YAAkC,2DACnHuF,oCAAa,iBAAiB/E,KAAK,SAASwF,IAAI,yDAAahG,eAAW+F,SAAU/F,oCAArBA,cACwBA,6BAArFF,2CAAc,2BAA4BgG,sCAAO9F,4CAAW+F,SAAU/F,WAA4B,+EAG1GuF,2BAAAU,GACIV,qCAAc,0BAA+BO,sCAAO9F,kCAAM+F,SAAU/F,YAChEkG,iCAAOC,MAAOV,wBAAd,kBACIW,EAGAb,4BAAAc,oBACOZ,wCAMZA,OAAKC,KAAKhF,iBAAmBV,mBAAmBA,wBAA3DF,kEACO2F,mCAAoCzF,iBACvCsG,EACAf,0BAAQO,uDAAe9F,sDAAS+F,SAAU/F,sBAASuG,kBAAQd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perevorot/shop",
3
- "version": "2.0.149",
3
+ "version": "2.0.151",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist/*"