chore: remove paypal scripts (migrate to admin dashboard)
This commit is contained in:
parent
246fdb865d
commit
54c4d8219d
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
"use strict";(self.webpackChunkliebling=self.webpackChunkliebling||[]).push([[151],{769:(e,t,a)=>{a.d(t,{dZ:()=>i,e:()=>n,eS:()=>l,ej:()=>o,tq:()=>s});var i=function(){var e=document.querySelector("html");return["ar","he","fa"].includes(e.getAttribute("lang"))},s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},n=function(){for(var e=document.querySelectorAll(".kg-gallery-image img"),t=0,a=e.length;t<a;t++){var i=e[t].closest(".kg-gallery-image"),s=e[t].attributes.width.value/e[t].attributes.height.value;i.style.flex="".concat(s," 1 0%")}},l=function(e){e(".js-post-content").find("img").each((function(){e(this).closest("figure").hasClass("kg-bookmark-card")||e(this).closest("figure").hasClass("kg-nft-card")||e(this).parent().is("a")||e(this).hasClass("kg-product-card-image")||e(this).hasClass("kg-audio-thumbnail")||e(this).addClass("js-zoomable")}))},o=function(e,t){t(".js-zoomable").on("opened",(function(){setTimeout((function(){var t=e(".medium-zoom-image--opened");t.length>1&&t.last().hide()}),10)}))}},214:()=>{},550:()=>{},823:()=>{},140:()=>{},521:()=>{},305:()=>{},672:()=>{}},e=>{var t=t=>e(e.s=t);e.O(0,[459,698,724,449,170,87,882],(()=>(t(769),t(823),t(140),t(521),t(305),t(672),t(214),t(550))));e.O()}]);
|
||||
"use strict";(self.webpackChunkliebling=self.webpackChunkliebling||[]).push([[151],{769:(e,t,a)=>{a.d(t,{dZ:()=>n,e:()=>o,eS:()=>l,ej:()=>c,p6:()=>s,tq:()=>i});var n=function(){var e=document.querySelector("html");return["ar","he","fa"].includes(e.getAttribute("lang"))},i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},s=function(e){return e?new Date(e).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},o=function(){for(var e=document.querySelectorAll(".kg-gallery-image img"),t=0,a=e.length;t<a;t++){var n=e[t].closest(".kg-gallery-image"),i=e[t].attributes.width.value/e[t].attributes.height.value;n.style.flex="".concat(i," 1 0%")}},l=function(e){e(".js-post-content").find("img").each((function(){e(this).closest("figure").hasClass("kg-bookmark-card")||e(this).closest("figure").hasClass("kg-nft-card")||e(this).parent().is("a")||e(this).hasClass("kg-product-card-image")||e(this).hasClass("kg-audio-thumbnail")||e(this).addClass("js-zoomable")}))},c=function(e,t){t(".js-zoomable").on("opened",(function(){setTimeout((function(){var t=e(".medium-zoom-image--opened");t.length>1&&t.last().hide()}),10)}))}},214:()=>{},550:()=>{},823:()=>{},140:()=>{},521:()=>{},305:()=>{},672:()=>{}},e=>{var t=t=>e(e.s=t);e.O(0,[459,698,724,449,170,87,882],(()=>(t(769),t(823),t(140),t(521),t(305),t(672),t(214),t(550))));e.O()}]);
|
@ -1 +1 @@
|
||||
"use strict";(self.webpackChunkliebling=self.webpackChunkliebling||[]).push([[321],{769:(e,t,a)=>{a.d(t,{dZ:()=>n,e:()=>i,eS:()=>o,ej:()=>l,tq:()=>s});var n=function(){var e=document.querySelector("html");return["ar","he","fa"].includes(e.getAttribute("lang"))},s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},i=function(){for(var e=document.querySelectorAll(".kg-gallery-image img"),t=0,a=e.length;t<a;t++){var n=e[t].closest(".kg-gallery-image"),s=e[t].attributes.width.value/e[t].attributes.height.value;n.style.flex="".concat(s," 1 0%")}},o=function(e){e(".js-post-content").find("img").each((function(){e(this).closest("figure").hasClass("kg-bookmark-card")||e(this).closest("figure").hasClass("kg-nft-card")||e(this).parent().is("a")||e(this).hasClass("kg-product-card-image")||e(this).hasClass("kg-audio-thumbnail")||e(this).addClass("js-zoomable")}))},l=function(e,t){t(".js-zoomable").on("opened",(function(){setTimeout((function(){var t=e(".medium-zoom-image--opened");t.length>1&&t.last().hide()}),10)}))}},209:(e,t,a)=>{var n=a(755),s=a.n(n),i=a(729),o=a.n(i),l=a(557),r=a(769);s()((function(){o()(".js-post-content"),(0,r.e)(),(0,r.eS)(s()),(0,r.ej)(s(),l.Z)}))}},e=>{e.O(0,[898],(()=>{return t=209,e(e.s=t);var t}));e.O()}]);
|
||||
"use strict";(self.webpackChunkliebling=self.webpackChunkliebling||[]).push([[321],{769:(e,t,n)=>{n.d(t,{dZ:()=>a,e:()=>s,eS:()=>l,ej:()=>r,p6:()=>o,tq:()=>i});var a=function(){var e=document.querySelector("html");return["ar","he","fa"].includes(e.getAttribute("lang"))},i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},o=function(e){return e?new Date(e).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},s=function(){for(var e=document.querySelectorAll(".kg-gallery-image img"),t=0,n=e.length;t<n;t++){var a=e[t].closest(".kg-gallery-image"),i=e[t].attributes.width.value/e[t].attributes.height.value;a.style.flex="".concat(i," 1 0%")}},l=function(e){e(".js-post-content").find("img").each((function(){e(this).closest("figure").hasClass("kg-bookmark-card")||e(this).closest("figure").hasClass("kg-nft-card")||e(this).parent().is("a")||e(this).hasClass("kg-product-card-image")||e(this).hasClass("kg-audio-thumbnail")||e(this).addClass("js-zoomable")}))},r=function(e,t){t(".js-zoomable").on("opened",(function(){setTimeout((function(){var t=e(".medium-zoom-image--opened");t.length>1&&t.last().hide()}),10)}))}},209:(e,t,n)=>{var a=n(755),i=n.n(a),o=n(729),s=n.n(o),l=n(557),r=n(769);i()((function(){s()(".js-post-content"),(0,r.e)(),(0,r.eS)(i()),(0,r.ej)(i(),l.Z)}))}},e=>{e.O(0,[898],(()=>{return t=209,e(e.s=t);var t}));e.O()}]);
|
@ -1 +1 @@
|
||||
"use strict";(self.webpackChunkliebling=self.webpackChunkliebling||[]).push([[571],{769:(e,t,n)=>{n.d(t,{dZ:()=>i,e:()=>a,eS:()=>s,ej:()=>l,tq:()=>o});var i=function(){var e=document.querySelector("html");return["ar","he","fa"].includes(e.getAttribute("lang"))},o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},a=function(){for(var e=document.querySelectorAll(".kg-gallery-image img"),t=0,n=e.length;t<n;t++){var i=e[t].closest(".kg-gallery-image"),o=e[t].attributes.width.value/e[t].attributes.height.value;i.style.flex="".concat(o," 1 0%")}},s=function(e){e(".js-post-content").find("img").each((function(){e(this).closest("figure").hasClass("kg-bookmark-card")||e(this).closest("figure").hasClass("kg-nft-card")||e(this).parent().is("a")||e(this).hasClass("kg-product-card-image")||e(this).hasClass("kg-audio-thumbnail")||e(this).addClass("js-zoomable")}))},l=function(e,t){t(".js-zoomable").on("opened",(function(){setTimeout((function(){var t=e(".medium-zoom-image--opened");t.length>1&&t.last().hide()}),10)}))}},717:(e,t,n)=>{var i=n(755),o=n.n(i),a=n(557),s=n(729),l=n.n(s),r=n(433),c=n(911),u=(n(350),n(769)),d=null,h=null,f=window.pageYOffset,m=0,p=0,v=0,g=!1,w=function(){f=window.pageYOffset,b()},y=function(e){(0,u.tq)("1023px")?(o()("body").addClass("share-menu-displayed"),setTimeout((function(){d.removeAttr("data-animate")}),e)):o()("body").removeClass("share-menu-displayed")},k=function(){C(),y(100),setTimeout((function(){x(),b()}),200)},b=function(){g||requestAnimationFrame(j),g=!0},j=function(){var e=p-m,t=Math.ceil(f/e*100);t<=100&&T(t),g=!1},C=function(){m=window.innerHeight,p=o()(document).height()},x=function(){var e,t;if(null!==(e=h)&&void 0!==e&&null!==(t=e[0])&&void 0!==t&&t.style){var n=h.parent().width(),i=n/2,o=(0,u.tq)()?2:3;h.parent().attr("viewBox","0 0 ".concat(n," ").concat(n)),h.attr("stroke-width",o),h.attr("r",i-(o-1)),h.attr("cx",i),h.attr("cy",i),v=2*i*Math.PI,h[0].style.strokeDasharray="".concat(v," ").concat(v),h[0].style.strokeDashoffset=v}},T=function(e){var t,n;if(null!==(t=h)&&void 0!==t&&null!==(n=t[0])&&void 0!==n&&n.style&&e<=100){var i=v-e/100*v;h[0].style.strokeDashoffset=i}};o()((function(){d=o()(".js-animation-wrapper");var e=o()(".js-scrolltop"),t=o()(".js-recommended-slider");if(l()(".js-post-content"),(0,u.e)(),y(1e3),t.length>0)new c.ZP(".js-recommended-slider",{modules:[c.W_,c.s5],navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"},slidesPerView:1,allowTouchMove:!0,loop:!0,a11y:!0,breakpoints:{720:{slidesPerView:2,allowTouchMove:!0,loop:!0},1024:{slidesPerView:3,allowTouchMove:!1,loop:!1}},on:{init:function(){(0,r.Z)(".js-article-card-title",100),(0,r.Z)(".js-article-card-title-no-image",250)}}});(0,r.Z)(".js-article-card-title",100),(0,r.Z)(".js-article-card-title-no-image",250),e.on("click",(function(){o()("html, body").animate({scrollTop:0},500)})),(0,u.eS)(o()),(0,u.ej)(o(),a.Z),window.addEventListener("scroll",w,{passive:!0}),window.addEventListener("resize",k,{passive:!0})})),o()(window).on("load",(function(){(h=o()(".js-progress"))&&(C(),x(),j(),setTimeout((function(){h.parent().css("opacity",1)}),300))}))}},e=>{e.O(0,[898],(()=>{return t=717,e(e.s=t);var t}));e.O()}]);
|
||||
"use strict";(self.webpackChunkliebling=self.webpackChunkliebling||[]).push([[571],{769:(e,t,n)=>{n.d(t,{dZ:()=>o,e:()=>s,eS:()=>r,ej:()=>l,p6:()=>a,tq:()=>i});var o=function(){var e=document.querySelector("html");return["ar","he","fa"].includes(e.getAttribute("lang"))},i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"768px";return window.matchMedia("(max-width: ".concat(e,")")).matches},a=function(e){return e?new Date(e).toLocaleDateString(document.documentElement.lang,{year:"numeric",month:"long",day:"numeric"}):""},s=function(){for(var e=document.querySelectorAll(".kg-gallery-image img"),t=0,n=e.length;t<n;t++){var o=e[t].closest(".kg-gallery-image"),i=e[t].attributes.width.value/e[t].attributes.height.value;o.style.flex="".concat(i," 1 0%")}},r=function(e){e(".js-post-content").find("img").each((function(){e(this).closest("figure").hasClass("kg-bookmark-card")||e(this).closest("figure").hasClass("kg-nft-card")||e(this).parent().is("a")||e(this).hasClass("kg-product-card-image")||e(this).hasClass("kg-audio-thumbnail")||e(this).addClass("js-zoomable")}))},l=function(e,t){t(".js-zoomable").on("opened",(function(){setTimeout((function(){var t=e(".medium-zoom-image--opened");t.length>1&&t.last().hide()}),10)}))}},717:(e,t,n)=>{var o=n(755),i=n.n(o),a=n(557),s=n(729),r=n.n(s),l=n(433),c=n(911),u=(n(350),n(769)),d=null,m=null,h=window.pageYOffset,f=0,g=0,p=0,v=!1,w=function(){h=window.pageYOffset,b()},y=function(e){(0,u.tq)("1023px")?(i()("body").addClass("share-menu-displayed"),setTimeout((function(){d.removeAttr("data-animate")}),e)):i()("body").removeClass("share-menu-displayed")},k=function(){C(),y(100),setTimeout((function(){x(),b()}),200)},b=function(){v||requestAnimationFrame(j),v=!0},j=function(){var e=g-f,t=Math.ceil(h/e*100);t<=100&&T(t),v=!1},C=function(){f=window.innerHeight,g=i()(document).height()},x=function(){var e,t;if(null!==(e=m)&&void 0!==e&&null!==(t=e[0])&&void 0!==t&&t.style){var n=m.parent().width(),o=n/2,i=(0,u.tq)()?2:3;m.parent().attr("viewBox","0 0 ".concat(n," ").concat(n)),m.attr("stroke-width",i),m.attr("r",o-(i-1)),m.attr("cx",o),m.attr("cy",o),p=2*o*Math.PI,m[0].style.strokeDasharray="".concat(p," ").concat(p),m[0].style.strokeDashoffset=p}},T=function(e){var t,n;if(null!==(t=m)&&void 0!==t&&null!==(n=t[0])&&void 0!==n&&n.style&&e<=100){var o=p-e/100*p;m[0].style.strokeDashoffset=o}};i()((function(){d=i()(".js-animation-wrapper");var e=i()(".js-scrolltop"),t=i()(".js-recommended-slider");if(r()(".js-post-content"),(0,u.e)(),y(1e3),t.length>0)new c.ZP(".js-recommended-slider",{modules:[c.W_,c.s5],navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"},slidesPerView:1,allowTouchMove:!0,loop:!0,a11y:!0,breakpoints:{720:{slidesPerView:2,allowTouchMove:!0,loop:!0},1024:{slidesPerView:3,allowTouchMove:!1,loop:!1}},on:{init:function(){(0,l.Z)(".js-article-card-title",100),(0,l.Z)(".js-article-card-title-no-image",250)}}});(0,l.Z)(".js-article-card-title",100),(0,l.Z)(".js-article-card-title-no-image",250),e.on("click",(function(){i()("html, body").animate({scrollTop:0},500)})),(0,u.eS)(i()),(0,u.ej)(i(),a.Z),window.addEventListener("scroll",w,{passive:!0}),window.addEventListener("resize",k,{passive:!0})})),i()(window).on("load",(function(){(m=i()(".js-progress"))&&(C(),x(),j(),setTimeout((function(){m.parent().css("opacity",1)}),300))}))}},e=>{e.O(0,[898],(()=>{return t=717,e(e.s=t);var t}));e.O()}]);
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
nodeLinker: "node-modules"
|
108
src/js/app.js
108
src/js/app.js
@ -4,13 +4,10 @@ import tippy from 'tippy.js';
|
||||
import 'tippy.js/dist/tippy.css';
|
||||
import shave from 'shave';
|
||||
import GhostContentAPI from '@tryghost/content-api';
|
||||
import Fuse from 'fuse.js/dist/fuse.basic.esm.min.js';
|
||||
import Swiper, { FreeMode, A11y } from 'swiper';
|
||||
import 'swiper/css';
|
||||
import { isRTL, formatDate, isMobile } from './helpers';
|
||||
/* pyv */
|
||||
import fuzzysort from 'fuzzysort';
|
||||
import './paypal';
|
||||
/* /pyv */
|
||||
|
||||
$(() => {
|
||||
if (isRTL()) {
|
||||
@ -43,9 +40,7 @@ $(() => {
|
||||
const $nativeComments = $('.js-native-comments > div > iframe')[0];
|
||||
const currentSavedTheme = localStorage.getItem('theme');
|
||||
|
||||
/* pyv */
|
||||
let allPages = null;
|
||||
/* /pyv */
|
||||
let fuse = null;
|
||||
let submenuIsOpen = false;
|
||||
let secondaryMenuTippy = null;
|
||||
|
||||
@ -81,30 +76,38 @@ $(() => {
|
||||
}
|
||||
};
|
||||
|
||||
const getAllPosts = async (host, key) => {
|
||||
const getAllPosts = (host, key) => {
|
||||
const api = new GhostContentAPI({
|
||||
url: host,
|
||||
key,
|
||||
version: 'v5.0',
|
||||
version: 'v5.0'
|
||||
});
|
||||
const allPosts = [];
|
||||
const fuseOptions = {
|
||||
shouldSort: true,
|
||||
ignoreLocation: true,
|
||||
findAllMatches: true,
|
||||
includeScore: true,
|
||||
minMatchCharLength: 2,
|
||||
keys: ['title', 'custom_excerpt', 'tags.name']
|
||||
};
|
||||
|
||||
/* pyv */
|
||||
try {
|
||||
const posts = await api.posts.browse({
|
||||
limit: 'all',
|
||||
include: 'tags',
|
||||
fields: 'id, title, url, published_at, plaintext',
|
||||
}),
|
||||
pages = await api.pages.browse({
|
||||
limit: 'all',
|
||||
include: 'tags',
|
||||
fields: 'id, title, url, published_at, plaintext',
|
||||
});
|
||||
allPages = [...pages, ...posts];
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
/* /pyv */
|
||||
api.posts
|
||||
.browse({
|
||||
limit: 'all',
|
||||
include: 'tags',
|
||||
fields: 'id, title, url, published_at, custom_excerpt'
|
||||
})
|
||||
.then(posts => {
|
||||
for (let i = 0, len = posts.length; i < len; i++) {
|
||||
allPosts.push(posts[i]);
|
||||
}
|
||||
|
||||
fuse = new Fuse(allPosts, fuseOptions);
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
|
||||
const toggleDesktopTopbarOverflow = disableOverflow => {
|
||||
@ -156,51 +159,28 @@ $(() => {
|
||||
});
|
||||
|
||||
$inputSearch.on('keyup', () => {
|
||||
/* pyv */
|
||||
if ($inputSearch.val().length > 0 && allPages) {
|
||||
const results = fuzzysort.go($inputSearch.val(), allPages, {
|
||||
keys: ['title', 'plaintext'],
|
||||
limit: 4,
|
||||
if ($inputSearch.val().length > 0 && fuse) {
|
||||
const results = fuse.search($inputSearch.val());
|
||||
const bestResults = results.filter(result => {
|
||||
if (result.score <= 0.5) {
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
let htmlString = '';
|
||||
if (results.length > 0) {
|
||||
for (let i = 0, len = results.length; i < len; i++) {
|
||||
const title =
|
||||
fuzzysort.highlight(results[i][0]) || results[i].obj.title,
|
||||
previewLength = 192;
|
||||
let preview = fuzzysort.highlight(results[i][1]),
|
||||
appendTrailing = false;
|
||||
if (preview) {
|
||||
const highlightIndex = preview.indexOf('<b>'),
|
||||
startIndex = highlightIndex - previewLength / 4;
|
||||
if (startIndex > 0) {
|
||||
preview = '...' + preview.slice(startIndex);
|
||||
}
|
||||
if (preview.length > previewLength) {
|
||||
preview = preview.slice(0, previewLength);
|
||||
appendTrailing = true;
|
||||
}
|
||||
} else {
|
||||
preview = results[i].obj.plaintext.slice(0, previewLength);
|
||||
if (results[i].obj.plaintext.length > previewLength) {
|
||||
preview = preview.split(' ').slice(0, -1).join(' ');
|
||||
appendTrailing = true;
|
||||
}
|
||||
}
|
||||
const openingTags = preview.match(/<b>/g)?.length,
|
||||
closingTags = preview.match(/<\/b>/g)?.length;
|
||||
if (openingTags > closingTags) preview += '</b>';
|
||||
if (appendTrailing) preview += '...';
|
||||
|
||||
if (bestResults.length > 0) {
|
||||
for (let i = 0, len = bestResults.length; i < len; i++) {
|
||||
htmlString += `
|
||||
<article class="m-result">\
|
||||
<a href="${results[i].obj.url}" class="m-result__link">\
|
||||
<h3 class="m-result__title">${title}</h3>\
|
||||
<span class="m-result__date">${preview}</span>\
|
||||
</a>\
|
||||
<a href="${bestResults[i].item.url}" class="m-result__link">\
|
||||
<h3 class="m-result__title">${bestResults[i].item.title}</h3>\
|
||||
<span class="m-result__date">${formatDate(
|
||||
bestResults[i].item.published_at
|
||||
)}</span>\
|
||||
</a>\
|
||||
</article>`;
|
||||
}
|
||||
/* /pyv */
|
||||
|
||||
$searchNoResults.hide();
|
||||
$searchResults.html(htmlString);
|
||||
|
@ -1,86 +0,0 @@
|
||||
/* pyv */
|
||||
|
||||
{
|
||||
/* <div class="paypal-cart" data-id="test-cart-id"><div class="buttons"><div class="paypal-item" data-id="youth" data-cost="10"><div class="paypal-item-name">Youth</div></div><div class="paypal-item" data-id="leader" data-cost="10"><div class="paypal-item-name">Leader</div></div></div><div class="paypal-confirmation"><span>Payment successful.</span></div><noscript><p class="javascript-required">You must enable JavaScript to checkout via PayPal.</p></noscript></div> */
|
||||
}
|
||||
|
||||
const ITEM_REMOVE = `<div class="paypal-item-remove m-button primary focusable" title="-1" role="button" tabindex="0"><i class="icon-minus"></i></div>`,
|
||||
ITEM_ADD = `<div class="paypal-item-add m-button primary focusable" title="+1" role="button" tabindex="0"><i class="icon-plus"></i></div>`,
|
||||
CHECKOUT = `<div class="paypal-order">
|
||||
<div class="paypal-order-total"></div>
|
||||
<div class="paypal-order-checkout m-button primary focusable" role="button" tabindex="0"><span>Checkout with</span> <span title="PayPal" class="paypal-checkout-logo"></span></div>
|
||||
</div>`.replace(/\s+/g, ' ');
|
||||
|
||||
const createElement = (html) => {
|
||||
const tmpl = document.createElement('template');
|
||||
tmpl.innerHTML = html.trim();
|
||||
return tmpl.content.firstChild;
|
||||
},
|
||||
getDataAttrAsInt = (elem, attr) => {
|
||||
let value = parseInt(elem.dataset[attr]);
|
||||
if (isNaN(value)) value = 0;
|
||||
return value;
|
||||
},
|
||||
onClick = (elem, handler) => {
|
||||
elem.addEventListener('click', handler);
|
||||
elem.addEventListener('keydown', (event) => {
|
||||
if (['Space', 'Enter'].includes(event.code)) handler();
|
||||
});
|
||||
};
|
||||
|
||||
const hydrateCart = (cart) => {
|
||||
const { id: cartId } = cart.dataset,
|
||||
order = createElement(CHECKOUT),
|
||||
items = [...cart.querySelectorAll('.paypal-item')],
|
||||
total = order.querySelector('.paypal-order-total'),
|
||||
checkout = order.querySelector('.paypal-order-checkout'),
|
||||
confirmation = cart.querySelector('.paypal-confirmation');
|
||||
if (confirmation) confirmation.before(order);
|
||||
else cart.append(order);
|
||||
|
||||
const getCount = (item) => getDataAttrAsInt(item, 'count'),
|
||||
getCost = (item) => getDataAttrAsInt(item, 'cost'),
|
||||
getTotal = () =>
|
||||
items.reduce((charge, item) => {
|
||||
return charge + getCount(item) * getCost(item);
|
||||
}, 0);
|
||||
|
||||
const updateTotal = () => (total.innerText = `$${getTotal()}`),
|
||||
updateCount = (item, increment) => {
|
||||
item.dataset.count = Math.max(getCount(item) + increment, 0);
|
||||
updateTotal();
|
||||
};
|
||||
updateTotal();
|
||||
|
||||
const showConfirmation = () => {
|
||||
if (!confirmation) return;
|
||||
confirmation.style.setProperty('display', 'flex');
|
||||
};
|
||||
|
||||
for (const item of items) {
|
||||
const add = createElement(ITEM_ADD),
|
||||
remove = createElement(ITEM_REMOVE);
|
||||
onClick(add, () => updateCount(item, +1));
|
||||
onClick(remove, () => updateCount(item, -1));
|
||||
item.append(remove, add);
|
||||
}
|
||||
|
||||
onClick(checkout, () => {
|
||||
console.log({
|
||||
cart: cartId,
|
||||
items: items.map((item) => {
|
||||
return {
|
||||
id: item.dataset.id,
|
||||
count: getCount(item),
|
||||
};
|
||||
}),
|
||||
});
|
||||
showConfirmation();
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const carts = document.querySelectorAll('.paypal-cart');
|
||||
for (const cart of carts) hydrateCart(cart);
|
||||
});
|
||||
/* /pyv */
|
@ -70,7 +70,7 @@ const setHeights = () => {
|
||||
};
|
||||
|
||||
const setCircleStyles = () => {
|
||||
/* pyv */if (!$progressCircle?.[0]?.style) return;/* /pyv */
|
||||
if (!$progressCircle?.[0]?.style) return;
|
||||
const svgWidth = $progressCircle.parent().width();
|
||||
const radiusCircle = svgWidth / 2;
|
||||
const borderWidth = isMobile() ? 2 : 3;
|
||||
@ -88,7 +88,7 @@ const setCircleStyles = () => {
|
||||
};
|
||||
|
||||
const setProgress = percent => {
|
||||
/* pyv */if (!$progressCircle?.[0]?.style) return;/* /pyv */
|
||||
if (!$progressCircle?.[0]?.style) return;
|
||||
if (percent <= 100) {
|
||||
const offset = circumference - (percent / 100) * circumference;
|
||||
$progressCircle[0].style.strokeDashoffset = offset;
|
||||
@ -97,7 +97,7 @@ const setProgress = percent => {
|
||||
|
||||
const prepareProgressCircle = () => {
|
||||
$progressCircle = $('.js-progress');
|
||||
/* pyv */if (!$progressCircle) return;/* /pyv */
|
||||
if (!$progressCircle) return;
|
||||
|
||||
setHeights();
|
||||
setCircleStyles();
|
||||
@ -171,20 +171,4 @@ $(() => {
|
||||
|
||||
$(window).on('load', () => {
|
||||
prepareProgressCircle();
|
||||
/* pyv */
|
||||
// const $openShareMenu = $('#open-share-menu');
|
||||
// if ($openShareMenu) {
|
||||
// if (navigator?.share) {
|
||||
// $openShareMenu.on('click', () => {
|
||||
// navigator.share({
|
||||
// title: document.title,
|
||||
// text: $('.js-post-content')
|
||||
// .text().split(' ').slice(0, 42)
|
||||
// .join(' ') + '...',
|
||||
// url: location.href,
|
||||
// });
|
||||
// });
|
||||
// } else $openShareMenu.remove();
|
||||
// }
|
||||
/* /pyv */
|
||||
});
|
||||
|
6
src/package-lock.json
generated
6
src/package-lock.json
generated
@ -12,7 +12,6 @@
|
||||
"@tryghost/content-api": "^1.11.1",
|
||||
"fitvids": "^2.0.0",
|
||||
"fuse.js": "^6.4.6",
|
||||
"fuzzysort": "^2.0.4",
|
||||
"headroom.js": "^0.12.0",
|
||||
"jquery": "^3.6.0",
|
||||
"medium-zoom": "^1.0.6",
|
||||
@ -7107,11 +7106,6 @@
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/fuzzysort": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/fuzzysort/-/fuzzysort-2.0.4.tgz",
|
||||
"integrity": "sha512-Api1mJL+Ad7W7vnDZnWq5pGaXJjyencT+iKGia2PlHUcSsSzWwIQ3S1isiMpwpavjYtGd2FzhUIhnnhOULZgDw=="
|
||||
},
|
||||
"node_modules/generate-function": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz",
|
||||
|
@ -50,7 +50,6 @@
|
||||
"@tryghost/content-api": "^1.11.1",
|
||||
"fitvids": "^2.0.0",
|
||||
"fuse.js": "^6.4.6",
|
||||
"fuzzysort": "^2.0.4",
|
||||
"headroom.js": "^0.12.0",
|
||||
"jquery": "^3.6.0",
|
||||
"medium-zoom": "^1.0.6",
|
||||
|
@ -6,10 +6,7 @@ html:not([data-theme]),
|
||||
--primary-subtle-color: #0470ee;
|
||||
--secondary-subtle-color: #f4f8fd;
|
||||
--titles-color: #333;
|
||||
/* pyv */
|
||||
// --link-color: #133467;
|
||||
--link-color: #1d3c85;
|
||||
/* /pyv */
|
||||
--primary-border-color: #9b9b9b;
|
||||
--secondary-border-color: aliceblue;
|
||||
--article-shadow-normal: 0 10px 10px rgba(0, 0, 0, 0.08);
|
||||
@ -36,10 +33,7 @@ html:not([data-theme]),
|
||||
--primary-subtle-color: #2c2fe6;
|
||||
--secondary-subtle-color: #141920;
|
||||
--titles-color: #b4b4b4;
|
||||
/* pyv */
|
||||
// --link-color: #b6b7f6;
|
||||
--link-color: #5bbaeb;
|
||||
/* /pyv */
|
||||
--primary-border-color: #1d1d1d;
|
||||
--secondary-border-color: #0f0f0f;
|
||||
--article-shadow-normal: 0 4px 5px 5px rgba(0, 0, 0, 0.1);
|
||||
|
11940
src/yarn.lock
11940
src/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user