@salla.sa/twilight-components 1.0.35 → 1.0.37
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/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-button_7.cjs.entry.js +34 -29
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +14 -4
- package/dist/cjs/salla-offer.cjs.entry.js +65 -16
- package/dist/cjs/salla-product-availability.cjs.entry.js +14 -10
- package/dist/cjs/salla-rating.cjs.entry.js +7 -8
- package/dist/cjs/{salla-search-6738ec5e.js → salla-search-f95dcd0c.js} +8 -6
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/components/salla-infinite-scroll/salla-infinite-scroll.js +14 -4
- package/dist/collection/components/salla-localization/salla-localization.js +22 -25
- package/dist/collection/components/salla-login/salla-login.css +0 -4
- package/dist/collection/components/salla-login/salla-login.js +6 -4
- package/dist/collection/components/salla-modal/salla-modal.js +7 -5
- package/dist/collection/components/salla-offer/salla-offer.css +23 -0
- package/dist/collection/components/salla-offer/salla-offer.js +88 -25
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +16 -11
- package/dist/collection/components/salla-rating/salla-rating.js +7 -8
- package/dist/collection/components/salla-search/salla-search.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-button_7.entry.js +34 -29
- package/dist/esm/salla-infinite-scroll.entry.js +14 -4
- package/dist/esm/salla-offer.entry.js +65 -16
- package/dist/esm/salla-product-availability.entry.js +14 -10
- package/dist/esm/salla-rating.entry.js +7 -8
- package/dist/esm/{salla-search-90231876.js → salla-search-8bb6a0da.js} +8 -6
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/index.esm.js +1 -1
- package/dist/twilight-components/p-187bdf52.js +1 -0
- package/dist/twilight-components/p-19a124e9.entry.js +1 -0
- package/dist/twilight-components/p-6ccad297.entry.js +1 -0
- package/dist/twilight-components/p-855690ed.entry.js +1 -0
- package/dist/twilight-components/p-a90a5872.entry.js +1 -0
- package/dist/twilight-components/p-ec676556.entry.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/components/salla-localization/salla-localization.d.ts +2 -1
- package/dist/types/components/salla-offer/salla-offer.d.ts +4 -1
- package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +1 -0
- package/dist/types/components.d.ts +1 -1
- package/example/index.html +1 -1
- package/package.json +2 -2
- package/dist/twilight-components/p-15751894.entry.js +0 -1
- package/dist/twilight-components/p-2abf9fc5.js +0 -1
- package/dist/twilight-components/p-5a498763.entry.js +0 -1
- package/dist/twilight-components/p-ca832aac.entry.js +0 -1
- package/dist/twilight-components/p-f36fa4c6.entry.js +0 -1
- package/dist/twilight-components/p-fa3b938e.entry.js +0 -1
package/dist/cjs/index.cjs.js
CHANGED
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["salla-button_7.cjs",[[4,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"isMobileAllowed":[4,"is-mobile-allowed"],"isEmailRequired":[4,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[
|
|
17
|
+
return index.bootstrapLazy([["salla-button_7.cjs",[[4,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"isMobileAllowed":[4,"is-mobile-allowed"],"isEmailRequired":[4,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[0,"salla-localization",{"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}],[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[4],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-714023c8.js');
|
|
6
6
|
const Helper = require('./Helper-98cc9f18.js');
|
|
7
|
-
const sallaSearch = require('./salla-search-
|
|
7
|
+
const sallaSearch = require('./salla-search-f95dcd0c.js');
|
|
8
8
|
|
|
9
9
|
const sallaButtonCss = ":host{display:block}";
|
|
10
10
|
|
|
@@ -118,10 +118,11 @@ const SallaLocalization = class {
|
|
|
118
118
|
constructor(hostRef) {
|
|
119
119
|
index.registerInstance(this, hostRef);
|
|
120
120
|
var _a, _b;
|
|
121
|
-
this.language = salla.config.get('
|
|
122
|
-
this.currency = salla.config.get('
|
|
121
|
+
this.language = salla.config.get('user.language_code');
|
|
122
|
+
this.currency = salla.config.get('user.currency_code');
|
|
123
123
|
this.languages = [];
|
|
124
124
|
this.currencies = [];
|
|
125
|
+
this.isLoading = true;
|
|
125
126
|
Helper.Helper.setHost(this.host);
|
|
126
127
|
salla.event.on('localization::show', () => this.show());
|
|
127
128
|
salla.event.on('languages::translations.loaded', () => {
|
|
@@ -146,9 +147,10 @@ const SallaLocalization = class {
|
|
|
146
147
|
* Show the component
|
|
147
148
|
*/
|
|
148
149
|
async show() {
|
|
149
|
-
return this.
|
|
150
|
+
return this.modal.show()
|
|
151
|
+
.then(() => this.getLanguages())
|
|
150
152
|
.then(() => this.getCurrencies())
|
|
151
|
-
.then(() => this.
|
|
153
|
+
.then(() => this.isLoading = false);
|
|
152
154
|
}
|
|
153
155
|
/**
|
|
154
156
|
* Hide the component
|
|
@@ -163,37 +165,38 @@ const SallaLocalization = class {
|
|
|
163
165
|
return this.currencies.length > 1 ? null : await salla.config.currencies().then(data => this.currencies = data);
|
|
164
166
|
}
|
|
165
167
|
onChangeCurrency(event) {
|
|
166
|
-
this.currency =
|
|
168
|
+
this.currency = event.target.value;
|
|
167
169
|
}
|
|
168
170
|
onChangeLanguage(event) {
|
|
169
|
-
this.language =
|
|
171
|
+
this.language = event.target.value;
|
|
170
172
|
}
|
|
171
173
|
async submit() {
|
|
172
174
|
let url;
|
|
173
|
-
console.log('this.currency.code::::', this.currency, this.currency.code); //todo:: remove it
|
|
174
175
|
this.btn.load()
|
|
175
|
-
.then(() => this.currency
|
|
176
|
-
.then(() => this.language
|
|
176
|
+
.then(() => this.currency === salla.config.get('user.currency_code', 'SAR') || ((url = window.location.href) && salla.currency.api.change(this.currency)))
|
|
177
|
+
.then(() => this.language === salla.config.get('user.language_code', 'ar') || (url = salla.helpers.addParamsToUrl('lang', this.language)))
|
|
177
178
|
.then(() => this.btn.stop())
|
|
178
179
|
.then(() => this.hide())
|
|
179
180
|
.then(() => url && (window.location.href = url));
|
|
180
181
|
}
|
|
181
182
|
render() {
|
|
182
|
-
return (index.h("salla-modal", { id: "salla-localization", class: "s-hidden", ref: modal => this.modal = modal, width: "xs" },
|
|
183
|
-
index.h("div", { class: "s-localization-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
183
|
+
return (index.h("salla-modal", { isLoading: this.isLoading, id: "salla-localization", class: "s-hidden", ref: modal => this.modal = modal, width: "xs" }, !this.isLoading ?
|
|
184
|
+
index.h("div", { class: "s-localization-inner" }, this.languages.length > 1 ?
|
|
185
|
+
index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, this.languagesTitle), index.h("div", { class: "s-localization-section-inner" }, this.languages.length < 6 ?
|
|
186
|
+
this.languages.map(lang => index.h("div", { class: "s-localization-item" }, index.h("input", { class: "s-localization-input", type: "radio", checked: this.language == lang.iso_code, onChange: () => this.language = lang.iso_code, name: "language", id: 'lang-' + lang.code.toLowerCase(), value: lang.code }), index.h("div", { id: "language-slot", innerHTML: this.languageSlot
|
|
187
|
+
.replace(/\{name\}/g, lang.name)
|
|
188
|
+
.replace(/\{code\}/g, lang.code)
|
|
189
|
+
.replace(/\{country_code\}/g, lang.country_code) }))) :
|
|
190
|
+
index.h("select", { class: "s-localization-select", name: "currency", onChange: e => this.onChangeLanguage(e) }, this.languages.map(lang => index.h("option", { value: lang.code, selected: this.language == lang.code }, lang.name)))))
|
|
191
|
+
: '', this.currencies.length > 1 ?
|
|
192
|
+
index.h("div", { class: "s-localization-section" }, index.h("label", { class: "s-localization-title" }, this.currenciesTitle), index.h("div", { class: "s-localization-section-inner" }, this.currencies.length < 6 ?
|
|
193
|
+
this.currencies.map(currency => index.h("div", { class: "s-localization-item" }, index.h("input", { class: "s-localization-input", type: "radio", name: "currency", checked: this.currency == currency.code, onChange: () => this.currency = currency.code, id: 'currency-' + currency.code, value: currency.code }), index.h("div", { id: "currency-slot", innerHTML: this.currencySlot
|
|
194
|
+
.replace(/\{name\}/g, currency.name)
|
|
195
|
+
.replace(/\{code\}/g, currency.code)
|
|
196
|
+
.replace(/\{country_code\}/g, currency.country_code) }))) :
|
|
197
|
+
index.h("select", { class: "s-localization-select", name: "currency", onChange: e => this.onChangeCurrency(e) }, this.currencies.map(currency => index.h("option", { value: currency.code, selected: this.currency == currency.code }, currency.name)))))
|
|
198
|
+
: '', index.h("salla-button", { wide: true, ref: btn => this.btn = btn, onClick: () => this.submit() }, salla.lang.get('common.elements.ok')))
|
|
199
|
+
: ''));
|
|
197
200
|
}
|
|
198
201
|
/**
|
|
199
202
|
* to reduce dom levels we will move slot data into the parent dom
|
|
@@ -297,7 +300,8 @@ const SallaModal = class {
|
|
|
297
300
|
return this.host;
|
|
298
301
|
}
|
|
299
302
|
toggleModal(isOpen) {
|
|
300
|
-
|
|
303
|
+
const body = this.host.querySelector('.s-modal-body');
|
|
304
|
+
Helper.Helper.toggleElement(body, 's-modal-entering', 's-modal-leaving', () => isOpen)
|
|
301
305
|
.toggleElement(this.overlay, 's-modal-entering', 's-modal-overlay-leaving', () => isOpen)
|
|
302
306
|
//todo:: use united class names
|
|
303
307
|
.toggleElement(document.body, 'modal-is-open', 'modal-is-closed', () => isOpen);
|
|
@@ -332,10 +336,11 @@ const SallaModal = class {
|
|
|
332
336
|
//todo:: pref for each modal
|
|
333
337
|
render() {
|
|
334
338
|
this.host.id = this.host.id || 'salla-modal';
|
|
335
|
-
return (index.h(index.Host, { class: 's-modal-container s-hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-
|
|
336
|
-
|
|
339
|
+
return (index.h(index.Host, { class: 's-modal-container s-hidden', "aria-modal": "true", role: "dialog" }, index.h("div", { class: "s-modal-overlay", ref: el => this.overlay = el, onClick: () => this.closeModal() }), index.h("div", { class: "s-modal-wrapper" }, index.h("span", { class: 's-modal-spacer s-modal-align-' + this.position }, "\u200B"), index.h("div", { class: 's-modal-body ' + 's-modal-align-' + this.position + ' s-modal-' + this.width + (this.noPadding ? ' s-modal-nopadding' : ' s-modal-padding') }, this.isLoading ?
|
|
340
|
+
index.h("div", { class: "s-modal-loader-wrap" }, index.h("span", { class: "s-modal-loader" }))
|
|
337
341
|
:
|
|
338
|
-
[
|
|
342
|
+
[
|
|
343
|
+
index.h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
|
|
339
344
|
index.h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" }, index.h("span", { class: "sicon-cancel" }))
|
|
340
345
|
: '', this.title || this.subTitle ?
|
|
341
346
|
index.h("div", { class: "s-modal-header-inner" }, this.error || this.success || this.icon
|
|
@@ -33,7 +33,7 @@ const SallaInfiniteScroll = class {
|
|
|
33
33
|
</div>
|
|
34
34
|
<a href="${this.nextPage}" class="s-button-btn btn--has-loading s-button-primary">
|
|
35
35
|
<span class="s-button-text">${salla.lang.get('common.elements.load_more')}</span>
|
|
36
|
-
<span class="s-button-loader s-button-loader-
|
|
36
|
+
<span class="s-button-loader s-button-loader-center" style="display: none"></span>
|
|
37
37
|
</a>`;
|
|
38
38
|
this.btnLoader = this.status.querySelector('.s-button-loader');
|
|
39
39
|
salla.event.on('languages::translations.loaded', () => {
|
|
@@ -43,7 +43,9 @@ const SallaInfiniteScroll = class {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
loading(isLoading = true) {
|
|
46
|
-
this.
|
|
46
|
+
let btnText = this.status.querySelector('.s-button-text');
|
|
47
|
+
Helper.Helper.toggleElement(btnText, 's-button-hide', 's-button-show', () => isLoading);
|
|
48
|
+
this.btnLoader.style.display = isLoading ? 'inherit' : 'none';
|
|
47
49
|
}
|
|
48
50
|
render() {
|
|
49
51
|
return this.nextPage.length > 1 ?
|
|
@@ -55,7 +57,7 @@ const SallaInfiniteScroll = class {
|
|
|
55
57
|
}
|
|
56
58
|
this.host.insertAdjacentElement('afterend', this.status);
|
|
57
59
|
let that = this;
|
|
58
|
-
salla.infiniteScroll.initiate(this.container, {
|
|
60
|
+
let infScroll = salla.infiniteScroll.initiate(this.container, {
|
|
59
61
|
history: this.autoload ? 'push' : false,
|
|
60
62
|
scrollThreshold: this.autoload ? 400 : false,
|
|
61
63
|
nextPage: this.nextPage,
|
|
@@ -68,7 +70,15 @@ const SallaInfiniteScroll = class {
|
|
|
68
70
|
},
|
|
69
71
|
})
|
|
70
72
|
.on('request', () => this.loading())
|
|
71
|
-
.on('load', () =>
|
|
73
|
+
.on('load', () => {
|
|
74
|
+
this.loading(false);
|
|
75
|
+
if (infScroll.pageIndex == 2) {
|
|
76
|
+
infScroll.option({ loadOnScroll: false });
|
|
77
|
+
}
|
|
78
|
+
if (infScroll.pageIndex == 3) {
|
|
79
|
+
infScroll.option({ loadOnScroll: true });
|
|
80
|
+
}
|
|
81
|
+
})
|
|
72
82
|
.on('error', () => this.loading(false));
|
|
73
83
|
}
|
|
74
84
|
get host() { return index.getElement(this); }
|
|
@@ -5,15 +5,22 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const index = require('./index-714023c8.js');
|
|
6
6
|
const Helper = require('./Helper-98cc9f18.js');
|
|
7
7
|
|
|
8
|
+
const sallaOfferCss = ".s-offer-body{-webkit-overflow-scrolling:touch}.s-offer-body::-webkit-scrollbar{display:none}.s-offer-next-btn{background:linear-gradient(90deg, #fff 25%, rgba(255, 255, 255, 0.4) 80%, rgba(255, 255, 255, 0) 100%)}.s-offer-prev-btn{background:linear-gradient(-90deg, #fff 25%, rgba(255, 255, 255, 0.4) 80%, rgba(255, 255, 255, 0) 100%)}";
|
|
9
|
+
|
|
8
10
|
const SallaOffer = class {
|
|
9
11
|
constructor(hostRef) {
|
|
10
12
|
index.registerInstance(this, hostRef);
|
|
11
|
-
var _a, _b
|
|
13
|
+
var _a, _b;
|
|
12
14
|
this.offer = null;
|
|
15
|
+
this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
|
|
16
|
+
this.remember_my_choice = salla.lang.get('commone.remember_my_choice');
|
|
13
17
|
Helper.Helper.setHost(this.host);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
salla.event.on('languages::translations.loaded', () => {
|
|
19
|
+
this.offer_expires_in = salla.lang.get('pages.products.offer_expires_in');
|
|
20
|
+
this.remember_my_choice = salla.lang.get('common.remember_my_choice');
|
|
21
|
+
});
|
|
22
|
+
this.categorySlot = ((_a = Helper.Helper.getElement('[slot="category"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || '<i class="s-offer-badge-icon sicon-tag"></i><span class="s-offer-badge-text">{name}</span>';
|
|
23
|
+
this.productSlot = ((_b = Helper.Helper.getElement('[slot="product"]')) === null || _b === void 0 ? void 0 : _b.innerHTML) || this.defaultProductSlot();
|
|
17
24
|
salla.offer.event.onExisted(data => {
|
|
18
25
|
//TODO:: use the best, should we hide the offer by product Id or Offer id🤔
|
|
19
26
|
if (salla.localData.get('remember-offer-' + data.offer.offer_id)) {
|
|
@@ -29,7 +36,8 @@ const SallaOffer = class {
|
|
|
29
36
|
*/
|
|
30
37
|
async show(product_id) {
|
|
31
38
|
//TODO:: make sure there is only one offer
|
|
32
|
-
return salla.api.offer.details(product_id)
|
|
39
|
+
return salla.api.offer.details(product_id)
|
|
40
|
+
.then(response => this.showOffer(response.data[0]));
|
|
33
41
|
}
|
|
34
42
|
/**
|
|
35
43
|
* Show offer details
|
|
@@ -37,6 +45,8 @@ const SallaOffer = class {
|
|
|
37
45
|
*/
|
|
38
46
|
async showOffer(offer) {
|
|
39
47
|
this.offer = offer;
|
|
48
|
+
this.offer_name = offer.name;
|
|
49
|
+
this.offer_message = offer.message;
|
|
40
50
|
return this.modal.show();
|
|
41
51
|
}
|
|
42
52
|
rememberMe(event) {
|
|
@@ -50,7 +60,7 @@ const SallaOffer = class {
|
|
|
50
60
|
.finally(() => this['stop']());
|
|
51
61
|
}
|
|
52
62
|
defaultProductSlot() {
|
|
53
|
-
return '<a href={url} class="s-offer-product-image"><img class="s-offer-product-
|
|
63
|
+
return '<a href={url} class="s-offer-product-image-wrap"><img class="s-offer-product-image" src="{image}" /></a>' +
|
|
54
64
|
'<div class="s-offer-product-info">' +
|
|
55
65
|
' <a href={url} class="s-offer-product-name">{name}</a>' +
|
|
56
66
|
' <div class="s-offer-product-price">{price}</div>' +
|
|
@@ -58,32 +68,71 @@ const SallaOffer = class {
|
|
|
58
68
|
}
|
|
59
69
|
render() {
|
|
60
70
|
var _a, _b;
|
|
61
|
-
return index.h("salla-modal", { ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
|
|
62
|
-
? [index.h("div", { class: "s-offer-
|
|
63
|
-
|
|
64
|
-
.replace(/\{message\}/g, this.offer.message) }),
|
|
65
|
-
index.h("div", { class: "s-offer-body" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
|
|
66
|
-
? this.offer.get.categories.map(category => index.h("a", { href: category.urls.customer, class: "s-offer-badge", innerHTML: this.categorySlot
|
|
71
|
+
return index.h("salla-modal", { "sub-title-first": true, icon: "sicon-special-discount", title: "\u0639\u0631\u0648\u0636 \u0631\u0627\u0626\u0639\u0629 \u0641\u064A \u0627\u0646\u062A\u0638\u0627\u0631\u0643\u060C \u0645\u0627\u0630\u0627 \u0646\u062A\u0646\u0638\u0631!", "sub-title": this.offer_message, ref: modal => this.modal = modal, "is-loading": this.offer === null }, this.offer !== null
|
|
72
|
+
? [index.h("div", { class: "s-offer-scrolled-slider-wrap" }, index.h("div", { class: "s-offer-body s-offer-scrolled-slider" }, ((_a = this.offer.get.categories) === null || _a === void 0 ? void 0 : _a.length) > 0
|
|
73
|
+
? this.offer.get.categories.map(category => index.h("a", { href: category.urls.customer, class: "s-offer-badge s-offer-slider-item", innerHTML: this.categorySlot
|
|
67
74
|
.replace(/\{name\}/g, category.name)
|
|
68
75
|
.replace(/\{url\}/g, category.urls.customer) }))
|
|
69
|
-
: (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => index.h("div", { class: "s-offer-product", id: 'product_' + product.id, innerHTML: this.productSlot
|
|
76
|
+
: (_b = this.offer.get.products) === null || _b === void 0 ? void 0 : _b.map(product => index.h("div", { class: "s-offer-product s-offer-slider-item", id: 'product_' + product.id, innerHTML: this.productSlot
|
|
70
77
|
.replace(/\{name\}/g, product.name)
|
|
71
78
|
.replace(/\{url\}/g, product.url)
|
|
72
79
|
.replace(/\{image\}/g, product.thumbnail)
|
|
73
80
|
.replace(/\{price\}/g, product.has_special_price
|
|
74
81
|
? salla.money(product.price) + '<span class="s-offer-product-old-price">' + salla.money(product.regular_price) + '</span>'
|
|
75
|
-
: salla.money(product.price)) }, index.h("salla-button", { "btn-style": 'outline-primary', "data-id": product.id, onClick: this.addItem }, salla.lang.get('pages.cart.add_to_cart'))))),
|
|
82
|
+
: salla.money({ amount: product.price, currency: salla.config.get('user').currency_code })) }, index.h("div", { class: "s-offer-btn-wrap" }, index.h("salla-button", { wide: true, "btn-style": 'outline-primary', "data-id": product.id, "loader-position": "center", onClick: this.addItem }, salla.lang.get('pages.cart.add_to_cart')))))), index.h("div", { class: "s-offer-slider-nav" }, index.h("button", { class: "s-offer-nav-btn s-offer-prev-btn" }, index.h("span", { class: "s-offer-nav-btn-icon sicon-keyboard_arrow_right" })), index.h("button", { class: "s-offer-nav-btn s-offer-next-btn" }, index.h("span", { class: "s-offer-nav-btn-icon sicon-keyboard_arrow_left" })))),
|
|
76
83
|
index.h("div", { class: "s-offer-footer", slot: "footer" }, this.offer.expiry_date ?
|
|
77
|
-
index.h("p", { class: "s-offer-expiry" },
|
|
78
|
-
: '', index.h("label", { class: "s-offer-remember-label" }, index.h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-remember-input" }), "\u00A0 ",
|
|
84
|
+
index.h("p", { class: "s-offer-expiry" }, this.offer_expires_in, " ", this.offer.expiry_date)
|
|
85
|
+
: '', index.h("label", { class: "s-offer-remember-label" }, index.h("input", { type: "checkbox", onChange: e => this.rememberMe(e), class: "s-offer-remember-input" }), "\u00A0 ", this.remember_my_choice)),
|
|
79
86
|
] : '');
|
|
80
87
|
}
|
|
81
88
|
componentDidRender() {
|
|
82
89
|
//todo:: know from where there is hidden attributes to the doms🤔
|
|
83
90
|
//todo:: add animation
|
|
84
91
|
this.modal.querySelectorAll('[hidden]').forEach(el => el.removeAttribute('hidden'));
|
|
92
|
+
// Sooo mini Slider
|
|
93
|
+
if (this.offer && window.screen.width > 639) {
|
|
94
|
+
let sliderWrap = this.host.querySelector('.s-offer-scrolled-slider-wrap'), slider = this.host.querySelector('.s-offer-scrolled-slider'), navButtons = this.host.querySelectorAll('.s-offer-nav-btn'), nexBtn = this.host.querySelector('.s-offer-next-btn'), prevBtn = this.host.querySelector('.s-offer-prev-btn'), items = this.host.querySelectorAll('.s-offer-slider-item'), sliderNavMargin = 20, // space before displaying the next/prev btns.
|
|
95
|
+
current = 0, // current slide
|
|
96
|
+
slidesToScroll = 3, itemsLength = items.length, itemSize = items[0].offsetWidth, sliderSize = itemsLength * itemSize, sliderWrapperSize = sliderWrap.offsetWidth, sliderInvisibleSize = sliderSize - sliderWrapperSize, isRTL = document.body.classList.contains('rtl') ? true : false;
|
|
97
|
+
if (sliderInvisibleSize > sliderNavMargin)
|
|
98
|
+
nexBtn.classList.add('s-offer-btn-is-active');
|
|
99
|
+
window.onresize = function () {
|
|
100
|
+
sliderWrapperSize = sliderWrap.offsetWidth;
|
|
101
|
+
sliderInvisibleSize = sliderSize - sliderWrapperSize;
|
|
102
|
+
};
|
|
103
|
+
slider.addEventListener('scroll', function () {
|
|
104
|
+
let sliderPosition = Math.abs(slider.scrollLeft);
|
|
105
|
+
let sliderEndOffset = sliderInvisibleSize - sliderNavMargin;
|
|
106
|
+
// show & hide the navigation btns depending on scroll position
|
|
107
|
+
if (sliderPosition <= sliderNavMargin) {
|
|
108
|
+
nexBtn.classList.add('s-offer-btn-is-active');
|
|
109
|
+
prevBtn.classList.remove('s-offer-btn-is-active');
|
|
110
|
+
}
|
|
111
|
+
else if (sliderPosition < sliderEndOffset) {
|
|
112
|
+
// show both btns in the middle
|
|
113
|
+
nexBtn.classList.add('s-offer-btn-is-active');
|
|
114
|
+
prevBtn.classList.add('s-offer-btn-is-active');
|
|
115
|
+
}
|
|
116
|
+
else if (sliderPosition >= sliderEndOffset) {
|
|
117
|
+
nexBtn.classList.remove('s-offer-btn-is-active');
|
|
118
|
+
prevBtn.classList.add('s-offer-btn-is-active');
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
// Navigation
|
|
122
|
+
navButtons.forEach(btn => {
|
|
123
|
+
btn.addEventListener('click', function () {
|
|
124
|
+
btn.classList.contains('s-offer-next-btn') ? current++ : current--;
|
|
125
|
+
slider.scrollTo({
|
|
126
|
+
top: 0,
|
|
127
|
+
left: itemSize * slidesToScroll * current * (isRTL ? -1 : 1),
|
|
128
|
+
behavior: 'smooth'
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
85
133
|
}
|
|
86
134
|
get host() { return index.getElement(this); }
|
|
87
135
|
};
|
|
136
|
+
SallaOffer.style = sallaOfferCss;
|
|
88
137
|
|
|
89
138
|
exports.salla_offer = SallaOffer;
|
|
@@ -30,7 +30,10 @@ const SallaProductAvailability = class {
|
|
|
30
30
|
return this.btn.load()
|
|
31
31
|
.then(() => this.btn.disable())
|
|
32
32
|
.then(() => salla.api.product.availabilitySubscribe(data))
|
|
33
|
-
.then(() =>
|
|
33
|
+
.then(() => {
|
|
34
|
+
this.isSubscribed = true;
|
|
35
|
+
salla.localData.set(`product-${this.productId}-subscribed`, true);
|
|
36
|
+
}) //no need to wait until finishing alert animation
|
|
34
37
|
.then(() => this.btn.stop())
|
|
35
38
|
.then(() => this.modal.hide())
|
|
36
39
|
.catch(() => this.btn.stop() && this.btn.enable());
|
|
@@ -42,26 +45,27 @@ const SallaProductAvailability = class {
|
|
|
42
45
|
(error === null || error === void 0 ? void 0 : error.classList.contains('s-product-availability-error-msg')) && (error.innerText = '');
|
|
43
46
|
e.key == 'Enter' && submitMethod();
|
|
44
47
|
};
|
|
45
|
-
if (this.isUser) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
this.channelsWatcher(this.channels);
|
|
49
|
-
this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
|
|
50
|
-
this.host.removeAttribute('title');
|
|
51
48
|
salla.event.on('languages::translations.loaded', () => {
|
|
52
49
|
var _a, _b, _c, _d;
|
|
50
|
+
// console.log('translations:', salla.lang);
|
|
51
|
+
this.subscribedMessage = salla.lang.get('pages.products.notify_availability_success');
|
|
53
52
|
this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
|
|
54
53
|
this.subTitle = salla.lang.get('pages.products.notify_availability_subtitle');
|
|
55
54
|
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
56
55
|
this.emailLabel = salla.lang.get('common.elements.email');
|
|
57
56
|
this.emailPlaceholder = salla.lang.get('common.elements.email_placeholder');
|
|
58
|
-
this.subscribedMessage = salla.lang.get('pages.products.notify_availability_success');
|
|
59
57
|
this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
|
|
60
58
|
(_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title_);
|
|
61
59
|
(_b = this.btn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('common.elements.submit'));
|
|
62
60
|
(_c = this.cancelBtn) === null || _c === void 0 ? void 0 : _c.setText(salla.lang.get('common.elements.cancel'));
|
|
63
61
|
(_d = this.inlineBtn) === null || _d === void 0 ? void 0 : _d.setText(salla.lang.get('pages.products.notify_availability'));
|
|
64
62
|
});
|
|
63
|
+
if (this.isUser)
|
|
64
|
+
return;
|
|
65
|
+
this.channelsWatcher(this.channels);
|
|
66
|
+
this.title_ = this.host.title || salla.lang.get('pages.products.notify_availability_title');
|
|
67
|
+
this.host.removeAttribute('title');
|
|
68
|
+
this.isVisitorSubscribed = salla.localData.get(`product-${this.productId}-subscribed`);
|
|
65
69
|
}
|
|
66
70
|
channelsWatcher(newValue) {
|
|
67
71
|
this.channels_ = newValue.split(',');
|
|
@@ -85,9 +89,9 @@ const SallaProductAvailability = class {
|
|
|
85
89
|
field.nextElementSibling['innerText'] = '* ' + errorMsg;
|
|
86
90
|
}
|
|
87
91
|
render() {
|
|
88
|
-
return (index.h(index.Host, null, this.isSubscribed
|
|
92
|
+
return (index.h(index.Host, null, this.isSubscribed || this.isVisitorSubscribed
|
|
89
93
|
? index.h("div", { class: "s-product-availability-subscribed" }, index.h("i", { class: "sicon-bell-ring s-product-availability-subs-icon" }), " ", this.subscribedMessage)
|
|
90
|
-
: index.h("slot", null, index.h("salla-button", { onClick: () => this.isUser ? this.submit() : this.modal.show(), wide: true, ref: btn => this.inlineBtn = btn }, salla.lang.get('pages.products.notify_availability'))), this.isUser || this.isSubscribed ? '' : this.renderModal()));
|
|
94
|
+
: index.h("slot", null, index.h("salla-button", { onClick: () => this.isUser ? this.submit() : this.modal.show(), wide: true, ref: btn => this.inlineBtn = btn }, salla.lang.get('pages.products.notify_availability'))), this.isUser || this.isSubscribed || this.isVisitorSubscribed ? '' : this.renderModal()));
|
|
91
95
|
}
|
|
92
96
|
renderModal() {
|
|
93
97
|
return (index.h("salla-modal", { ref: modal => this.modal = modal, title: this.title_, subTitle: this.subTitle, icon: "sicon-bell-ring", width: "sm" }, index.h("div", { class: "s-product-availability-body" }, this.channels_.includes('email') ? [
|
|
@@ -64,7 +64,7 @@ const SallaRating = class {
|
|
|
64
64
|
// Prevent form from submitting
|
|
65
65
|
event.preventDefault();
|
|
66
66
|
// Get the selected star - activeElement is not supported in safari
|
|
67
|
-
let activeStars = event.target.querySelectorAll('.s-rating-btn-star.hovered');
|
|
67
|
+
let activeStars = event.target.querySelectorAll('.s-rating-btn-star.s-rating-hovered');
|
|
68
68
|
let selected = activeStars[activeStars.length - 1];
|
|
69
69
|
if (!selected)
|
|
70
70
|
return;
|
|
@@ -74,7 +74,7 @@ const SallaRating = class {
|
|
|
74
74
|
// Loop through each star, and add or remove the `.selected` class to toggle highlighting
|
|
75
75
|
event.target
|
|
76
76
|
.querySelectorAll('.s-rating-btn-star')
|
|
77
|
-
.forEach((star, index) => Helper.Helper.toggleElement(star, 'selected', 'un-selected', () => index < selectedIndex));
|
|
77
|
+
.forEach((star, index) => Helper.Helper.toggleElement(star, 's-rating-selected', 's-rating-un-selected', () => index < selectedIndex));
|
|
78
78
|
// Remove aria-pressed from any previously selected star
|
|
79
79
|
event.target.querySelectorAll('.s-rating-btn-star[aria-pressed="true"]').forEach(star => star.removeAttribute('aria-pressed'));
|
|
80
80
|
// Add aria-pressed role to the selected button
|
|
@@ -99,13 +99,12 @@ const SallaRating = class {
|
|
|
99
99
|
}
|
|
100
100
|
// Btn text
|
|
101
101
|
let nextType = (_a = this.steps[this.currentIndex + 1]) === null || _a === void 0 ? void 0 : _a.dataset.type;
|
|
102
|
-
this.nextBtn.
|
|
103
|
-
|
|
104
|
-
: salla.lang.get('pages.rating.send_ratings');
|
|
102
|
+
this.nextBtn.setText(nextType ? salla.lang.get('pages.rating.rate') + ' ' + salla.lang.get('pages.rating.' + nextType)
|
|
103
|
+
: salla.lang.get('pages.rating.send_ratings'));
|
|
105
104
|
setTimeout(() => { var _a; return this.body.setAttribute('style', 'height:' + ((_a = this.currentTab) === null || _a === void 0 ? void 0 : _a.scrollHeight) + 'px'); });
|
|
106
105
|
}
|
|
107
106
|
highlightSelectedStars() {
|
|
108
|
-
let hover = ['hovered'];
|
|
107
|
+
let hover = ['s-rating-hovered'];
|
|
109
108
|
Helper.Helper.all('.s-rating-stars-element', el => {
|
|
110
109
|
let starElements = el.querySelectorAll('.s-rating-btn-star');
|
|
111
110
|
// remove hovered state from stars ---
|
|
@@ -159,12 +158,12 @@ const SallaRating = class {
|
|
|
159
158
|
let comment = rating.querySelector('.s-rating-comment');
|
|
160
159
|
let validationMessage = rating.querySelector('.s-rating-validation-msg');
|
|
161
160
|
if (stars && comment.value && comment.value.length > 3) {
|
|
162
|
-
comment.classList.remove('s-
|
|
161
|
+
comment.classList.remove('s-has-error');
|
|
163
162
|
validationMessage.innerHTML = '';
|
|
164
163
|
return;
|
|
165
164
|
}
|
|
166
165
|
type = type || rating['dataset'].type;
|
|
167
|
-
Helper.Helper.toggleElement(comment, 'save', 's-
|
|
166
|
+
Helper.Helper.toggleElement(comment, 'save', 's-has-error', el => el.value.length > 3);
|
|
168
167
|
throw validationMessage.innerHTML = stars
|
|
169
168
|
? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + comment.getAttribute('placeholder'))
|
|
170
169
|
: salla.lang.get(`pages.rating.rate_${type}_stars`).replace(' (:item)', '');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const index = require('./index-714023c8.js');
|
|
4
4
|
const Helper = require('./Helper-98cc9f18.js');
|
|
5
5
|
|
|
6
|
-
const sallaLoginCss = "salla-verify{display:block}
|
|
6
|
+
const sallaLoginCss = "salla-verify{display:block}";
|
|
7
7
|
|
|
8
8
|
const SallaLogin = class {
|
|
9
9
|
constructor(hostRef) {
|
|
@@ -79,14 +79,13 @@ const SallaLogin = class {
|
|
|
79
79
|
this.title = this.host.title || salla.lang.get('blocks.header.login');
|
|
80
80
|
this.host.removeAttribute('title');
|
|
81
81
|
salla.event.on('languages::translations.loaded', () => {
|
|
82
|
-
var _a;
|
|
82
|
+
var _a, _b, _c, _d;
|
|
83
83
|
this.title = salla.lang.get('blocks.header.login');
|
|
84
84
|
this.loginTypeTitle = salla.lang.get('blocks.header.select_login_way');
|
|
85
85
|
this.loginText = salla.lang.get('blocks.header.login');
|
|
86
86
|
this.smsLabel = salla.lang.get('blocks.header.sms');
|
|
87
87
|
this.mobileLabel = salla.lang.get('common.elements.mobile');
|
|
88
88
|
this.emailLabel = salla.lang.get('common.elements.email');
|
|
89
|
-
this.enterText = salla.lang.get('blocks.header.enter');
|
|
90
89
|
this.bySMSText = salla.lang.get('blocks.header.login_by_sms');
|
|
91
90
|
this.byEmailText = salla.lang.get('blocks.header.login_by_email');
|
|
92
91
|
this.emailErrorMsg = salla.lang.get('common.elements.email_is_valid');
|
|
@@ -95,6 +94,9 @@ const SallaLogin = class {
|
|
|
95
94
|
this.firstNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.firstNameLabel });
|
|
96
95
|
this.lastNameErrorMsg = salla.lang.get('common.errors.field_required', { attribute: this.lastNameLabel });
|
|
97
96
|
(_a = this.modal) === null || _a === void 0 ? void 0 : _a.setTitle(this.title);
|
|
97
|
+
(_b = this.smsBtn) === null || _b === void 0 ? void 0 : _b.setText(salla.lang.get('blocks.header.enter'));
|
|
98
|
+
(_c = this.emailBtn) === null || _c === void 0 ? void 0 : _c.setText(salla.lang.get('blocks.header.enter'));
|
|
99
|
+
(_d = this.regBtn) === null || _d === void 0 ? void 0 : _d.setText(salla.lang.get('blocks.header.register'));
|
|
98
100
|
});
|
|
99
101
|
salla.auth.event.onVerificationFailed(() => {
|
|
100
102
|
//
|
|
@@ -176,9 +178,9 @@ const SallaLogin = class {
|
|
|
176
178
|
return (index.h("salla-modal", { id: "salla-login", icon: "sicon-user", title: this.title, ref: modal => this.modal = modal, width: "xs" }, index.h("div", { class: "s-login-wrapper" }, this.isEmailAllowed && this.isMobileAllowed ?
|
|
177
179
|
index.h("div", { class: "s-login-tab", ref: tab => this.homeTab = tab }, index.h("p", { class: "s-login-sub-title" }, this.loginTypeTitle), index.h("slot", { name: "before-login-type" }), index.h("a", { href: "#", class: "s-login-main-btn", onClick: (evt) => this.showTab(this.mobileTab, evt) }, index.h("i", { class: "s-login-main-btn-icon sicon-phone" }), index.h("span", { class: "s-login-main-btn-text" }, this.smsLabel), index.h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })), index.h("a", { href: "#", class: "s-login-main-btn", onClick: (evt) => this.showTab(this.emailTab, evt) }, index.h("i", { class: "s-login-main-btn-icon sicon-mail" }), index.h("span", { class: "s-login-main-btn-text" }, this.emailLabel), index.h("i", { class: "main-btn-arrow sicon-keyboard_arrow_left" })), index.h("slot", { name: "after-login-type" }))
|
|
178
180
|
: '', this.isMobileAllowed ?
|
|
179
|
-
index.h("div", { class: "s-login-tab", ref: tab => this.mobileTab = tab }, index.h("slot", { name: "before-login-mobile" }), index.h("label", { class: "s-login-label" }, this.mobileLabel), index.h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b },
|
|
181
|
+
index.h("div", { class: "s-login-tab", ref: tab => this.mobileTab = tab }, index.h("slot", { name: "before-login-mobile" }), index.h("label", { class: "s-login-label" }, this.mobileLabel), index.h("salla-tel-input", { ref: el => this.loginTelInput = el, onKeyDown: e => this.typing(e, this.loginBySMS) }), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginBySMS(), ref: b => this.smsBtn = b }, salla.lang.get('blocks.header.enter')), this.isEmailAllowed ?
|
|
180
182
|
index.h("a", { href: "#", onClick: () => this.showTab(this.emailTab), class: "s-login-link" }, this.byEmailText) : '', index.h("slot", { name: "after-login-mobile" })) : '', this.isEmailAllowed ?
|
|
181
|
-
index.h("div", { class: "s-login-tab", ref: tab => this.emailTab = tab }, index.h("slot", { name: "before-login-email" }), index.h("label", { class: "s-login-label" }, this.emailLabel), index.h("input", { type: "email", ref: el => this.loginEmail = el, onKeyDown: e => this.typing(e, this.loginByEmail), placeholder: "your@email.com", class: "s-login-input s-ltr" }), index.h("span", { class: "s-login-error-message" }), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b },
|
|
183
|
+
index.h("div", { class: "s-login-tab", ref: tab => this.emailTab = tab }, index.h("slot", { name: "before-login-email" }), index.h("label", { class: "s-login-label" }, this.emailLabel), index.h("input", { type: "email", ref: el => this.loginEmail = el, onKeyDown: e => this.typing(e, this.loginByEmail), placeholder: "your@email.com", class: "s-login-input s-ltr" }), index.h("span", { class: "s-login-error-message" }), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.loginByEmail(), ref: b => this.emailBtn = b }, salla.lang.get('blocks.header.enter')), this.isMobileAllowed ?
|
|
182
184
|
index.h("a", { href: "#", onClick: () => this.showTab(this.mobileTab), class: "s-login-link" }, this.bySMSText) : '', index.h("slot", { name: "after-login-email" })) : '', index.h("salla-verify", { "without-modal": true, ref: tab => this.verifyTab = tab, autoReload: false }, index.h("a", { onClick: () => this.showTab(this.regType == 'phone' ? this.mobileTab : this.emailTab), class: "s-verify-back sicon-arrow-right", slot: "after-footer", href: "#" })), index.h("div", { ref: tab => this.registrationTab = tab }, index.h("slot", { name: "before-registration" }), index.h("label", { class: "s-login-label" }, this.firstNameLabel), index.h("input", { type: "text", class: "s-login-input", ref: el => this.firstName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.first_name') }), index.h("span", { class: "s-login-error-message" }), index.h("label", { class: "s-login-label" }, this.lastNameLabel), index.h("input", { type: "text", class: "s-login-input", ref: el => this.lastName = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: salla.lang.get('pages.profile.last_name') }), index.h("span", { class: "s-login-error-message" }), index.h("div", { ref: el => this.regMobileBlock = el, class: "mb-1.5" }, index.h("label", { class: "s-login-label" }, this.mobileLabel), index.h("salla-tel-input", { ref: el => this.regTelInput = el, onKeyDown: e => this.typing(e, this.newUser) })), index.h("div", { ref: el => this.regEmailBlock = el, class: "mb-1.5" }, index.h("label", { class: "s-login-label" }, this.emailLabel), index.h("input", { type: "email", ref: el => this.regEmail = el, onKeyDown: e => this.typing(e, this.newUser), placeholder: "your@email.com", class: "s-login-input s-ltr" }), index.h("span", { class: "s-login-error-message" })), index.h("salla-button", { "loader-position": 'center', wide: true, onClick: () => this.newUser(), ref: b => this.regBtn = b }, salla.lang.get('blocks.header.register')), index.h("slot", { name: "after-registration" })))));
|
|
183
185
|
}
|
|
184
186
|
get host() { return index.getElement(this); }
|
|
@@ -212,7 +214,7 @@ const SallaSearch = class {
|
|
|
212
214
|
' <img class="s-search-product-image" src="{image}" alt="{name}"/>' +
|
|
213
215
|
'</div>' +
|
|
214
216
|
'<div class="s-search-product-details">' +
|
|
215
|
-
' <div class="s-search-product-
|
|
217
|
+
' <div class="s-search-product-title">{name}</div> <div class="s-search-product-price">{price}</div>' +
|
|
216
218
|
'</div>';
|
|
217
219
|
}
|
|
218
220
|
//todo:: reset data when closing
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["salla-button_7.cjs",[[4,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"isMobileAllowed":[4,"is-mobile-allowed"],"isEmailRequired":[4,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[
|
|
18
|
+
return index.bootstrapLazy([["salla-button_7.cjs",[[4,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"isMobileAllowed":[4,"is-mobile-allowed"],"isEmailRequired":[4,"is-email-required"],"title":[32],"loginTypeTitle":[32],"loginText":[32],"smsLabel":[32],"mobileLabel":[32],"emailLabel":[32],"enterText":[32],"bySMSText":[32],"byEmailText":[32],"emailErrorMsg":[32],"firstNameLabel":[32],"lastNameLabel":[32],"firstNameErrorMsg":[32],"lastNameErrorMsg":[32],"show":[64]},[[0,"verified","onVerified"]]],[0,"salla-localization",{"languages":[32],"currencies":[32],"languagesTitle":[32],"currenciesTitle":[32],"isLoading":[32],"show":[64],"hide":[64],"submit":[64]}],[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]],[4,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[513],"by":[1],"autoReload":[4,"auto-reload"],"title":[32],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"mobile":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"mobileRequired":[32],"countryCodeLabel":[32],"mobileLabel":[32],"tooShort":[32],"tooLong":[32],"invalidCountryCode":[32],"invalidNumber":[32],"errorMap":[32],"getValues":[64],"isValid":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"setText":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"noPadding":[4,"no-padding"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"productId":[2,"product-id"],"isSubscribed":[1028,"is-subscribed"],"subTitle":[32],"mobileLabel":[32],"emailLabel":[32],"emailPlaceholder":[32],"subscribedMessage":[32],"title_":[32],"emailErrorMsg":[32],"isVisitorSubscribed":[32]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"offer_name":[32],"offer_message":[32],"offer_expires_in":[32],"remember_my_choice":[32],"show":[64],"showOffer":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"orderId":[2,"order-id"],"order":[32],"show":[64],"hide":[64]}]]],["salla-infinite-scroll.cjs",[[4,"salla-infinite-scroll",{"nextPage":[1,"next-page"],"autoload":[4],"container":[1],"item":[1],"loadMore":[32],"noMore":[32],"failedToLoad":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -29,7 +29,7 @@ export class SallaInfiniteScroll {
|
|
|
29
29
|
</div>
|
|
30
30
|
<a href="${this.nextPage}" class="s-button-btn btn--has-loading s-button-primary">
|
|
31
31
|
<span class="s-button-text">${salla.lang.get('common.elements.load_more')}</span>
|
|
32
|
-
<span class="s-button-loader s-button-loader-
|
|
32
|
+
<span class="s-button-loader s-button-loader-center" style="display: none"></span>
|
|
33
33
|
</a>`;
|
|
34
34
|
this.btnLoader = this.status.querySelector('.s-button-loader');
|
|
35
35
|
salla.event.on('languages::translations.loaded', () => {
|
|
@@ -39,7 +39,9 @@ export class SallaInfiniteScroll {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
loading(isLoading = true) {
|
|
42
|
-
this.
|
|
42
|
+
let btnText = this.status.querySelector('.s-button-text');
|
|
43
|
+
Helper.toggleElement(btnText, 's-button-hide', 's-button-show', () => isLoading);
|
|
44
|
+
this.btnLoader.style.display = isLoading ? 'inherit' : 'none';
|
|
43
45
|
}
|
|
44
46
|
render() {
|
|
45
47
|
return this.nextPage.length > 1 ?
|
|
@@ -52,7 +54,7 @@ export class SallaInfiniteScroll {
|
|
|
52
54
|
}
|
|
53
55
|
this.host.insertAdjacentElement('afterend', this.status);
|
|
54
56
|
let that = this;
|
|
55
|
-
salla.infiniteScroll.initiate(this.container, {
|
|
57
|
+
let infScroll = salla.infiniteScroll.initiate(this.container, {
|
|
56
58
|
history: this.autoload ? 'push' : false,
|
|
57
59
|
scrollThreshold: this.autoload ? 400 : false,
|
|
58
60
|
nextPage: this.nextPage,
|
|
@@ -65,7 +67,15 @@ export class SallaInfiniteScroll {
|
|
|
65
67
|
},
|
|
66
68
|
})
|
|
67
69
|
.on('request', () => this.loading())
|
|
68
|
-
.on('load', () =>
|
|
70
|
+
.on('load', () => {
|
|
71
|
+
this.loading(false);
|
|
72
|
+
if (infScroll.pageIndex == 2) {
|
|
73
|
+
infScroll.option({ loadOnScroll: false });
|
|
74
|
+
}
|
|
75
|
+
if (infScroll.pageIndex == 3) {
|
|
76
|
+
infScroll.option({ loadOnScroll: true });
|
|
77
|
+
}
|
|
78
|
+
})
|
|
69
79
|
.on('error', () => this.loading(false));
|
|
70
80
|
}
|
|
71
81
|
static get is() { return "salla-infinite-scroll"; }
|