@salla.sa/twilight-components 2.12.14 → 2.12.16
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/dist/cjs/salla-add-product-button_41.cjs.entry.js +1 -1
- package/dist/cjs/salla-add-product-button_41.cjs.entry.js.map +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +61 -14
- package/dist/cjs/salla-installment.cjs.entry.js.map +1 -1
- package/dist/collection/components/salla-installment/salla-installment.js +61 -14
- package/dist/collection/components/salla-installment/salla-installment.js.map +1 -1
- package/dist/collection/components/salla-product-card/salla-product-card.js +1 -1
- package/dist/collection/components/salla-product-card/salla-product-card.js.map +1 -1
- package/dist/components/salla-installment.js +61 -14
- package/dist/components/salla-installment.js.map +1 -1
- package/dist/components/salla-product-card2.js +1 -1
- package/dist/components/salla-product-card2.js.map +1 -1
- package/dist/esm/salla-add-product-button_41.entry.js +1 -1
- package/dist/esm/salla-add-product-button_41.entry.js.map +1 -1
- package/dist/esm/salla-installment.entry.js +62 -15
- package/dist/esm/salla-installment.entry.js.map +1 -1
- package/dist/esm-es5/salla-add-product-button_41.entry.js +1 -1
- package/dist/esm-es5/salla-add-product-button_41.entry.js.map +1 -1
- package/dist/esm-es5/salla-installment.entry.js +1 -1
- package/dist/esm-es5/salla-installment.entry.js.map +1 -1
- package/dist/twilight/p-5e28ad7e.system.js +1 -1
- package/dist/twilight/p-d80d1435.system.entry.js +5 -0
- package/dist/twilight/p-d80d1435.system.entry.js.map +1 -0
- package/dist/twilight/{p-35c48642.entry.js → p-ddafee19.entry.js} +2 -2
- package/dist/twilight/{p-35c48642.entry.js.map → p-ddafee19.entry.js.map} +1 -1
- package/dist/twilight/p-e9437753.entry.js +5 -0
- package/dist/twilight/p-e9437753.entry.js.map +1 -0
- package/dist/twilight/{p-6aa2f6bd.system.entry.js → p-fcd0c9bc.system.entry.js} +2 -2
- package/dist/twilight/{p-6aa2f6bd.system.entry.js.map → p-fcd0c9bc.system.entry.js.map} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-installment/salla-installment.d.ts +2 -1
- package/dist/types/global.d.ts +17 -0
- package/package.json +2 -2
- package/dist/twilight/p-0973f52a.system.entry.js +0 -5
- package/dist/twilight/p-0973f52a.system.entry.js.map +0 -1
- package/dist/twilight/p-5f0dffdf.entry.js +0 -5
- package/dist/twilight/p-5f0dffdf.entry.js.map +0 -1
|
@@ -29,6 +29,13 @@ const SallaInstallment = class {
|
|
|
29
29
|
}
|
|
30
30
|
this.renderInstallments();
|
|
31
31
|
});
|
|
32
|
+
salla.event.on('product::price.updated', ({ data }) => {
|
|
33
|
+
if (!data.price || data.price == this.price) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.price = data.price;
|
|
37
|
+
this.renderInstallments(true);
|
|
38
|
+
});
|
|
32
39
|
}
|
|
33
40
|
render() {
|
|
34
41
|
return (index.h(index.Host, null, this.tamaraIsActive ?
|
|
@@ -39,13 +46,19 @@ const SallaInstallment = class {
|
|
|
39
46
|
index.h("div", { class: "spotii-wrapper" }, index.h("div", { class: "spotii-promo" }))
|
|
40
47
|
: ''));
|
|
41
48
|
}
|
|
42
|
-
renderInstallments() {
|
|
49
|
+
renderInstallments(isUpdating = false) {
|
|
43
50
|
// Tamara
|
|
44
51
|
if (this.tamaraIsActive) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
if (isUpdating) {
|
|
53
|
+
var oldTamaraScript = document.querySelector('script[src="https://cdn.tamara.co/widget/product-widget.min.js"]');
|
|
54
|
+
if (oldTamaraScript) {
|
|
55
|
+
oldTamaraScript.remove();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
var tamaraScript = document.createElement('script');
|
|
59
|
+
tamaraScript.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');
|
|
60
|
+
document.head.appendChild(tamaraScript);
|
|
61
|
+
tamaraScript.onload = () => {
|
|
49
62
|
window.TamaraProductWidget.init({ lang: this.language });
|
|
50
63
|
setTimeout(() => {
|
|
51
64
|
window.TamaraProductWidget.render();
|
|
@@ -54,10 +67,27 @@ const SallaInstallment = class {
|
|
|
54
67
|
}
|
|
55
68
|
// tabby
|
|
56
69
|
if (this.tabbyIsActive) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
if (isUpdating) {
|
|
71
|
+
// remove #tabbyPromoWrapper and re append it
|
|
72
|
+
var oldTabbyWrapper = this.host.querySelector('#tabbyPromoWrapper');
|
|
73
|
+
if (oldTabbyWrapper) {
|
|
74
|
+
oldTabbyWrapper.remove();
|
|
75
|
+
}
|
|
76
|
+
var tabbyPromoWrapper = document.createElement('div');
|
|
77
|
+
tabbyPromoWrapper.setAttribute('id', 'tabbyPromoWrapper');
|
|
78
|
+
var tabbyPromo = document.createElement('div');
|
|
79
|
+
tabbyPromo.setAttribute('id', 'tabbyPromo');
|
|
80
|
+
tabbyPromoWrapper.appendChild(tabbyPromo);
|
|
81
|
+
this.host.appendChild(tabbyPromoWrapper);
|
|
82
|
+
var oldTabbyScript = document.querySelector('script[src="https://checkout.tabby.ai/tabby-promo.js"]');
|
|
83
|
+
if (oldTabbyScript) {
|
|
84
|
+
oldTabbyScript.remove();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
var tabbyScript = document.createElement('script');
|
|
88
|
+
tabbyScript.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');
|
|
89
|
+
document.head.appendChild(tabbyScript);
|
|
90
|
+
tabbyScript.onload = () => {
|
|
61
91
|
const TabbyPromo = window.TabbyPromo;
|
|
62
92
|
new TabbyPromo({
|
|
63
93
|
selector: '#tabbyPromo',
|
|
@@ -69,11 +99,27 @@ const SallaInstallment = class {
|
|
|
69
99
|
element.setAttribute('aria-label', 'Tabby Logo');
|
|
70
100
|
});
|
|
71
101
|
};
|
|
72
|
-
//this is workaround to remove the default border and add margin
|
|
102
|
+
// this is a workaround to remove the default border and add margin
|
|
73
103
|
this.removeTabbyBorder();
|
|
74
104
|
}
|
|
75
105
|
// Spotii
|
|
76
106
|
if (this.spotiiIsActive) {
|
|
107
|
+
if (isUpdating) {
|
|
108
|
+
var oldSpotiiWrapper = this.host.querySelector('.spotii-wrapper');
|
|
109
|
+
if (oldSpotiiWrapper) {
|
|
110
|
+
oldSpotiiWrapper.remove();
|
|
111
|
+
}
|
|
112
|
+
var spotiiPromoWrapper = document.createElement('div');
|
|
113
|
+
spotiiPromoWrapper.classList.add('spotii-wrapper');
|
|
114
|
+
var spotiiPromo = document.createElement('div');
|
|
115
|
+
spotiiPromo.classList.add('spotii-promo');
|
|
116
|
+
spotiiPromoWrapper.appendChild(spotiiPromo);
|
|
117
|
+
this.host.appendChild(spotiiPromoWrapper);
|
|
118
|
+
var oldSpotiiScript = document.querySelector('script[src="' + salla.url.cdn('js/price-widget-ar-salla.js') + '"]');
|
|
119
|
+
if (oldSpotiiScript) {
|
|
120
|
+
oldSpotiiScript.remove();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
77
123
|
let amount = salla.money((Number(this.price) / 3).toFixed(2));
|
|
78
124
|
let isRTL = salla.config.get('theme.is_rtl', true);
|
|
79
125
|
window.spotiiConfig = {
|
|
@@ -90,10 +136,10 @@ const SallaInstallment = class {
|
|
|
90
136
|
// forcedShow: false,
|
|
91
137
|
// merchantID: null,
|
|
92
138
|
};
|
|
93
|
-
var
|
|
94
|
-
|
|
95
|
-
document.head.appendChild(
|
|
96
|
-
//
|
|
139
|
+
var spotiiScript = document.createElement('script');
|
|
140
|
+
spotiiScript.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));
|
|
141
|
+
document.head.appendChild(spotiiScript);
|
|
142
|
+
// spotiiScript.onload = () => {
|
|
97
143
|
// // setTimeout()
|
|
98
144
|
// }
|
|
99
145
|
}
|
|
@@ -119,6 +165,7 @@ const SallaInstallment = class {
|
|
|
119
165
|
}
|
|
120
166
|
}, this.tabbyRemoveBorderTries * 500);
|
|
121
167
|
}
|
|
168
|
+
get host() { return index.getElement(this); }
|
|
122
169
|
};
|
|
123
170
|
SallaInstallment.style = sallaInstallmentCss;
|
|
124
171
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"salla-installment.entry.cjs.js","mappings":";;;;;;;;;AAAA,MAAM,mBAAmB,GAAG,mvGAAmvG;;MCOlwG,gBAAgB;EAI3B;;IAHQ,uBAAkB,GAAY,KAAK,CAAC;IACpC,2BAAsB,GAAW,CAAC,CAAC;;oBAqBhB,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;oBAItC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;;;;IAtB/D,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;MAClB,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;MACpE,IAAI,WAAW,EAAE;QACf,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC/D,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;OAC1D;MACD,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAC3B,CAAC,CAAC;GACJ;EAmBD,MAAM;IACJ,QACEA,QAACC,UAAI,QACF,IAAI,CAAC,cAAc;MAClBD,iBAAK,KAAK,EAAC,uBAAuB,gBACjB,IAAI,CAAC,KAAK,mBACP,IAAI,CAAC,QAAQ,eACjB,IAAI,CAAC,QAAQ,uBACN,aAAa,GAC9B;QACJ,EAAE,EAEL,IAAI,CAAC,aAAa;MACjBA,iBAAK,EAAE,EAAC,mBAAmB,IACzBA,iBAAK,EAAE,EAAC,YAAY,GAAO,CACvB;QACJ,EAAE,EAEL,IAAI,CAAC,cA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D,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,6CAA6C,CAAC,GAAG,IAAI,CAAC;MACrG,IAAI,KAAK,EAAE;QACT,KAAK,CAAC,KAAK,GAAG,yCAAyC,CAAC;QACxD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;OAChC;WAAM;QACL,IAAI,CAAC,iBAAiB,EAAE,CAAC;OAC1B;KACF,EAAE,IAAI,CAAC,sBAAsB,GAAG,GAAG,CAAC,CAAA;GACtC;;;;;;","names":["h","Host"],"sources":["./src/components/salla-installment/salla-installment.scss?tag=salla-installment","./src/components/salla-installment/salla-installment.tsx"],"sourcesContent":["/*\n The whole installment methods is a third-party widgets,\n So there aren't a custom classes (as other components) to style them.\n*/\n\nsalla-installment:empty {\n display: none;\n}\n/*\n* Installment::Tabby\n*/\n#tabbyPromoWrapper {\n background: white;\n border-radius: 0.375rem;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n margin-bottom: 20px;\n\n .salla-y &{\n border: 1px solid var(--color-grey-dark);\n border-radius: 12px\n }\n\n &:hover{\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n }\n\n #tabbyPromo {\n * {\n font-family: var(--font-main);\n }\n\n > div > div {\n max-width: none;\n //padding: 15px;\n box-shadow: none;\n border: none;\n }\n\n .tabby-promo-snippet {\n max-width: 100%;\n min-height: 100px;\n padding: 18px 20px;\n // border-color: var(--color-grey-dark);\n border: none !important;\n\n\n &__text, &__link {\n font-size: var(--font-sm);\n color: var(--color-text) !important;\n }\n\n &__link {\n font-weight: bold;\n }\n }\n }\n}\n\n.tabby-promo-wrapper {\n #tabby-promo {\n font-family: var(--font-main) !important;\n\n .tabby-promo {\n &__feature-title {\n font-size: var(--font-md);\n }\n\n &__feature-desc {\n font-size: var(--font-sm);\n line-height: 20px;\n }\n }\n }\n}\n\n/*\n* Installment::Tamara & Spotii\n*/\n.tamara-product-widget{\n margin-bottom: 20px;\n}\n\n.tamara-product-widget,\n.spotii-wrapper {\n min-height: 100px;\n position: relative;\n color: var(--color-text);\n font-size: var(--font-sm);\n line-height: 1.25;\n padding: 18px 20px 18px 100px !important;\n background: white;\n border-radius: 0.375rem;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n\n .salla-y &{\n border-radius: 12px;\n border: 1px solid var(--color-grey-dark);\n }\n\n &:hover{\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n }\n .spotii-logo {\n float: left;\n margin: 0 0 0 -75px;\n }\n}\n.ltr .tamara-product-widget,\n.ltr .spotii-wrapper{\n text-align: left;\n padding: 18px 100px 18px 20px !important;\n .spotii-logo {\n float: right;\n margin: 0 -75px 0 0;\n }\n .spotii-product-widget {\n text-align: left !important;\n }\n}\n\n.spotii-wrapper {\n margin-bottom: 20px;\n .spotii-promo {\n font-size: var(--font-md);\n }\n\n .spotii-product-widget {\n font-size: var(--font-sm) !important;\n margin-top: 10px;\n }\n}\n\n.tamara-product-widget{\n .tamara-logo {\n position: absolute;\n left: 20px;\n top: 18px;\n margin: 0 !important;\n\n .ltr &{\n right: 20px;\n left: auto;\n }\n }\n\n span {\n font-family: var(--font-main);\n font-size: var(--font-sm);\n color: var(--color-text);\n\n &:last-child {\n display: block;\n position: relative;\n margin-top: 8px;\n }\n }\n}\n\n.tamara-popup {\n &__wrap {\n overflow: auto !important;\n }\n}\n","import {Component, Host, h, Prop, State} from '@stencil/core';\n\n@Component({\n tag: 'salla-installment',\n styleUrl: 'salla-installment.scss',\n})\n\nexport class SallaInstallment {\n private tabbyBorderRemoved: boolean = false;\n private tabbyRemoveBorderTries: number = 0;\n\n constructor() {\n salla.lang.onLoaded(() => {\n const installment = salla.config.get('store.settings.installments');\n if (installment) {\n this.tamaraIsActive = installment.includes('tamara_installment');\n this.tabbyIsActive = installment.includes('tabby_installment');\n this.spotiiIsActive = installment.includes('spotii_pay');\n }\n this.renderInstallments();\n });\n }\n\n /**\n * Current product price\n */\n @Prop() price: string;\n /**\n * Language code\n */\n @Prop() language: string = salla.config.get('user.language_code');\n /**\n * Currency code\n */\n @Prop() currency: string = salla.config.get('user.currency_code');\n\n @State() tamaraIsActive: boolean;\n @State() tabbyIsActive: boolean;\n @State() spotiiIsActive: boolean;\n\n render() {\n return (\n <Host>\n {this.tamaraIsActive ?\n <div class=\"tamara-product-widget\"\n data-price={this.price}\n data-currency={this.currency}\n data-lang={this.language}\n data-payment-type=\"installment\">\n </div>\n : ''}\n\n {this.tabbyIsActive ?\n <div id=\"tabbyPromoWrapper\">\n <div id=\"tabbyPromo\"></div>\n </div>\n : ''}\n\n {this.spotiiIsActive ?\n <div class=\"spotii-wrapper\">\n {/*No need for the price, the price already in the page, and also tammara & tabby doesn't have price */}\n <div class=\"spotii-promo\"></div>\n </div>\n : ''}\n </Host>\n );\n }\n\n renderInstallments() {\n // Tamara\n if (this.tamaraIsActive) {\n var script = document.createElement('script');\n script.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');\n document.head.appendChild(script);\n script.onload = () => {\n window.TamaraProductWidget.init({lang: this.language})\n setTimeout(() => {\n window.TamaraProductWidget.render()\n }, 300)\n }\n }\n\n // tabby\n if (this.tabbyIsActive) {\n var script = document.createElement('script');\n script.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');\n document.head.appendChild(script);\n script.onload = () => {\n const TabbyPromo = window.TabbyPromo;\n new TabbyPromo({\n selector: '#tabbyPromo',\n currency: this.currency,\n price: this.price,\n lang: this.language,\n });\n document.querySelectorAll('.tabby-promo-snippet__logo').forEach(function (element) {\n element.setAttribute('aria-label', 'Tabby Logo')\n });\n }\n //this is workaround to remove the default border and add margin\n this.removeTabbyBorder();\n }\n\n // Spotii\n if (this.spotiiIsActive) {\n let amount = salla.money((Number(this.price) / 3).toFixed(2));\n let isRTL = salla.config.get('theme.is_rtl', true);\n window.spotiiConfig = {\n targetXPath: ['.spotii-wrapper'],\n renderToPath: ['.spotii-promo'],\n numberOfPayment: 3,\n currency: this.currency,\n templateLine: \"${textOne} ${number} ${textTwo} \" + amount + \"${logo} ${info}\",\n //todo:: translate these\n textOne: isRTL ? \"جزء الدفع على\" : \"Split it into\",\n textTwo: isRTL ? \"أقساط متساوية بدون تكاليف اضافية بقيمة\" : \"payments of\",\n textThree: \"مع\",\n price: this.price,\n // forcedShow: false,\n // merchantID: null,\n }\n\n var script = document.createElement('script');\n\n script.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));\n document.head.appendChild(script);\n // script.onload = () => {\n // // setTimeout()\n // }\n }\n\n }\n\n /**\n * this is workaround to remove the default border and add margin\n * we will try to remove tabby border 5 times for 7.5 seconds\n */\n removeTabbyBorder() {\n if (this.tabbyBorderRemoved || this.tabbyRemoveBorderTries > 5) {\n return;\n }\n this.tabbyRemoveBorderTries++;\n setTimeout(() => {\n let promo: any = document.querySelector('#tabbyPromo>div>div');\n promo = promo ? promo.shadowRoot.querySelector('div[class^=\"styles__tabby-promo-snippet--\"]') : null;\n if (promo) {\n promo.style = 'border: none; margin: 15px 0!important;';\n this.tabbyBorderRemoved = true;\n } else {\n this.removeTabbyBorder();\n }\n }, this.tabbyRemoveBorderTries * 500)\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"salla-installment.entry.cjs.js","mappings":";;;;;;;;;AAAA,MAAM,mBAAmB,GAAG,mvGAAmvG;;MCOlwG,gBAAgB;EAI3B;;IAHQ,uBAAkB,GAAY,KAAK,CAAC;IACpC,2BAAsB,GAAW,CAAC,CAAC;;oBA6BhB,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;oBAItC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;;;;IA9B/D,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;MAClB,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;MACpE,IAAI,WAAW,EAAE;QACf,I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C,sBAAsB,EAAE,CAAC;IAC9B,UAAU,CAAC;MACT,IAAI,KAAK,GAAQ,QAAQ,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;MAC/D,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,6CAA6C,CAAC,GAAG,IAAI,CAAC;MACrG,IAAI,KAAK,EAAE;QACT,KAAK,CAAC,KAAK,GAAG,yCAAyC,CAAC;QACxD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;OAChC;WAAM;QACL,IAAI,CAAC,iBAAiB,EAAE,CAAC;OAC1B;KACF,EAAE,IAAI,CAAC,sBAAsB,GAAG,GAAG,CAAC,CAAA;GACtC;;;;;;;","names":["h","Host"],"sources":["./src/components/salla-installment/salla-installment.scss?tag=salla-installment","./src/components/salla-installment/salla-installment.tsx"],"sourcesContent":["/*\n The whole installment methods is a third-party widgets,\n So there aren't a custom classes (as other components) to style them.\n*/\n\nsalla-installment:empty {\n display: none;\n}\n/*\n* Installment::Tabby\n*/\n#tabbyPromoWrapper {\n background: white;\n border-radius: 0.375rem;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n margin-bottom: 20px;\n\n .salla-y &{\n border: 1px solid var(--color-grey-dark);\n border-radius: 12px\n }\n\n &:hover{\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n }\n\n #tabbyPromo {\n * {\n font-family: var(--font-main);\n }\n\n > div > div {\n max-width: none;\n //padding: 15px;\n box-shadow: none;\n border: none;\n }\n\n .tabby-promo-snippet {\n max-width: 100%;\n min-height: 100px;\n padding: 18px 20px;\n // border-color: var(--color-grey-dark);\n border: none !important;\n\n\n &__text, &__link {\n font-size: var(--font-sm);\n color: var(--color-text) !important;\n }\n\n &__link {\n font-weight: bold;\n }\n }\n }\n}\n\n.tabby-promo-wrapper {\n #tabby-promo {\n font-family: var(--font-main) !important;\n\n .tabby-promo {\n &__feature-title {\n font-size: var(--font-md);\n }\n\n &__feature-desc {\n font-size: var(--font-sm);\n line-height: 20px;\n }\n }\n }\n}\n\n/*\n* Installment::Tamara & Spotii\n*/\n.tamara-product-widget{\n margin-bottom: 20px;\n}\n\n.tamara-product-widget,\n.spotii-wrapper {\n min-height: 100px;\n position: relative;\n color: var(--color-text);\n font-size: var(--font-sm);\n line-height: 1.25;\n padding: 18px 20px 18px 100px !important;\n background: white;\n border-radius: 0.375rem;\n transition: box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1);\n\n .salla-y &{\n border-radius: 12px;\n border: 1px solid var(--color-grey-dark);\n }\n\n &:hover{\n box-shadow: 0 0 #0000, 0 0 #0000, 5px 10px 30px #2B2D340D;\n }\n .spotii-logo {\n float: left;\n margin: 0 0 0 -75px;\n }\n}\n.ltr .tamara-product-widget,\n.ltr .spotii-wrapper{\n text-align: left;\n padding: 18px 100px 18px 20px !important;\n .spotii-logo {\n float: right;\n margin: 0 -75px 0 0;\n }\n .spotii-product-widget {\n text-align: left !important;\n }\n}\n\n.spotii-wrapper {\n margin-bottom: 20px;\n .spotii-promo {\n font-size: var(--font-md);\n }\n\n .spotii-product-widget {\n font-size: var(--font-sm) !important;\n margin-top: 10px;\n }\n}\n\n.tamara-product-widget{\n .tamara-logo {\n position: absolute;\n left: 20px;\n top: 18px;\n margin: 0 !important;\n\n .ltr &{\n right: 20px;\n left: auto;\n }\n }\n\n span {\n font-family: var(--font-main);\n font-size: var(--font-sm);\n color: var(--color-text);\n\n &:last-child {\n display: block;\n position: relative;\n margin-top: 8px;\n }\n }\n}\n\n.tamara-popup {\n &__wrap {\n overflow: auto !important;\n }\n}\n","import { Component, Host, h, Prop, State, Element } from '@stencil/core';\n\n@Component({\n tag: 'salla-installment',\n styleUrl: 'salla-installment.scss',\n})\n\nexport class SallaInstallment {\n private tabbyBorderRemoved: boolean = false;\n private tabbyRemoveBorderTries: number = 0;\n @Element() host: HTMLElement;\n constructor() {\n salla.lang.onLoaded(() => {\n const installment = salla.config.get('store.settings.installments');\n if (installment) {\n this.tamaraIsActive = installment.includes('tamara_installment');\n this.tabbyIsActive = installment.includes('tabby_installment');\n this.spotiiIsActive = installment.includes('spotii_pay');\n }\n this.renderInstallments();\n });\n\n salla.event.on('product::price.updated', ({ data }) => {\n if (!data.price || data.price == this.price) {\n return;\n }\n this.price = data.price;\n this.renderInstallments(true);\n });\n }\n\n /**\n * Current product price\n */\n @Prop() price: string;\n /**\n * Language code\n */\n @Prop() language: string = salla.config.get('user.language_code');\n /**\n * Currency code\n */\n @Prop() currency: string = salla.config.get('user.currency_code');\n\n @State() tamaraIsActive: boolean;\n @State() tabbyIsActive: boolean;\n @State() spotiiIsActive: boolean;\n\n render() {\n return (\n <Host>\n {this.tamaraIsActive ?\n <div class=\"tamara-product-widget\"\n data-price={this.price}\n data-currency={this.currency}\n data-lang={this.language}\n data-payment-type=\"installment\">\n </div>\n : ''}\n\n {this.tabbyIsActive ?\n <div id=\"tabbyPromoWrapper\">\n <div id=\"tabbyPromo\"></div>\n </div>\n : ''}\n\n {this.spotiiIsActive ?\n <div class=\"spotii-wrapper\">\n {/*No need for the price, the price already in the page, and also tammara & tabby doesn't have price */}\n <div class=\"spotii-promo\"></div>\n </div>\n : ''}\n </Host>\n );\n }\n\n renderInstallments(isUpdating: boolean = false) {\n // Tamara\n if (this.tamaraIsActive) {\n if (isUpdating) {\n var oldTamaraScript = document.querySelector('script[src=\"https://cdn.tamara.co/widget/product-widget.min.js\"]');\n if (oldTamaraScript) {\n oldTamaraScript.remove();\n }\n }\n\n var tamaraScript = document.createElement('script');\n tamaraScript.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');\n document.head.appendChild(tamaraScript);\n tamaraScript.onload = () => {\n window.TamaraProductWidget.init({ lang: this.language });\n setTimeout(() => {\n window.TamaraProductWidget.render();\n }, 300);\n };\n }\n\n // tabby\n if (this.tabbyIsActive) {\n if (isUpdating) {\n\n // remove #tabbyPromoWrapper and re append it\n var oldTabbyWrapper = this.host.querySelector('#tabbyPromoWrapper');\n if (oldTabbyWrapper) {\n oldTabbyWrapper.remove();\n }\n\n var tabbyPromoWrapper = document.createElement('div');\n tabbyPromoWrapper.setAttribute('id', 'tabbyPromoWrapper');\n var tabbyPromo = document.createElement('div');\n tabbyPromo.setAttribute('id', 'tabbyPromo');\n tabbyPromoWrapper.appendChild(tabbyPromo);\n this.host.appendChild(tabbyPromoWrapper);\n\n var oldTabbyScript = document.querySelector('script[src=\"https://checkout.tabby.ai/tabby-promo.js\"]');\n if (oldTabbyScript) {\n oldTabbyScript.remove();\n }\n }\n\n var tabbyScript = document.createElement('script');\n tabbyScript.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');\n document.head.appendChild(tabbyScript);\n tabbyScript.onload = () => {\n const TabbyPromo = window.TabbyPromo;\n new TabbyPromo({\n selector: '#tabbyPromo',\n currency: this.currency,\n price: this.price,\n lang: this.language,\n });\n document.querySelectorAll('.tabby-promo-snippet__logo').forEach(function (element) {\n element.setAttribute('aria-label', 'Tabby Logo');\n });\n }\n // this is a workaround to remove the default border and add margin\n this.removeTabbyBorder();\n }\n\n // Spotii\n if (this.spotiiIsActive) {\n if (isUpdating) {\n\n var oldSpotiiWrapper = this.host.querySelector('.spotii-wrapper');\n if (oldSpotiiWrapper) {\n oldSpotiiWrapper.remove();\n }\n\n var spotiiPromoWrapper = document.createElement('div');\n spotiiPromoWrapper.classList.add('spotii-wrapper');\n var spotiiPromo = document.createElement('div');\n spotiiPromo.classList.add('spotii-promo');\n spotiiPromoWrapper.appendChild(spotiiPromo);\n this.host.appendChild(spotiiPromoWrapper);\n var oldSpotiiScript = document.querySelector('script[src=\"' + salla.url.cdn('js/price-widget-ar-salla.js') + '\"]');\n if (oldSpotiiScript) {\n oldSpotiiScript.remove();\n }\n }\n\n let amount = salla.money((Number(this.price) / 3).toFixed(2));\n let isRTL = salla.config.get('theme.is_rtl', true);\n window.spotiiConfig = {\n targetXPath: ['.spotii-wrapper'],\n renderToPath: ['.spotii-promo'],\n numberOfPayment: 3,\n currency: this.currency,\n templateLine: \"${textOne} ${number} ${textTwo} \" + amount + \"${logo} ${info}\",\n //todo:: translate these\n textOne: isRTL ? \"جزء الدفع على\" : \"Split it into\",\n textTwo: isRTL ? \"أقساط متساوية بدون تكاليف اضافية بقيمة\" : \"payments of\",\n textThree: \"مع\",\n price: this.price,\n // forcedShow: false,\n // merchantID: null,\n };\n\n var spotiiScript = document.createElement('script');\n spotiiScript.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));\n document.head.appendChild(spotiiScript);\n // spotiiScript.onload = () => {\n // // setTimeout()\n // }\n }\n }\n\n\n /**\n * this is workaround to remove the default border and add margin\n * we will try to remove tabby border 5 times for 7.5 seconds\n */\n removeTabbyBorder() {\n if (this.tabbyBorderRemoved || this.tabbyRemoveBorderTries > 5) {\n return;\n }\n this.tabbyRemoveBorderTries++;\n setTimeout(() => {\n let promo: any = document.querySelector('#tabbyPromo>div>div');\n promo = promo ? promo.shadowRoot.querySelector('div[class^=\"styles__tabby-promo-snippet--\"]') : null;\n if (promo) {\n promo.style = 'border: none; margin: 15px 0!important;';\n this.tabbyBorderRemoved = true;\n } else {\n this.removeTabbyBorder();\n }\n }, this.tabbyRemoveBorderTries * 500)\n }\n}\n"],"version":3}
|
|
@@ -21,6 +21,13 @@ export class SallaInstallment {
|
|
|
21
21
|
}
|
|
22
22
|
this.renderInstallments();
|
|
23
23
|
});
|
|
24
|
+
salla.event.on('product::price.updated', ({ data }) => {
|
|
25
|
+
if (!data.price || data.price == this.price) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.price = data.price;
|
|
29
|
+
this.renderInstallments(true);
|
|
30
|
+
});
|
|
24
31
|
}
|
|
25
32
|
render() {
|
|
26
33
|
return (h(Host, null, this.tamaraIsActive ?
|
|
@@ -31,13 +38,19 @@ export class SallaInstallment {
|
|
|
31
38
|
h("div", { class: "spotii-wrapper" }, h("div", { class: "spotii-promo" }))
|
|
32
39
|
: ''));
|
|
33
40
|
}
|
|
34
|
-
renderInstallments() {
|
|
41
|
+
renderInstallments(isUpdating = false) {
|
|
35
42
|
// Tamara
|
|
36
43
|
if (this.tamaraIsActive) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
if (isUpdating) {
|
|
45
|
+
var oldTamaraScript = document.querySelector('script[src="https://cdn.tamara.co/widget/product-widget.min.js"]');
|
|
46
|
+
if (oldTamaraScript) {
|
|
47
|
+
oldTamaraScript.remove();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
var tamaraScript = document.createElement('script');
|
|
51
|
+
tamaraScript.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');
|
|
52
|
+
document.head.appendChild(tamaraScript);
|
|
53
|
+
tamaraScript.onload = () => {
|
|
41
54
|
window.TamaraProductWidget.init({ lang: this.language });
|
|
42
55
|
setTimeout(() => {
|
|
43
56
|
window.TamaraProductWidget.render();
|
|
@@ -46,10 +59,27 @@ export class SallaInstallment {
|
|
|
46
59
|
}
|
|
47
60
|
// tabby
|
|
48
61
|
if (this.tabbyIsActive) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
if (isUpdating) {
|
|
63
|
+
// remove #tabbyPromoWrapper and re append it
|
|
64
|
+
var oldTabbyWrapper = this.host.querySelector('#tabbyPromoWrapper');
|
|
65
|
+
if (oldTabbyWrapper) {
|
|
66
|
+
oldTabbyWrapper.remove();
|
|
67
|
+
}
|
|
68
|
+
var tabbyPromoWrapper = document.createElement('div');
|
|
69
|
+
tabbyPromoWrapper.setAttribute('id', 'tabbyPromoWrapper');
|
|
70
|
+
var tabbyPromo = document.createElement('div');
|
|
71
|
+
tabbyPromo.setAttribute('id', 'tabbyPromo');
|
|
72
|
+
tabbyPromoWrapper.appendChild(tabbyPromo);
|
|
73
|
+
this.host.appendChild(tabbyPromoWrapper);
|
|
74
|
+
var oldTabbyScript = document.querySelector('script[src="https://checkout.tabby.ai/tabby-promo.js"]');
|
|
75
|
+
if (oldTabbyScript) {
|
|
76
|
+
oldTabbyScript.remove();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
var tabbyScript = document.createElement('script');
|
|
80
|
+
tabbyScript.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');
|
|
81
|
+
document.head.appendChild(tabbyScript);
|
|
82
|
+
tabbyScript.onload = () => {
|
|
53
83
|
const TabbyPromo = window.TabbyPromo;
|
|
54
84
|
new TabbyPromo({
|
|
55
85
|
selector: '#tabbyPromo',
|
|
@@ -61,11 +91,27 @@ export class SallaInstallment {
|
|
|
61
91
|
element.setAttribute('aria-label', 'Tabby Logo');
|
|
62
92
|
});
|
|
63
93
|
};
|
|
64
|
-
//this is workaround to remove the default border and add margin
|
|
94
|
+
// this is a workaround to remove the default border and add margin
|
|
65
95
|
this.removeTabbyBorder();
|
|
66
96
|
}
|
|
67
97
|
// Spotii
|
|
68
98
|
if (this.spotiiIsActive) {
|
|
99
|
+
if (isUpdating) {
|
|
100
|
+
var oldSpotiiWrapper = this.host.querySelector('.spotii-wrapper');
|
|
101
|
+
if (oldSpotiiWrapper) {
|
|
102
|
+
oldSpotiiWrapper.remove();
|
|
103
|
+
}
|
|
104
|
+
var spotiiPromoWrapper = document.createElement('div');
|
|
105
|
+
spotiiPromoWrapper.classList.add('spotii-wrapper');
|
|
106
|
+
var spotiiPromo = document.createElement('div');
|
|
107
|
+
spotiiPromo.classList.add('spotii-promo');
|
|
108
|
+
spotiiPromoWrapper.appendChild(spotiiPromo);
|
|
109
|
+
this.host.appendChild(spotiiPromoWrapper);
|
|
110
|
+
var oldSpotiiScript = document.querySelector('script[src="' + salla.url.cdn('js/price-widget-ar-salla.js') + '"]');
|
|
111
|
+
if (oldSpotiiScript) {
|
|
112
|
+
oldSpotiiScript.remove();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
69
115
|
let amount = salla.money((Number(this.price) / 3).toFixed(2));
|
|
70
116
|
let isRTL = salla.config.get('theme.is_rtl', true);
|
|
71
117
|
window.spotiiConfig = {
|
|
@@ -82,10 +128,10 @@ export class SallaInstallment {
|
|
|
82
128
|
// forcedShow: false,
|
|
83
129
|
// merchantID: null,
|
|
84
130
|
};
|
|
85
|
-
var
|
|
86
|
-
|
|
87
|
-
document.head.appendChild(
|
|
88
|
-
//
|
|
131
|
+
var spotiiScript = document.createElement('script');
|
|
132
|
+
spotiiScript.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));
|
|
133
|
+
document.head.appendChild(spotiiScript);
|
|
134
|
+
// spotiiScript.onload = () => {
|
|
89
135
|
// // setTimeout()
|
|
90
136
|
// }
|
|
91
137
|
}
|
|
@@ -186,5 +232,6 @@ export class SallaInstallment {
|
|
|
186
232
|
"spotiiIsActive": {}
|
|
187
233
|
};
|
|
188
234
|
}
|
|
235
|
+
static get elementRef() { return "host"; }
|
|
189
236
|
}
|
|
190
237
|
//# sourceMappingURL=salla-installment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"salla-installment.js","sourceRoot":"","sources":["../../../src/components/salla-installment/salla-installment.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,eAAe,CAAC;AAO9D,MAAM,OAAO,gBAAgB;EAI3B;IAHQ,uBAAkB,GAAY,KAAK,CAAC;IACpC,2BAAsB,GAAW,CAAC,CAAC;;oBAqBhB,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;oBAItC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;;;;IAtB/D,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;MACvB,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;MACpE,IAAI,WAAW,EAAE;QACf,IAAI,CAAC,cAAc,GAAG,WAAW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C,EAAE,IAAI,CAAC,sBAAsB,GAAG,GAAG,CAAC,CAAA;EACvC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {Component, Host, h, Prop, State} from '@stencil/core';\n\n@Component({\n tag: 'salla-installment',\n styleUrl: 'salla-installment.scss',\n})\n\nexport class SallaInstallment {\n private tabbyBorderRemoved: boolean = false;\n private tabbyRemoveBorderTries: number = 0;\n\n constructor() {\n salla.lang.onLoaded(() => {\n const installment = salla.config.get('store.settings.installments');\n if (installment) {\n this.tamaraIsActive = installment.includes('tamara_installment');\n this.tabbyIsActive = installment.includes('tabby_installment');\n this.spotiiIsActive = installment.includes('spotii_pay');\n }\n this.renderInstallments();\n });\n }\n\n /**\n * Current product price\n */\n @Prop() price: string;\n /**\n * Language code\n */\n @Prop() language: string = salla.config.get('user.language_code');\n /**\n * Currency code\n */\n @Prop() currency: string = salla.config.get('user.currency_code');\n\n @State() tamaraIsActive: boolean;\n @State() tabbyIsActive: boolean;\n @State() spotiiIsActive: boolean;\n\n render() {\n return (\n <Host>\n {this.tamaraIsActive ?\n <div class=\"tamara-product-widget\"\n data-price={this.price}\n data-currency={this.currency}\n data-lang={this.language}\n data-payment-type=\"installment\">\n </div>\n : ''}\n\n {this.tabbyIsActive ?\n <div id=\"tabbyPromoWrapper\">\n <div id=\"tabbyPromo\"></div>\n </div>\n : ''}\n\n {this.spotiiIsActive ?\n <div class=\"spotii-wrapper\">\n {/*No need for the price, the price already in the page, and also tammara & tabby doesn't have price */}\n <div class=\"spotii-promo\"></div>\n </div>\n : ''}\n </Host>\n );\n }\n\n renderInstallments() {\n // Tamara\n if (this.tamaraIsActive) {\n var script = document.createElement('script');\n script.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');\n document.head.appendChild(script);\n script.onload = () => {\n window.TamaraProductWidget.init({lang: this.language})\n setTimeout(() => {\n window.TamaraProductWidget.render()\n }, 300)\n }\n }\n\n // tabby\n if (this.tabbyIsActive) {\n var script = document.createElement('script');\n script.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');\n document.head.appendChild(script);\n script.onload = () => {\n const TabbyPromo = window.TabbyPromo;\n new TabbyPromo({\n selector: '#tabbyPromo',\n currency: this.currency,\n price: this.price,\n lang: this.language,\n });\n document.querySelectorAll('.tabby-promo-snippet__logo').forEach(function (element) {\n element.setAttribute('aria-label', 'Tabby Logo')\n });\n }\n //this is workaround to remove the default border and add margin\n this.removeTabbyBorder();\n }\n\n // Spotii\n if (this.spotiiIsActive) {\n let amount = salla.money((Number(this.price) / 3).toFixed(2));\n let isRTL = salla.config.get('theme.is_rtl', true);\n window.spotiiConfig = {\n targetXPath: ['.spotii-wrapper'],\n renderToPath: ['.spotii-promo'],\n numberOfPayment: 3,\n currency: this.currency,\n templateLine: \"${textOne} ${number} ${textTwo} \" + amount + \"${logo} ${info}\",\n //todo:: translate these\n textOne: isRTL ? \"جزء الدفع على\" : \"Split it into\",\n textTwo: isRTL ? \"أقساط متساوية بدون تكاليف اضافية بقيمة\" : \"payments of\",\n textThree: \"مع\",\n price: this.price,\n // forcedShow: false,\n // merchantID: null,\n }\n\n var script = document.createElement('script');\n\n script.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));\n document.head.appendChild(script);\n // script.onload = () => {\n // // setTimeout()\n // }\n }\n\n }\n\n /**\n * this is workaround to remove the default border and add margin\n * we will try to remove tabby border 5 times for 7.5 seconds\n */\n removeTabbyBorder() {\n if (this.tabbyBorderRemoved || this.tabbyRemoveBorderTries > 5) {\n return;\n }\n this.tabbyRemoveBorderTries++;\n setTimeout(() => {\n let promo: any = document.querySelector('#tabbyPromo>div>div');\n promo = promo ? promo.shadowRoot.querySelector('div[class^=\"styles__tabby-promo-snippet--\"]') : null;\n if (promo) {\n promo.style = 'border: none; margin: 15px 0!important;';\n this.tabbyBorderRemoved = true;\n } else {\n this.removeTabbyBorder();\n }\n }, this.tabbyRemoveBorderTries * 500)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"salla-installment.js","sourceRoot":"","sources":["../../../src/components/salla-installment/salla-installment.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAOzE,MAAM,OAAO,gBAAgB;EAI3B;IAHQ,uBAAkB,GAAY,KAAK,CAAC;IACpC,2BAAsB,GAAW,CAAC,CAAC;;oBA6BhB,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;oBAItC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;;;;IA9B/D,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;MACvB,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;MACpE,IAAI,WAAW,EAAE;QACf,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC;QACjE,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC/D,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;OAC1D;MACD,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,wBAAwB,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;MACpD,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE;QAC3C,OAAO;OACR;MACD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;MACxB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC,CAA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AAI,KAAK,EAAE;QACT,KAAK,CAAC,KAAK,GAAG,yCAAyC,CAAC;QACxD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;OAChC;WAAM;QACL,IAAI,CAAC,iBAAiB,EAAE,CAAC;OAC1B;IACH,CAAC,EAAE,IAAI,CAAC,sBAAsB,GAAG,GAAG,CAAC,CAAA;EACvC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element } from '@stencil/core';\n\n@Component({\n tag: 'salla-installment',\n styleUrl: 'salla-installment.scss',\n})\n\nexport class SallaInstallment {\n private tabbyBorderRemoved: boolean = false;\n private tabbyRemoveBorderTries: number = 0;\n @Element() host: HTMLElement;\n constructor() {\n salla.lang.onLoaded(() => {\n const installment = salla.config.get('store.settings.installments');\n if (installment) {\n this.tamaraIsActive = installment.includes('tamara_installment');\n this.tabbyIsActive = installment.includes('tabby_installment');\n this.spotiiIsActive = installment.includes('spotii_pay');\n }\n this.renderInstallments();\n });\n\n salla.event.on('product::price.updated', ({ data }) => {\n if (!data.price || data.price == this.price) {\n return;\n }\n this.price = data.price;\n this.renderInstallments(true);\n });\n }\n\n /**\n * Current product price\n */\n @Prop() price: string;\n /**\n * Language code\n */\n @Prop() language: string = salla.config.get('user.language_code');\n /**\n * Currency code\n */\n @Prop() currency: string = salla.config.get('user.currency_code');\n\n @State() tamaraIsActive: boolean;\n @State() tabbyIsActive: boolean;\n @State() spotiiIsActive: boolean;\n\n render() {\n return (\n <Host>\n {this.tamaraIsActive ?\n <div class=\"tamara-product-widget\"\n data-price={this.price}\n data-currency={this.currency}\n data-lang={this.language}\n data-payment-type=\"installment\">\n </div>\n : ''}\n\n {this.tabbyIsActive ?\n <div id=\"tabbyPromoWrapper\">\n <div id=\"tabbyPromo\"></div>\n </div>\n : ''}\n\n {this.spotiiIsActive ?\n <div class=\"spotii-wrapper\">\n {/*No need for the price, the price already in the page, and also tammara & tabby doesn't have price */}\n <div class=\"spotii-promo\"></div>\n </div>\n : ''}\n </Host>\n );\n }\n\n renderInstallments(isUpdating: boolean = false) {\n // Tamara\n if (this.tamaraIsActive) {\n if (isUpdating) {\n var oldTamaraScript = document.querySelector('script[src=\"https://cdn.tamara.co/widget/product-widget.min.js\"]');\n if (oldTamaraScript) {\n oldTamaraScript.remove();\n }\n }\n\n var tamaraScript = document.createElement('script');\n tamaraScript.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');\n document.head.appendChild(tamaraScript);\n tamaraScript.onload = () => {\n window.TamaraProductWidget.init({ lang: this.language });\n setTimeout(() => {\n window.TamaraProductWidget.render();\n }, 300);\n };\n }\n\n // tabby\n if (this.tabbyIsActive) {\n if (isUpdating) {\n\n // remove #tabbyPromoWrapper and re append it\n var oldTabbyWrapper = this.host.querySelector('#tabbyPromoWrapper');\n if (oldTabbyWrapper) {\n oldTabbyWrapper.remove();\n }\n\n var tabbyPromoWrapper = document.createElement('div');\n tabbyPromoWrapper.setAttribute('id', 'tabbyPromoWrapper');\n var tabbyPromo = document.createElement('div');\n tabbyPromo.setAttribute('id', 'tabbyPromo');\n tabbyPromoWrapper.appendChild(tabbyPromo);\n this.host.appendChild(tabbyPromoWrapper);\n\n var oldTabbyScript = document.querySelector('script[src=\"https://checkout.tabby.ai/tabby-promo.js\"]');\n if (oldTabbyScript) {\n oldTabbyScript.remove();\n }\n }\n\n var tabbyScript = document.createElement('script');\n tabbyScript.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');\n document.head.appendChild(tabbyScript);\n tabbyScript.onload = () => {\n const TabbyPromo = window.TabbyPromo;\n new TabbyPromo({\n selector: '#tabbyPromo',\n currency: this.currency,\n price: this.price,\n lang: this.language,\n });\n document.querySelectorAll('.tabby-promo-snippet__logo').forEach(function (element) {\n element.setAttribute('aria-label', 'Tabby Logo');\n });\n }\n // this is a workaround to remove the default border and add margin\n this.removeTabbyBorder();\n }\n\n // Spotii\n if (this.spotiiIsActive) {\n if (isUpdating) {\n\n var oldSpotiiWrapper = this.host.querySelector('.spotii-wrapper');\n if (oldSpotiiWrapper) {\n oldSpotiiWrapper.remove();\n }\n\n var spotiiPromoWrapper = document.createElement('div');\n spotiiPromoWrapper.classList.add('spotii-wrapper');\n var spotiiPromo = document.createElement('div');\n spotiiPromo.classList.add('spotii-promo');\n spotiiPromoWrapper.appendChild(spotiiPromo);\n this.host.appendChild(spotiiPromoWrapper);\n var oldSpotiiScript = document.querySelector('script[src=\"' + salla.url.cdn('js/price-widget-ar-salla.js') + '\"]');\n if (oldSpotiiScript) {\n oldSpotiiScript.remove();\n }\n }\n\n let amount = salla.money((Number(this.price) / 3).toFixed(2));\n let isRTL = salla.config.get('theme.is_rtl', true);\n window.spotiiConfig = {\n targetXPath: ['.spotii-wrapper'],\n renderToPath: ['.spotii-promo'],\n numberOfPayment: 3,\n currency: this.currency,\n templateLine: \"${textOne} ${number} ${textTwo} \" + amount + \"${logo} ${info}\",\n //todo:: translate these\n textOne: isRTL ? \"جزء الدفع على\" : \"Split it into\",\n textTwo: isRTL ? \"أقساط متساوية بدون تكاليف اضافية بقيمة\" : \"payments of\",\n textThree: \"مع\",\n price: this.price,\n // forcedShow: false,\n // merchantID: null,\n };\n\n var spotiiScript = document.createElement('script');\n spotiiScript.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));\n document.head.appendChild(spotiiScript);\n // spotiiScript.onload = () => {\n // // setTimeout()\n // }\n }\n }\n\n\n /**\n * this is workaround to remove the default border and add margin\n * we will try to remove tabby border 5 times for 7.5 seconds\n */\n removeTabbyBorder() {\n if (this.tabbyBorderRemoved || this.tabbyRemoveBorderTries > 5) {\n return;\n }\n this.tabbyRemoveBorderTries++;\n setTimeout(() => {\n let promo: any = document.querySelector('#tabbyPromo>div>div');\n promo = promo ? promo.shadowRoot.querySelector('div[class^=\"styles__tabby-promo-snippet--\"]') : null;\n if (promo) {\n promo.style = 'border: none; margin: 15px 0!important;';\n this.tabbyBorderRemoved = true;\n } else {\n this.removeTabbyBorder();\n }\n }, this.tabbyRemoveBorderTries * 500)\n }\n}\n"]}
|
|
@@ -139,7 +139,7 @@ export class SallaProductCard {
|
|
|
139
139
|
}
|
|
140
140
|
componentDidLoad() {
|
|
141
141
|
var _a, _b;
|
|
142
|
-
(_a = document.lazyLoadInstance) === null || _a === void 0 ? void 0 : _a.update(
|
|
142
|
+
(_a = document.lazyLoadInstance) === null || _a === void 0 ? void 0 : _a.update(this.host.querySelectorAll('.lazy'));
|
|
143
143
|
if (((_b = this.productData) === null || _b === void 0 ? void 0 : _b.quantity) && this.isSpecial) {
|
|
144
144
|
this.initCircleBar();
|
|
145
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"salla-product-card.js","sourceRoot":"","sources":["../../../src/components/salla-product-card/salla-product-card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,MAAM,4BAA4B,CAAC;AAC/C,OAAO,IAAI,MAAM,4BAA4B,CAAC;AAE9C;;GAEG;AAOH,MAAM,OAAO,gBAAgB;EAC3B;;;;;;;;;;;;;;;;;IACE,gBAAgB;IAChB,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;MACjB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;MAC1E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;MAC9E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,kB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} from '@stencil/core';\nimport Heart from '../../assets/svg/heart.svg';\nimport Star from '../../assets/svg/star2.svg';\n\n/**\n * @slot add-to-cart-label - Add to cart label.\n */\n@Component({\n tag: 'salla-product-card',\n styleUrl: 'salla-product-card.scss',\n assetsDirs: ['assets']\n})\n\nexport class SallaProductCard {\n constructor() {\n // Store configs\n salla.onReady(() => {\n this.fitImageHeight = salla.config.get('store.settings.product.fit_type');\n salla.wishlist.event.onAdded((_res, id) => this.toggleFavoriteIcon(true, id));\n salla.wishlist.event.onRemoved((_res, id) => this.toggleFavoriteIcon(false, id));\n this.placeholder = salla.url.asset(salla.config.get('theme.settings.placeholder'));\n });\n\n // Language\n salla.lang.onLoaded(() => {\n this.remained = salla.lang.get('pages.products.remained');\n this.donationAmount = salla.lang.get('pages.products.donation_amount');\n this.startingPrice = salla.lang.get('pages.products.starting_price');\n this.addToCart = salla.lang.get('pages.cart.add_to_cart');\n this.outOfStock = salla.lang.get('pages.products.out_of_stock');\n })\n\n // Parse product data\n if (this.product) {\n try {\n this.productData = typeof this.product == 'object' ? this.product : JSON.parse(this.product);\n return;\n } catch (e) {\n // TODO: Don't you think it's better not to render the component in this case?\n salla.log('Bad json passed via product prop');\n }\n }\n }\n\n @Element() host: HTMLElement;\n // State\n @State() productData: any;\n @State() fitImageHeight: boolean;\n @State() remained: string;\n @State() outOfStock: string;\n @State() donationAmount: string;\n @State() startingPrice: string;\n @State() addToCart: string;\n @State() placeholder: string;\n\n\n // Refs\n private pie: any;\n private wishlistBtn: HTMLSallaButtonElement;\n private addBtn: HTMLSallaAddProductButtonElement;\n\n // Props\n\n\n /**\n * Product information.\n */\n @Prop() product: string;\n\n /**\n * Horizontal card.\n */\n @Prop() horizontal: boolean;\n\n /**\n * Support shadow on hover.\n */\n @Prop() shadowOnHover: boolean;\n\n /**\n * Hide add to cart button.\n */\n @Prop() hideAddBtn: boolean;\n\n /**\n * Full image card.\n */\n @Prop() fullImage: boolean;\n\n /**\n * Minimal card.\n */\n @Prop() minimal: boolean;\n\n /**\n * Special card.\n */\n @Prop() isSpecial: boolean;\n\n /**\n * Show quantity.\n */\n @Prop() showQuantity: boolean;\n\n\n // Private Methods\n private initCircleBar() {\n let qty = this.productData.quantity,\n total = this.productData.quantity > 100 ? this.productData.quantity * 2 : 100,\n roundPercent = (qty / total) * 100,\n bar = this.pie.querySelector('.s-product-card-content-pie-svg-bar'),\n strokeDashOffsetValue = 100 - roundPercent;\n bar.style.strokeDashoffset = strokeDashOffsetValue;\n }\n\n private toggleFavoriteIcon(isAdded = true, id = null) {\n if (id && id !== this.productData.id) {\n return;\n }\n this.wishlistBtn?.classList.toggle('s-product-card-wishlist-added', isAdded);\n }\n\n private formatDate(date) {\n let d = new Date(date);\n return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;\n }\n\n private getProductBadge() {\n if (this.productData.promotion_title) {\n return <div class=\"s-product-card-promotion-title\">{this.productData.promotion_title}</div>\n }\n if (this.showQuantity && this.productData?.quantity) {\n return <div\n class=\"s-product-card-quantity\">{this.remained} {salla.helpers.number(this.productData?.quantity)}</div>\n }\n if (this.showQuantity && this.productData?.is_out_of_stock) {\n return <div class=\"s-product-card-out-badge\">{this.outOfStock}</div>\n }\n return '';\n\n }\n\n getPriceFormat(price) {\n if (!price) {\n return;\n }\n\n return salla.money(price);\n }\n\n private getProductPrice() {\n if (this.productData.is_on_sale) {\n return <div class=\"s-product-card-sale-price\">\n <h4>{this.getPriceFormat(this.productData.sale_price)}</h4>\n <span>{this.getPriceFormat(this.productData?.regular_price)}</span>\n </div>;\n }\n if (this.productData.starting_price) {\n return <div class=\"s-product-card-starting-price\"><p>{this.startingPrice}</p>\n <h4> {this.getPriceFormat(this.productData?.starting_price)} </h4></div>\n }\n return <h4 class=\"s-product-card-price\">{this.getPriceFormat(this.productData?.price)}</h4>\n }\n\n render() {\n const classes = {\n 's-product-card-entry': true,\n 's-product-card-vertical': !this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-horizontal': this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-fit-height': this.fitImageHeight && !this.isSpecial && !this.fullImage && !this.minimal,\n 's-product-card-special': this.isSpecial,\n 's-product-card-full-image': this.fullImage,\n 's-product-card-minimal': this.minimal,\n 's-product-card-donation': this.productData?.donation,\n 's-product-card-shadow': this.shadowOnHover,\n 's-product-card-out-of-stock': this.productData?.is_out_of_stock,\n };\n return (\n <Host id={`product-${this.productData?.id}`} class={classes}>\n <div class={!this.fullImage ? 's-product-card-image' : 's-product-card-image-full'}>\n <a href={this.productData?.url}>\n <img class={`s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)\n ? 'contain'\n : this.fitImageHeight\n ? this.fitImageHeight\n : 'cover'} lazy`}\n src={this.placeholder}\n alt={this.productData?.image?.alt}\n data-src={this.productData?.image?.url || this.productData?.thumbnail}\n />\n {!this.fullImage && !this.minimal ? this.getProductBadge() : ''}\n </a>\n {this.fullImage && <a href={this.productData?.url} class=\"s-product-card-overlay\" />}\n {!this.horizontal && !this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n aria-label=\"Add or remove to wishlist\"\n ref={el => this.wishlistBtn = el}\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}>\n <span innerHTML={Heart} />\n </salla-button> : ''\n }\n </div>\n <div class=\"s-product-card-content\">\n {this.isSpecial && this.productData?.quantity ?\n <div class=\"s-product-card-content-pie\" ref={pie => this.pie = pie}>\n <span>\n <b>{salla.helpers.number(this.productData?.quantity)}</b>\n {this.remained}\n </span>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-2 -1 36 34\" class=\"s-product-card-content-pie-svg\">\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-base\" />\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-bar\" />\n </svg>\n </div>\n : ''}\n\n <div class={{ 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n <h3 class=\"s-product-card-content-title\">\n <a href={this.productData?.url}>{this.productData?.name}</a>\n </h3>\n\n {this.productData?.subtitle && !this.minimal ?\n <p class=\"s-product-card-content-subtitle\">{this.productData?.subtitle}</p>\n : ''}\n </div>\n {this.productData?.donation && !this.minimal && !this.fullImage ?\n [<salla-progress-bar donation={this.productData?.donation} />,\n <div class=\"s-product-card-donation-input\">\n {this.productData?.donation?.can_donate ?\n [<label htmlFor=\"donation-amount\">{this.donationAmount} <span>*</span></label>,\n <input\n type=\"text\"\n onInput={e => {\n salla.helpers.inputDigitsOnly(e.target);\n this.addBtn.donatingAmount = (e.target as any).value;\n }}\n id=\"donation-amount\"\n name=\"donating_amount\"\n class=\"s-form-control\"\n placeholder={this.donationAmount} />]\n : ''}\n </div>]\n : ''}\n <div class={{ 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n {this.getProductPrice()}\n {this.productData?.rating?.stars && !this.minimal ?\n <div class=\"s-product-card-rating\">\n <span innerHTML={Star}/>\n <span>{this.productData.rating.stars}</span>\n </div>\n : ''}\n </div>\n\n {this.isSpecial && this.productData.discount_ends\n ? <salla-count-down date={this.formatDate(this.productData.discount_ends)} end-of-day={true} boxed={true}\n labeled={true} />\n : ''}\n\n\n {!this.hideAddBtn ?\n <div class=\"s-product-card-content-footer\">\n {/* @ts-ignore */}\n <salla-add-product-button fill=\"outline\" width=\"wide\"\n ref={el => this.addBtn = el}\n product-id={this.productData.id}\n product-status={this.productData.status}\n product-type={this.productData.type}>\n <slot name=\"add-to-cart-label\">{this.productData.add_to_cart_label}</slot>\n </salla-add-product-button>\n\n {this.horizontal || this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n ref={el => this.wishlistBtn = el}\n aria-label=\"Add or remove to wishlist\"\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}\n data-id=\"{{ product.id }}\">\n <span class=\"text-xl\" innerHTML={Heart} />\n </salla-button>\n : ''}\n </div>\n : ''}\n </div>\n </Host>\n );\n }\n\n componentDidLoad() {\n document.lazyLoadInstance?.update(document.querySelectorAll('.s-product-card-image .lazy'));\n if (this.productData?.quantity && this.isSpecial) {\n this.initCircleBar();\n }\n\n if (!salla.config.isGuest() && salla.storage.get('salla::wishlist', []).includes(this.productData.id)) {\n this.toggleFavoriteIcon();\n }\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"salla-product-card.js","sourceRoot":"","sources":["../../../src/components/salla-product-card/salla-product-card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,MAAM,4BAA4B,CAAC;AAC/C,OAAO,IAAI,MAAM,4BAA4B,CAAC;AAE9C;;GAEG;AAOH,MAAM,OAAO,gBAAgB;EAC3B;;;;;;;;;;;;;;;;;IACE,gBAAgB;IAChB,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;MACjB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;MAC1E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;MAC9E,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;MACjF,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,CAAC;IACrF,CAA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AG,EAAE,gBACrB,2BAA2B,EACtC,KAAK,EAAC,sCAAsC,EAC5C,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,aACjD,kBAAkB;gBAC1B,YAAM,KAAK,EAAC,SAAS,EAAC,SAAS,EAAE,KAAK,GAAI,CAC7B;cACf,CAAC,CAAC,EAAE,CACF;UACN,CAAC,CAAC,EAAE,CACF,CACD,CACR,CAAC;EACJ,CAAC;EAED,gBAAgB;;IACd,MAAA,QAAQ,CAAC,gBAAgB,0CAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACvE,IAAI,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,QAAQ,KAAI,IAAI,CAAC,SAAS,EAAE;MAChD,IAAI,CAAC,aAAa,EAAE,CAAC;KACtB;IAED,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE;MACrG,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAC3B;EACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAEF","sourcesContent":["import { Component, Host, h, Prop, State, Element } from '@stencil/core';\nimport Heart from '../../assets/svg/heart.svg';\nimport Star from '../../assets/svg/star2.svg';\n\n/**\n * @slot add-to-cart-label - Add to cart label.\n */\n@Component({\n tag: 'salla-product-card',\n styleUrl: 'salla-product-card.scss',\n assetsDirs: ['assets']\n})\n\nexport class SallaProductCard {\n constructor() {\n // Store configs\n salla.onReady(() => {\n this.fitImageHeight = salla.config.get('store.settings.product.fit_type');\n salla.wishlist.event.onAdded((_res, id) => this.toggleFavoriteIcon(true, id));\n salla.wishlist.event.onRemoved((_res, id) => this.toggleFavoriteIcon(false, id));\n this.placeholder = salla.url.asset(salla.config.get('theme.settings.placeholder'));\n });\n\n // Language\n salla.lang.onLoaded(() => {\n this.remained = salla.lang.get('pages.products.remained');\n this.donationAmount = salla.lang.get('pages.products.donation_amount');\n this.startingPrice = salla.lang.get('pages.products.starting_price');\n this.addToCart = salla.lang.get('pages.cart.add_to_cart');\n this.outOfStock = salla.lang.get('pages.products.out_of_stock');\n })\n\n // Parse product data\n if (this.product) {\n try {\n this.productData = typeof this.product == 'object' ? this.product : JSON.parse(this.product);\n return;\n } catch (e) {\n // TODO: Don't you think it's better not to render the component in this case?\n salla.log('Bad json passed via product prop');\n }\n }\n }\n\n @Element() host: HTMLElement;\n // State\n @State() productData: any;\n @State() fitImageHeight: boolean;\n @State() remained: string;\n @State() outOfStock: string;\n @State() donationAmount: string;\n @State() startingPrice: string;\n @State() addToCart: string;\n @State() placeholder: string;\n\n\n // Refs\n private pie: any;\n private wishlistBtn: HTMLSallaButtonElement;\n private addBtn: HTMLSallaAddProductButtonElement;\n\n // Props\n\n\n /**\n * Product information.\n */\n @Prop() product: string;\n\n /**\n * Horizontal card.\n */\n @Prop() horizontal: boolean;\n\n /**\n * Support shadow on hover.\n */\n @Prop() shadowOnHover: boolean;\n\n /**\n * Hide add to cart button.\n */\n @Prop() hideAddBtn: boolean;\n\n /**\n * Full image card.\n */\n @Prop() fullImage: boolean;\n\n /**\n * Minimal card.\n */\n @Prop() minimal: boolean;\n\n /**\n * Special card.\n */\n @Prop() isSpecial: boolean;\n\n /**\n * Show quantity.\n */\n @Prop() showQuantity: boolean;\n\n\n // Private Methods\n private initCircleBar() {\n let qty = this.productData.quantity,\n total = this.productData.quantity > 100 ? this.productData.quantity * 2 : 100,\n roundPercent = (qty / total) * 100,\n bar = this.pie.querySelector('.s-product-card-content-pie-svg-bar'),\n strokeDashOffsetValue = 100 - roundPercent;\n bar.style.strokeDashoffset = strokeDashOffsetValue;\n }\n\n private toggleFavoriteIcon(isAdded = true, id = null) {\n if (id && id !== this.productData.id) {\n return;\n }\n this.wishlistBtn?.classList.toggle('s-product-card-wishlist-added', isAdded);\n }\n\n private formatDate(date) {\n let d = new Date(date);\n return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;\n }\n\n private getProductBadge() {\n if (this.productData.promotion_title) {\n return <div class=\"s-product-card-promotion-title\">{this.productData.promotion_title}</div>\n }\n if (this.showQuantity && this.productData?.quantity) {\n return <div\n class=\"s-product-card-quantity\">{this.remained} {salla.helpers.number(this.productData?.quantity)}</div>\n }\n if (this.showQuantity && this.productData?.is_out_of_stock) {\n return <div class=\"s-product-card-out-badge\">{this.outOfStock}</div>\n }\n return '';\n\n }\n\n getPriceFormat(price) {\n if (!price) {\n return;\n }\n\n return salla.money(price);\n }\n\n private getProductPrice() {\n if (this.productData.is_on_sale) {\n return <div class=\"s-product-card-sale-price\">\n <h4>{this.getPriceFormat(this.productData.sale_price)}</h4>\n <span>{this.getPriceFormat(this.productData?.regular_price)}</span>\n </div>;\n }\n if (this.productData.starting_price) {\n return <div class=\"s-product-card-starting-price\"><p>{this.startingPrice}</p>\n <h4> {this.getPriceFormat(this.productData?.starting_price)} </h4></div>\n }\n return <h4 class=\"s-product-card-price\">{this.getPriceFormat(this.productData?.price)}</h4>\n }\n\n render() {\n const classes = {\n 's-product-card-entry': true,\n 's-product-card-vertical': !this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-horizontal': this.horizontal && !this.fullImage && !this.minimal,\n 's-product-card-fit-height': this.fitImageHeight && !this.isSpecial && !this.fullImage && !this.minimal,\n 's-product-card-special': this.isSpecial,\n 's-product-card-full-image': this.fullImage,\n 's-product-card-minimal': this.minimal,\n 's-product-card-donation': this.productData?.donation,\n 's-product-card-shadow': this.shadowOnHover,\n 's-product-card-out-of-stock': this.productData?.is_out_of_stock,\n };\n return (\n <Host id={`product-${this.productData?.id}`} class={classes}>\n <div class={!this.fullImage ? 's-product-card-image' : 's-product-card-image-full'}>\n <a href={this.productData?.url}>\n <img class={`s-product-card-image-${salla.url.is_placeholder(this.productData?.image?.url)\n ? 'contain'\n : this.fitImageHeight\n ? this.fitImageHeight\n : 'cover'} lazy`}\n src={this.placeholder}\n alt={this.productData?.image?.alt}\n data-src={this.productData?.image?.url || this.productData?.thumbnail}\n />\n {!this.fullImage && !this.minimal ? this.getProductBadge() : ''}\n </a>\n {this.fullImage && <a href={this.productData?.url} class=\"s-product-card-overlay\" />}\n {!this.horizontal && !this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n aria-label=\"Add or remove to wishlist\"\n ref={el => this.wishlistBtn = el}\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}>\n <span innerHTML={Heart} />\n </salla-button> : ''\n }\n </div>\n <div class=\"s-product-card-content\">\n {this.isSpecial && this.productData?.quantity ?\n <div class=\"s-product-card-content-pie\" ref={pie => this.pie = pie}>\n <span>\n <b>{salla.helpers.number(this.productData?.quantity)}</b>\n {this.remained}\n </span>\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"-2 -1 36 34\" class=\"s-product-card-content-pie-svg\">\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-base\" />\n <circle cx=\"16\" cy=\"16\" r=\"15.9155\" class=\"s-product-card-content-pie-svg-bar\" />\n </svg>\n </div>\n : ''}\n\n <div class={{ 's-product-card-content-main': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n <h3 class=\"s-product-card-content-title\">\n <a href={this.productData?.url}>{this.productData?.name}</a>\n </h3>\n\n {this.productData?.subtitle && !this.minimal ?\n <p class=\"s-product-card-content-subtitle\">{this.productData?.subtitle}</p>\n : ''}\n </div>\n {this.productData?.donation && !this.minimal && !this.fullImage ?\n [<salla-progress-bar donation={this.productData?.donation} />,\n <div class=\"s-product-card-donation-input\">\n {this.productData?.donation?.can_donate ?\n [<label htmlFor=\"donation-amount\">{this.donationAmount} <span>*</span></label>,\n <input\n type=\"text\"\n onInput={e => {\n salla.helpers.inputDigitsOnly(e.target);\n this.addBtn.donatingAmount = (e.target as any).value;\n }}\n id=\"donation-amount\"\n name=\"donating_amount\"\n class=\"s-form-control\"\n placeholder={this.donationAmount} />]\n : ''}\n </div>]\n : ''}\n <div class={{ 's-product-card-content-sub': true, 's-product-card-content-extra-padding': this.isSpecial }}>\n {this.getProductPrice()}\n {this.productData?.rating?.stars && !this.minimal ?\n <div class=\"s-product-card-rating\">\n <span innerHTML={Star}/>\n <span>{this.productData.rating.stars}</span>\n </div>\n : ''}\n </div>\n\n {this.isSpecial && this.productData.discount_ends\n ? <salla-count-down date={this.formatDate(this.productData.discount_ends)} end-of-day={true} boxed={true}\n labeled={true} />\n : ''}\n\n\n {!this.hideAddBtn ?\n <div class=\"s-product-card-content-footer\">\n {/* @ts-ignore */}\n <salla-add-product-button fill=\"outline\" width=\"wide\"\n ref={el => this.addBtn = el}\n product-id={this.productData.id}\n product-status={this.productData.status}\n product-type={this.productData.type}>\n <slot name=\"add-to-cart-label\">{this.productData.add_to_cart_label}</slot>\n </salla-add-product-button>\n\n {this.horizontal || this.fullImage ?\n <salla-button\n shape=\"icon\"\n fill=\"none\"\n color=\"light\"\n ref={el => this.wishlistBtn = el}\n aria-label=\"Add or remove to wishlist\"\n class=\"s-product-card-wishlist-btn animated\"\n onClick={() => salla.wishlist.toggle(this.productData.id)}\n data-id=\"{{ product.id }}\">\n <span class=\"text-xl\" innerHTML={Heart} />\n </salla-button>\n : ''}\n </div>\n : ''}\n </div>\n </Host>\n );\n }\n\n componentDidLoad() {\n document.lazyLoadInstance?.update(this.host.querySelectorAll('.lazy'));\n if (this.productData?.quantity && this.isSpecial) {\n this.initCircleBar();\n }\n\n if (!salla.config.isGuest() && salla.storage.get('salla::wishlist', []).includes(this.productData.id)) {\n this.toggleFavoriteIcon();\n }\n }\n\n}\n"]}
|
|
@@ -26,6 +26,13 @@ const SallaInstallment$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
|
26
26
|
}
|
|
27
27
|
this.renderInstallments();
|
|
28
28
|
});
|
|
29
|
+
salla.event.on('product::price.updated', ({ data }) => {
|
|
30
|
+
if (!data.price || data.price == this.price) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.price = data.price;
|
|
34
|
+
this.renderInstallments(true);
|
|
35
|
+
});
|
|
29
36
|
}
|
|
30
37
|
render() {
|
|
31
38
|
return (h(Host, null, this.tamaraIsActive ?
|
|
@@ -36,13 +43,19 @@ const SallaInstallment$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
|
36
43
|
h("div", { class: "spotii-wrapper" }, h("div", { class: "spotii-promo" }))
|
|
37
44
|
: ''));
|
|
38
45
|
}
|
|
39
|
-
renderInstallments() {
|
|
46
|
+
renderInstallments(isUpdating = false) {
|
|
40
47
|
// Tamara
|
|
41
48
|
if (this.tamaraIsActive) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
if (isUpdating) {
|
|
50
|
+
var oldTamaraScript = document.querySelector('script[src="https://cdn.tamara.co/widget/product-widget.min.js"]');
|
|
51
|
+
if (oldTamaraScript) {
|
|
52
|
+
oldTamaraScript.remove();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
var tamaraScript = document.createElement('script');
|
|
56
|
+
tamaraScript.setAttribute('src', 'https://cdn.tamara.co/widget/product-widget.min.js');
|
|
57
|
+
document.head.appendChild(tamaraScript);
|
|
58
|
+
tamaraScript.onload = () => {
|
|
46
59
|
window.TamaraProductWidget.init({ lang: this.language });
|
|
47
60
|
setTimeout(() => {
|
|
48
61
|
window.TamaraProductWidget.render();
|
|
@@ -51,10 +64,27 @@ const SallaInstallment$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
|
51
64
|
}
|
|
52
65
|
// tabby
|
|
53
66
|
if (this.tabbyIsActive) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
if (isUpdating) {
|
|
68
|
+
// remove #tabbyPromoWrapper and re append it
|
|
69
|
+
var oldTabbyWrapper = this.host.querySelector('#tabbyPromoWrapper');
|
|
70
|
+
if (oldTabbyWrapper) {
|
|
71
|
+
oldTabbyWrapper.remove();
|
|
72
|
+
}
|
|
73
|
+
var tabbyPromoWrapper = document.createElement('div');
|
|
74
|
+
tabbyPromoWrapper.setAttribute('id', 'tabbyPromoWrapper');
|
|
75
|
+
var tabbyPromo = document.createElement('div');
|
|
76
|
+
tabbyPromo.setAttribute('id', 'tabbyPromo');
|
|
77
|
+
tabbyPromoWrapper.appendChild(tabbyPromo);
|
|
78
|
+
this.host.appendChild(tabbyPromoWrapper);
|
|
79
|
+
var oldTabbyScript = document.querySelector('script[src="https://checkout.tabby.ai/tabby-promo.js"]');
|
|
80
|
+
if (oldTabbyScript) {
|
|
81
|
+
oldTabbyScript.remove();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
var tabbyScript = document.createElement('script');
|
|
85
|
+
tabbyScript.setAttribute('src', 'https://checkout.tabby.ai/tabby-promo.js');
|
|
86
|
+
document.head.appendChild(tabbyScript);
|
|
87
|
+
tabbyScript.onload = () => {
|
|
58
88
|
const TabbyPromo = window.TabbyPromo;
|
|
59
89
|
new TabbyPromo({
|
|
60
90
|
selector: '#tabbyPromo',
|
|
@@ -66,11 +96,27 @@ const SallaInstallment$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
|
66
96
|
element.setAttribute('aria-label', 'Tabby Logo');
|
|
67
97
|
});
|
|
68
98
|
};
|
|
69
|
-
//this is workaround to remove the default border and add margin
|
|
99
|
+
// this is a workaround to remove the default border and add margin
|
|
70
100
|
this.removeTabbyBorder();
|
|
71
101
|
}
|
|
72
102
|
// Spotii
|
|
73
103
|
if (this.spotiiIsActive) {
|
|
104
|
+
if (isUpdating) {
|
|
105
|
+
var oldSpotiiWrapper = this.host.querySelector('.spotii-wrapper');
|
|
106
|
+
if (oldSpotiiWrapper) {
|
|
107
|
+
oldSpotiiWrapper.remove();
|
|
108
|
+
}
|
|
109
|
+
var spotiiPromoWrapper = document.createElement('div');
|
|
110
|
+
spotiiPromoWrapper.classList.add('spotii-wrapper');
|
|
111
|
+
var spotiiPromo = document.createElement('div');
|
|
112
|
+
spotiiPromo.classList.add('spotii-promo');
|
|
113
|
+
spotiiPromoWrapper.appendChild(spotiiPromo);
|
|
114
|
+
this.host.appendChild(spotiiPromoWrapper);
|
|
115
|
+
var oldSpotiiScript = document.querySelector('script[src="' + salla.url.cdn('js/price-widget-ar-salla.js') + '"]');
|
|
116
|
+
if (oldSpotiiScript) {
|
|
117
|
+
oldSpotiiScript.remove();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
74
120
|
let amount = salla.money((Number(this.price) / 3).toFixed(2));
|
|
75
121
|
let isRTL = salla.config.get('theme.is_rtl', true);
|
|
76
122
|
window.spotiiConfig = {
|
|
@@ -87,10 +133,10 @@ const SallaInstallment$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
|
87
133
|
// forcedShow: false,
|
|
88
134
|
// merchantID: null,
|
|
89
135
|
};
|
|
90
|
-
var
|
|
91
|
-
|
|
92
|
-
document.head.appendChild(
|
|
93
|
-
//
|
|
136
|
+
var spotiiScript = document.createElement('script');
|
|
137
|
+
spotiiScript.setAttribute('src', salla.url.cdn('js/price-widget-ar-salla.js'));
|
|
138
|
+
document.head.appendChild(spotiiScript);
|
|
139
|
+
// spotiiScript.onload = () => {
|
|
94
140
|
// // setTimeout()
|
|
95
141
|
// }
|
|
96
142
|
}
|
|
@@ -116,6 +162,7 @@ const SallaInstallment$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
|
|
|
116
162
|
}
|
|
117
163
|
}, this.tabbyRemoveBorderTries * 500);
|
|
118
164
|
}
|
|
165
|
+
get host() { return this; }
|
|
119
166
|
static get style() { return sallaInstallmentCss; }
|
|
120
167
|
}, [0, "salla-installment", {
|
|
121
168
|
"price": [1],
|