Solar Cells Experiment DIY Solar Assembling Creative Educational Toy

$100.00
كمية
const priceItemClass = 'loyalty-benefit-package-card-item-price-item'; const priceItemActiveClass = 'loyalty-benefit-package-card-item-price-item-active'; const MAX_PACKAGE_COUNT = 3; const tagName = 'spz-custom-loyalty-benefits-package-card-entry'; class LoyaltyBenefitsPackageCardEntry extends SPZ.BaseElement { constructor(element) { super(element); this.sectionType = element.getAttribute('data-section-type'); this.modalContainerId = element.getAttribute('data-modal-container-id'); this.eventBusId = element.getAttribute('data-event-bus-id'); this.eventBusDom = document.getElementById(this.eventBusId); } isLayoutSupported(layout) { return layout === SPZCore.Layout.CONTAINER; } buildCallback() { if (!window.loyalty_benefit_package_card_id_num) { window.loyalty_benefit_package_card_id_num = 1; } this.pageTemplateName = window.SHOPLAZZA?.meta?.page?.template_name; this.isProductPage = (this.pageTemplateName == 'product' || this.pageTemplateName == 'product.custom') && this.sectionType != 'cart_drawer'; this.productId = this.isProductPage ? window.SHOPLAZZA?.meta?.page?.resource_id : ''; this.ljsRenderDom = this.element.querySelector('ljs-render'); this.productFormBundleComponentsInput = null; this.plans = []; this.viewPlanBenefitPackageId = null; this.viewPlanBenefitId = null; this.setSelectedData_(null, null); this.cardInitSuccess = false; this.startInit = false; this.setupAction_(); this.listeningCartChange_(); if (!this.element.hasAttribute('manual')) { this.init_(); } } setupAction_() { this.registerAction("render", () => { this.init_(); }); this.registerAction("setViewBenefitPackageId", (invocation) => { this.setViewBenefitPackageId_(invocation.args); }); this.registerAction("getViewPlanBenefitPackageData", () => { this.getViewPlan_(); }); this.registerAction("getViewPlanDetail_", () => { this.getViewPlanDetail_(); }); this.registerAction("setViewBenefitId", (invocation) => { this.setViewBenefitId_(invocation.args); }); this.registerAction("getViewPlanBenefitDetail", () => { this.getViewPlanBenefitDetail_(); }); this.registerAction("selectPlan", (invocation) => { this.selectPlan_(invocation.args); }); this.registerAction("setPlanSelectedStyle", () => { this.setPlanSelectedStyle_(); }); this.registerAction("onSelectPlan", (invocation) => { this.onSelectPlan_(invocation.event.detail.detail); }); } async init_() { this.startInit = true; const canLoadCard = await this.getCanLoadCard_(); if (!canLoadCard) { return; } this.getPlans_() .then(() => { this.renderPlans_(); this.cardInitSuccess = true; }); } getCanLoadCard_() { if (this.isProductPage) { return Promise.resolve(true); } return this.getCartCount_().then((count) => { return count > 0; }); } getCartCount_() { return fetch(`/ar/api/cart/count`, { method: 'GET', }).then((response) => { return response.json(); }).then((data) => { return data.data?.count; }); } listeningCartChange_() { if (this.isProductPage) { return; } window.addEventListener('dj.cartChange', (e) => { this.getCartCount_() .then((cartCount) => { if (0 >= cartCount) { if (this.cardInitSuccess) { this.element.style.display = 'none'; } } else { if (!this.cardInitSuccess) { if (this.startInit) { this.init_(); } } else if (this.element.style.display === 'none') { this.element.style.display = 'block'; } } }); }) } getPlans_() { const otherFinishedCards = document.querySelector(`${tagName}[finished="true"]`); if (otherFinishedCards) { return SPZ.whenApiDefined(otherFinishedCards) .then((api) => { this.element.setAttribute('finished', 'true'); this.plans = api.plans; this.selectedBenefitPackageId = api.selectedBenefitPackageId; this.selectedSellingPlanOptionId = api.selectedSellingPlanOptionId; this.setSelectedData_(this.selectedBenefitPackageId, this.selectedSellingPlanOptionId); return; }); } return fetch( `/ar/api/loyalty-server/benefit-package/selling-plans?limit=${MAX_PACKAGE_COUNT}&product_id=${this.productId}`, { method: 'GET', } ).then((response) => { return response.json(); }).then((data) => { this.element.setAttribute('finished', 'true'); return this.plans = data.plans || []; }); } renderPlans_() { SPZ.whenApiDefined(this.ljsRenderDom).then((api) => { api.render({ plans: this.plans, selectedBenefitPackageId: this.selectedBenefitPackageId, selectedSellingPlanOptionId: this.selectedSellingPlanOptionId, showViewButton: true, idNum: ++window.loyalty_benefit_package_card_id_num, }); }); } selectPlan_(data) { SPZ.whenApiDefined(this.eventBusDom).then((api) => { api.emit_('loyalty.select_benefit_package_plan', { ...data, origin: this.eventBusDom.dataset.origin, }); }); this.onSelectPlan_(data); } onSelectPlan_(data) { const { benefit_package_id, selling_plan_option_id } = data; const { selectedBenefitPackageId, selectedSellingPlanOptionId } = this; if (benefit_package_id === selectedBenefitPackageId && selling_plan_option_id === selectedSellingPlanOptionId) { this.setSelectedData_(null, null); this.setPlanSelectedStyle_(); return; } const plan = this.plans.find((plan) => plan.benefit_package.id === benefit_package_id); if (!plan) { return; } if (selling_plan_option_id && plan.selling_plan_option_id !== selling_plan_option_id) { return; } this.setSelectedData_(benefit_package_id, selling_plan_option_id); this.setPlanSelectedStyle_(); } setPlanSelectedStyle_() { const { selectedBenefitPackageId, selectedSellingPlanOptionId } = this; document.querySelectorAll(`#${this.modalContainerId} .${priceItemActiveClass}`).forEach((item) => item.classList.remove(priceItemActiveClass)); this.element.querySelectorAll(`.${priceItemActiveClass}`).forEach((item) => item.classList.remove(priceItemActiveClass)); const activePlanDomList = document.querySelectorAll(`#${this.modalContainerId} .${priceItemClass}[data-benefit_package_id="${selectedBenefitPackageId}"][data-selling_plan_option_id="${selectedSellingPlanOptionId}"]`); const elementActivePlanDomList = this.element.querySelectorAll(`.${priceItemClass}[data-benefit_package_id="${selectedBenefitPackageId}"][data-selling_plan_option_id="${selectedSellingPlanOptionId}"]`); if (activePlanDomList.length > 0 || elementActivePlanDomList.length > 0) { activePlanDomList.forEach((activePlanDom) => { activePlanDom.classList.add(priceItemActiveClass); }); elementActivePlanDomList.forEach((activePlanDom) => { activePlanDom.classList.add(priceItemActiveClass); }); } else { this.setSelectedData_(null, null); } } setSelectedData_(benefit_package_id, selling_plan_option_id) { this.selectedBenefitPackageId = benefit_package_id; this.selectedSellingPlanOptionId = selling_plan_option_id; const currentSelectedPlan = this.plans.find((plan) => plan.benefit_package.id === benefit_package_id); if (!currentSelectedPlan) { this.setSubmitData_(''); return; } const planPurchaseData = [{ "quantity":1, "product_id": currentSelectedPlan.benefit_package.product_id, "variant_id": currentSelectedPlan.benefit_package.variant_id, "note":"", "properties": selling_plan_option_id.length ? JSON.stringify({_selling_plan_option_id: selling_plan_option_id}) : '', }]; this.setSubmitData_(JSON.stringify(planPurchaseData)); } setSubmitData_(data) { if (this.isProductPage) { this.getProductFormBundleComponentsInput_().value = data; } else { window.djInterceptors?.request?.eject(window.loyalty_benefit_package_card_request_interceptor); window.loyalty_benefit_package_card_request_interceptor = window.djInterceptors?.request?.use((config)=>{ if(config.url == '/api/checkout/order') { try { config.body.line_items[0].bundle_components = data; } catch (error) { console.error('error', error); } } return config; }); } } getProductFormBundleComponentsInput_() { if (!this.productFormBundleComponentsInput) { this.productFormBundleComponentsInput = document.createElement('input'); this.productFormBundleComponentsInput.type = 'hidden'; this.productFormBundleComponentsInput.name = 'bundle_components'; this.productFormBundleComponentsInput.autocomplete = 'off'; this.element.appendChild(this.productFormBundleComponentsInput); } return this.productFormBundleComponentsInput; } setViewBenefitPackageId_(data) { const { benefit_package_id } = data; this.viewPlanBenefitPackageId = benefit_package_id; } setViewBenefitId_(data) { const { benefit_id } = data; this.viewPlanBenefitId = benefit_id; } getViewPlan_() { const plan = this.plans.find((plan) => plan.benefit_package.id === this.viewPlanBenefitPackageId) || this.plans[0]; return { plans: [plan], selectedBenefitPackageId: this.selectedBenefitPackageId, selectedSellingPlanOptionId: this.selectedSellingPlanOptionId, showViewButton: false, idNum: ++window.loyalty_benefit_package_card_id_num, }; } getViewPlanDetail_() { return fetch( `/ar/api/loyalty-server/benefit-package/${this.viewPlanBenefitPackageId}`, { method: 'GET', } ).then((response) => { return response.json(); }); } getViewPlanBenefitDetail_() { return fetch( `/ar/api/loyalty-server/benefit//${this.viewPlanBenefitId}`, { method: 'GET', } ).then((response) => { return response.json(); }); } } SPZ.defineElement(tagName, LoyaltyBenefitsPackageCardEntry); const TAG = 'spz-custom-loyalty-app-config'; class SpzCustomLoyaltyAppConfig extends SPZ.BaseElement { constructor(element) { super(element); this.allConfig = null; this.configPath = element.getAttribute('data-config-path'); } buildCallback() { this.action_ = SPZServices.actionServiceForDoc(); window.__loyalty_settings__.then((allConfig) => { this.allConfig = allConfig; const eventName = this.allConfig[this.configPath] ? 'configPass' : 'configFail'; const event = SPZUtils.Event.create(this.win, `${TAG}.${eventName}`, {}); this.action_.trigger(this.element, eventName, event); }); } _getAllConfig() { if (this.allConfig) { return this.allConfig; } return window.__loyalty_settings__.then((allConfig) => { this.allConfig = allConfig; return this.allConfig; }); } isLayoutSupported(layout) { return layout === SPZCore.Layout.LOGIC; } } SPZ.defineElement(TAG, SpzCustomLoyaltyAppConfig); class SpzCustomLoyaltyPoint extends SPZ.BaseElement { constructor(element) { super(element); this.value_ = element.getAttribute('value'); } buildCallback() { if (this.win.__loyalty_settings__) { this.win.__loyalty_settings__.then((settings) => { this.pointName_ = (settings.points_rule && settings.points_rule.points_name) || "Points"; this.render_(); }); } } mutatedAttributesCallback(mutations) { if (!SPZCore.Types.hasOwn(mutations, 'value')) { return; } this.value_ = mutations.value; this.render_(); } render_() { if (this.element.childElementCount > 0) { this.element.innerHTML = ''; } this.container_ = document.createElement("span"); this.container_.classList.add("loyalty-point"); this.container_.innerHTML = `${this.value_ !== null ? `${this.value_} ` : ''}${this.pointName_}`; this.element.appendChild(this.container_); } isLayoutSupported(layout) { return layout === SPZCore.Layout.CONTAINER; } } SPZ.defineElement("spz-custom-loyalty-point", SpzCustomLoyaltyPoint); class SpzCustomLoyaltyEvent extends SPZ.BaseElement { constructor(element) { super(element); } buildCallback() { this.setupAction_(); this.action_ = SPZServices.actionServiceForDoc(this.element); this.origin = this.element.dataset.origin; const attributes = this.element.attributes; for (let i = 0; i < attributes.length; i++) { const attributeName = attributes[i].name; if (attributeName.startsWith('@event:')) { const eventName = attributeName.replace('@event:', ''); window.SPZUtils.Event.listen( window, eventName, (data) => { if(data.detail.origin !== this.origin) { this.triggerEvent_(`event:${eventName}`, data); } } ) } } } triggerEvent_(eventName, data) { const event = SPZUtils.Event.create( this.win, `spz-custom-loyalty-event.${eventName}`, data ); this.action_.trigger(this.element, eventName, event); } setupAction_() { this.registerAction("emit", (invocation) => { const { args } = invocation; const {eventName} = args; this.emit_(eventName, args); }); } emit_(eventName, args) { const event = window.SPZUtils.Event.create( window, eventName, args ); window.dispatchEvent(event); } isLayoutSupported(layout) { return layout === SPZCore.Layout.LOGIC; } } SPZ.defineElement("spz-custom-loyalty-event", SpzCustomLoyaltyEvent);
document.addEventListener("DOMContentLoaded", function() { const modalContainer = document.getElementById('loyalty-benefit-package-card-modal-container-21'); if (modalContainer && modalContainer.parentNode !== document.body) { document.body.appendChild(modalContainer); } });

وصف

1773pz I Love England. What do you think of when you think of England? Artist Charlie Girard gathered brands, events, famous locations and more in this 1000 piece jigsaw puzzle.  Finished size 24" x 30".</p >

Every Puzzle includes our HAPPINESS GUARANTEE: If you are not completely delighted with your puzzle experience, we will replace your puzzle with a new one for free.</p >