@perevorot/shop 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("vue"),t=e.defineComponent({setup:function(){var t=e.ref(!1),n=e.ref(!0),o=e.ref([]),a=[],r={},c=!1,i=!1,l={},u=function(e){var t=e.substring(e.lastIndexOf("/")+1);return"page-product-"+(t.match(/^page([0-9]+)$/)?t:"page1")},s=[u(window.location.href)],d=function(e){e.preventDefault(),s=[u(e.currentTarget.href)],p(e.currentTarget)},p=function(n,i){var s=n.href,d=u(s);if(c||(window.app.component("products-paginate",{data:function(){return{components:o}},template:'<teleport to="#products"><component :is="component" v-for="(component, key) in components" v-bind:key="key"></component></teleport>'}),t.value="products-paginate",c=!0),-1===a.indexOf(d))n.classList.add("is-loading"),$http.get(s+"?paginator").then((function(t){f(i);var n=document.createElement("html");n.innerHTML=t.data.products;var c=t.data.h1;c&&(document.querySelector(".shop-subcategory-title h1").innerHTML=c),window.app.component(d,{template:n.querySelector("#products").innerHTML}),l[d]=c,a.push(d),history.pushState({urlPath:s},document.title,s),n.innerHTML=t.data.paginator,r[d]=t.data.paginator,document.getElementById("pagination").replaceWith(n.querySelector("#pagination")),i?(o.value.push(d),m()):(o.value=[d],window.scrollTo({top:0,left:0,behavior:"smooth"})),window.lazyImages&&window.lazyImages.update(),e.nextTick((function(){"function"==typeof window.loadProductsCallback&&window.loadProductsCallback()})),e.nextTick(h)}));else{history.pushState({urlPath:s},document.title,s);var p=document.createElement("html");p.innerHTML=r[d],document.getElementById("pagination").replaceWith(p.querySelector("#pagination")),i?(o.value.push(d),m()):(o.value=[d],l[d]&&(document.querySelector(".shop-subcategory-title h1").innerHTML=l[d]),window.scrollTo({top:0,left:0,behavior:"smooth"})),e.nextTick((function(){"function"==typeof window.loadProductsCallback&&window.loadProductsCallback()})),e.nextTick(h)}},m=function(){var e=document.getElementById("pagination");s.forEach((function(t){var n=e.querySelector("."+t);n&&n.classList.add("is-current")}))},f=function(e){e||i||(document.querySelectorAll("#products > *").forEach((function(e){e.remove()})),i=!0)},h=function(){var e=document.querySelector("#pagination .pagination-next:not([disabled])");document.querySelectorAll("#pagination a:not([disabled])").forEach((function(e){e.addEventListener("click",d)})),n.value=Boolean(e),window.lazyImages&&window.lazyImages.update()};return e.onMounted((function(){h()})),{component:t,hasMorePages:n,more:function(){var e=document.querySelector("#pagination .pagination-next:not([disabled])"),t=u(e.href);s.push(t),p(e,!0)}}}}),n={class:"shop-pagination has-text-centered mb-3"},o={key:0,class:"shop-pagination-more"},a=e.createElementVNode("span",{class:"icon is-small"},[e.createElementVNode("i",{class:"fas fa-sync-alt"})],-1);t.render=function(t,r,c,i,l,u){return e.openBlock(),e.createElementBlock("div",n,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.component))),t.hasMorePages?(e.openBlock(),e.createElementBlock("div",o,[e.renderSlot(t.$slots,"default",{more:t.more},(function(){return[e.createElementVNode("button",{class:"button is-small",onClick:r[0]||(r[0]=function(){return t.more&&t.more.apply(t,arguments)})},[a,e.createElementVNode("span",null,e.toDisplayString(t.__("shop.pagination.more")),1)])]}))])):e.createCommentVNode("v-if",!0)])},module.exports=t;
|
|
2
|
-
//# sourceMappingURL=Pagination.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination.js","sources":["../../../../src/js/components/shop/Pagination.vue","../../../../src/js/components/shop/Pagination.vue?vue&type=template&id=1d789ee5&lang.js"],"sourcesContent":["<template>\n <div class=\"shop-pagination has-text-centered mb-3\">\n <component :is=\"component\"></component>\n <div class=\"shop-pagination-more\" v-if=\"hasMorePages\">\n <slot :more=\"more\">\n <button class=\"button is-small\" @click=\"more\">\n <span class=\"icon is-small\">\n <i class=\"fas fa-sync-alt\"></i>\n </span>\n <span>{{ __('shop.pagination.more') }}</span>\n </button>\n </slot>\n </div>\n </div>\n</template>\n<script>\nimport { ref, onMounted, defineComponent, nextTick } from 'vue';\n\nexport default defineComponent({\n setup() {\n const component = ref(false);\n const hasMorePages = ref(true);\n const visiblePages = ref([]);\n\n let pages = [];\n let paginators = {};\n let inited = false;\n let cleared = false;\n let titles = {};\n\n const getComponentName = (href) => {\n const last = href.substring(href.lastIndexOf('/') + 1);\n\n return 'page-product-' + (last.match(/^page([0-9]+)$/) ? last : 'page1');\n };\n\n let nextPages = [getComponentName(window.location.href)];\n\n const get = (e) => {\n e.preventDefault();\n\n nextPages = [getComponentName(e.currentTarget.href)];\n\n load(e.currentTarget);\n };\n\n const load = (button, isAppend) => {\n const href = button.href;\n\n const componentName = getComponentName(href);\n\n if (!inited) {\n window.app.component('products-paginate', {\n data() {\n return {\n components: visiblePages\n };\n },\n template: '<teleport to=\"#products\"><component :is=\"component\" v-for=\"(component, key) in components\" v-bind:key=\"key\"></component></teleport>'\n });\n\n component.value = 'products-paginate';\n inited = true;\n }\n\n if (pages.indexOf(componentName) === -1) {\n button.classList.add('is-loading');\n\n $http.get(href + '?paginator').then((response) => {\n clearInitial(isAppend);\n\n let html = document.createElement('html');\n\n html.innerHTML = response.data.products;\n\n const title = response.data.h1;\n\n if (title) {\n document.querySelector('.shop-subcategory-title h1').innerHTML = title;\n }\n\n window.app.component(componentName, {\n template: html.querySelector('#products').innerHTML\n });\n\n titles[componentName] = title;\n\n pages.push(componentName);\n\n history.pushState({ urlPath: href }, document.title, href);\n html.innerHTML = response.data.paginator;\n\n paginators[componentName] = response.data.paginator;\n\n document.getElementById('pagination').replaceWith(html.querySelector('#pagination'));\n\n if (!isAppend) {\n visiblePages.value = [componentName];\n\n window.scrollTo({\n top: 0,\n left: 0,\n behavior: 'smooth'\n });\n } else {\n visiblePages.value.push(componentName);\n setPaginatorCurrentPages(null, 'Pagination');\n }\n\n if (window.lazyImages) {\n window.lazyImages.update();\n }\n\n nextTick(() => {\n if (typeof window.loadProductsCallback == 'function') {\n window.loadProductsCallback();\n }\n });\n\n nextTick(init);\n });\n } else {\n history.pushState({ urlPath: href }, document.title, href);\n\n let html = document.createElement('html');\n html.innerHTML = paginators[componentName];\n\n document.getElementById('pagination').replaceWith(html.querySelector('#pagination'));\n\n if (!isAppend) {\n visiblePages.value = [componentName];\n\n if (titles[componentName]) {\n document.querySelector('.shop-subcategory-title h1').innerHTML = titles[componentName];\n }\n\n window.scrollTo({\n top: 0,\n left: 0,\n behavior: 'smooth'\n });\n } else {\n visiblePages.value.push(componentName);\n setPaginatorCurrentPages(null, 'Pagination');\n }\n\n nextTick(() => {\n if (typeof window.loadProductsCallback == 'function') {\n window.loadProductsCallback();\n }\n });\n\n nextTick(init);\n }\n };\n\n const setPaginatorCurrentPages = () => {\n const paginator = document.getElementById('pagination');\n\n nextPages.forEach((componentName) => {\n const link = paginator.querySelector('.' + componentName);\n\n if (link) {\n link.classList.add('is-current');\n }\n });\n };\n\n const clearInitial = (isAppend) => {\n if (!isAppend && !cleared) {\n let productsOld = document.querySelectorAll('#products > *');\n\n productsOld.forEach((product) => {\n product.remove();\n });\n\n cleared = true;\n }\n };\n\n const init = () => {\n const next = document.querySelector('#pagination .pagination-next:not([disabled])');\n\n const links = document.querySelectorAll('#pagination a:not([disabled])');\n\n links.forEach((link) => {\n link.addEventListener('click', get);\n });\n\n hasMorePages.value = Boolean(next);\n\n if (window.lazyImages) {\n window.lazyImages.update();\n }\n };\n\n const more = () => {\n const next = document.querySelector('#pagination .pagination-next:not([disabled])');\n\n const componentName = getComponentName(next.href);\n\n nextPages.push(componentName);\n\n load(next, true);\n };\n\n onMounted(() => {\n init();\n });\n\n return {\n component,\n hasMorePages,\n more\n };\n }\n});\n</script>","<template>\n <div class=\"shop-pagination has-text-centered mb-3\">\n <component :is=\"component\"></component>\n <div class=\"shop-pagination-more\" v-if=\"hasMorePages\">\n <slot :more=\"more\">\n <button class=\"button is-small\" @click=\"more\">\n <span class=\"icon is-small\">\n <i class=\"fas fa-sync-alt\"></i>\n </span>\n <span>{{ __('shop.pagination.more') }}</span>\n </button>\n </slot>\n </div>\n </div>\n</template>\n<script>\nimport { ref, onMounted, defineComponent, nextTick } from 'vue';\n\nexport default defineComponent({\n setup() {\n const component = ref(false);\n const hasMorePages = ref(true);\n const visiblePages = ref([]);\n\n let pages = [];\n let paginators = {};\n let inited = false;\n let cleared = false;\n let titles = {};\n\n const getComponentName = (href) => {\n const last = href.substring(href.lastIndexOf('/') + 1);\n\n return 'page-product-' + (last.match(/^page([0-9]+)$/) ? last : 'page1');\n };\n\n let nextPages = [getComponentName(window.location.href)];\n\n const get = (e) => {\n e.preventDefault();\n\n nextPages = [getComponentName(e.currentTarget.href)];\n\n load(e.currentTarget);\n };\n\n const load = (button, isAppend) => {\n const href = button.href;\n\n const componentName = getComponentName(href);\n\n if (!inited) {\n window.app.component('products-paginate', {\n data() {\n return {\n components: visiblePages\n };\n },\n template: '<teleport to=\"#products\"><component :is=\"component\" v-for=\"(component, key) in components\" v-bind:key=\"key\"></component></teleport>'\n });\n\n component.value = 'products-paginate';\n inited = true;\n }\n\n if (pages.indexOf(componentName) === -1) {\n button.classList.add('is-loading');\n\n $http.get(href + '?paginator').then((response) => {\n clearInitial(isAppend);\n\n let html = document.createElement('html');\n\n html.innerHTML = response.data.products;\n\n const title = response.data.h1;\n\n if (title) {\n document.querySelector('.shop-subcategory-title h1').innerHTML = title;\n }\n\n window.app.component(componentName, {\n template: html.querySelector('#products').innerHTML\n });\n\n titles[componentName] = title;\n\n pages.push(componentName);\n\n history.pushState({ urlPath: href }, document.title, href);\n html.innerHTML = response.data.paginator;\n\n paginators[componentName] = response.data.paginator;\n\n document.getElementById('pagination').replaceWith(html.querySelector('#pagination'));\n\n if (!isAppend) {\n visiblePages.value = [componentName];\n\n window.scrollTo({\n top: 0,\n left: 0,\n behavior: 'smooth'\n });\n } else {\n visiblePages.value.push(componentName);\n setPaginatorCurrentPages(null, 'Pagination');\n }\n\n if (window.lazyImages) {\n window.lazyImages.update();\n }\n\n nextTick(() => {\n if (typeof window.loadProductsCallback == 'function') {\n window.loadProductsCallback();\n }\n });\n\n nextTick(init);\n });\n } else {\n history.pushState({ urlPath: href }, document.title, href);\n\n let html = document.createElement('html');\n html.innerHTML = paginators[componentName];\n\n document.getElementById('pagination').replaceWith(html.querySelector('#pagination'));\n\n if (!isAppend) {\n visiblePages.value = [componentName];\n\n if (titles[componentName]) {\n document.querySelector('.shop-subcategory-title h1').innerHTML = titles[componentName];\n }\n\n window.scrollTo({\n top: 0,\n left: 0,\n behavior: 'smooth'\n });\n } else {\n visiblePages.value.push(componentName);\n setPaginatorCurrentPages(null, 'Pagination');\n }\n\n nextTick(() => {\n if (typeof window.loadProductsCallback == 'function') {\n window.loadProductsCallback();\n }\n });\n\n nextTick(init);\n }\n };\n\n const setPaginatorCurrentPages = () => {\n const paginator = document.getElementById('pagination');\n\n nextPages.forEach((componentName) => {\n const link = paginator.querySelector('.' + componentName);\n\n if (link) {\n link.classList.add('is-current');\n }\n });\n };\n\n const clearInitial = (isAppend) => {\n if (!isAppend && !cleared) {\n let productsOld = document.querySelectorAll('#products > *');\n\n productsOld.forEach((product) => {\n product.remove();\n });\n\n cleared = true;\n }\n };\n\n const init = () => {\n const next = document.querySelector('#pagination .pagination-next:not([disabled])');\n\n const links = document.querySelectorAll('#pagination a:not([disabled])');\n\n links.forEach((link) => {\n link.addEventListener('click', get);\n });\n\n hasMorePages.value = Boolean(next);\n\n if (window.lazyImages) {\n window.lazyImages.update();\n }\n };\n\n const more = () => {\n const next = document.querySelector('#pagination .pagination-next:not([disabled])');\n\n const componentName = getComponentName(next.href);\n\n nextPages.push(componentName);\n\n load(next, true);\n };\n\n onMounted(() => {\n init();\n });\n\n return {\n component,\n hasMorePages,\n more\n };\n }\n});\n</script>"],"names":["defineComponent","setup","component","ref","hasMorePages","visiblePages","pages","paginators","inited","cleared","titles","getComponentName","href","last","substring","lastIndexOf","match","nextPages","window","location","get","e","preventDefault","currentTarget","load","button","isAppend","componentName","app","data","components","template","value","indexOf","classList","add","$http","then","response","clearInitial","html","document","createElement","innerHTML","products","title","h1","querySelector","push","history","pushState","urlPath","paginator","getElementById","replaceWith","setPaginatorCurrentPages","scrollTo","top","left","behavior","lazyImages","update","nextTick","loadProductsCallback","init","forEach","link","querySelectorAll","product","remove","next","addEventListener","Boolean","onMounted","more","class","_createElementVNode","_createElementBlock","_hoisted_1","_createBlock","_ctx","_hoisted_2","_renderSlot","onClick","_hoisted_3"],"mappings":"oCAkBeA,kBAAgB,CAC3BC,qBACUC,EAAYC,OAAI,GAChBC,EAAeD,OAAI,GACnBE,EAAeF,MAAI,IAErBG,EAAQ,GACRC,EAAa,GACbC,GAAS,EACTC,GAAU,EACVC,EAAS,GAEPC,EAAmB,SAACC,OAChBC,EAAOD,EAAKE,UAAUF,EAAKG,YAAY,KAAO,SAE7C,iBAAmBF,EAAKG,MAAM,kBAAoBH,EAAO,UAGhEI,EAAY,CAACN,EAAiBO,OAAOC,SAASP,OAE5CQ,EAAM,SAACC,GACTA,EAAEC,iBAEFL,EAAY,CAACN,EAAiBU,EAAEE,cAAcX,OAE9CY,EAAKH,EAAEE,gBAGLC,EAAO,SAACC,EAAQC,OACZd,EAAOa,EAAOb,KAEde,EAAgBhB,EAAiBC,MAElCJ,IACDU,OAAOU,IAAI1B,UAAU,oBAAqB,CACtC2B,sBACW,CACHC,WAAYzB,IAGpB0B,SAAU,wIAGd7B,EAAU8B,MAAQ,oBAClBxB,GAAS,IAGyB,IAAlCF,EAAM2B,QAAQN,GACdF,EAAOS,UAAUC,IAAI,cAErBC,MAAMhB,IAAIR,EAAO,cAAcyB,MAAK,SAACC,GACjCC,EAAab,OAETc,EAAOC,SAASC,cAAc,QAElCF,EAAKG,UAAYL,EAAST,KAAKe,aAEzBC,EAAQP,EAAST,KAAKiB,GAExBD,IACAJ,SAASM,cAAc,8BAA8BJ,UAAYE,GAGrE3B,OAAOU,IAAI1B,UAAUyB,EAAe,CAChCI,SAAUS,EAAKO,cAAc,aAAaJ,YAG9CjC,EAAOiB,GAA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