@salla.sa/twilight-components 1.0.9 → 1.0.11
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/{Helper-8c75b6ac.js → Helper-8852feaa.js} +3 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{multi-warehouse_3.cjs.entry.js → multi-warehouse_4.cjs.entry.js} +91 -10
- package/dist/cjs/salla-localization.cjs.entry.js +35 -11
- package/dist/cjs/salla-product-availability.cjs.entry.js +78 -0
- package/dist/cjs/salla-rating.cjs.entry.js +299 -0
- package/dist/cjs/{salla-search-b9403062.js → salla-search-f9e00be9.js} +1 -0
- package/dist/cjs/salla-search.cjs.entry.js +1 -1
- package/dist/cjs/salla-verify.cjs.entry.js +5 -3
- package/dist/cjs/twilight-components.cjs.js +1 -1
- package/dist/collection/Helpers/Helper.js +3 -0
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/multi-warehouse/multi-warehouse.css +13 -0
- package/dist/collection/components/multi-warehouse/multi-warehouse.js +38 -39
- package/dist/collection/components/salla-button/salla-button.js +42 -9
- package/dist/collection/components/salla-localization/salla-localization.js +112 -20
- package/dist/collection/components/salla-modal/salla-modal.js +26 -19
- package/dist/collection/components/salla-product-availability/salla-product-availability.js +333 -0
- package/dist/collection/components/{order-rating/order-rating.css → salla-rating/salla-rating.css} +0 -0
- package/dist/collection/components/salla-rating/salla-rating.js +484 -0
- package/dist/collection/components/salla-search/salla-search.js +1 -0
- package/dist/collection/components/salla-verify/salla-verify.js +4 -2
- package/dist/esm/{Helper-23b2de40.js → Helper-81ac9a8c.js} +3 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{multi-warehouse_3.entry.js → multi-warehouse_4.entry.js} +91 -11
- package/dist/esm/salla-localization.entry.js +35 -11
- package/dist/esm/salla-product-availability.entry.js +74 -0
- package/dist/esm/salla-rating.entry.js +295 -0
- package/dist/esm/{salla-search-5d4a6f1a.js → salla-search-615b8f94.js} +1 -0
- package/dist/esm/salla-search.entry.js +1 -1
- package/dist/esm/salla-verify.entry.js +5 -3
- package/dist/esm/twilight-components.js +1 -1
- package/dist/twilight-components/index.esm.js +1 -1
- package/dist/twilight-components/p-2b8a5fa4.entry.js +1 -0
- package/dist/twilight-components/p-4e37a6cb.entry.js +1 -0
- package/dist/twilight-components/p-751643d8.entry.js +1 -0
- package/dist/twilight-components/{p-4b137380.js → p-8a2410e6.js} +0 -0
- package/dist/twilight-components/p-94b18718.entry.js +1 -0
- package/dist/twilight-components/{p-520446eb.js → p-9bc28e0c.js} +1 -1
- package/dist/twilight-components/p-bb503365.entry.js +1 -0
- package/dist/twilight-components/p-d34bbfc4.entry.js +1 -0
- package/dist/twilight-components/twilight-components.esm.js +1 -1
- package/dist/types/Helpers/Helper.d.ts +1 -0
- package/dist/types/components/multi-warehouse/multi-warehouse.d.ts +1 -0
- package/dist/types/components/salla-button/salla-button.d.ts +2 -1
- package/dist/types/components/salla-localization/salla-localization.d.ts +10 -3
- package/dist/types/components/salla-product-availability/salla-product-availability.d.ts +27 -0
- package/dist/types/components/salla-rating/salla-rating.d.ts +35 -0
- package/dist/types/components.d.ts +76 -17
- package/package.json +1 -1
- package/dist/cjs/order-rating.cjs.entry.js +0 -252
- package/dist/cjs/salla-button.cjs.entry.js +0 -57
- package/dist/collection/components/order-rating/order-rating.js +0 -321
- package/dist/esm/order-rating.entry.js +0 -248
- package/dist/esm/salla-button.entry.js +0 -53
- package/dist/twilight-components/p-653bb9a8.entry.js +0 -1
- package/dist/twilight-components/p-a2395c9d.entry.js +0 -1
- package/dist/twilight-components/p-baeca520.entry.js +0 -1
- package/dist/twilight-components/p-bd10d8d5.entry.js +0 -1
- package/dist/twilight-components/p-ea986bca.entry.js +0 -1
- package/dist/twilight-components/p-f4340bd9.entry.js +0 -1
- package/dist/types/components/order-rating/order-rating.d.ts +0 -20
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-23da2c6b.js');
|
|
6
|
-
const Helper = require('./Helper-8c75b6ac.js');
|
|
7
|
-
|
|
8
|
-
const orderRatingCss = ":host{display:block}";
|
|
9
|
-
|
|
10
|
-
const OrderRating = class {
|
|
11
|
-
constructor(hostRef) {
|
|
12
|
-
index.registerInstance(this, hostRef);
|
|
13
|
-
this.stars = [1, 2, 3, 4, 5];
|
|
14
|
-
this.order = {
|
|
15
|
-
shipping: { id: 5622 },
|
|
16
|
-
order_id: "179794",
|
|
17
|
-
products: [
|
|
18
|
-
{
|
|
19
|
-
"title": "ميكروفون عالى الجودة",
|
|
20
|
-
"image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",
|
|
21
|
-
"price": "10,978.00 ر.س",
|
|
22
|
-
"qty": "2",
|
|
23
|
-
"totalBefore": "1120 ر.س",
|
|
24
|
-
"discount": "-5%",
|
|
25
|
-
"total": "1064 ر.س",
|
|
26
|
-
"id": "2314513454",
|
|
27
|
-
"getOptimusRouteKey": "7351233357"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"title": "وحدة تحكم لمشغل العاب",
|
|
31
|
-
"image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/NOa4kHvOkd1hBWHk3JIgAo1602oVACfuWGFz3vXv.jpg",
|
|
32
|
-
"price": "10,978.00 ر.س",
|
|
33
|
-
"qty": "2",
|
|
34
|
-
"totalBefore": "1120 ر.س",
|
|
35
|
-
"discount": "-5%",
|
|
36
|
-
"total": "1064 ر.س",
|
|
37
|
-
"id": "9842833",
|
|
38
|
-
"getOptimusRouteKey": "735152357"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"title": "ساعة ذكية بنظام اندرويد",
|
|
42
|
-
"image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg",
|
|
43
|
-
"price": "10,978.00 ر.س",
|
|
44
|
-
"qty": "2",
|
|
45
|
-
"totalBefore": "1120 ر.س",
|
|
46
|
-
"discount": "-5%",
|
|
47
|
-
"total": "1064 ر.س",
|
|
48
|
-
"id": "679822376",
|
|
49
|
-
"getOptimusRouteKey": "73233357"
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
ratingMessage: {
|
|
53
|
-
1: "غير راضي <span class='emoji mx-1'>😒</span>",
|
|
54
|
-
2: "لم يعجبني <span class='emoji mx-1'>😌</span>",
|
|
55
|
-
3: "معقول <span class='emoji mx-1'>🙄</span>",
|
|
56
|
-
4: "أعجبني <span class='emoji mx-1'>👍</span>",
|
|
57
|
-
5: "أعجبني جداً <span class='emoji mx-1'>🤩</span>"
|
|
58
|
-
},
|
|
59
|
-
settings: {
|
|
60
|
-
isProductsRating: true,
|
|
61
|
-
isStoreRating: true,
|
|
62
|
-
isShippingRating: true,
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
this.ratingChain = Promise.resolve();
|
|
66
|
-
this.wizardInex = 0;
|
|
67
|
-
}
|
|
68
|
-
componentDidRender() {
|
|
69
|
-
this.initiateRating();
|
|
70
|
-
}
|
|
71
|
-
render() {
|
|
72
|
-
return (index.h(index.Host, null, index.h("div", { class: "pannel__body" }, this.order.settings.isStoreRating && this.renderStoreRating(), this.order.settings.isProductsRating && this.renderProductsRating(), this.order.settings.isShippingRating && this.renderShippingRating()), index.h("div", { class: "pannel__footer relative flex justify-between items-center" }, index.h("button", { id: "prev-btn", class: "font-bold text-sm text-primary hidden" }, "\u0627\u0644\u0633\u0627\u0628\u0642"), index.h("ul", { class: "flex justify-center text-center space-s-1.5 py-8 flex-1" }, index.h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-primary rounded-full transition-colors duration-300" }), index.h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-gray-200 rounded-full transition-colors duration-300" }), index.h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-gray-200 rounded-full transition-colors duration-300" })), index.h("button", { id: "next-btn", class: "btn btn-primary h-10 px-8 flex-none" }, "\u0627\u0644\u062A\u0627\u0644\u064A"))));
|
|
73
|
-
}
|
|
74
|
-
renderProductsRating() {
|
|
75
|
-
return (index.h("section", { class: "step rating-section products-section hidden", "data-type": "product" }, index.h("div", { class: "bg-white mb-5 p-5 rounded-md overflow-hidden mb-10" }, this.order.products.map((item, index$1) => {
|
|
76
|
-
var _a;
|
|
77
|
-
return index.h("div", { class: "rating-outer-form", "data-stars-error": `يرجى تقييم (${item.title}) بواسطة النجمات` }, index.h("div", { class: "product-item mb-4" }, index.h("div", { class: "mb-5" }, index.h("div", { class: "flex space-s-5 mb-8" }, index.h("img", { src: item.image, alt: item.title, class: "w-18 h-14 object-cover rounded-md" }), index.h("div", { class: "flex-1" }, index.h("h3", { class: "section-title leading-5 mb-1.5 md:text-base" }, " ", item.title), index.h("div", { class: "rw-product-entry__rate" }, index.h("div", { class: "rating-wrap flex items-center space-s-4" }, index.h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating()), index.h("p", { class: "rate-label fix-align font-xsm my-0" })), index.h("input", { type: "hidden", name: "order_id", value: (_a = this.order) === null || _a === void 0 ? void 0 : _a.order_id }), index.h("input", { type: "hidden", name: `products[${index$1}][product_id]`, value: item.getOptimusRouteKey }), index.h("input", { type: "hidden", name: "type", value: "products" }), index.h("textarea", { "data-product-id": item.id, name: `products[${index$1}][comment]`, id: `productReview_${item.id}`, class: "comment form-input h-20 product-review", placeholder: `اضف رأيك عن المنتج (${item.title})` }), index.h("small", { class: "text-red-400 validation-message" })))))));
|
|
78
|
-
}))));
|
|
79
|
-
}
|
|
80
|
-
renderStoreRating() {
|
|
81
|
-
return (index.h("section", { class: "step rating-section bg-white my-10 p-5 rounded-md mb-5 active", "data-type": "store" }, index.h("div", { class: "rating-outer-form", "data-stars-error": "\u064A\u0631\u062C\u0649 \u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u062A\u062C\u0631 \u0628\u0648\u0627\u0633\u0637\u0629 \u0627\u0644\u0646\u062C\u0645\u0627\u062A" }, index.h("input", { type: "hidden", name: "order_id", value: this.order.order_id }), index.h("input", { type: "hidden", name: "type", value: "store" }), index.h("h2", { class: "section-title text-lg font-bold mb-5" }, "\u0643\u064A\u0641 \u0643\u0627\u0646\u062A \u062A\u062C\u0631\u0628\u062A\u0643 \u0645\u0639 \u0627\u0644\u0645\u062A\u062C\u0631 \u0647\u0630\u0647 \u0627\u0644\u0645\u0631\u0629"), index.h("div", { class: "mb-2" }, index.h("textarea", { id: "storeReview", name: "comment", class: "form-input comment h-20", placeholder: "\u0627\u0636\u0641 \u0631\u0623\u064A\u0643 \u0639\u0646 \u0627\u0644\u0645\u062A\u062C\u0631.." })), index.h("div", { class: "rating-wrap flex items-center space-s-4" }, index.h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating()), index.h("p", { class: "rate-label fix-align font-sm center mb-0" })), index.h("small", { class: "text-red-400 validation-message" }))));
|
|
82
|
-
}
|
|
83
|
-
renderShippingRating() {
|
|
84
|
-
return (index.h("section", { class: "step rating-section bg-white my-10 p-5 rounded-md mb-5 hidden", "data-type": "shipping" }, index.h("div", { class: "rating-outer-form", "data-stars-error": "\u064A\u0631\u062C\u0649 \u062A\u0642\u064A\u064A\u0645 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646 \u0628\u0648\u0627\u0633\u0637\u0629 \u0627\u0644\u0646\u062C\u0645\u0627\u062A" }, index.h("input", { type: "hidden", name: "order_id", value: this.order.order_id }), index.h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }), index.h("input", { type: "hidden", name: "type", value: "shipping" }), index.h("h2", { class: "section-title text-lg font-bold mb-5" }, "\u062E\u0628\u0631\u0646\u0627 \u0639\u0646 \u062A\u062C\u0631\u0628\u062A\u0643 \u0645\u0639 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646"), index.h("div", { class: "mb-2" }, index.h("textarea", { id: "shippingReview", name: "comment", class: "form-input comment h-20 mb-2", placeholder: "\u0627\u0636\u0641 \u0631\u0623\u064A\u0643 \u0639\u0646 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646" })), index.h("div", { class: "rating-wrap flex items-center space-s-4" }, index.h("form", { class: "rate-element ratFeedbackPresentere-element--has-label" }, this.getStarsRating()), index.h("p", { class: "rate-label fix-align font-sm center mb-0" })), index.h("small", { class: "text-red-400 validation-message" }))));
|
|
85
|
-
}
|
|
86
|
-
getStarsRating() {
|
|
87
|
-
return (index.h("div", { class: "mb-1" }, index.h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }), this.stars.map((star) => index.h("button", { type: "submit", class: "btn btn--transparent px-1 text-lg text-gray-400 btn--star", "data-star": star, "data-text": this.order.ratingMessage[`${star}`] }, index.h("i", { class: "sicon-star2" })))));
|
|
88
|
-
}
|
|
89
|
-
initiateRating() {
|
|
90
|
-
this.highlightSelectedStars();
|
|
91
|
-
this.starsRating();
|
|
92
|
-
this.handleWizard();
|
|
93
|
-
//show submitRating Button Only When there is a comment field
|
|
94
|
-
// Helper.toggle('#submitRating', 'btn', 'hidden', () => Helper.element('#shippingReview,#storeReview,.product-review'))
|
|
95
|
-
// this.ratingChain = Promise.resolve();
|
|
96
|
-
// Helper.onClick('#submitRating', () => this.sendRating().then(() => window.location.reload()));
|
|
97
|
-
salla.event.on('submit::order-rating', () => this.sendRating().then(() => window.location.reload()));
|
|
98
|
-
}
|
|
99
|
-
handleWizard() {
|
|
100
|
-
let steps = document.querySelectorAll(".step"), stepsCount = document.querySelectorAll(".step").length;
|
|
101
|
-
Helper.Helper.onClick("#prev-btn", () => {
|
|
102
|
-
this.wizardInex > 0 && this.wizardInex--;
|
|
103
|
-
this.showActiveStep(steps);
|
|
104
|
-
this.wizardInex == 0 && Helper.Helper.toggle('#prev-btn', 'hidden', 'block', () => true);
|
|
105
|
-
});
|
|
106
|
-
Helper.Helper.onClick("#next-btn", () => {
|
|
107
|
-
this.ratingValidation();
|
|
108
|
-
this.wizardInex == stepsCount - 1 && salla.event.dispatch("submit::order-rating");
|
|
109
|
-
this.wizardInex < stepsCount - 1 && this.wizardInex++;
|
|
110
|
-
this.showActiveStep(steps);
|
|
111
|
-
Helper.Helper.toggle('#prev-btn', 'block', 'hidden', () => true);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
showActiveStep(steps) {
|
|
115
|
-
Helper.Helper.toggle('.step', 'hidden', 'active', () => true);
|
|
116
|
-
Helper.Helper.toggleElement(steps[this.wizardInex], 'active', 'hidden', () => true);
|
|
117
|
-
}
|
|
118
|
-
sendRating() {
|
|
119
|
-
// this.ratingValidation()
|
|
120
|
-
Helper.Helper.all('.rating-section', ratingSection => {
|
|
121
|
-
let type = ratingSection.dataset.type;
|
|
122
|
-
let formsData = [];
|
|
123
|
-
ratingSection.querySelectorAll('.rating-outer-form')
|
|
124
|
-
.forEach((form) => {
|
|
125
|
-
let formData = {};
|
|
126
|
-
form.querySelectorAll('[name]')
|
|
127
|
-
.forEach(function (input) {
|
|
128
|
-
let inputData = salla.helpers.inputData(input.name, input.value, formData);
|
|
129
|
-
formData[inputData.name] = inputData.value;
|
|
130
|
-
});
|
|
131
|
-
formsData = [];
|
|
132
|
-
formsData.push(formData);
|
|
133
|
-
this.sendFeedback(type, formsData);
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
return this.ratingChain;
|
|
137
|
-
}
|
|
138
|
-
sendFeedback(type, formsData) {
|
|
139
|
-
if (!formsData || formsData.length == 0) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
salla.config.canLeave = false;
|
|
143
|
-
this.ratingChain = salla.feedback.api[type](formsData[0])
|
|
144
|
-
.then(function () {
|
|
145
|
-
salla.config.canLeave = true;
|
|
146
|
-
}).catch(() => salla.config.canLeave = true);
|
|
147
|
-
}
|
|
148
|
-
ratingValidation() {
|
|
149
|
-
let errorMsg = '';
|
|
150
|
-
document.querySelectorAll('.rating-section.active')
|
|
151
|
-
.forEach((ratingSection) => {
|
|
152
|
-
ratingSection.querySelectorAll('.rating-outer-form')
|
|
153
|
-
.forEach((rating) => {
|
|
154
|
-
let ratingInput = rating.querySelector('.rating_hidden_input');
|
|
155
|
-
let commentInput = rating.querySelector('.comment');
|
|
156
|
-
let sectionTitle = rating.querySelector('.section-title');
|
|
157
|
-
let validationMessage = rating.querySelector('.validation-message');
|
|
158
|
-
if (ratingInput.value && commentInput.value && commentInput.value.length > 3) {
|
|
159
|
-
commentInput.classList.remove('has-error');
|
|
160
|
-
sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.classList.remove('has-error', 'text-red-400');
|
|
161
|
-
validationMessage.innerHTML = '';
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
else if (commentInput.value && commentInput.value.length > 3) {
|
|
165
|
-
commentInput.classList.remove('has-error');
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
commentInput.classList.add('has-error');
|
|
169
|
-
}
|
|
170
|
-
sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.classList.add('has-error', 'text-red-400');
|
|
171
|
-
errorMsg = ratingInput.value
|
|
172
|
-
? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + commentInput.getAttribute('placeholder'))
|
|
173
|
-
: (rating.dataset.starsError || salla.lang.get('pages.rating.rate_store_stars'));
|
|
174
|
-
validationMessage.innerHTML = errorMsg;
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
//Fire error to prevent sending rating
|
|
178
|
-
if (errorMsg) {
|
|
179
|
-
// scroll to first error
|
|
180
|
-
let ratingErrors = document.querySelectorAll('.has-error');
|
|
181
|
-
if (ratingErrors.length) {
|
|
182
|
-
let firstError = ratingErrors[0].offsetTop;
|
|
183
|
-
window.scrollTo({ top: firstError - 80 }); // 80 = fixed nav height
|
|
184
|
-
}
|
|
185
|
-
throw new Error(errorMsg);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
// for hovered star ---
|
|
189
|
-
highlightSelectedStars() {
|
|
190
|
-
let hover = ['hovered', 'text-theme-yellow'];
|
|
191
|
-
Helper.Helper.all('.rate-element', el => {
|
|
192
|
-
let starElements = el.querySelectorAll('.btn--star');
|
|
193
|
-
// remove hovered state from stars ---
|
|
194
|
-
el.addEventListener('mouseout', () => el.querySelectorAll('.btn--star').forEach(star => star.classList.remove(...hover)));
|
|
195
|
-
starElements.forEach((starElement, index) => {
|
|
196
|
-
starElement.addEventListener('mouseover', () => {
|
|
197
|
-
starElement.classList.add(...hover);
|
|
198
|
-
if (index <= 1) {
|
|
199
|
-
starElement.previousElementSibling.tagName === 'BUTTON' ? starElement.previousElementSibling.classList.add(...hover) : null;
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
for (let i = 0; i < index; i++) {
|
|
203
|
-
starElements[i].classList.add(...hover);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
starElement.addEventListener('mouseout', () => {
|
|
208
|
-
starElement.classList.contains(...hover) ? starElement.classList.remove(...hover) : null;
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
starsRating() {
|
|
214
|
-
let selectedClasses = ['selected', 'text-theme-yellow'];
|
|
215
|
-
// Listen for form submissions
|
|
216
|
-
salla.document.event.onSubmit('.rate-element', function (event) {
|
|
217
|
-
// Prevent form from submitting
|
|
218
|
-
event.preventDefault();
|
|
219
|
-
// Get the selected star - activeElement is not supported in safari
|
|
220
|
-
var activeStars = event.target.querySelectorAll('.btn--star.hovered');
|
|
221
|
-
var selected = activeStars[activeStars.length - 1];
|
|
222
|
-
if (!selected)
|
|
223
|
-
return;
|
|
224
|
-
var selectedIndex = parseInt(selected.dataset.star, 10), selectedText = selected.dataset.text;
|
|
225
|
-
event.target.nextElementSibling.innerHTML = selectedText;
|
|
226
|
-
event.target.querySelector('.rating_hidden_input').value = selectedIndex;
|
|
227
|
-
// Get all stars in this form (only search in the form, not the whole document)
|
|
228
|
-
// Loop through each star, and add or remove the `.selected` class to toggle highlighting
|
|
229
|
-
event.target
|
|
230
|
-
.querySelectorAll('.btn--star')
|
|
231
|
-
.forEach(function (star, index) {
|
|
232
|
-
if (index < selectedIndex) {
|
|
233
|
-
// Selected star or before it, Add highlighting
|
|
234
|
-
star.classList.add(...selectedClasses);
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
// After selected star, Remove highlight
|
|
238
|
-
star.classList.remove(...selectedClasses);
|
|
239
|
-
});
|
|
240
|
-
// Remove aria-pressed from any previously selected star
|
|
241
|
-
var previousRating = event.target.querySelector('.star[aria-pressed="true"]');
|
|
242
|
-
if (previousRating) {
|
|
243
|
-
previousRating.removeAttribute('aria-pressed');
|
|
244
|
-
}
|
|
245
|
-
// Add aria-pressed role to the selected button
|
|
246
|
-
selected.setAttribute('aria-pressed', true);
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
OrderRating.style = orderRatingCss;
|
|
251
|
-
|
|
252
|
-
exports.order_rating = OrderRating;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-23da2c6b.js');
|
|
6
|
-
const Helper = require('./Helper-8c75b6ac.js');
|
|
7
|
-
|
|
8
|
-
const sallaButtonCss = ":host{display:block}";
|
|
9
|
-
|
|
10
|
-
const SallaButton = class {
|
|
11
|
-
constructor(hostRef) {
|
|
12
|
-
index.registerInstance(this, hostRef);
|
|
13
|
-
this.kind = 'primary';
|
|
14
|
-
this.loading = false;
|
|
15
|
-
this.disabled = false;
|
|
16
|
-
this.hostAttributes = {};
|
|
17
|
-
for (let i = 0; i < this.host.attributes.length; i++) {
|
|
18
|
-
this.hostAttributes[this.host.attributes[i].name] = this.host.attributes[i].value;
|
|
19
|
-
}
|
|
20
|
-
this.hostAttributes['type'] = this.hostAttributes['type'] || 'button';
|
|
21
|
-
this.hostAttributes['class'] = (this.hostAttributes['class'] || '') + ' s-button-btn btn--has-loading btn-' + this.kind;
|
|
22
|
-
delete this.hostAttributes['kind'];
|
|
23
|
-
delete this.hostAttributes['id'];
|
|
24
|
-
}
|
|
25
|
-
async load() {
|
|
26
|
-
this.host.setAttribute('loading', '');
|
|
27
|
-
return this.host;
|
|
28
|
-
}
|
|
29
|
-
async stop() {
|
|
30
|
-
this.host.removeAttribute('loading');
|
|
31
|
-
return this.host;
|
|
32
|
-
}
|
|
33
|
-
async disable() {
|
|
34
|
-
this.host.setAttribute('disabled', '');
|
|
35
|
-
}
|
|
36
|
-
async enable() {
|
|
37
|
-
this.host.removeAttribute('disabled');
|
|
38
|
-
}
|
|
39
|
-
handleVisible(newKind, oldKind) {
|
|
40
|
-
this.btn.classList.remove('btn-' + oldKind);
|
|
41
|
-
this.btn.classList.add('btn-' + newKind);
|
|
42
|
-
}
|
|
43
|
-
handleLoading(newVal) {
|
|
44
|
-
Helper.Helper.toggleElement(this.btn, 'btn--is-loading', 'btn--no-loading', () => newVal);
|
|
45
|
-
}
|
|
46
|
-
render() {
|
|
47
|
-
return (index.h("button", Object.assign({ ref: btn => this.btn = btn, disabled: this.disabled }, this.hostAttributes), index.h("slot", null), this.loading ? index.h("span", { class: "loader loader--small s-button-loader" }) : ''));
|
|
48
|
-
}
|
|
49
|
-
get host() { return index.getElement(this); }
|
|
50
|
-
static get watchers() { return {
|
|
51
|
-
"kind": ["handleVisible"],
|
|
52
|
-
"loading": ["handleLoading"]
|
|
53
|
-
}; }
|
|
54
|
-
};
|
|
55
|
-
SallaButton.style = sallaButtonCss;
|
|
56
|
-
|
|
57
|
-
exports.salla_button = SallaButton;
|
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
import { Component, Host, h, Prop } from '@stencil/core';
|
|
2
|
-
import Helper from "../../Helpers/Helper";
|
|
3
|
-
export class OrderRating {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.stars = [1, 2, 3, 4, 5];
|
|
6
|
-
this.order = {
|
|
7
|
-
shipping: { id: 5622 },
|
|
8
|
-
order_id: "179794",
|
|
9
|
-
products: [
|
|
10
|
-
{
|
|
11
|
-
"title": "ميكروفون عالى الجودة",
|
|
12
|
-
"image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg",
|
|
13
|
-
"price": "10,978.00 ر.س",
|
|
14
|
-
"qty": "2",
|
|
15
|
-
"totalBefore": "1120 ر.س",
|
|
16
|
-
"discount": "-5%",
|
|
17
|
-
"total": "1064 ر.س",
|
|
18
|
-
"id": "2314513454",
|
|
19
|
-
"getOptimusRouteKey": "7351233357"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"title": "وحدة تحكم لمشغل العاب",
|
|
23
|
-
"image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/NOa4kHvOkd1hBWHk3JIgAo1602oVACfuWGFz3vXv.jpg",
|
|
24
|
-
"price": "10,978.00 ر.س",
|
|
25
|
-
"qty": "2",
|
|
26
|
-
"totalBefore": "1120 ر.س",
|
|
27
|
-
"discount": "-5%",
|
|
28
|
-
"total": "1064 ر.س",
|
|
29
|
-
"id": "9842833",
|
|
30
|
-
"getOptimusRouteKey": "735152357"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"title": "ساعة ذكية بنظام اندرويد",
|
|
34
|
-
"image": "https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg",
|
|
35
|
-
"price": "10,978.00 ر.س",
|
|
36
|
-
"qty": "2",
|
|
37
|
-
"totalBefore": "1120 ر.س",
|
|
38
|
-
"discount": "-5%",
|
|
39
|
-
"total": "1064 ر.س",
|
|
40
|
-
"id": "679822376",
|
|
41
|
-
"getOptimusRouteKey": "73233357"
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
ratingMessage: {
|
|
45
|
-
1: "غير راضي <span class='emoji mx-1'>😒</span>",
|
|
46
|
-
2: "لم يعجبني <span class='emoji mx-1'>😌</span>",
|
|
47
|
-
3: "معقول <span class='emoji mx-1'>🙄</span>",
|
|
48
|
-
4: "أعجبني <span class='emoji mx-1'>👍</span>",
|
|
49
|
-
5: "أعجبني جداً <span class='emoji mx-1'>🤩</span>"
|
|
50
|
-
},
|
|
51
|
-
settings: {
|
|
52
|
-
isProductsRating: true,
|
|
53
|
-
isStoreRating: true,
|
|
54
|
-
isShippingRating: true,
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
this.ratingChain = Promise.resolve();
|
|
58
|
-
this.wizardInex = 0;
|
|
59
|
-
}
|
|
60
|
-
componentDidRender() {
|
|
61
|
-
this.initiateRating();
|
|
62
|
-
}
|
|
63
|
-
render() {
|
|
64
|
-
return (h(Host, null,
|
|
65
|
-
h("div", { class: "pannel__body" },
|
|
66
|
-
this.order.settings.isStoreRating && this.renderStoreRating(),
|
|
67
|
-
this.order.settings.isProductsRating && this.renderProductsRating(),
|
|
68
|
-
this.order.settings.isShippingRating && this.renderShippingRating()),
|
|
69
|
-
h("div", { class: "pannel__footer relative flex justify-between items-center" },
|
|
70
|
-
h("button", { id: "prev-btn", class: "font-bold text-sm text-primary hidden" }, "\u0627\u0644\u0633\u0627\u0628\u0642"),
|
|
71
|
-
h("ul", { class: "flex justify-center text-center space-s-1.5 py-8 flex-1" },
|
|
72
|
-
h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-primary rounded-full transition-colors duration-300" }),
|
|
73
|
-
h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-gray-200 rounded-full transition-colors duration-300" }),
|
|
74
|
-
h("li", { class: "cursor-pointer w-2.5 h-2.5 bg-gray-200 rounded-full transition-colors duration-300" })),
|
|
75
|
-
h("button", { id: "next-btn", class: "btn btn-primary h-10 px-8 flex-none" }, "\u0627\u0644\u062A\u0627\u0644\u064A"))));
|
|
76
|
-
}
|
|
77
|
-
renderProductsRating() {
|
|
78
|
-
return (h("section", { class: "step rating-section products-section hidden", "data-type": "product" },
|
|
79
|
-
h("div", { class: "bg-white mb-5 p-5 rounded-md overflow-hidden mb-10" }, this.order.products.map((item, index) => {
|
|
80
|
-
var _a;
|
|
81
|
-
return h("div", { class: "rating-outer-form", "data-stars-error": `يرجى تقييم (${item.title}) بواسطة النجمات` },
|
|
82
|
-
h("div", { class: "product-item mb-4" },
|
|
83
|
-
h("div", { class: "mb-5" },
|
|
84
|
-
h("div", { class: "flex space-s-5 mb-8" },
|
|
85
|
-
h("img", { src: item.image, alt: item.title, class: "w-18 h-14 object-cover rounded-md" }),
|
|
86
|
-
h("div", { class: "flex-1" },
|
|
87
|
-
h("h3", { class: "section-title leading-5 mb-1.5 md:text-base" },
|
|
88
|
-
" ",
|
|
89
|
-
item.title),
|
|
90
|
-
h("div", { class: "rw-product-entry__rate" },
|
|
91
|
-
h("div", { class: "rating-wrap flex items-center space-s-4" },
|
|
92
|
-
h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating()),
|
|
93
|
-
h("p", { class: "rate-label fix-align font-xsm my-0" })),
|
|
94
|
-
h("input", { type: "hidden", name: "order_id", value: (_a = this.order) === null || _a === void 0 ? void 0 : _a.order_id }),
|
|
95
|
-
h("input", { type: "hidden", name: `products[${index}][product_id]`, value: item.getOptimusRouteKey }),
|
|
96
|
-
h("input", { type: "hidden", name: "type", value: "products" }),
|
|
97
|
-
h("textarea", { "data-product-id": item.id, name: `products[${index}][comment]`, id: `productReview_${item.id}`, class: "comment form-input h-20 product-review", placeholder: `اضف رأيك عن المنتج (${item.title})` }),
|
|
98
|
-
h("small", { class: "text-red-400 validation-message" })))))));
|
|
99
|
-
}))));
|
|
100
|
-
}
|
|
101
|
-
renderStoreRating() {
|
|
102
|
-
return (h("section", { class: "step rating-section bg-white my-10 p-5 rounded-md mb-5 active", "data-type": "store" },
|
|
103
|
-
h("div", { class: "rating-outer-form", "data-stars-error": "\u064A\u0631\u062C\u0649 \u062A\u0642\u064A\u064A\u0645 \u0627\u0644\u0645\u062A\u062C\u0631 \u0628\u0648\u0627\u0633\u0637\u0629 \u0627\u0644\u0646\u062C\u0645\u0627\u062A" },
|
|
104
|
-
h("input", { type: "hidden", name: "order_id", value: this.order.order_id }),
|
|
105
|
-
h("input", { type: "hidden", name: "type", value: "store" }),
|
|
106
|
-
h("h2", { class: "section-title text-lg font-bold mb-5" }, "\u0643\u064A\u0641 \u0643\u0627\u0646\u062A \u062A\u062C\u0631\u0628\u062A\u0643 \u0645\u0639 \u0627\u0644\u0645\u062A\u062C\u0631 \u0647\u0630\u0647 \u0627\u0644\u0645\u0631\u0629"),
|
|
107
|
-
h("div", { class: "mb-2" },
|
|
108
|
-
h("textarea", { id: "storeReview", name: "comment", class: "form-input comment h-20", placeholder: "\u0627\u0636\u0641 \u0631\u0623\u064A\u0643 \u0639\u0646 \u0627\u0644\u0645\u062A\u062C\u0631.." })),
|
|
109
|
-
h("div", { class: "rating-wrap flex items-center space-s-4" },
|
|
110
|
-
h("form", { class: "rate-element rate-element--has-label" }, this.getStarsRating()),
|
|
111
|
-
h("p", { class: "rate-label fix-align font-sm center mb-0" })),
|
|
112
|
-
h("small", { class: "text-red-400 validation-message" }))));
|
|
113
|
-
}
|
|
114
|
-
renderShippingRating() {
|
|
115
|
-
return (h("section", { class: "step rating-section bg-white my-10 p-5 rounded-md mb-5 hidden", "data-type": "shipping" },
|
|
116
|
-
h("div", { class: "rating-outer-form", "data-stars-error": "\u064A\u0631\u062C\u0649 \u062A\u0642\u064A\u064A\u0645 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646 \u0628\u0648\u0627\u0633\u0637\u0629 \u0627\u0644\u0646\u062C\u0645\u0627\u062A" },
|
|
117
|
-
h("input", { type: "hidden", name: "order_id", value: this.order.order_id }),
|
|
118
|
-
h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.id }),
|
|
119
|
-
h("input", { type: "hidden", name: "type", value: "shipping" }),
|
|
120
|
-
h("h2", { class: "section-title text-lg font-bold mb-5" }, "\u062E\u0628\u0631\u0646\u0627 \u0639\u0646 \u062A\u062C\u0631\u0628\u062A\u0643 \u0645\u0639 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646"),
|
|
121
|
-
h("div", { class: "mb-2" },
|
|
122
|
-
h("textarea", { id: "shippingReview", name: "comment", class: "form-input comment h-20 mb-2", placeholder: "\u0627\u0636\u0641 \u0631\u0623\u064A\u0643 \u0639\u0646 \u0634\u0631\u0643\u0629 \u0627\u0644\u0634\u062D\u0646" })),
|
|
123
|
-
h("div", { class: "rating-wrap flex items-center space-s-4" },
|
|
124
|
-
h("form", { class: "rate-element ratFeedbackPresentere-element--has-label" }, this.getStarsRating()),
|
|
125
|
-
h("p", { class: "rate-label fix-align font-sm center mb-0" })),
|
|
126
|
-
h("small", { class: "text-red-400 validation-message" }))));
|
|
127
|
-
}
|
|
128
|
-
getStarsRating() {
|
|
129
|
-
return (h("div", { class: "mb-1" },
|
|
130
|
-
h("input", { type: "hidden", class: "rating_hidden_input", name: "rating", value: "" }),
|
|
131
|
-
this.stars.map((star) => h("button", { type: "submit", class: "btn btn--transparent px-1 text-lg text-gray-400 btn--star", "data-star": star, "data-text": this.order.ratingMessage[`${star}`] },
|
|
132
|
-
h("i", { class: "sicon-star2" })))));
|
|
133
|
-
}
|
|
134
|
-
initiateRating() {
|
|
135
|
-
this.highlightSelectedStars();
|
|
136
|
-
this.starsRating();
|
|
137
|
-
this.handleWizard();
|
|
138
|
-
//show submitRating Button Only When there is a comment field
|
|
139
|
-
// Helper.toggle('#submitRating', 'btn', 'hidden', () => Helper.element('#shippingReview,#storeReview,.product-review'))
|
|
140
|
-
// this.ratingChain = Promise.resolve();
|
|
141
|
-
// Helper.onClick('#submitRating', () => this.sendRating().then(() => window.location.reload()));
|
|
142
|
-
salla.event.on('submit::order-rating', () => this.sendRating().then(() => window.location.reload()));
|
|
143
|
-
}
|
|
144
|
-
handleWizard() {
|
|
145
|
-
let steps = document.querySelectorAll(".step"), stepsCount = document.querySelectorAll(".step").length;
|
|
146
|
-
Helper.onClick("#prev-btn", () => {
|
|
147
|
-
this.wizardInex > 0 && this.wizardInex--;
|
|
148
|
-
this.showActiveStep(steps);
|
|
149
|
-
this.wizardInex == 0 && Helper.toggle('#prev-btn', 'hidden', 'block', () => true);
|
|
150
|
-
});
|
|
151
|
-
Helper.onClick("#next-btn", () => {
|
|
152
|
-
this.ratingValidation();
|
|
153
|
-
this.wizardInex == stepsCount - 1 && salla.event.dispatch("submit::order-rating");
|
|
154
|
-
this.wizardInex < stepsCount - 1 && this.wizardInex++;
|
|
155
|
-
this.showActiveStep(steps);
|
|
156
|
-
Helper.toggle('#prev-btn', 'block', 'hidden', () => true);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
showActiveStep(steps) {
|
|
160
|
-
Helper.toggle('.step', 'hidden', 'active', () => true);
|
|
161
|
-
Helper.toggleElement(steps[this.wizardInex], 'active', 'hidden', () => true);
|
|
162
|
-
}
|
|
163
|
-
sendRating() {
|
|
164
|
-
// this.ratingValidation()
|
|
165
|
-
Helper.all('.rating-section', ratingSection => {
|
|
166
|
-
let type = ratingSection.dataset.type;
|
|
167
|
-
let formsData = [];
|
|
168
|
-
ratingSection.querySelectorAll('.rating-outer-form')
|
|
169
|
-
.forEach((form) => {
|
|
170
|
-
let formData = {};
|
|
171
|
-
form.querySelectorAll('[name]')
|
|
172
|
-
.forEach(function (input) {
|
|
173
|
-
let inputData = salla.helpers.inputData(input.name, input.value, formData);
|
|
174
|
-
formData[inputData.name] = inputData.value;
|
|
175
|
-
});
|
|
176
|
-
formsData = [];
|
|
177
|
-
formsData.push(formData);
|
|
178
|
-
this.sendFeedback(type, formsData);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
return this.ratingChain;
|
|
182
|
-
}
|
|
183
|
-
sendFeedback(type, formsData) {
|
|
184
|
-
if (!formsData || formsData.length == 0) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
salla.config.canLeave = false;
|
|
188
|
-
this.ratingChain = salla.feedback.api[type](formsData[0])
|
|
189
|
-
.then(function () {
|
|
190
|
-
salla.config.canLeave = true;
|
|
191
|
-
}).catch(() => salla.config.canLeave = true);
|
|
192
|
-
}
|
|
193
|
-
ratingValidation() {
|
|
194
|
-
let errorMsg = '';
|
|
195
|
-
document.querySelectorAll('.rating-section.active')
|
|
196
|
-
.forEach((ratingSection) => {
|
|
197
|
-
ratingSection.querySelectorAll('.rating-outer-form')
|
|
198
|
-
.forEach((rating) => {
|
|
199
|
-
let ratingInput = rating.querySelector('.rating_hidden_input');
|
|
200
|
-
let commentInput = rating.querySelector('.comment');
|
|
201
|
-
let sectionTitle = rating.querySelector('.section-title');
|
|
202
|
-
let validationMessage = rating.querySelector('.validation-message');
|
|
203
|
-
if (ratingInput.value && commentInput.value && commentInput.value.length > 3) {
|
|
204
|
-
commentInput.classList.remove('has-error');
|
|
205
|
-
sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.classList.remove('has-error', 'text-red-400');
|
|
206
|
-
validationMessage.innerHTML = '';
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
else if (commentInput.value && commentInput.value.length > 3) {
|
|
210
|
-
commentInput.classList.remove('has-error');
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
commentInput.classList.add('has-error');
|
|
214
|
-
}
|
|
215
|
-
sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.classList.add('has-error', 'text-red-400');
|
|
216
|
-
errorMsg = ratingInput.value
|
|
217
|
-
? (salla.lang.get('common.errors.not_less_than_chars', { chars: 4 }) + ' ' + commentInput.getAttribute('placeholder'))
|
|
218
|
-
: (rating.dataset.starsError || salla.lang.get('pages.rating.rate_store_stars'));
|
|
219
|
-
validationMessage.innerHTML = errorMsg;
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
//Fire error to prevent sending rating
|
|
223
|
-
if (errorMsg) {
|
|
224
|
-
// scroll to first error
|
|
225
|
-
let ratingErrors = document.querySelectorAll('.has-error');
|
|
226
|
-
if (ratingErrors.length) {
|
|
227
|
-
let firstError = ratingErrors[0].offsetTop;
|
|
228
|
-
window.scrollTo({ top: firstError - 80 }); // 80 = fixed nav height
|
|
229
|
-
}
|
|
230
|
-
throw new Error(errorMsg);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
// for hovered star ---
|
|
234
|
-
highlightSelectedStars() {
|
|
235
|
-
let hover = ['hovered', 'text-theme-yellow'];
|
|
236
|
-
Helper.all('.rate-element', el => {
|
|
237
|
-
let starElements = el.querySelectorAll('.btn--star');
|
|
238
|
-
// remove hovered state from stars ---
|
|
239
|
-
el.addEventListener('mouseout', () => el.querySelectorAll('.btn--star').forEach(star => star.classList.remove(...hover)));
|
|
240
|
-
starElements.forEach((starElement, index) => {
|
|
241
|
-
starElement.addEventListener('mouseover', () => {
|
|
242
|
-
starElement.classList.add(...hover);
|
|
243
|
-
if (index <= 1) {
|
|
244
|
-
starElement.previousElementSibling.tagName === 'BUTTON' ? starElement.previousElementSibling.classList.add(...hover) : null;
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
for (let i = 0; i < index; i++) {
|
|
248
|
-
starElements[i].classList.add(...hover);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
starElement.addEventListener('mouseout', () => {
|
|
253
|
-
starElement.classList.contains(...hover) ? starElement.classList.remove(...hover) : null;
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
starsRating() {
|
|
259
|
-
let selectedClasses = ['selected', 'text-theme-yellow'];
|
|
260
|
-
// Listen for form submissions
|
|
261
|
-
salla.document.event.onSubmit('.rate-element', function (event) {
|
|
262
|
-
// Prevent form from submitting
|
|
263
|
-
event.preventDefault();
|
|
264
|
-
// Get the selected star - activeElement is not supported in safari
|
|
265
|
-
var activeStars = event.target.querySelectorAll('.btn--star.hovered');
|
|
266
|
-
var selected = activeStars[activeStars.length - 1];
|
|
267
|
-
if (!selected)
|
|
268
|
-
return;
|
|
269
|
-
var selectedIndex = parseInt(selected.dataset.star, 10), selectedText = selected.dataset.text;
|
|
270
|
-
event.target.nextElementSibling.innerHTML = selectedText;
|
|
271
|
-
event.target.querySelector('.rating_hidden_input').value = selectedIndex;
|
|
272
|
-
// Get all stars in this form (only search in the form, not the whole document)
|
|
273
|
-
// Loop through each star, and add or remove the `.selected` class to toggle highlighting
|
|
274
|
-
event.target
|
|
275
|
-
.querySelectorAll('.btn--star')
|
|
276
|
-
.forEach(function (star, index) {
|
|
277
|
-
if (index < selectedIndex) {
|
|
278
|
-
// Selected star or before it, Add highlighting
|
|
279
|
-
star.classList.add(...selectedClasses);
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
// After selected star, Remove highlight
|
|
283
|
-
star.classList.remove(...selectedClasses);
|
|
284
|
-
});
|
|
285
|
-
// Remove aria-pressed from any previously selected star
|
|
286
|
-
var previousRating = event.target.querySelector('.star[aria-pressed="true"]');
|
|
287
|
-
if (previousRating) {
|
|
288
|
-
previousRating.removeAttribute('aria-pressed');
|
|
289
|
-
}
|
|
290
|
-
// Add aria-pressed role to the selected button
|
|
291
|
-
selected.setAttribute('aria-pressed', true);
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
static get is() { return "order-rating"; }
|
|
295
|
-
static get originalStyleUrls() { return {
|
|
296
|
-
"$": ["order-rating.css"]
|
|
297
|
-
}; }
|
|
298
|
-
static get styleUrls() { return {
|
|
299
|
-
"$": ["order-rating.css"]
|
|
300
|
-
}; }
|
|
301
|
-
static get properties() { return {
|
|
302
|
-
"order": {
|
|
303
|
-
"type": "any",
|
|
304
|
-
"mutable": false,
|
|
305
|
-
"complexType": {
|
|
306
|
-
"original": "any",
|
|
307
|
-
"resolved": "any",
|
|
308
|
-
"references": {}
|
|
309
|
-
},
|
|
310
|
-
"required": false,
|
|
311
|
-
"optional": false,
|
|
312
|
-
"docs": {
|
|
313
|
-
"tags": [],
|
|
314
|
-
"text": ""
|
|
315
|
-
},
|
|
316
|
-
"attribute": "order",
|
|
317
|
-
"reflect": false,
|
|
318
|
-
"defaultValue": "{\n shipping: { id: 5622 },\n order_id: \"179794\",\n products: [\n {\n \"title\": \"\u0645\u064A\u0643\u0631\u0648\u0641\u0648\u0646 \u0639\u0627\u0644\u0649 \u0627\u0644\u062C\u0648\u062F\u0629\",\n \"image\": \"https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/pMdEEyMVpZFj4L1Hrdm2g48AuiSx0TrKULBiOnPo.jpg\",\n \"price\": \"\u200F10,978.00 \u0631.\u0633\",\n \"qty\": \"\u200F2\",\n \"totalBefore\": \"\u200F1120 \u0631.\u0633\",\n \"discount\": \"-5%\",\n \"total\": \"\u200F1064 \u0631.\u0633\",\n \"id\": \"2314513454\",\n \"getOptimusRouteKey\": \"7351233357\"\n\n },\n {\n \"title\": \"\u0648\u062D\u062F\u0629 \u062A\u062D\u0643\u0645 \u0644\u0645\u0634\u063A\u0644 \u0627\u0644\u0639\u0627\u0628\",\n \"image\": \"https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/NOa4kHvOkd1hBWHk3JIgAo1602oVACfuWGFz3vXv.jpg\",\n \"price\": \"\u200F10,978.00 \u0631.\u0633\",\n \"qty\": \"\u200F2\",\n \"totalBefore\": \"\u200F1120 \u0631.\u0633\",\n \"discount\": \"-5%\",\n \"total\": \"\u200F1064 \u0631.\u0633\",\n \"id\": \"9842833\",\n \"getOptimusRouteKey\": \"735152357\"\n },\n {\n \"title\": \"\u0633\u0627\u0639\u0629 \u0630\u0643\u064A\u0629 \u0628\u0646\u0638\u0627\u0645 \u0627\u0646\u062F\u0631\u0648\u064A\u062F\",\n \"image\": \"https://salla-dev.s3.eu-central-1.amazonaws.com/Mvyk/T4kTqYNuPAZmPMLw1bx92RnjVMZyFszVXOUZQsFJ.jpg\",\n \"price\": \"\u200F10,978.00 \u0631.\u0633\",\n \"qty\": \"\u200F2\",\n \"totalBefore\": \"\u200F1120 \u0631.\u0633\",\n \"discount\": \"-5%\",\n \"total\": \"\u200F1064 \u0631.\u0633\",\n \"id\": \"679822376\",\n \"getOptimusRouteKey\": \"73233357\"\n\n }\n ],\n ratingMessage: {\n 1: \"\u063A\u064A\u0631 \u0631\u0627\u0636\u064A <span class='emoji mx-1'>\uD83D\uDE12</span>\",\n 2: \"\u0644\u0645 \u064A\u0639\u062C\u0628\u0646\u064A <span class='emoji mx-1'>\uD83D\uDE0C</span>\",\n 3: \"\u0645\u0639\u0642\u0648\u0644 <span class='emoji mx-1'>\uD83D\uDE44</span>\",\n 4: \"\u0623\u0639\u062C\u0628\u0646\u064A <span class='emoji mx-1'>\uD83D\uDC4D</span>\",\n 5: \"\u0623\u0639\u062C\u0628\u0646\u064A \u062C\u062F\u0627\u064B <span class='emoji mx-1'>\uD83E\uDD29</span>\"\n },\n\n settings: {\n isProductsRating: true,\n isStoreRating: true,\n isShippingRating: true,\n }\n }"
|
|
319
|
-
}
|
|
320
|
-
}; }
|
|
321
|
-
}
|