@recras/online-booking-js 2.0.9 → 2.1.0
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/.github/workflows/npmpublish.yml +2 -2
- package/.jshintrc +1 -1
- package/README.md +11 -11
- package/changelog.md +3 -0
- package/dist/onlinebooking.js +243 -778
- package/dist/onlinebooking.min.js +1 -1
- package/package.json +13 -13
- package/src/booking.js +1 -1
- package/src/contactForm.js +4 -0
package/dist/onlinebooking.js
CHANGED
|
@@ -3,74 +3,51 @@
|
|
|
3
3
|
function _objectValues(obj) {
|
|
4
4
|
var values = [];
|
|
5
5
|
var keys = Object.keys(obj);
|
|
6
|
-
|
|
7
6
|
for (var k = 0; k < keys.length; k++) values.push(obj[keys[k]]);
|
|
8
|
-
|
|
9
7
|
return values;
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
function _objectEntries(obj) {
|
|
13
10
|
var entries = [];
|
|
14
11
|
var keys = Object.keys(obj);
|
|
15
|
-
|
|
16
12
|
for (var k = 0; k < keys.length; k++) entries.push([keys[k], obj[keys[k]]]);
|
|
17
|
-
|
|
18
13
|
return entries;
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
26
|
-
|
|
15
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
16
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
17
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
18
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
27
19
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
28
|
-
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
32
|
-
|
|
33
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
34
|
-
|
|
20
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
21
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
22
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
35
23
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
36
|
-
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
46
|
-
|
|
47
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
48
|
-
|
|
49
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
50
|
-
|
|
24
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
25
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
26
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
27
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
28
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
29
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
30
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
31
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
32
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
51
33
|
/*******************************
|
|
52
34
|
* Recras integration library *
|
|
53
|
-
* v 2.0
|
|
35
|
+
* v 2.1.0 *
|
|
54
36
|
*******************************/
|
|
55
37
|
var RecrasBooking = /*#__PURE__*/function () {
|
|
56
38
|
function RecrasBooking() {
|
|
57
39
|
var _this = this;
|
|
58
|
-
|
|
59
40
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
60
|
-
|
|
61
41
|
_classCallCheck(this, RecrasBooking);
|
|
62
|
-
|
|
63
42
|
this.datePicker = null;
|
|
64
43
|
this.PAYMENT_DIRECT = 'mollie';
|
|
65
44
|
this.PAYMENT_AFTERWARDS = 'factuur';
|
|
66
45
|
this.RECRAS_INFINITY = 99999; // This is used instead of "true infinity" because JSON doesn't have infinity
|
|
67
46
|
|
|
68
47
|
this.languageHelper = new RecrasLanguageHelper();
|
|
69
|
-
|
|
70
48
|
if (!(options instanceof RecrasOptions)) {
|
|
71
49
|
throw new Error(this.languageHelper.translate('ERR_OPTIONS_INVALID'));
|
|
72
50
|
}
|
|
73
|
-
|
|
74
51
|
this.options = options;
|
|
75
52
|
this.eventHelper = new RecrasEventHelper();
|
|
76
53
|
this.eventHelper.setAnalytics(this.options.getAnalytics());
|
|
@@ -78,15 +55,12 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
78
55
|
var optionsPromise = this.languageHelper.setOptions(options);
|
|
79
56
|
this.element = this.options.getElement();
|
|
80
57
|
this.element.classList.add('recras-onlinebooking');
|
|
81
|
-
|
|
82
58
|
this.fetchJson = function (url) {
|
|
83
59
|
return RecrasHttpHelper.fetchJson(url, _this.error);
|
|
84
60
|
};
|
|
85
|
-
|
|
86
61
|
this.postJson = function (url, data) {
|
|
87
62
|
return RecrasHttpHelper.postJson(_this.options.getApiBase() + url, data, _this.error.bind(_this));
|
|
88
63
|
};
|
|
89
|
-
|
|
90
64
|
if (this.options.getLocale()) {
|
|
91
65
|
if (!RecrasLanguageHelper.isValid(this.options.getLocale())) {
|
|
92
66
|
console.warn(this.languageHelper.translate('ERR_INVALID_LOCALE', {
|
|
@@ -96,21 +70,17 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
96
70
|
this.languageHelper.setLocale(this.options.getLocale());
|
|
97
71
|
}
|
|
98
72
|
}
|
|
99
|
-
|
|
100
73
|
if (this.options.getPreFilledAmounts()) {
|
|
101
74
|
if (!this.options.isSinglePackage()) {
|
|
102
75
|
console.warn(this.languageHelper.translate('ERR_AMOUNTS_NO_PACKAGE'));
|
|
103
76
|
}
|
|
104
77
|
}
|
|
105
|
-
|
|
106
78
|
if (this.options.getPreFilledDate()) {
|
|
107
79
|
this.prefillDateIfPossible();
|
|
108
80
|
}
|
|
109
|
-
|
|
110
81
|
if (this.options.getPreFilledTime()) {
|
|
111
82
|
this.prefillTimeIfPossible();
|
|
112
83
|
}
|
|
113
|
-
|
|
114
84
|
RecrasCSSHelper.loadCSS('global');
|
|
115
85
|
RecrasCSSHelper.loadCSS('booking');
|
|
116
86
|
RecrasCSSHelper.loadCSS('pikaday');
|
|
@@ -125,45 +95,36 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
125
95
|
return _this.getPackages();
|
|
126
96
|
}).then(function (packages) {
|
|
127
97
|
_this.loadingIndicatorHide();
|
|
128
|
-
|
|
129
98
|
var pck = _this.options.getPackageId();
|
|
130
|
-
|
|
131
99
|
if (_this.options.isSinglePackage()) {
|
|
132
100
|
if (Array.isArray(pck)) {
|
|
133
101
|
pck = pck[0];
|
|
134
102
|
}
|
|
135
|
-
|
|
136
103
|
return _this.changePackage(pck);
|
|
137
104
|
} else if (Array.isArray(pck) && pck.length > 1) {
|
|
138
105
|
packages = packages.filter(function (p) {
|
|
139
106
|
return pck.includes(p.id);
|
|
140
107
|
});
|
|
141
108
|
}
|
|
142
|
-
|
|
143
109
|
return _this.showPackages(packages);
|
|
144
110
|
});
|
|
145
111
|
}
|
|
146
|
-
|
|
147
|
-
_createClass(RecrasBooking, [{
|
|
112
|
+
return _createClass(RecrasBooking, [{
|
|
148
113
|
key: "prefillDateIfPossible",
|
|
149
114
|
value: function prefillDateIfPossible() {
|
|
150
115
|
var date = new Date(this.options.getPreFilledDate());
|
|
151
|
-
|
|
152
116
|
if (isNaN(date.getTime())) {
|
|
153
117
|
console.warn(this.languageHelper.translate('ERR_INVALID_DATE'));
|
|
154
118
|
return false;
|
|
155
119
|
}
|
|
156
|
-
|
|
157
120
|
if (date < new Date()) {
|
|
158
121
|
console.warn(this.languageHelper.translate('ERR_DATE_PAST'));
|
|
159
122
|
return false;
|
|
160
123
|
}
|
|
161
|
-
|
|
162
124
|
if (!this.options.isSinglePackage()) {
|
|
163
125
|
console.warn(this.languageHelper.translate('ERR_DATE_NO_SINGLE_PACKAGE'));
|
|
164
126
|
return false;
|
|
165
127
|
}
|
|
166
|
-
|
|
167
128
|
this.prefilledDate = date;
|
|
168
129
|
return true;
|
|
169
130
|
}
|
|
@@ -171,12 +132,10 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
171
132
|
key: "prefillTimeIfPossible",
|
|
172
133
|
value: function prefillTimeIfPossible() {
|
|
173
134
|
var time = this.options.getPreFilledTime();
|
|
174
|
-
|
|
175
135
|
if (!time.match(/^(2[0-3]|[01]?[0-9]):([0-5]?[0-9])$/)) {
|
|
176
136
|
console.warn(this.languageHelper.translate('ERR_INVALID_TIME'));
|
|
177
137
|
return false;
|
|
178
138
|
}
|
|
179
|
-
|
|
180
139
|
this.prefilledTime = time;
|
|
181
140
|
return true;
|
|
182
141
|
}
|
|
@@ -186,18 +145,14 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
186
145
|
if (this.shouldShowBookingSize(pack) && this.bookingSize() > 0) {
|
|
187
146
|
return true;
|
|
188
147
|
}
|
|
189
|
-
|
|
190
148
|
var hasAtLeastOneProduct = false;
|
|
191
|
-
|
|
192
149
|
for (var _i2 = 0, _this$getLinesNoBooki2 = this.getLinesNoBookingSize(pack); _i2 < _this$getLinesNoBooki2.length; _i2++) {
|
|
193
150
|
var line = _this$getLinesNoBooki2[_i2];
|
|
194
151
|
var lineEl = this.findElement("[data-package-id=\"".concat(line.id, "\"]"));
|
|
195
|
-
|
|
196
152
|
if (lineEl && lineEl.value > 0) {
|
|
197
153
|
hasAtLeastOneProduct = true;
|
|
198
154
|
}
|
|
199
155
|
}
|
|
200
|
-
|
|
201
156
|
return hasAtLeastOneProduct;
|
|
202
157
|
}
|
|
203
158
|
}, {
|
|
@@ -206,33 +161,26 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
206
161
|
for (var _i4 = 0, _this$getLinesNoBooki4 = this.getLinesNoBookingSize(pack); _i4 < _this$getLinesNoBooki4.length; _i4++) {
|
|
207
162
|
var line = _this$getLinesNoBooki4[_i4];
|
|
208
163
|
var lineEl = this.findElement("[data-package-id=\"".concat(line.id, "\"]"));
|
|
209
|
-
|
|
210
164
|
if (!lineEl) {
|
|
211
165
|
console.warn("Element for line ".concat(line.id, " not found"));
|
|
212
166
|
return false;
|
|
213
167
|
}
|
|
214
|
-
|
|
215
168
|
var aantal = lineEl.value;
|
|
216
|
-
|
|
217
169
|
if (aantal > 0 && aantal < line.aantal_personen) {
|
|
218
170
|
return false;
|
|
219
171
|
}
|
|
220
|
-
|
|
221
172
|
if (aantal > 0 && line.min && aantal < line.min) {
|
|
222
173
|
return false;
|
|
223
174
|
}
|
|
224
|
-
|
|
225
175
|
if (line.max && aantal > line.max) {
|
|
226
176
|
return false;
|
|
227
177
|
}
|
|
228
178
|
}
|
|
229
|
-
|
|
230
179
|
if (this.shouldShowBookingSize(pack) && this.bookingSize() > 0) {
|
|
231
180
|
if (this.bookingSize() < this.bookingSizeMinimum(pack) || this.bookingSize() > this.bookingSizeMaximum(pack)) {
|
|
232
181
|
return false;
|
|
233
182
|
}
|
|
234
183
|
}
|
|
235
|
-
|
|
236
184
|
return this.hasAtLeastOneProduct(pack);
|
|
237
185
|
}
|
|
238
186
|
}, {
|
|
@@ -244,22 +192,18 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
244
192
|
key: "applyVoucher",
|
|
245
193
|
value: function applyVoucher(packageID, voucherCode) {
|
|
246
194
|
var _this2 = this;
|
|
247
|
-
|
|
248
195
|
if (!voucherCode) {
|
|
249
196
|
this.setDiscountStatus(this.languageHelper.translate('VOUCHER_EMPTY'));
|
|
250
197
|
return Promise.resolve(false);
|
|
251
198
|
}
|
|
252
|
-
|
|
253
199
|
if (this.appliedVouchers[voucherCode]) {
|
|
254
200
|
this.setDiscountStatus(this.languageHelper.translate('VOUCHER_ALREADY_APPLIED'));
|
|
255
201
|
return Promise.resolve(false);
|
|
256
202
|
}
|
|
257
|
-
|
|
258
203
|
if (!this.selectedDate) {
|
|
259
204
|
this.setDiscountStatus(this.languageHelper.translate('DATE_INVALID'));
|
|
260
205
|
return Promise.resolve(false);
|
|
261
206
|
}
|
|
262
|
-
|
|
263
207
|
return this.postJson('onlineboeking/controleervoucher', {
|
|
264
208
|
arrangement_id: packageID,
|
|
265
209
|
datum: RecrasDateHelper.datePartOnly(this.selectedDate),
|
|
@@ -267,15 +211,11 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
267
211
|
vouchers: [voucherCode]
|
|
268
212
|
}).then(function (json) {
|
|
269
213
|
var result = json[voucherCode];
|
|
270
|
-
|
|
271
214
|
if (!result.valid) {
|
|
272
215
|
return Promise.resolve(false);
|
|
273
216
|
}
|
|
274
|
-
|
|
275
217
|
_this2.appliedVouchers[voucherCode] = result.processed;
|
|
276
|
-
|
|
277
218
|
_this2.showTotalPrice();
|
|
278
|
-
|
|
279
219
|
return true;
|
|
280
220
|
});
|
|
281
221
|
}
|
|
@@ -283,17 +223,13 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
283
223
|
key: "recheckDiscountCode",
|
|
284
224
|
value: function recheckDiscountCode() {
|
|
285
225
|
var _this3 = this;
|
|
286
|
-
|
|
287
226
|
this.checkDiscountcode(this.selectedPackage.id, RecrasDateHelper.datePartOnly(this.selectedDate), this.discount.code).then(function (status) {
|
|
288
227
|
if (status) {
|
|
289
228
|
_this3.setDiscountStatus(_this3.languageHelper.translate('DISCOUNT_APPLIED'), false);
|
|
290
229
|
} else {
|
|
291
230
|
_this3.discount = null;
|
|
292
|
-
|
|
293
231
|
_this3.showTotalPrice();
|
|
294
|
-
|
|
295
232
|
var statusEl = _this3.findElement('.discount-status');
|
|
296
|
-
|
|
297
233
|
if (statusEl) {
|
|
298
234
|
statusEl.parentNode.removeChild(statusEl);
|
|
299
235
|
}
|
|
@@ -306,29 +242,23 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
306
242
|
var voucherCodes = Object.keys(this.appliedVouchers);
|
|
307
243
|
this.appliedVouchers = [];
|
|
308
244
|
var promises = [];
|
|
309
|
-
|
|
310
245
|
for (var _i6 = 0; _i6 < voucherCodes.length; _i6++) {
|
|
311
246
|
var voucherCode = voucherCodes[_i6];
|
|
312
247
|
promises.push(this.applyVoucher(this.selectedPackage.id, voucherCode));
|
|
313
248
|
}
|
|
314
|
-
|
|
315
249
|
return Promise.all(promises);
|
|
316
250
|
}
|
|
317
251
|
}, {
|
|
318
252
|
key: "bookingSize",
|
|
319
253
|
value: function bookingSize() {
|
|
320
254
|
var bookingSizeEl = this.findElement('.bookingsize');
|
|
321
|
-
|
|
322
255
|
if (!bookingSizeEl) {
|
|
323
256
|
return 0;
|
|
324
257
|
}
|
|
325
|
-
|
|
326
258
|
var bookingSizeValue = parseInt(bookingSizeEl.value, 10);
|
|
327
|
-
|
|
328
259
|
if (isNaN(bookingSizeValue)) {
|
|
329
260
|
return 0;
|
|
330
261
|
}
|
|
331
|
-
|
|
332
262
|
return bookingSizeValue;
|
|
333
263
|
}
|
|
334
264
|
}, {
|
|
@@ -344,11 +274,9 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
344
274
|
var lines = this.bookingSizeLines(pack).filter(function (line) {
|
|
345
275
|
return line.max;
|
|
346
276
|
});
|
|
347
|
-
|
|
348
277
|
if (lines.length === 0) {
|
|
349
278
|
return this.RECRAS_INFINITY;
|
|
350
279
|
}
|
|
351
|
-
|
|
352
280
|
var maxes = lines.map(function (line) {
|
|
353
281
|
return line.max;
|
|
354
282
|
});
|
|
@@ -360,18 +288,15 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
360
288
|
if (line.min) {
|
|
361
289
|
return line.min;
|
|
362
290
|
}
|
|
363
|
-
|
|
364
291
|
if (line.onlineboeking_aantalbepalingsmethode === 'vast') {
|
|
365
292
|
return 0;
|
|
366
293
|
}
|
|
367
|
-
|
|
368
294
|
return line.product.minimum_aantal;
|
|
369
295
|
}
|
|
370
296
|
}, {
|
|
371
297
|
key: "bookingSizeMinimum",
|
|
372
298
|
value: function bookingSizeMinimum(pack) {
|
|
373
299
|
var _this4 = this;
|
|
374
|
-
|
|
375
300
|
var minSize = 0;
|
|
376
301
|
this.bookingSizeLines(pack).forEach(function (line) {
|
|
377
302
|
minSize = Math.max(minSize, _this4.bookingSizeLineMinimum(line));
|
|
@@ -381,13 +306,13 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
381
306
|
}, {
|
|
382
307
|
key: "amountFromPersons",
|
|
383
308
|
value: function amountFromPersons(product, persons) {
|
|
384
|
-
return persons;
|
|
385
|
-
// aantalbepaling, aantal, per_x_personen_afronding, per_x_personen
|
|
309
|
+
return persons;
|
|
386
310
|
|
|
311
|
+
//TODO: this doesn't work yet because public product API does not send:
|
|
312
|
+
// aantalbepaling, aantal, per_x_personen_afronding, per_x_personen
|
|
387
313
|
if (product.aantalbepaling === 'vast') {
|
|
388
314
|
return product.aantal;
|
|
389
315
|
}
|
|
390
|
-
|
|
391
316
|
var fn = product.per_x_personen_afronding === 'beneden' ? Math.floor : Math.ceil;
|
|
392
317
|
return product.aantal * fn(persons / product.per_x_personen);
|
|
393
318
|
}
|
|
@@ -395,7 +320,6 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
395
320
|
key: "bookingSizePrice",
|
|
396
321
|
value: function bookingSizePrice(pack) {
|
|
397
322
|
var _this5 = this;
|
|
398
|
-
|
|
399
323
|
var nrOfPersons = Math.max(pack.aantal_personen, 1);
|
|
400
324
|
var price = 0;
|
|
401
325
|
var lines = this.bookingSizeLines(pack);
|
|
@@ -408,11 +332,9 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
408
332
|
key: "filterPackagesFromoptions",
|
|
409
333
|
value: function filterPackagesFromoptions(packages) {
|
|
410
334
|
var pck = this.options.getPackageId();
|
|
411
|
-
|
|
412
335
|
if (!Array.isArray(pck)) {
|
|
413
336
|
return packages;
|
|
414
337
|
}
|
|
415
|
-
|
|
416
338
|
return packages.filter(function (p) {
|
|
417
339
|
return pck.includes(p.id);
|
|
418
340
|
});
|
|
@@ -421,13 +343,11 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
421
343
|
key: "changePackage",
|
|
422
344
|
value: function changePackage(packageID) {
|
|
423
345
|
var _this6 = this;
|
|
424
|
-
|
|
425
346
|
var selectedPackage = this.packages.filter(function (p) {
|
|
426
347
|
return p.id === packageID;
|
|
427
348
|
});
|
|
428
349
|
this.appliedVouchers = {};
|
|
429
350
|
this.discount = null;
|
|
430
|
-
|
|
431
351
|
if (selectedPackage.length === 0) {
|
|
432
352
|
// Reset form
|
|
433
353
|
this.selectedPackage = null;
|
|
@@ -443,33 +363,24 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
443
363
|
item_id: selectedPackage[0].id
|
|
444
364
|
});
|
|
445
365
|
}
|
|
446
|
-
|
|
447
366
|
this.selectedPackage = selectedPackage[0];
|
|
448
367
|
return this.showProducts(this.selectedPackage).then(function () {
|
|
449
368
|
_this6.nextSectionActive('.recras-package-select', '.recras-amountsform');
|
|
450
|
-
|
|
451
369
|
_this6.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_PRODUCTS_SHOWN);
|
|
452
|
-
|
|
453
370
|
if (_this6.options.getAutoScroll() === true) {
|
|
454
371
|
var scrollOptions = {
|
|
455
372
|
behavior: 'smooth'
|
|
456
373
|
};
|
|
457
|
-
|
|
458
374
|
if (!('scrollBehavior' in document.documentElement.style)) {
|
|
459
375
|
scrollOptions = true;
|
|
460
376
|
}
|
|
461
|
-
|
|
462
377
|
_this6.findElement('.recras-amountsform').scrollIntoView(scrollOptions);
|
|
463
378
|
}
|
|
464
|
-
|
|
465
379
|
_this6.checkDependencies();
|
|
466
|
-
|
|
467
380
|
_this6.loadingIndicatorShow(_this6.findElement('.recras-amountsform'));
|
|
468
|
-
|
|
469
381
|
return _this6.showDateTimeSelection(_this6.selectedPackage);
|
|
470
382
|
}).then(function () {
|
|
471
383
|
_this6.loadingIndicatorHide();
|
|
472
|
-
|
|
473
384
|
_this6.showContactForm(_this6.selectedPackage);
|
|
474
385
|
});
|
|
475
386
|
}
|
|
@@ -479,41 +390,32 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
479
390
|
if (!this.shouldShowBookingSize(pack)) {
|
|
480
391
|
return;
|
|
481
392
|
}
|
|
482
|
-
|
|
483
393
|
var bookingSize = this.bookingSize();
|
|
484
394
|
var bsMaximum = this.bookingSizeMaximum(pack);
|
|
485
395
|
var bsMinimum = this.bookingSizeMinimum(pack);
|
|
486
|
-
|
|
487
396
|
if (bookingSize < bsMinimum) {
|
|
488
397
|
this.setMinMaxAmountWarning('bookingsize', bsMinimum, 'minimum');
|
|
489
398
|
} else if (bookingSize > bsMaximum) {
|
|
490
399
|
this.setMinMaxAmountWarning('bookingsize', bsMaximum, 'maximum');
|
|
491
400
|
}
|
|
492
|
-
|
|
493
401
|
this.maybeDisableBookButton();
|
|
494
402
|
}
|
|
495
403
|
}, {
|
|
496
404
|
key: "checkDependencies",
|
|
497
405
|
value: function checkDependencies() {
|
|
498
406
|
var _this7 = this;
|
|
499
|
-
|
|
500
407
|
_toConsumableArray(this.findElements('.recras-product-dependency')).forEach(function (el) {
|
|
501
408
|
el.parentNode.removeChild(el);
|
|
502
409
|
});
|
|
503
|
-
|
|
504
410
|
_toConsumableArray(this.findElements('[data-package-id]')).forEach(function (el) {
|
|
505
411
|
el.classList.remove('recras-input-invalid');
|
|
506
412
|
});
|
|
507
|
-
|
|
508
413
|
this.requiresProduct = false;
|
|
509
414
|
this.productCounts().forEach(function (line) {
|
|
510
415
|
if (line.aantal > 0) {
|
|
511
416
|
var packageLineID = line.arrangementsregel_id;
|
|
512
|
-
|
|
513
417
|
var product = _this7.findProduct(packageLineID).product;
|
|
514
|
-
|
|
515
418
|
var thisProductRequiresProduct = false;
|
|
516
|
-
|
|
517
419
|
if (!product.vereist_product) {
|
|
518
420
|
console.warn('You are logged in to this particular Recras. Because of API differences between logged-in and logged-out state, required products do not work as expected.');
|
|
519
421
|
} else {
|
|
@@ -521,26 +423,20 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
521
423
|
if (!_this7.dependencySatisfied(line.aantal, vp)) {
|
|
522
424
|
thisProductRequiresProduct = true;
|
|
523
425
|
_this7.requiresProduct = true;
|
|
524
|
-
|
|
525
426
|
var requiredAmount = _this7.requiredAmount(line.aantal, vp);
|
|
526
|
-
|
|
527
427
|
var requiredProductName = _this7.getProductByID(vp.vereist_product_id).weergavenaam;
|
|
528
|
-
|
|
529
428
|
var message = _this7.languageHelper.translate('PRODUCT_REQUIRED', {
|
|
530
429
|
NUM: line.aantal,
|
|
531
430
|
PRODUCT: product.weergavenaam,
|
|
532
431
|
REQUIRED_AMOUNT: requiredAmount,
|
|
533
432
|
REQUIRED_PRODUCT: requiredProductName
|
|
534
433
|
});
|
|
535
|
-
|
|
536
434
|
_this7.findElement('.recras-amountsform').insertAdjacentHTML('beforeend', "<span class=\"recras-product-dependency\">".concat(message, "</span>"));
|
|
537
435
|
}
|
|
538
436
|
});
|
|
539
437
|
}
|
|
540
|
-
|
|
541
438
|
if (thisProductRequiresProduct) {
|
|
542
439
|
var productInput = _this7.findElement("[data-package-id=\"".concat(packageLineID, "\"]"));
|
|
543
|
-
|
|
544
440
|
productInput.classList.add('recras-input-invalid');
|
|
545
441
|
}
|
|
546
442
|
}
|
|
@@ -551,27 +447,21 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
551
447
|
key: "checkDiscountAndVoucher",
|
|
552
448
|
value: function checkDiscountAndVoucher() {
|
|
553
449
|
var _this8 = this;
|
|
554
|
-
|
|
555
450
|
var discountPromise = this.checkDiscountcode(this.selectedPackage.id, RecrasDateHelper.datePartOnly(this.selectedDate), this.findElement('#discountcode').value.trim());
|
|
556
451
|
var voucherPromise = this.applyVoucher(this.selectedPackage.id, this.findElement('#discountcode').value.trim());
|
|
557
452
|
Promise.all([discountPromise, voucherPromise]).then(function (_ref) {
|
|
558
453
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
454
|
+
discountStatus = _ref2[0],
|
|
455
|
+
voucherStatus = _ref2[1];
|
|
562
456
|
if (discountStatus || voucherStatus) {
|
|
563
457
|
var status;
|
|
564
|
-
|
|
565
458
|
if (discountStatus) {
|
|
566
459
|
status = 'DISCOUNT_APPLIED';
|
|
567
460
|
} else {
|
|
568
461
|
status = 'VOUCHER_APPLIED';
|
|
569
462
|
}
|
|
570
|
-
|
|
571
463
|
_this8.setDiscountStatus(_this8.languageHelper.translate(status), false);
|
|
572
|
-
|
|
573
464
|
_this8.findElement('#discountcode').value = '';
|
|
574
|
-
|
|
575
465
|
_this8.nextSectionActive('.recras-discounts', '.recras-contactform');
|
|
576
466
|
} else {
|
|
577
467
|
_this8.setDiscountStatus(_this8.languageHelper.translate('DISCOUNT_INVALID'));
|
|
@@ -582,42 +472,33 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
582
472
|
key: "checkDiscountcode",
|
|
583
473
|
value: function checkDiscountcode(packageID, date, code) {
|
|
584
474
|
var _this9 = this;
|
|
585
|
-
|
|
586
475
|
return this.fetchJson(this.options.getApiBase() + 'onlineboeking/controleerkortingscode' + '?datum=' + date + '&arrangement=' + packageID + '&kortingscode=' + encodeURIComponent(code)).then(function (discount) {
|
|
587
476
|
if (discount === false) {
|
|
588
477
|
return false;
|
|
589
478
|
}
|
|
590
|
-
|
|
591
479
|
discount.code = code;
|
|
592
480
|
_this9.discount = discount;
|
|
593
|
-
|
|
594
481
|
_this9.showTotalPrice();
|
|
595
|
-
|
|
596
482
|
return true;
|
|
597
483
|
});
|
|
598
484
|
}
|
|
599
485
|
}, {
|
|
600
486
|
key: "checkMaximumForPackage",
|
|
601
487
|
value: function checkMaximumForPackage() {
|
|
602
|
-
var
|
|
603
|
-
|
|
488
|
+
var _this0 = this;
|
|
604
489
|
var maxPerLine = this.selectedPackage.maximum_aantal_personen_online;
|
|
605
|
-
|
|
606
490
|
if (maxPerLine === null) {
|
|
607
491
|
return Promise.resolve(null);
|
|
608
492
|
}
|
|
609
|
-
|
|
610
493
|
var showWarning = false;
|
|
611
494
|
var selectedProducts = this.productCounts();
|
|
612
495
|
return this.languageHelper.filterTags(this.texts.maximum_aantal_online_boeking_overschreden, this.selectedPackage ? this.selectedPackage.id : null).then(function (msg) {
|
|
613
496
|
selectedProducts.forEach(function (p) {
|
|
614
497
|
if (p.aantal > maxPerLine && !showWarning) {
|
|
615
|
-
var input =
|
|
616
|
-
|
|
498
|
+
var input = _this0.findElement("[data-package-id=\"".concat(p.arrangementsregel_id, "\"]"));
|
|
617
499
|
if (!input) {
|
|
618
|
-
input =
|
|
500
|
+
input = _this0.findElement('#bookingsize');
|
|
619
501
|
}
|
|
620
|
-
|
|
621
502
|
if (input) {
|
|
622
503
|
var warningEl = document.createElement('div');
|
|
623
504
|
warningEl.classList.add('maximum-amount');
|
|
@@ -626,9 +507,8 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
626
507
|
input.parentNode.parentNode.insertBefore(warningEl, input.parentNode.nextSibling);
|
|
627
508
|
input.classList.add('recras-input-invalid');
|
|
628
509
|
} else {
|
|
629
|
-
|
|
510
|
+
_this0.findElement('.recras-amountsform').insertAdjacentHTML('beforeend', "<span class=\"maximum-amount\">".concat(msg, "</span>"));
|
|
630
511
|
}
|
|
631
|
-
|
|
632
512
|
showWarning = true;
|
|
633
513
|
}
|
|
634
514
|
});
|
|
@@ -648,15 +528,12 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
648
528
|
var warnEl = document.createElement('span');
|
|
649
529
|
warnEl.classList.add(type + '-amount');
|
|
650
530
|
var lineEl = this.findElement("#".concat(lineID));
|
|
651
|
-
|
|
652
531
|
if (!lineEl) {
|
|
653
532
|
console.warn("Element for line ".concat(lineID, " not found"));
|
|
654
533
|
return false;
|
|
655
534
|
}
|
|
656
|
-
|
|
657
535
|
lineEl.classList.add('recras-input-invalid');
|
|
658
536
|
var text;
|
|
659
|
-
|
|
660
537
|
if (type === 'minimum') {
|
|
661
538
|
text = this.languageHelper.translate('PRODUCT_MINIMUM', {
|
|
662
539
|
MINIMUM: minAmount
|
|
@@ -666,7 +543,6 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
666
543
|
MAXIMUM: minAmount
|
|
667
544
|
});
|
|
668
545
|
}
|
|
669
|
-
|
|
670
546
|
warnEl.innerHTML = text;
|
|
671
547
|
var label = this.findElement("label[for=\"".concat(lineID, "\"]"));
|
|
672
548
|
label.parentNode.appendChild(warnEl);
|
|
@@ -676,20 +552,16 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
676
552
|
value: function checkMinMaxAmounts() {
|
|
677
553
|
for (var _i8 = 0, _this$productCounts2 = this.productCounts(); _i8 < _this$productCounts2.length; _i8++) {
|
|
678
554
|
var product = _this$productCounts2[_i8];
|
|
679
|
-
|
|
680
555
|
if (product.aantal < 1) {
|
|
681
556
|
continue;
|
|
682
557
|
}
|
|
683
|
-
|
|
684
558
|
var packageLineID = product.arrangementsregel_id;
|
|
685
559
|
var packageLine = this.findProduct(packageLineID);
|
|
686
560
|
var input = this.findElement("[data-package-id=\"".concat(packageLineID, "\"]"));
|
|
687
|
-
|
|
688
561
|
if (!input) {
|
|
689
562
|
// This is a "booking size" line - this is handled in checkBookingSize
|
|
690
563
|
continue;
|
|
691
564
|
}
|
|
692
|
-
|
|
693
565
|
if (product.aantal < packageLine.product.minimum_aantal) {
|
|
694
566
|
this.setMinMaxAmountWarning(input.id, packageLine.product.minimum_aantal, 'minimum');
|
|
695
567
|
} else if (packageLine.min !== undefined && product.aantal < packageLine.min) {
|
|
@@ -708,12 +580,10 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
708
580
|
key: "clearAllExceptPackageSelection",
|
|
709
581
|
value: function clearAllExceptPackageSelection() {
|
|
710
582
|
var packageSelect = this.findElement('.recras-package-select');
|
|
711
|
-
|
|
712
583
|
if (packageSelect) {
|
|
713
584
|
packageSelect.classList.remove('recras-completed');
|
|
714
585
|
packageSelect.classList.add('recras-active');
|
|
715
586
|
}
|
|
716
|
-
|
|
717
587
|
var elements = document.querySelectorAll('#' + this.element.id + ' > *:not(.recras-package-select)');
|
|
718
588
|
this.clearElements(elements);
|
|
719
589
|
}
|
|
@@ -723,35 +593,27 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
723
593
|
if (this.datePicker) {
|
|
724
594
|
this.datePicker.destroy();
|
|
725
595
|
}
|
|
726
|
-
|
|
727
596
|
this.availableDays = [];
|
|
728
|
-
|
|
729
597
|
_toConsumableArray(elements).forEach(function (el) {
|
|
730
598
|
el.parentNode.removeChild(el);
|
|
731
599
|
});
|
|
732
|
-
|
|
733
600
|
this.maybeAddLatestErrorElement();
|
|
734
601
|
}
|
|
735
602
|
}, {
|
|
736
603
|
key: "dependencySatisfied",
|
|
737
604
|
value: function dependencySatisfied(hasNow, requiredProduct) {
|
|
738
|
-
for (var
|
|
739
|
-
var line = _this$productCounts4[
|
|
740
|
-
|
|
605
|
+
for (var _i0 = 0, _this$productCounts4 = this.productCounts(); _i0 < _this$productCounts4.length; _i0++) {
|
|
606
|
+
var line = _this$productCounts4[_i0];
|
|
741
607
|
if (line.aantal === 0) {
|
|
742
608
|
continue;
|
|
743
609
|
}
|
|
744
|
-
|
|
745
610
|
var product = this.findProduct(line.arrangementsregel_id).product;
|
|
746
|
-
|
|
747
611
|
if (product.id !== parseInt(requiredProduct.vereist_product_id, 10)) {
|
|
748
612
|
continue;
|
|
749
613
|
}
|
|
750
|
-
|
|
751
614
|
var requiredAmount = this.requiredAmount(hasNow, requiredProduct);
|
|
752
615
|
return line.aantal >= requiredAmount;
|
|
753
616
|
}
|
|
754
|
-
|
|
755
617
|
return false;
|
|
756
618
|
}
|
|
757
619
|
}, {
|
|
@@ -759,11 +621,9 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
759
621
|
value: function error(msg) {
|
|
760
622
|
this.loadingIndicatorHide();
|
|
761
623
|
var bookingErrorsEl = this.findElement('#bookingErrors');
|
|
762
|
-
|
|
763
624
|
if (bookingErrorsEl) {
|
|
764
625
|
bookingErrorsEl.parentNode.appendChild(this.findElement('.latestError'));
|
|
765
626
|
}
|
|
766
|
-
|
|
767
627
|
this.maybeAddLatestErrorElement();
|
|
768
628
|
this.findElement('.latestError').innerHTML = "<strong>".concat(this.languageHelper.translate('ERR_GENERAL'), "</strong><p>").concat(msg, "</p>");
|
|
769
629
|
}
|
|
@@ -792,47 +652,42 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
792
652
|
}, {
|
|
793
653
|
key: "getAvailableDays",
|
|
794
654
|
value: function getAvailableDays(packageID, begin, end) {
|
|
795
|
-
var
|
|
796
|
-
|
|
655
|
+
var _this1 = this;
|
|
797
656
|
var postData = {
|
|
798
657
|
arrangement_id: packageID,
|
|
799
658
|
begin: RecrasDateHelper.datePartOnly(begin),
|
|
800
659
|
eind: RecrasDateHelper.datePartOnly(end),
|
|
801
660
|
producten: this.productCountsNoBookingSize()
|
|
802
661
|
};
|
|
803
|
-
|
|
804
662
|
if (this.shouldShowBookingSize(this.selectedPackage)) {
|
|
805
663
|
postData.boekingsgrootte = this.bookingSize();
|
|
806
664
|
}
|
|
807
|
-
|
|
808
665
|
return this.postJson('onlineboeking/beschikbaredagen', postData).then(function (json) {
|
|
809
|
-
|
|
810
|
-
return
|
|
666
|
+
_this1.availableDays = _this1.availableDays.concat(json);
|
|
667
|
+
return _this1.availableDays;
|
|
811
668
|
});
|
|
812
669
|
}
|
|
813
670
|
}, {
|
|
814
671
|
key: "getAvailableTimes",
|
|
815
672
|
value: function getAvailableTimes(packageID, date) {
|
|
816
|
-
var
|
|
817
|
-
|
|
673
|
+
var _this10 = this;
|
|
818
674
|
return this.postJson('onlineboeking/beschikbaretijden', {
|
|
819
675
|
arrangement_id: packageID,
|
|
820
676
|
datum: RecrasDateHelper.datePartOnly(date),
|
|
821
677
|
producten: this.productCounts()
|
|
822
678
|
}).then(function (json) {
|
|
823
|
-
|
|
824
|
-
return
|
|
679
|
+
_this10.availableTimes = json;
|
|
680
|
+
return _this10.availableTimes;
|
|
825
681
|
});
|
|
826
682
|
}
|
|
827
683
|
}, {
|
|
828
684
|
key: "getContactForm",
|
|
829
685
|
value: function getContactForm(pack) {
|
|
830
|
-
var
|
|
831
|
-
|
|
686
|
+
var _this11 = this;
|
|
832
687
|
this.options.setOption('form_id', pack.onlineboeking_contactformulier_id);
|
|
833
688
|
var contactForm = new RecrasContactForm(this.options);
|
|
834
689
|
return contactForm.getContactFormFields().then(function () {
|
|
835
|
-
|
|
690
|
+
_this11.contactForm = contactForm;
|
|
836
691
|
return contactForm;
|
|
837
692
|
});
|
|
838
693
|
}
|
|
@@ -842,7 +697,6 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
842
697
|
if (!discount) {
|
|
843
698
|
return 0;
|
|
844
699
|
}
|
|
845
|
-
|
|
846
700
|
return discount.percentage / 100 * this.getSubTotal() * -1;
|
|
847
701
|
}
|
|
848
702
|
}, {
|
|
@@ -862,11 +716,10 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
862
716
|
}, {
|
|
863
717
|
key: "getPackages",
|
|
864
718
|
value: function getPackages() {
|
|
865
|
-
var
|
|
866
|
-
|
|
719
|
+
var _this12 = this;
|
|
867
720
|
return this.fetchJson(this.options.getApiBase() + 'arrangementen').then(function (json) {
|
|
868
|
-
|
|
869
|
-
return
|
|
721
|
+
_this12.packages = json;
|
|
722
|
+
return _this12.packages;
|
|
870
723
|
});
|
|
871
724
|
}
|
|
872
725
|
}, {
|
|
@@ -882,18 +735,14 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
882
735
|
}, {
|
|
883
736
|
key: "getSubTotal",
|
|
884
737
|
value: function getSubTotal() {
|
|
885
|
-
var
|
|
886
|
-
|
|
738
|
+
var _this13 = this;
|
|
887
739
|
var total = 0;
|
|
888
740
|
this.productCounts().forEach(function (line) {
|
|
889
|
-
var product =
|
|
890
|
-
|
|
741
|
+
var product = _this13.findProduct(line.arrangementsregel_id).product;
|
|
891
742
|
var aantal = line.aantal;
|
|
892
|
-
|
|
893
743
|
if (isNaN(aantal)) {
|
|
894
744
|
aantal = 0;
|
|
895
745
|
}
|
|
896
|
-
|
|
897
746
|
total += aantal * parseFloat(product.verkoop);
|
|
898
747
|
});
|
|
899
748
|
return total;
|
|
@@ -908,12 +757,10 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
908
757
|
value: function getTexts() {
|
|
909
758
|
var settings = ['maximum_aantal_online_boeking_overschreden', 'online_boeking_betaalkeuze', 'online_boeking_betaalkeuze_achteraf_titel', 'online_boeking_betaalkeuze_ideal_titel', 'online_boeking_step0_text_pre', 'online_boeking_step0_text_post', 'online_boeking_step1_text_pre', 'online_boeking_step1_text_post', 'online_boeking_step3_text_post'];
|
|
910
759
|
var promises = [];
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
var setting = settings[_i12];
|
|
760
|
+
for (var _i10 = 0; _i10 < settings.length; _i10++) {
|
|
761
|
+
var setting = settings[_i10];
|
|
914
762
|
promises.push(this.getSetting(setting));
|
|
915
763
|
}
|
|
916
|
-
|
|
917
764
|
return Promise.all(promises).then(function (settings) {
|
|
918
765
|
var texts = {};
|
|
919
766
|
settings.forEach(function (setting) {
|
|
@@ -934,13 +781,11 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
934
781
|
key: "getVouchersPrice",
|
|
935
782
|
value: function getVouchersPrice() {
|
|
936
783
|
var voucherPrice = 0;
|
|
937
|
-
|
|
938
784
|
_objectValues(this.appliedVouchers).forEach(function (voucher) {
|
|
939
785
|
_objectValues(voucher).forEach(function (line) {
|
|
940
786
|
voucherPrice -= line.aantal * line.prijs_per_stuk;
|
|
941
787
|
});
|
|
942
788
|
});
|
|
943
|
-
|
|
944
789
|
return voucherPrice;
|
|
945
790
|
}
|
|
946
791
|
}, {
|
|
@@ -956,14 +801,12 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
956
801
|
if (!afterEl) {
|
|
957
802
|
return;
|
|
958
803
|
}
|
|
959
|
-
|
|
960
804
|
afterEl.insertAdjacentHTML('beforeend', "<span class=\"recrasLoadingIndicator\">".concat(this.languageHelper.translate('LOADING'), "</span>"));
|
|
961
805
|
}
|
|
962
806
|
}, {
|
|
963
807
|
key: "maybeAddLatestErrorElement",
|
|
964
808
|
value: function maybeAddLatestErrorElement() {
|
|
965
809
|
var errorEl = this.findElement('.latestError');
|
|
966
|
-
|
|
967
810
|
if (!errorEl) {
|
|
968
811
|
this.appendHtml("<div class=\"latestError\"></div>");
|
|
969
812
|
}
|
|
@@ -971,45 +814,34 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
971
814
|
}, {
|
|
972
815
|
key: "maybeDisableBookButton",
|
|
973
816
|
value: function maybeDisableBookButton() {
|
|
974
|
-
var
|
|
975
|
-
|
|
817
|
+
var _this14 = this;
|
|
976
818
|
var button = this.findElement('.bookPackage');
|
|
977
|
-
|
|
978
819
|
if (!button) {
|
|
979
820
|
return false;
|
|
980
821
|
}
|
|
981
|
-
|
|
982
822
|
var bookingDisabledReasons = [];
|
|
983
|
-
|
|
984
823
|
if (this.requiresProduct) {
|
|
985
824
|
bookingDisabledReasons.push('BOOKING_DISABLED_REQUIRED_PRODUCT');
|
|
986
825
|
}
|
|
987
|
-
|
|
988
826
|
if (!this.amountsValid(this.selectedPackage)) {
|
|
989
827
|
bookingDisabledReasons.push('BOOKING_DISABLED_AMOUNTS_INVALID');
|
|
990
828
|
}
|
|
991
|
-
|
|
992
829
|
if (!this.selectedDate) {
|
|
993
830
|
bookingDisabledReasons.push('BOOKING_DISABLED_INVALID_DATE');
|
|
994
831
|
}
|
|
995
|
-
|
|
996
832
|
if (!this.selectedTime) {
|
|
997
833
|
bookingDisabledReasons.push('BOOKING_DISABLED_INVALID_TIME');
|
|
998
834
|
}
|
|
999
|
-
|
|
1000
835
|
if (!this.contactFormValid()) {
|
|
1001
836
|
bookingDisabledReasons.push('BOOKING_DISABLED_CONTACT_FORM_INVALID');
|
|
1002
837
|
}
|
|
1003
|
-
|
|
1004
838
|
var agreeEl = this.findElement('#recrasAgreeToAttachments');
|
|
1005
|
-
|
|
1006
839
|
if (agreeEl && !agreeEl.checked) {
|
|
1007
840
|
bookingDisabledReasons.push('BOOKING_DISABLED_AGREEMENT');
|
|
1008
841
|
}
|
|
1009
|
-
|
|
1010
842
|
if (bookingDisabledReasons.length > 0) {
|
|
1011
843
|
var reasonsList = bookingDisabledReasons.map(function (reason) {
|
|
1012
|
-
return
|
|
844
|
+
return _this14.languageHelper.translate(reason);
|
|
1013
845
|
}).join('<li>');
|
|
1014
846
|
this.findElement('#bookingErrors').innerHTML = "<ul><li>".concat(reasonsList, "</ul>");
|
|
1015
847
|
button.setAttribute('disabled', 'disabled');
|
|
@@ -1024,8 +856,9 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1024
856
|
if (completedQuery && this.findElement(completedQuery)) {
|
|
1025
857
|
this.findElement(completedQuery).classList.add('recras-completed');
|
|
1026
858
|
this.findElement(completedQuery).classList.remove('recras-active');
|
|
1027
|
-
}
|
|
859
|
+
}
|
|
1028
860
|
|
|
861
|
+
//TODO: remove active from all sections? Test with invalid amount
|
|
1029
862
|
|
|
1030
863
|
if (activeQuery && this.findElement(activeQuery)) {
|
|
1031
864
|
this.findElement(activeQuery).classList.add('recras-active');
|
|
@@ -1042,49 +875,39 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1042
875
|
key: "paymentMethods",
|
|
1043
876
|
value: function paymentMethods(pack) {
|
|
1044
877
|
var methods = [];
|
|
1045
|
-
|
|
1046
878
|
if (pack.mag_online_geboekt_worden_direct_betalen) {
|
|
1047
879
|
methods.push(this.PAYMENT_DIRECT);
|
|
1048
880
|
}
|
|
1049
|
-
|
|
1050
881
|
if (pack.mag_online_geboekt_worden_achteraf_betalen) {
|
|
1051
882
|
methods.push(this.PAYMENT_AFTERWARDS);
|
|
1052
883
|
}
|
|
1053
|
-
|
|
1054
884
|
return methods;
|
|
1055
885
|
}
|
|
1056
886
|
}, {
|
|
1057
887
|
key: "preFillAmounts",
|
|
1058
888
|
value: function preFillAmounts(amounts) {
|
|
1059
|
-
var
|
|
1060
|
-
|
|
889
|
+
var _this15 = this;
|
|
1061
890
|
_objectEntries(amounts).forEach(function (idAmount) {
|
|
1062
891
|
var el;
|
|
1063
|
-
|
|
1064
892
|
if (idAmount[0] === 'bookingsize') {
|
|
1065
|
-
el =
|
|
893
|
+
el = _this15.findElement('#bookingsize');
|
|
1066
894
|
} else {
|
|
1067
|
-
el =
|
|
895
|
+
el = _this15.findElement("[data-package-id=\"".concat(idAmount[0], "\"]"));
|
|
1068
896
|
}
|
|
1069
|
-
|
|
1070
897
|
if (el) {
|
|
1071
898
|
el.value = idAmount[1];
|
|
1072
|
-
|
|
1073
|
-
_this17.updateProductPrice(el);
|
|
899
|
+
_this15.updateProductPrice(el);
|
|
1074
900
|
}
|
|
1075
901
|
});
|
|
1076
|
-
|
|
1077
902
|
this.updateProductAmounts();
|
|
1078
903
|
}
|
|
1079
904
|
}, {
|
|
1080
905
|
key: "previewTimes",
|
|
1081
906
|
value: function previewTimes() {
|
|
1082
|
-
var
|
|
1083
|
-
|
|
907
|
+
var _this16 = this;
|
|
1084
908
|
_toConsumableArray(this.findElements('.time-preview')).forEach(function (el) {
|
|
1085
909
|
el.parentNode.removeChild(el);
|
|
1086
910
|
});
|
|
1087
|
-
|
|
1088
911
|
if (this.selectedTime) {
|
|
1089
912
|
var linesWithTime = this.selectedPackage.regels.filter(function (line) {
|
|
1090
913
|
return !!line.begin;
|
|
@@ -1097,11 +920,9 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1097
920
|
var linesNoBookingSize = this.getLinesNoBookingSize(this.selectedPackage);
|
|
1098
921
|
linesNoBookingSize.forEach(function (line, idx) {
|
|
1099
922
|
if (line.begin !== null || line.eind !== null) {
|
|
1100
|
-
var normalisedStart =
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
_this18.findElement("label[for=\"packageline".concat(idx, "\"]")).insertAdjacentHTML('afterbegin', "<span class=\"time-preview\">".concat(RecrasDateHelper.timePartOnly(normalisedStart), " \u2013 ").concat(RecrasDateHelper.timePartOnly(normalisedEnd), "</span>"));
|
|
923
|
+
var normalisedStart = _this16.normaliseDate(new Date(line.begin), packageStart, _this16.selectedDate);
|
|
924
|
+
var normalisedEnd = _this16.normaliseDate(new Date(line.eind), packageStart, _this16.selectedDate);
|
|
925
|
+
_this16.findElement("label[for=\"packageline".concat(idx, "\"]")).insertAdjacentHTML('afterbegin', "<span class=\"time-preview\">".concat(RecrasDateHelper.timePartOnly(normalisedStart), " \u2013 ").concat(RecrasDateHelper.timePartOnly(normalisedEnd), "</span>"));
|
|
1105
926
|
}
|
|
1106
927
|
});
|
|
1107
928
|
}
|
|
@@ -1109,11 +930,10 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1109
930
|
}, {
|
|
1110
931
|
key: "productCountsBookingSize",
|
|
1111
932
|
value: function productCountsBookingSize() {
|
|
1112
|
-
var
|
|
1113
|
-
|
|
933
|
+
var _this17 = this;
|
|
1114
934
|
return this.getLinesBookingSize(this.selectedPackage).map(function (line) {
|
|
1115
935
|
return {
|
|
1116
|
-
aantal:
|
|
936
|
+
aantal: _this17.bookingSize(),
|
|
1117
937
|
arrangementsregel_id: line.id
|
|
1118
938
|
};
|
|
1119
939
|
});
|
|
@@ -1142,23 +962,20 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1142
962
|
_toConsumableArray(this.findElements('.booking-error:not(#bookingErrors)')).forEach(function (el) {
|
|
1143
963
|
el.parentNode.removeChild(el);
|
|
1144
964
|
});
|
|
1145
|
-
|
|
1146
965
|
_toConsumableArray(this.findElements('.minimum-amount')).forEach(function (el) {
|
|
1147
966
|
el.parentNode.removeChild(el);
|
|
1148
967
|
});
|
|
1149
|
-
|
|
1150
968
|
_toConsumableArray(this.findElements('.maximum-amount')).forEach(function (el) {
|
|
1151
969
|
el.parentNode.removeChild(el);
|
|
1152
970
|
});
|
|
1153
|
-
|
|
1154
971
|
_toConsumableArray(this.findElements('.recras-input-invalid')).forEach(function (el) {
|
|
1155
972
|
el.classList.remove('recras-input-invalid');
|
|
1156
973
|
});
|
|
1157
|
-
|
|
1158
974
|
_toConsumableArray(this.findElements('.recras-success')).forEach(function (el) {
|
|
1159
975
|
el.parentNode.removeChild(el);
|
|
1160
976
|
});
|
|
1161
977
|
}
|
|
978
|
+
|
|
1162
979
|
/**
|
|
1163
980
|
* requiredAmount calculates the amount N needed of Y in the sentence 'product X requires N times product Y'
|
|
1164
981
|
*
|
|
@@ -1169,18 +986,15 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1169
986
|
* @param {"boven"|"beneden"} requiredProduct.afronding Indication of how hasNow / per_x_aantal should be rounded ("boven" will round up, "beneden" will round down)
|
|
1170
987
|
* @return {number} The amount of product Y needed
|
|
1171
988
|
*/
|
|
1172
|
-
|
|
1173
989
|
}, {
|
|
1174
990
|
key: "requiredAmount",
|
|
1175
991
|
value: function requiredAmount(hasNow, requiredProduct) {
|
|
1176
992
|
var requiredFraction = hasNow / requiredProduct.per_x_aantal;
|
|
1177
|
-
|
|
1178
993
|
if (requiredProduct.afronding === 'boven') {
|
|
1179
994
|
requiredFraction = Math.ceil(requiredFraction);
|
|
1180
995
|
} else {
|
|
1181
996
|
requiredFraction = Math.floor(requiredFraction);
|
|
1182
997
|
}
|
|
1183
|
-
|
|
1184
998
|
return requiredProduct.aantal * requiredFraction;
|
|
1185
999
|
}
|
|
1186
1000
|
}, {
|
|
@@ -1194,7 +1008,6 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1194
1008
|
if (this.findElements('#recras-onlinebooking-time option[value]').length !== 1) {
|
|
1195
1009
|
return;
|
|
1196
1010
|
}
|
|
1197
|
-
|
|
1198
1011
|
this.findElement('#recras-onlinebooking-time option[value]').selected = true;
|
|
1199
1012
|
this.findElement('#recras-onlinebooking-time').dispatchEvent(new Event('change'));
|
|
1200
1013
|
}
|
|
@@ -1203,18 +1016,15 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1203
1016
|
value: function setDiscountStatus(statusText) {
|
|
1204
1017
|
var isError = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
1205
1018
|
var statusEl = this.findElement('.discount-status');
|
|
1206
|
-
|
|
1207
1019
|
if (!statusEl) {
|
|
1208
1020
|
this.element.querySelector('.recras-discounts').insertAdjacentHTML('beforeend', "<span class=\"discount-status\"></span>");
|
|
1209
1021
|
statusEl = this.findElement('.discount-status');
|
|
1210
1022
|
}
|
|
1211
|
-
|
|
1212
1023
|
if (isError) {
|
|
1213
1024
|
statusEl.classList.add('booking-error');
|
|
1214
1025
|
} else {
|
|
1215
1026
|
statusEl.classList.remove('booking-error');
|
|
1216
1027
|
}
|
|
1217
|
-
|
|
1218
1028
|
statusEl.innerHTML = statusText;
|
|
1219
1029
|
}
|
|
1220
1030
|
}, {
|
|
@@ -1228,24 +1038,18 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1228
1038
|
if (!this.selectedPackage || !this.findElement('.standard-attachments')) {
|
|
1229
1039
|
return true;
|
|
1230
1040
|
}
|
|
1231
|
-
|
|
1232
1041
|
var attachments = this.standardAttachments(this.selectedPackage);
|
|
1233
1042
|
var attachmentHtml = "";
|
|
1234
|
-
|
|
1235
1043
|
if (Object.keys(attachments).length) {
|
|
1236
1044
|
attachmentHtml += "<p><label><input type=\"checkbox\" id=\"recrasAgreeToAttachments\" required>".concat(this.languageHelper.translate('AGREE_ATTACHMENTS'), "</label></p>");
|
|
1237
1045
|
attachmentHtml += "<ul>";
|
|
1238
|
-
|
|
1239
1046
|
_objectValues(attachments).forEach(function (attachment) {
|
|
1240
1047
|
attachmentHtml += "<li><a href=\"".concat(attachment.filename, "\" download target=\"_blank\">").concat(attachment.naam, "</a></li>");
|
|
1241
1048
|
});
|
|
1242
|
-
|
|
1243
1049
|
attachmentHtml += "</ul>";
|
|
1244
1050
|
}
|
|
1245
|
-
|
|
1246
1051
|
this.findElement('.standard-attachments').innerHTML = attachmentHtml;
|
|
1247
1052
|
var agreeEl = this.findElement('#recrasAgreeToAttachments');
|
|
1248
|
-
|
|
1249
1053
|
if (agreeEl) {
|
|
1250
1054
|
agreeEl.addEventListener('change', this.maybeDisableBookButton.bind(this));
|
|
1251
1055
|
}
|
|
@@ -1256,29 +1060,21 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1256
1060
|
_toConsumableArray(this.findElements('.discountLine, .voucherLine, .priceWithDiscount')).forEach(function (el) {
|
|
1257
1061
|
el.parentNode.removeChild(el);
|
|
1258
1062
|
});
|
|
1259
|
-
|
|
1260
1063
|
var html = "";
|
|
1261
|
-
|
|
1262
1064
|
if (this.discount) {
|
|
1263
1065
|
html += "<div class=\"discountLine\"><div>".concat(this.discount.naam, "</div><div>").concat(this.formatPrice(this.getDiscountPrice(this.discount)), "</div></div>");
|
|
1264
1066
|
}
|
|
1265
|
-
|
|
1266
1067
|
if (Object.keys(this.appliedVouchers).length) {
|
|
1267
1068
|
html += "<div class=\"voucherLine\"><div>".concat(this.languageHelper.translate('VOUCHERS_DISCOUNT'), "</div><div>").concat(this.formatPrice(this.getVouchersPrice()), "</div></div>");
|
|
1268
1069
|
}
|
|
1269
|
-
|
|
1270
1070
|
if (this.discount || Object.keys(this.appliedVouchers).length) {
|
|
1271
1071
|
html += "<div class=\"priceWithDiscount\"><div>".concat(this.languageHelper.translate('PRICE_TOTAL_WITH_DISCOUNT'), "</div><div>").concat(this.formatPrice(this.getTotalPrice()), "</div></div>");
|
|
1272
1072
|
}
|
|
1273
|
-
|
|
1274
1073
|
var elementToInsertBefore = this.findElement('.recras-amountsform p:last-of-type');
|
|
1275
|
-
|
|
1276
1074
|
if (elementToInsertBefore) {
|
|
1277
1075
|
elementToInsertBefore.insertAdjacentHTML('beforebegin', html);
|
|
1278
1076
|
}
|
|
1279
|
-
|
|
1280
1077
|
var subtotalEl = this.findElement('.priceSubtotal');
|
|
1281
|
-
|
|
1282
1078
|
if (subtotalEl) {
|
|
1283
1079
|
subtotalEl.innerHTML = this.formatPrice(this.getSubTotal());
|
|
1284
1080
|
}
|
|
@@ -1291,15 +1087,12 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1291
1087
|
return packages.sort(function (a, b) {
|
|
1292
1088
|
var aName = a.weergavenaam || a.arrangement;
|
|
1293
1089
|
var bName = b.weergavenaam || b.arrangement;
|
|
1294
|
-
|
|
1295
1090
|
if (aName < bName) {
|
|
1296
1091
|
return -1;
|
|
1297
1092
|
}
|
|
1298
|
-
|
|
1299
1093
|
if (aName > bName) {
|
|
1300
1094
|
return 1;
|
|
1301
1095
|
}
|
|
1302
|
-
|
|
1303
1096
|
return 0;
|
|
1304
1097
|
});
|
|
1305
1098
|
}
|
|
@@ -1311,13 +1104,11 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1311
1104
|
}, {
|
|
1312
1105
|
key: "showBookButton",
|
|
1313
1106
|
value: function showBookButton() {
|
|
1314
|
-
var
|
|
1315
|
-
|
|
1107
|
+
var _this18 = this;
|
|
1316
1108
|
var promises = [];
|
|
1317
1109
|
var paymentMethods = this.paymentMethods(this.selectedPackage);
|
|
1318
1110
|
var paymentText = '';
|
|
1319
1111
|
var textPostBooking = '';
|
|
1320
|
-
|
|
1321
1112
|
if (paymentMethods.indexOf(this.PAYMENT_DIRECT) > -1 && paymentMethods.indexOf(this.PAYMENT_AFTERWARDS) > -1) {
|
|
1322
1113
|
// Let user decide how to pay
|
|
1323
1114
|
promises.push(this.languageHelper.filterTags(this.texts.online_boeking_betaalkeuze, this.selectedPackage ? this.selectedPackage.id : null));
|
|
@@ -1325,71 +1116,56 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1325
1116
|
promises.push(this.languageHelper.filterTags(this.texts.online_boeking_betaalkeuze_achteraf_titel, this.selectedPackage ? this.selectedPackage.id : null));
|
|
1326
1117
|
Promise.all(promises).then(function (msgs) {
|
|
1327
1118
|
paymentText = "<p>".concat(msgs[0], "</p>");
|
|
1328
|
-
paymentText += "<ul>\n <li><label><input type=\"radio\" name=\"paymentMethod\" checked value=\"".concat(
|
|
1119
|
+
paymentText += "<ul>\n <li><label><input type=\"radio\" name=\"paymentMethod\" checked value=\"".concat(_this18.PAYMENT_DIRECT, "\"> ").concat(msgs[1], "</label>\n <li><label><input type=\"radio\" name=\"paymentMethod\" value=\"").concat(_this18.PAYMENT_AFTERWARDS, "\"> ").concat(msgs[2], "</label>\n </ul>");
|
|
1329
1120
|
});
|
|
1330
1121
|
} else {
|
|
1331
1122
|
// One fixed choice
|
|
1332
1123
|
promises.push(Promise.resolve(''));
|
|
1333
1124
|
}
|
|
1334
|
-
|
|
1335
1125
|
promises.push(this.languageHelper.filterTags(this.texts.online_boeking_step3_text_post, this.selectedPackage ? this.selectedPackage.id : null).then(function (msg) {
|
|
1336
1126
|
textPostBooking = msg;
|
|
1337
1127
|
}));
|
|
1338
1128
|
Promise.all(promises).then(function () {
|
|
1339
|
-
var html = "<div class=\"recras-finalise\">\n <p>".concat(textPostBooking, "</p>\n <div class=\"standard-attachments\"></div>\n ").concat(paymentText, "\n <button type=\"submit\" class=\"bookPackage\" disabled>").concat(
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
_this20.maybeDisableBookButton();
|
|
1346
|
-
|
|
1347
|
-
_this20.updateProductAmounts();
|
|
1129
|
+
var html = "<div class=\"recras-finalise\">\n <p>".concat(textPostBooking, "</p>\n <div class=\"standard-attachments\"></div>\n ").concat(paymentText, "\n <button type=\"submit\" class=\"bookPackage\" disabled>").concat(_this18.languageHelper.translate('BUTTON_BOOK_NOW'), "</button>\n <div class=\"booking-error\" id=\"bookingErrors\"></div>\n </div>");
|
|
1130
|
+
_this18.appendHtml(html);
|
|
1131
|
+
_this18.findElement('.bookPackage').addEventListener('click', _this18.submitBooking.bind(_this18));
|
|
1132
|
+
_this18.maybeDisableBookButton();
|
|
1133
|
+
_this18.updateProductAmounts();
|
|
1348
1134
|
});
|
|
1349
1135
|
}
|
|
1350
1136
|
}, {
|
|
1351
1137
|
key: "showDiscountFields",
|
|
1352
1138
|
value: function showDiscountFields() {
|
|
1353
|
-
var
|
|
1354
|
-
|
|
1139
|
+
var _this19 = this;
|
|
1355
1140
|
var existingEl = this.findElement('.recras-discounts');
|
|
1356
|
-
|
|
1357
1141
|
if (existingEl) {
|
|
1358
1142
|
existingEl.parentNode.removeChild(existingEl);
|
|
1359
1143
|
}
|
|
1360
|
-
|
|
1361
1144
|
var html = "\n <form class=\"recras-discounts\">\n <div>\n <label for=\"discountcode\">".concat(this.languageHelper.translate('DISCOUNT_TITLE'), "</label>\n <input type=\"text\" id=\"discountcode\" class=\"discountcode\" maxlength=\"50\" disabled>\n </div>\n <button type=\"submit\" class=\"button-secondary\">").concat(this.languageHelper.translate('DISCOUNT_CHECK'), "</button>\n </form>\n ");
|
|
1362
1145
|
this.findElement('.recras-datetime').insertAdjacentHTML('afterend', html);
|
|
1363
1146
|
this.findElement('.recras-discounts').addEventListener('submit', function (e) {
|
|
1364
1147
|
e.preventDefault();
|
|
1365
|
-
|
|
1366
|
-
_this21.checkDiscountAndVoucher();
|
|
1367
|
-
|
|
1148
|
+
_this19.checkDiscountAndVoucher();
|
|
1368
1149
|
return false;
|
|
1369
1150
|
});
|
|
1370
1151
|
}
|
|
1371
1152
|
}, {
|
|
1372
1153
|
key: "showContactForm",
|
|
1373
1154
|
value: function showContactForm(pack) {
|
|
1374
|
-
var
|
|
1375
|
-
|
|
1155
|
+
var _this20 = this;
|
|
1376
1156
|
this.loadingIndicatorShow(this.findElement('.recras-datetime'));
|
|
1377
1157
|
this.getContactForm(pack).then(function (form) {
|
|
1378
1158
|
return form.generateForm();
|
|
1379
1159
|
}).then(function (html) {
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
_this22.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_CONTACT_FORM_SHOWN);
|
|
1387
|
-
|
|
1388
|
-
_toConsumableArray(_this22.findElements('[name^="contactformulier"]')).forEach(function (el) {
|
|
1389
|
-
el.addEventListener('input', _this22.maybeDisableBookButton.bind(_this22));
|
|
1160
|
+
_this20.appendHtml(html);
|
|
1161
|
+
_this20.loadingIndicatorHide();
|
|
1162
|
+
_this20.showBookButton();
|
|
1163
|
+
_this20.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_CONTACT_FORM_SHOWN);
|
|
1164
|
+
_toConsumableArray(_this20.findElements('[name^="contactformulier"]')).forEach(function (el) {
|
|
1165
|
+
el.addEventListener('input', _this20.maybeDisableBookButton.bind(_this20));
|
|
1390
1166
|
el.addEventListener('input', function () {
|
|
1391
|
-
if (
|
|
1392
|
-
|
|
1167
|
+
if (_this20.contactFormValid()) {
|
|
1168
|
+
_this20.nextSectionActive('.recras-contactform', '.recras-finalise');
|
|
1393
1169
|
}
|
|
1394
1170
|
});
|
|
1395
1171
|
});
|
|
@@ -1403,45 +1179,36 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1403
1179
|
});
|
|
1404
1180
|
this.showTimes(times);
|
|
1405
1181
|
this.loadingIndicatorHide();
|
|
1406
|
-
|
|
1407
1182
|
if (!this.prefilledTime) {
|
|
1408
1183
|
this.selectSingleTime();
|
|
1409
1184
|
return;
|
|
1410
1185
|
}
|
|
1411
|
-
|
|
1412
1186
|
if (times.includes(this.prefilledTime)) {
|
|
1413
1187
|
this.selectTime(this.prefilledTime);
|
|
1414
1188
|
this.selectedDate = RecrasDateHelper.setTimeForDate(this.selectedDate, this.selectedTime);
|
|
1415
|
-
|
|
1416
1189
|
if (this.options.getPreviewTimes() === true) {
|
|
1417
1190
|
this.previewTimes();
|
|
1418
1191
|
}
|
|
1419
|
-
|
|
1420
1192
|
return;
|
|
1421
1193
|
}
|
|
1422
|
-
|
|
1423
1194
|
this.toggleTimeField('show');
|
|
1424
1195
|
}
|
|
1425
1196
|
}, {
|
|
1426
1197
|
key: "calendarOnDateSelect",
|
|
1427
1198
|
value: function calendarOnDateSelect(date, packageId) {
|
|
1428
|
-
var
|
|
1429
|
-
|
|
1199
|
+
var _this21 = this;
|
|
1430
1200
|
this.removeWarnings();
|
|
1431
1201
|
this.loadingIndicatorShow(this.findElement('label[for="recras-onlinebooking-time"]'));
|
|
1432
1202
|
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_DATE_SELECTED, RecrasDateHelper.datePartOnly(date));
|
|
1433
1203
|
this.selectedDate = date;
|
|
1434
|
-
|
|
1435
1204
|
if (this.hasAtLeastOneProduct(this.selectedPackage)) {
|
|
1436
1205
|
this.getAvailableTimes(packageId, date).then(function (times) {
|
|
1437
|
-
return
|
|
1206
|
+
return _this21.maybeFillTime(times);
|
|
1438
1207
|
});
|
|
1439
1208
|
}
|
|
1440
|
-
|
|
1441
1209
|
if (this.discount && this.discount.code) {
|
|
1442
1210
|
this.recheckDiscountCode();
|
|
1443
1211
|
}
|
|
1444
|
-
|
|
1445
1212
|
this.findElement('#discountcode').removeAttribute('disabled');
|
|
1446
1213
|
this.maybeDisableBookButton();
|
|
1447
1214
|
}
|
|
@@ -1453,17 +1220,14 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1453
1220
|
var lastAvailableDay = this.availableDays.reduce(function (acc, curVal) {
|
|
1454
1221
|
return curVal > acc ? curVal : acc;
|
|
1455
1222
|
}, '');
|
|
1456
|
-
|
|
1457
1223
|
if (!lastAvailableDay) {
|
|
1458
1224
|
lastAvailableDay = new Date();
|
|
1459
1225
|
} else {
|
|
1460
1226
|
lastAvailableDay = new Date(lastAvailableDay);
|
|
1461
1227
|
}
|
|
1462
|
-
|
|
1463
1228
|
if (lastAvailableDay > lastDay) {
|
|
1464
1229
|
return;
|
|
1465
1230
|
}
|
|
1466
|
-
|
|
1467
1231
|
var newEndDate = RecrasDateHelper.clone(lastAvailableDay);
|
|
1468
1232
|
newEndDate.setFullYear(lastMonthYear.year);
|
|
1469
1233
|
newEndDate.setMonth(lastMonthYear.month + 3);
|
|
@@ -1488,66 +1252,53 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1488
1252
|
}, {
|
|
1489
1253
|
key: "showDateTimeSelection",
|
|
1490
1254
|
value: function showDateTimeSelection(pack) {
|
|
1491
|
-
var
|
|
1492
|
-
|
|
1255
|
+
var _this22 = this;
|
|
1493
1256
|
this.addDateTimeSelectionHtml();
|
|
1494
1257
|
this.showDiscountFields();
|
|
1495
|
-
|
|
1496
1258
|
if (this.prefilledDate) {
|
|
1497
1259
|
this.toggleDateField('hide');
|
|
1498
1260
|
this.calendarOnDateSelect(this.prefilledDate, pack.id);
|
|
1499
1261
|
}
|
|
1500
|
-
|
|
1501
1262
|
if (this.prefilledTime) {
|
|
1502
1263
|
this.toggleTimeField('hide');
|
|
1503
1264
|
}
|
|
1504
|
-
|
|
1505
1265
|
if (this.prefilledDate && this.prefilledTime) {
|
|
1506
1266
|
this.findElement('.recras-datetime').classList.add('recrasHidden');
|
|
1507
1267
|
}
|
|
1508
|
-
|
|
1509
1268
|
if (this.options.getPreFilledAmounts()) {
|
|
1510
1269
|
this.preFillAmounts(this.options.getPreFilledAmounts());
|
|
1511
1270
|
}
|
|
1512
|
-
|
|
1513
1271
|
var pikadayOptions = _extends(RecrasCalendarHelper.defaultOptions(), {
|
|
1514
1272
|
disableDayFn: function disableDayFn(day) {
|
|
1515
1273
|
var dateFmt = RecrasDateHelper.datePartOnly(day);
|
|
1516
|
-
return
|
|
1274
|
+
return _this22.availableDays.indexOf(dateFmt) === -1;
|
|
1517
1275
|
},
|
|
1518
1276
|
field: this.findElement('.recras-onlinebooking-date'),
|
|
1519
1277
|
i18n: RecrasCalendarHelper.i18n(this.languageHelper),
|
|
1520
1278
|
onDraw: function onDraw(pika) {
|
|
1521
|
-
return
|
|
1279
|
+
return _this22.calendarOnDraw(pika, pack.id);
|
|
1522
1280
|
},
|
|
1523
1281
|
onSelect: function onSelect(date) {
|
|
1524
|
-
return
|
|
1282
|
+
return _this22.calendarOnDateSelect(date, pack.id);
|
|
1525
1283
|
},
|
|
1526
1284
|
parse: RecrasDateHelper.parseMDY
|
|
1527
1285
|
});
|
|
1528
|
-
|
|
1529
1286
|
this.datePicker = new Pikaday(pikadayOptions);
|
|
1530
1287
|
this.findElement('.recras-onlinebooking-time').addEventListener('change', function () {
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
_this24.selectedDate = RecrasDateHelper.setTimeForDate(_this24.selectedDate, _this24.selectedTime);
|
|
1538
|
-
|
|
1539
|
-
if (_this24.options.getPreviewTimes() === true) {
|
|
1540
|
-
_this24.previewTimes();
|
|
1288
|
+
_this22.selectTime(_this22.findElement('.recras-onlinebooking-time').value);
|
|
1289
|
+
_this22.nextSectionActive('.recras-datetime', '.recras-discounts');
|
|
1290
|
+
_this22.nextSectionActive(null, '.recras-contactform');
|
|
1291
|
+
_this22.selectedDate = RecrasDateHelper.setTimeForDate(_this22.selectedDate, _this22.selectedTime);
|
|
1292
|
+
if (_this22.options.getPreviewTimes() === true) {
|
|
1293
|
+
_this22.previewTimes();
|
|
1541
1294
|
}
|
|
1542
|
-
|
|
1543
|
-
_this24.maybeDisableBookButton();
|
|
1295
|
+
_this22.maybeDisableBookButton();
|
|
1544
1296
|
});
|
|
1545
1297
|
}
|
|
1546
1298
|
}, {
|
|
1547
1299
|
key: "showPackages",
|
|
1548
1300
|
value: function showPackages(packages) {
|
|
1549
|
-
var
|
|
1550
|
-
|
|
1301
|
+
var _this23 = this;
|
|
1551
1302
|
packages = packages.filter(function (p) {
|
|
1552
1303
|
return p.mag_online;
|
|
1553
1304
|
});
|
|
@@ -1560,59 +1311,49 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1560
1311
|
promises.push(this.languageHelper.filterTags(this.texts.online_boeking_step0_text_pre, this.selectedPackage ? this.selectedPackage.id : null));
|
|
1561
1312
|
promises.push(this.languageHelper.filterTags(this.texts.online_boeking_step0_text_post, this.selectedPackage ? this.selectedPackage.id : null));
|
|
1562
1313
|
return Promise.all(promises).then(function (msgs) {
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
var packageSelectEl = _this25.findElement('.recras-package-selection');
|
|
1568
|
-
|
|
1314
|
+
_this23.appendHtml("<div class=\"recras-package-select recras-active\"><p>".concat(msgs[0], "</p>").concat(html, "<p>\n").concat(msgs[1], "</p></div>"));
|
|
1315
|
+
_this23.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_PACKAGES_SHOWN);
|
|
1316
|
+
var packageSelectEl = _this23.findElement('.recras-package-selection');
|
|
1569
1317
|
packageSelectEl.addEventListener('change', function () {
|
|
1570
1318
|
var selectedPackageId = parseInt(packageSelectEl.value, 10);
|
|
1571
|
-
|
|
1572
|
-
_this25.changePackage(selectedPackageId);
|
|
1319
|
+
_this23.changePackage(selectedPackageId);
|
|
1573
1320
|
});
|
|
1574
1321
|
});
|
|
1575
1322
|
}
|
|
1576
1323
|
}, {
|
|
1577
1324
|
key: "showProducts",
|
|
1578
1325
|
value: function showProducts(pack) {
|
|
1579
|
-
var
|
|
1580
|
-
|
|
1326
|
+
var _this24 = this;
|
|
1581
1327
|
var promises = [];
|
|
1582
1328
|
promises.push(this.languageHelper.filterTags(this.texts.online_boeking_step1_text_pre, this.selectedPackage ? this.selectedPackage.id : null));
|
|
1583
1329
|
promises.push(this.languageHelper.filterTags(this.texts.online_boeking_step1_text_post, this.selectedPackage ? this.selectedPackage.id : null));
|
|
1584
1330
|
return Promise.all(promises).then(function (msgs) {
|
|
1585
1331
|
var html = '<form class="recras-amountsform" onsubmit="return false">';
|
|
1586
1332
|
html += "<p>".concat(msgs[0], "</p>");
|
|
1587
|
-
html += "<div class=\"recras-heading\">\n <div> </div>\n <div>".concat(
|
|
1588
|
-
|
|
1589
|
-
if (_this26.shouldShowBookingSize(pack)) {
|
|
1333
|
+
html += "<div class=\"recras-heading\">\n <div> </div>\n <div>".concat(_this24.languageHelper.translate('HEADING_QUANTITY'), "</div>\n <div class=\"recras-price\">").concat(_this24.languageHelper.translate('HEADING_PRICE'), "</div>\n </div>");
|
|
1334
|
+
if (_this24.shouldShowBookingSize(pack)) {
|
|
1590
1335
|
html += "<div>";
|
|
1591
1336
|
html += "<div><label for=\"bookingsize\">".concat(pack.weergavenaam || pack.arrangement, "</label></div>");
|
|
1592
|
-
html += "<input type=\"number\" id=\"bookingsize\" class=\"bookingsize\" min=\"".concat(
|
|
1593
|
-
html += "<div class=\"recras-price recrasUnitPrice\">".concat(
|
|
1337
|
+
html += "<input type=\"number\" id=\"bookingsize\" class=\"bookingsize\" min=\"".concat(_this24.bookingSizeMinimum(pack), "\" max=\"").concat(_this24.bookingSizeMaximum(pack), "\" placeholder=\"0\" data-price=\"").concat(_this24.bookingSizePrice(pack), "\">");
|
|
1338
|
+
html += "<div class=\"recras-price recrasUnitPrice\">".concat(_this24.formatPrice(_this24.bookingSizePrice(pack)), "</div>");
|
|
1594
1339
|
html += "</div>";
|
|
1595
1340
|
}
|
|
1596
|
-
|
|
1597
|
-
var linesNoBookingSize = _this26.getLinesNoBookingSize(pack);
|
|
1598
|
-
|
|
1341
|
+
var linesNoBookingSize = _this24.getLinesNoBookingSize(pack);
|
|
1599
1342
|
linesNoBookingSize.forEach(function (line, idx) {
|
|
1600
1343
|
html += '<div><div>';
|
|
1601
1344
|
html += "<label for=\"packageline".concat(idx, "\">").concat(line.beschrijving_templated, "</label>");
|
|
1602
1345
|
var maxAttr = line.max ? "max=\"".concat(line.max, "\"") : '';
|
|
1603
1346
|
html += "</div><input id=\"packageline".concat(idx, "\" type=\"number\" min=\"0\" ").concat(maxAttr, " placeholder=\"0\" data-package-id=\"").concat(line.id, "\" data-price=\"").concat(line.product.verkoop, "\">");
|
|
1604
|
-
html += "<div class=\"recras-price recrasUnitPrice\">".concat(
|
|
1347
|
+
html += "<div class=\"recras-price recrasUnitPrice\">".concat(_this24.formatPrice(line.product.verkoop), "</div>");
|
|
1605
1348
|
html += '</div>';
|
|
1606
1349
|
});
|
|
1607
|
-
html += "<div class=\"priceWithoutDiscount\">\n <div>".concat(
|
|
1350
|
+
html += "<div class=\"priceWithoutDiscount\">\n <div>".concat(_this24.languageHelper.translate('PRICE_TOTAL'), "</div>\n <div></div>\n <div class=\"priceSubtotal\"></div>\n </div>");
|
|
1608
1351
|
html += "<p>".concat(msgs[1], "</p>");
|
|
1609
1352
|
html += '</form>';
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
el.addEventListener('input', _this26.updateProductAmounts.bind(_this26));
|
|
1615
|
-
el.addEventListener('input', _this26.updateProductPrice.bind(_this26, el));
|
|
1353
|
+
_this24.appendHtml(html);
|
|
1354
|
+
_toConsumableArray(_this24.findElements('[id^="packageline"], .bookingsize')).forEach(function (el) {
|
|
1355
|
+
el.addEventListener('input', _this24.updateProductAmounts.bind(_this24));
|
|
1356
|
+
el.addEventListener('input', _this24.updateProductPrice.bind(_this24, el));
|
|
1616
1357
|
});
|
|
1617
1358
|
});
|
|
1618
1359
|
}
|
|
@@ -1625,7 +1366,6 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1625
1366
|
});
|
|
1626
1367
|
this.findElement('.recras-onlinebooking-time').innerHTML = html;
|
|
1627
1368
|
this.findElement('.recras-onlinebooking-time').removeAttribute('disabled');
|
|
1628
|
-
|
|
1629
1369
|
if (times.length === 0) {
|
|
1630
1370
|
this.findElement('.recras-datetime').insertAdjacentHTML('afterend', "<div class=\"booking-error\">".concat(this.languageHelper.translate('ERR_NO_TIMES_FOR_DATE'), "</div>"));
|
|
1631
1371
|
}
|
|
@@ -1639,18 +1379,14 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1639
1379
|
}, {
|
|
1640
1380
|
key: "standardAttachments",
|
|
1641
1381
|
value: function standardAttachments() {
|
|
1642
|
-
var
|
|
1643
|
-
|
|
1382
|
+
var _this25 = this;
|
|
1644
1383
|
var attachments = {};
|
|
1645
|
-
|
|
1646
1384
|
if (!this.selectedPackage.onlineboeking_standaardbijlagen_meesturen) {
|
|
1647
1385
|
return attachments;
|
|
1648
1386
|
}
|
|
1649
|
-
|
|
1650
1387
|
this.productCounts().forEach(function (line) {
|
|
1651
1388
|
if (line.aantal > 0) {
|
|
1652
|
-
var product =
|
|
1653
|
-
|
|
1389
|
+
var product = _this25.findProduct(line.arrangementsregel_id).product;
|
|
1654
1390
|
if (product.standaardbijlagen) {
|
|
1655
1391
|
product.standaardbijlagen.forEach(function (attachment) {
|
|
1656
1392
|
attachments[attachment.id] = attachment;
|
|
@@ -1663,10 +1399,8 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1663
1399
|
}, {
|
|
1664
1400
|
key: "formatGA4Items",
|
|
1665
1401
|
value: function formatGA4Items() {
|
|
1666
|
-
var
|
|
1667
|
-
|
|
1402
|
+
var _this26 = this;
|
|
1668
1403
|
var items = [];
|
|
1669
|
-
|
|
1670
1404
|
if (this.bookingSize() > 0) {
|
|
1671
1405
|
var pck = this.selectedPackage;
|
|
1672
1406
|
items.push({
|
|
@@ -1675,24 +1409,19 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1675
1409
|
quantity: this.bookingSize()
|
|
1676
1410
|
});
|
|
1677
1411
|
}
|
|
1678
|
-
|
|
1679
1412
|
var linesNoBookingSize = this.getLinesNoBookingSize(this.selectedPackage);
|
|
1680
1413
|
linesNoBookingSize = linesNoBookingSize.filter(function (line) {
|
|
1681
|
-
var lineEl =
|
|
1682
|
-
|
|
1414
|
+
var lineEl = _this26.findElement("[data-package-id=\"".concat(line.id, "\"]"));
|
|
1683
1415
|
if (!lineEl) {
|
|
1684
1416
|
return false;
|
|
1685
1417
|
}
|
|
1686
|
-
|
|
1687
1418
|
if (isNaN(parseInt(lineEl.value))) {
|
|
1688
1419
|
return false;
|
|
1689
1420
|
}
|
|
1690
|
-
|
|
1691
1421
|
return parseInt(lineEl.value) > 0;
|
|
1692
1422
|
});
|
|
1693
1423
|
linesNoBookingSize = linesNoBookingSize.map(function (line) {
|
|
1694
|
-
var lineEl =
|
|
1695
|
-
|
|
1424
|
+
var lineEl = _this26.findElement("[data-package-id=\"".concat(line.id, "\"]"));
|
|
1696
1425
|
return {
|
|
1697
1426
|
item_name: line.beschrijving_templated,
|
|
1698
1427
|
price: line.product.verkoop,
|
|
@@ -1705,42 +1434,33 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1705
1434
|
}, {
|
|
1706
1435
|
key: "submitBooking",
|
|
1707
1436
|
value: function submitBooking() {
|
|
1708
|
-
var
|
|
1709
|
-
|
|
1437
|
+
var _this27 = this;
|
|
1710
1438
|
var productCounts = this.productCounts().map(function (line) {
|
|
1711
1439
|
return line.aantal;
|
|
1712
1440
|
});
|
|
1713
1441
|
var productSum = productCounts.reduce(function (a, b) {
|
|
1714
1442
|
return a + b;
|
|
1715
1443
|
}, 0);
|
|
1716
|
-
|
|
1717
1444
|
if (this.bookingSize() === 0 && productSum === 0) {
|
|
1718
1445
|
this.error(this.languageHelper.translate('NO_PRODUCTS'));
|
|
1719
1446
|
return false;
|
|
1720
1447
|
}
|
|
1721
|
-
|
|
1722
1448
|
var status = this.contactForm.checkRequiredCheckboxes();
|
|
1723
|
-
|
|
1724
1449
|
if (!status) {
|
|
1725
1450
|
return false;
|
|
1726
1451
|
}
|
|
1727
|
-
|
|
1728
1452
|
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_BOOKING_SUBMITTED, this.selectedPackage.arrangement, Math.round(this.getTotalPrice()));
|
|
1729
1453
|
var paymentMethod = this.paymentMethods(this.selectedPackage)[0];
|
|
1730
1454
|
var paymentMethodEl = this.findElement('[name="paymentMethod"]:checked');
|
|
1731
|
-
|
|
1732
1455
|
if (paymentMethodEl && this.validPaymentMethod(this.selectedPackage, paymentMethodEl.value)) {
|
|
1733
1456
|
paymentMethod = paymentMethodEl.value;
|
|
1734
1457
|
}
|
|
1735
|
-
|
|
1736
1458
|
this.loadingIndicatorHide();
|
|
1737
1459
|
this.loadingIndicatorShow(this.findElement('.bookPackage'));
|
|
1738
1460
|
var elem;
|
|
1739
|
-
|
|
1740
1461
|
if (null !== (elem = this.findElement('.bookPackage'))) {
|
|
1741
1462
|
elem.setAttribute('disabled', 'disabled');
|
|
1742
1463
|
}
|
|
1743
|
-
|
|
1744
1464
|
var vouchers = Object.keys(this.appliedVouchers).length > 0 ? Object.keys(this.appliedVouchers) : null;
|
|
1745
1465
|
var bookingParams = {
|
|
1746
1466
|
arrangement_id: this.selectedPackage.id,
|
|
@@ -1753,45 +1473,35 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1753
1473
|
stuur_bevestiging_email: true,
|
|
1754
1474
|
vouchers: vouchers
|
|
1755
1475
|
};
|
|
1756
|
-
|
|
1757
1476
|
if (this.shouldShowBookingSize(this.selectedPackage)) {
|
|
1758
1477
|
bookingParams.boekingsgrootte = this.bookingSize();
|
|
1759
1478
|
}
|
|
1760
|
-
|
|
1761
1479
|
if (this.options.getRedirectUrl()) {
|
|
1762
1480
|
bookingParams.redirect_url = this.options.getRedirectUrl();
|
|
1763
1481
|
}
|
|
1764
|
-
|
|
1765
1482
|
return this.postJson('onlineboeking/reserveer', bookingParams).then(function (json) {
|
|
1766
1483
|
if (json.payment_url) {
|
|
1767
|
-
|
|
1768
|
-
currency:
|
|
1769
|
-
value:
|
|
1770
|
-
items:
|
|
1484
|
+
_this27.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_REDIRECT_PAYMENT, null, Math.round(_this27.getTotalPrice()), {
|
|
1485
|
+
currency: _this27.languageHelper.currency,
|
|
1486
|
+
value: _this27.getTotalPrice(),
|
|
1487
|
+
items: _this27.formatGA4Items()
|
|
1771
1488
|
});
|
|
1772
|
-
|
|
1773
1489
|
window.top.location.href = json.payment_url;
|
|
1774
1490
|
} else if (json.redirect) {
|
|
1775
1491
|
window.top.location.href = json.redirect;
|
|
1776
1492
|
} else if (json.message && json.status) {
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
_this29.findElement('.recras-contactform').reset();
|
|
1782
|
-
|
|
1783
|
-
_this29.element.scrollIntoView({
|
|
1493
|
+
_this27.findElement('.recras-amountsform').reset();
|
|
1494
|
+
_this27.findElement('.recras-datetime').reset();
|
|
1495
|
+
_this27.findElement('.recras-contactform').reset();
|
|
1496
|
+
_this27.element.scrollIntoView({
|
|
1784
1497
|
behavior: 'smooth'
|
|
1785
1498
|
});
|
|
1786
|
-
|
|
1787
|
-
_this29.element.insertAdjacentHTML('afterbegin', "<p class=\"recras-success\">".concat(json.message, "</p>"));
|
|
1499
|
+
_this27.element.insertAdjacentHTML('afterbegin', "<p class=\"recras-success\">".concat(json.message, "</p>"));
|
|
1788
1500
|
} else {
|
|
1789
1501
|
console.log(json);
|
|
1790
1502
|
}
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
_this29.findElement('.bookPackage').removeAttribute('disabled');
|
|
1503
|
+
_this27.loadingIndicatorHide();
|
|
1504
|
+
_this27.findElement('.bookPackage').removeAttribute('disabled');
|
|
1795
1505
|
});
|
|
1796
1506
|
}
|
|
1797
1507
|
}, {
|
|
@@ -1799,7 +1509,6 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1799
1509
|
value: function toggleDateField(showHide) {
|
|
1800
1510
|
var dateEl = this.findElement('#recras-onlinebooking-date');
|
|
1801
1511
|
var labelEl = this.findElement('[for="recras-onlinebooking-date"]');
|
|
1802
|
-
|
|
1803
1512
|
if (showHide === 'hide') {
|
|
1804
1513
|
dateEl.classList.add('recrasHidden');
|
|
1805
1514
|
labelEl.classList.add('recrasHidden');
|
|
@@ -1814,7 +1523,6 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1814
1523
|
value: function toggleTimeField(showHide) {
|
|
1815
1524
|
var timeEl = this.findElement('#recras-onlinebooking-time');
|
|
1816
1525
|
var labelEl = this.findElement('[for="recras-onlinebooking-time"]');
|
|
1817
|
-
|
|
1818
1526
|
if (showHide === 'hide') {
|
|
1819
1527
|
timeEl.classList.add('recrasHidden');
|
|
1820
1528
|
labelEl.classList.add('recrasHidden');
|
|
@@ -1827,8 +1535,7 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1827
1535
|
}, {
|
|
1828
1536
|
key: "updateProductAmounts",
|
|
1829
1537
|
value: function updateProductAmounts() {
|
|
1830
|
-
var
|
|
1831
|
-
|
|
1538
|
+
var _this28 = this;
|
|
1832
1539
|
this.loadingIndicatorHide();
|
|
1833
1540
|
this.availableDays = [];
|
|
1834
1541
|
this.removeWarnings();
|
|
@@ -1837,26 +1544,22 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1837
1544
|
var maxPromise = this.checkMaximumForPackage();
|
|
1838
1545
|
this.checkBookingSize(this.selectedPackage);
|
|
1839
1546
|
this.recheckVouchers().then(function () {
|
|
1840
|
-
|
|
1547
|
+
_this28.showTotalPrice();
|
|
1841
1548
|
});
|
|
1842
1549
|
this.showStandardAttachments();
|
|
1843
1550
|
var datePickerEl = this.findElement('.recras-onlinebooking-date');
|
|
1844
1551
|
var thisClass = this;
|
|
1845
1552
|
maxPromise.then(function () {
|
|
1846
1553
|
var amountErrors = thisClass.findElements('.minimum-amount, .maximum-amount, .recras-product-dependency');
|
|
1847
|
-
|
|
1848
1554
|
if (amountErrors.length > 0) {
|
|
1849
1555
|
thisClass.nextSectionActive(null, '.recras-amountsform');
|
|
1850
1556
|
datePickerEl.setAttribute('disabled', 'disabled');
|
|
1851
1557
|
return;
|
|
1852
1558
|
}
|
|
1853
|
-
|
|
1854
1559
|
thisClass.nextSectionActive('.recras-amountsform', '.recras-datetime');
|
|
1855
|
-
|
|
1856
1560
|
if (!thisClass.hasAtLeastOneProduct(thisClass.selectedPackage)) {
|
|
1857
1561
|
return;
|
|
1858
1562
|
}
|
|
1859
|
-
|
|
1860
1563
|
thisClass.loadingIndicatorShow(thisClass.findElement('label[for="recras-onlinebooking-date"]'));
|
|
1861
1564
|
var startDate = new Date();
|
|
1862
1565
|
var endDate = new Date();
|
|
@@ -1867,7 +1570,6 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1867
1570
|
thisClass.getAvailableDaysInPeriod(thisClass.selectedPackage.id, startDate, endDate);
|
|
1868
1571
|
return;
|
|
1869
1572
|
}
|
|
1870
|
-
|
|
1871
1573
|
var date = thisClass.prefilledDate;
|
|
1872
1574
|
startDate = new Date(date);
|
|
1873
1575
|
endDate = new Date(date);
|
|
@@ -1886,16 +1588,13 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1886
1588
|
}, {
|
|
1887
1589
|
key: "getAvailableDaysInPeriod",
|
|
1888
1590
|
value: function getAvailableDaysInPeriod(packageId, startDate, endDate) {
|
|
1889
|
-
var
|
|
1890
|
-
|
|
1591
|
+
var _this29 = this;
|
|
1891
1592
|
var datePickerEl = this.findElement('.recras-onlinebooking-date');
|
|
1892
1593
|
this.getAvailableDays(packageId, startDate, endDate).then(function (availableDays) {
|
|
1893
|
-
|
|
1894
|
-
|
|
1594
|
+
_this29.loadingIndicatorHide();
|
|
1895
1595
|
if (datePickerEl.value && availableDays.indexOf(datePickerEl.value) === -1) {
|
|
1896
1596
|
datePickerEl.value = '';
|
|
1897
|
-
|
|
1898
|
-
_this31.clearTimes();
|
|
1597
|
+
_this29.clearTimes();
|
|
1899
1598
|
} else {
|
|
1900
1599
|
datePickerEl.removeAttribute('disabled');
|
|
1901
1600
|
}
|
|
@@ -1906,17 +1605,14 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1906
1605
|
value: function updateProductPrice(el) {
|
|
1907
1606
|
var priceEl = el.parentNode.querySelector('.recras-price');
|
|
1908
1607
|
var amount = parseInt(el.value, 10);
|
|
1909
|
-
|
|
1910
1608
|
if (isNaN(amount)) {
|
|
1911
1609
|
amount = 0;
|
|
1912
1610
|
}
|
|
1913
|
-
|
|
1914
1611
|
if (amount > 0) {
|
|
1915
1612
|
priceEl.classList.remove('recrasUnitPrice');
|
|
1916
1613
|
} else {
|
|
1917
1614
|
priceEl.classList.add('recrasUnitPrice');
|
|
1918
1615
|
}
|
|
1919
|
-
|
|
1920
1616
|
amount = Math.max(amount, 1);
|
|
1921
1617
|
priceEl.innerHTML = this.formatPrice(amount * el.dataset.price);
|
|
1922
1618
|
}
|
|
@@ -1926,16 +1622,12 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1926
1622
|
return this.paymentMethods(pack).indexOf(method) > -1;
|
|
1927
1623
|
}
|
|
1928
1624
|
}]);
|
|
1929
|
-
|
|
1930
|
-
return RecrasBooking;
|
|
1931
1625
|
}();
|
|
1932
|
-
|
|
1933
1626
|
var RecrasCalendarHelper = /*#__PURE__*/function () {
|
|
1934
1627
|
function RecrasCalendarHelper() {
|
|
1935
1628
|
_classCallCheck(this, RecrasCalendarHelper);
|
|
1936
1629
|
}
|
|
1937
|
-
|
|
1938
|
-
_createClass(RecrasCalendarHelper, null, [{
|
|
1630
|
+
return _createClass(RecrasCalendarHelper, null, [{
|
|
1939
1631
|
key: "defaultOptions",
|
|
1940
1632
|
value: function defaultOptions() {
|
|
1941
1633
|
return {
|
|
@@ -1965,12 +1657,12 @@ var RecrasCalendarHelper = /*#__PURE__*/function () {
|
|
|
1965
1657
|
key: "loadScript",
|
|
1966
1658
|
value: function loadScript() {
|
|
1967
1659
|
return new Promise(function (resolve, reject) {
|
|
1968
|
-
var scriptID = 'recrasPikaday';
|
|
1660
|
+
var scriptID = 'recrasPikaday';
|
|
1969
1661
|
|
|
1662
|
+
// Only load script once
|
|
1970
1663
|
if (document.getElementById(scriptID)) {
|
|
1971
1664
|
resolve(true);
|
|
1972
1665
|
}
|
|
1973
|
-
|
|
1974
1666
|
var script = document.createElement('script');
|
|
1975
1667
|
script.id = scriptID;
|
|
1976
1668
|
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.8.2/pikaday.min.js';
|
|
@@ -1984,56 +1676,42 @@ var RecrasCalendarHelper = /*#__PURE__*/function () {
|
|
|
1984
1676
|
});
|
|
1985
1677
|
}
|
|
1986
1678
|
}]);
|
|
1987
|
-
|
|
1988
|
-
return RecrasCalendarHelper;
|
|
1989
1679
|
}();
|
|
1990
|
-
|
|
1991
1680
|
var RecrasContactForm = /*#__PURE__*/function () {
|
|
1992
1681
|
function RecrasContactForm() {
|
|
1993
|
-
var
|
|
1994
|
-
|
|
1682
|
+
var _this30 = this;
|
|
1995
1683
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1996
|
-
|
|
1997
1684
|
_classCallCheck(this, RecrasContactForm);
|
|
1998
|
-
|
|
1999
1685
|
this.languageHelper = new RecrasLanguageHelper();
|
|
2000
|
-
|
|
2001
1686
|
if (!(options instanceof RecrasOptions)) {
|
|
2002
1687
|
throw new Error(this.languageHelper.translate('ERR_OPTIONS_INVALID'));
|
|
2003
1688
|
}
|
|
2004
|
-
|
|
2005
1689
|
this.options = options;
|
|
2006
|
-
|
|
2007
1690
|
if (!this.options.getFormId()) {
|
|
2008
1691
|
throw new Error(this.languageHelper.translate('ERR_NO_FORM'));
|
|
2009
1692
|
}
|
|
2010
|
-
|
|
2011
1693
|
this.checkboxEventListeners = [];
|
|
2012
1694
|
this.eventHelper = new RecrasEventHelper();
|
|
2013
1695
|
this.eventHelper.setEvents(this.options.getAnalyticsEvents());
|
|
2014
1696
|
this.element = this.options.getElement();
|
|
2015
1697
|
this.element.classList.add('recras-contactform-wrapper');
|
|
2016
1698
|
this.languageHelper.setOptions(options);
|
|
2017
|
-
|
|
2018
1699
|
if (RecrasLanguageHelper.isValid(this.options.getLocale())) {
|
|
2019
1700
|
this.languageHelper.setLocale(this.options.getLocale());
|
|
2020
1701
|
}
|
|
2021
|
-
|
|
2022
1702
|
this.fetchJson = function (url) {
|
|
2023
|
-
return RecrasHttpHelper.fetchJson(url,
|
|
1703
|
+
return RecrasHttpHelper.fetchJson(url, _this30.error.bind(_this30));
|
|
2024
1704
|
};
|
|
2025
|
-
|
|
2026
1705
|
this.postJson = function (url, data) {
|
|
2027
|
-
return RecrasHttpHelper.postJson(
|
|
1706
|
+
return RecrasHttpHelper.postJson(_this30.options.getApiBase() + url, data, _this30.error.bind(_this30));
|
|
2028
1707
|
};
|
|
2029
|
-
|
|
2030
1708
|
RecrasCSSHelper.loadCSS('global');
|
|
2031
1709
|
this.GENDERS = {
|
|
2032
1710
|
onbekend: 'GENDER_UNKNOWN',
|
|
2033
1711
|
man: 'GENDER_MALE',
|
|
2034
1712
|
vrouw: 'GENDER_FEMALE'
|
|
2035
|
-
};
|
|
2036
|
-
|
|
1713
|
+
};
|
|
1714
|
+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#inappropriate-for-the-control
|
|
2037
1715
|
this.AUTOCOMPLETE_OPTIONS = {
|
|
2038
1716
|
'contact.naam': 'organization',
|
|
2039
1717
|
'contact.website': 'url',
|
|
@@ -2044,24 +1722,19 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2044
1722
|
'contactpersoon.voornaam': 'given-name'
|
|
2045
1723
|
};
|
|
2046
1724
|
}
|
|
2047
|
-
|
|
2048
|
-
_createClass(RecrasContactForm, [{
|
|
1725
|
+
return _createClass(RecrasContactForm, [{
|
|
2049
1726
|
key: "checkRequiredCheckboxes",
|
|
2050
1727
|
value: function checkRequiredCheckboxes() {
|
|
2051
|
-
var
|
|
2052
|
-
|
|
1728
|
+
var _this31 = this;
|
|
2053
1729
|
this.removeWarnings();
|
|
2054
1730
|
var isOkay = true;
|
|
2055
|
-
|
|
2056
1731
|
_toConsumableArray(this.findElements('.checkboxGroupRequired')).forEach(function (group) {
|
|
2057
1732
|
var checked = group.querySelectorAll('input:checked');
|
|
2058
|
-
|
|
2059
1733
|
if (checked.length === 0) {
|
|
2060
|
-
group.parentNode.querySelector('label').insertAdjacentHTML('beforeend', "<div class=\"recrasError\">".concat(
|
|
1734
|
+
group.parentNode.querySelector('label').insertAdjacentHTML('beforeend', "<div class=\"recrasError\">".concat(_this31.languageHelper.translate('CONTACT_FORM_CHECKBOX_REQUIRED'), "</div>"));
|
|
2061
1735
|
isOkay = false;
|
|
2062
1736
|
}
|
|
2063
1737
|
});
|
|
2064
|
-
|
|
2065
1738
|
return isOkay;
|
|
2066
1739
|
}
|
|
2067
1740
|
}, {
|
|
@@ -2093,38 +1766,29 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2093
1766
|
}, {
|
|
2094
1767
|
key: "generateForm",
|
|
2095
1768
|
value: function generateForm() {
|
|
2096
|
-
var
|
|
2097
|
-
|
|
1769
|
+
var _this32 = this;
|
|
2098
1770
|
var extraOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2099
1771
|
var waitFor = [];
|
|
2100
|
-
|
|
2101
1772
|
if (this.hasCountryField()) {
|
|
2102
1773
|
waitFor.push(this.getCountryList());
|
|
2103
1774
|
}
|
|
2104
|
-
|
|
2105
1775
|
if (this.hasBookingDateField() || this.hasRelationDateField()) {
|
|
2106
1776
|
waitFor.push(RecrasCalendarHelper.loadScript());
|
|
2107
1777
|
RecrasCSSHelper.loadCSS('pikaday');
|
|
2108
1778
|
}
|
|
2109
|
-
|
|
2110
1779
|
return Promise.all(waitFor).then(function () {
|
|
2111
|
-
var standalone =
|
|
2112
|
-
|
|
1780
|
+
var standalone = _this32.isStandalone(extraOptions);
|
|
2113
1781
|
var validateText = standalone ? 'novalidate' : '';
|
|
2114
1782
|
var html = "<form class=\"recras-contactform\" ".concat(validateText, ">");
|
|
2115
|
-
|
|
2116
1783
|
if (extraOptions.voucherQuantitySelector) {
|
|
2117
|
-
html +=
|
|
1784
|
+
html += _this32.quantitySelector(extraOptions.quantityTerm);
|
|
2118
1785
|
}
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
html += '<div>' + _this34.showField(field, idx) + '</div>';
|
|
1786
|
+
_this32.contactFormFields.forEach(function (field, idx) {
|
|
1787
|
+
html += '<div>' + _this32.showField(field, idx) + '</div>';
|
|
2122
1788
|
});
|
|
2123
|
-
|
|
2124
1789
|
if (standalone) {
|
|
2125
|
-
html +=
|
|
1790
|
+
html += _this32.submitButtonHtml();
|
|
2126
1791
|
}
|
|
2127
|
-
|
|
2128
1792
|
html += '</form>';
|
|
2129
1793
|
return html;
|
|
2130
1794
|
});
|
|
@@ -2135,44 +1799,42 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2135
1799
|
var formEl = this.options.getElement().querySelector('.recras-contactform');
|
|
2136
1800
|
var elements = formEl.querySelectorAll('[id^="contactformulier-"], input[type="radio"]:checked');
|
|
2137
1801
|
var contactForm = {};
|
|
2138
|
-
|
|
2139
1802
|
_toConsumableArray(elements).forEach(function (field) {
|
|
2140
1803
|
contactForm[field.dataset.identifier] = field.value;
|
|
2141
1804
|
});
|
|
2142
|
-
|
|
2143
1805
|
_toConsumableArray(formEl.querySelectorAll('input[type="checkbox"]:checked')).forEach(function (field) {
|
|
2144
1806
|
if (contactForm[field.dataset.identifier] === undefined) {
|
|
2145
1807
|
contactForm[field.dataset.identifier] = [];
|
|
2146
1808
|
}
|
|
2147
|
-
|
|
2148
1809
|
contactForm[field.dataset.identifier].push(field.value);
|
|
2149
1810
|
});
|
|
2150
|
-
|
|
2151
1811
|
if (contactForm['boeking.datum']) {
|
|
2152
1812
|
contactForm['boeking.datum'] = RecrasDateHelper.formatStringForAPI(contactForm['boeking.datum']);
|
|
2153
1813
|
}
|
|
2154
|
-
|
|
1814
|
+
if (this.nonce) {
|
|
1815
|
+
contactForm.nonce = this.nonce;
|
|
1816
|
+
}
|
|
2155
1817
|
return contactForm;
|
|
2156
1818
|
}
|
|
2157
1819
|
}, {
|
|
2158
1820
|
key: "getContactFormFields",
|
|
2159
1821
|
value: function getContactFormFields() {
|
|
2160
|
-
var
|
|
2161
|
-
|
|
1822
|
+
var _this33 = this;
|
|
2162
1823
|
return this.fetchJson(this.options.getApiBase() + 'contactformulieren/' + this.options.getFormId() + '?embed=Velden').then(function (form) {
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
1824
|
+
var _form$nonce;
|
|
1825
|
+
_this33.contactFormFields = form.Velden;
|
|
1826
|
+
_this33.packages = _this33.sortPackages(form.Arrangementen);
|
|
1827
|
+
_this33.nonce = (_form$nonce = form.nonce) !== null && _form$nonce !== void 0 ? _form$nonce : null;
|
|
1828
|
+
return _this33.contactFormFields;
|
|
2166
1829
|
});
|
|
2167
1830
|
}
|
|
2168
1831
|
}, {
|
|
2169
1832
|
key: "getCountryList",
|
|
2170
1833
|
value: function getCountryList() {
|
|
2171
|
-
var
|
|
2172
|
-
|
|
1834
|
+
var _this34 = this;
|
|
2173
1835
|
return this.fetchJson('https://cdn.rawgit.com/umpirsky/country-list/ddabf3a8/data/' + this.languageHelper.locale + '/country.json').then(function (json) {
|
|
2174
|
-
|
|
2175
|
-
return
|
|
1836
|
+
_this34.countries = json;
|
|
1837
|
+
return _this34.countries;
|
|
2176
1838
|
});
|
|
2177
1839
|
}
|
|
2178
1840
|
}, {
|
|
@@ -2183,21 +1845,17 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2183
1845
|
if (a.arrangement < b.arrangement) {
|
|
2184
1846
|
return -1;
|
|
2185
1847
|
}
|
|
2186
|
-
|
|
2187
1848
|
if (a.arrangement > b.arrangement) {
|
|
2188
1849
|
return 1;
|
|
2189
|
-
}
|
|
2190
|
-
|
|
2191
|
-
|
|
1850
|
+
}
|
|
1851
|
+
// Sort by ID in the off chance that two packages are named the same
|
|
2192
1852
|
if (a.id < b.id) {
|
|
2193
1853
|
return -1;
|
|
2194
1854
|
}
|
|
2195
|
-
|
|
2196
1855
|
if (a.id > b.id) {
|
|
2197
1856
|
return 1;
|
|
2198
|
-
}
|
|
2199
|
-
|
|
2200
|
-
|
|
1857
|
+
}
|
|
1858
|
+
// This cannot happen
|
|
2201
1859
|
return 0;
|
|
2202
1860
|
});
|
|
2203
1861
|
}
|
|
@@ -2207,15 +1865,12 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2207
1865
|
var invalid = [];
|
|
2208
1866
|
var required = this.getEmptyRequiredFields();
|
|
2209
1867
|
var els = this.findElements('.recras-contactform :invalid');
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
var el = els[_i14];
|
|
2213
|
-
|
|
1868
|
+
for (var _i12 = 0; _i12 < els.length; _i12++) {
|
|
1869
|
+
var el = els[_i12];
|
|
2214
1870
|
if (!required.includes(el)) {
|
|
2215
1871
|
invalid.push(el);
|
|
2216
1872
|
}
|
|
2217
1873
|
}
|
|
2218
|
-
|
|
2219
1874
|
return invalid;
|
|
2220
1875
|
}
|
|
2221
1876
|
}, {
|
|
@@ -2223,15 +1878,12 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2223
1878
|
value: function getEmptyRequiredFields() {
|
|
2224
1879
|
var isEmpty = [];
|
|
2225
1880
|
var els = this.findElements('.recras-contactform :required');
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
var el = els[_i16];
|
|
2229
|
-
|
|
1881
|
+
for (var _i14 = 0; _i14 < els.length; _i14++) {
|
|
1882
|
+
var el = els[_i14];
|
|
2230
1883
|
if (el.value === undefined || el.value === '') {
|
|
2231
1884
|
isEmpty.push(el);
|
|
2232
1885
|
}
|
|
2233
1886
|
}
|
|
2234
|
-
|
|
2235
1887
|
return isEmpty;
|
|
2236
1888
|
}
|
|
2237
1889
|
}, {
|
|
@@ -2272,11 +1924,9 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2272
1924
|
key: "isEmpty",
|
|
2273
1925
|
value: function isEmpty() {
|
|
2274
1926
|
var els = this.findElements('.recras-contactform input, .recras-contactform select, .recras-contactform textarea');
|
|
2275
|
-
|
|
2276
1927
|
var formValues = _toConsumableArray(els).map(function (el) {
|
|
2277
1928
|
return el.value;
|
|
2278
1929
|
});
|
|
2279
|
-
|
|
2280
1930
|
return !formValues.some(function (v) {
|
|
2281
1931
|
return v !== '';
|
|
2282
1932
|
});
|
|
@@ -2299,7 +1949,6 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2299
1949
|
if (!afterEl) {
|
|
2300
1950
|
return;
|
|
2301
1951
|
}
|
|
2302
|
-
|
|
2303
1952
|
afterEl.insertAdjacentHTML('beforeend', "<span class=\"recrasLoadingIndicator\">".concat(this.languageHelper.translate('LOADING'), "</span>"));
|
|
2304
1953
|
}
|
|
2305
1954
|
}, {
|
|
@@ -2308,14 +1957,12 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2308
1957
|
if (!quantityTerm) {
|
|
2309
1958
|
quantityTerm = this.languageHelper.translate('VOUCHER_QUANTITY');
|
|
2310
1959
|
}
|
|
2311
|
-
|
|
2312
1960
|
return "<div>\n <label for=\"number-of-vouchers\">".concat(quantityTerm, "</label>\n <input type=\"number\" id=\"number-of-vouchers\" class=\"number-of-vouchers\" min=\"1\" max=\"100\" value=\"1\" required>\n </div>");
|
|
2313
1961
|
}
|
|
2314
1962
|
}, {
|
|
2315
1963
|
key: "removeErrors",
|
|
2316
1964
|
value: function removeErrors() {
|
|
2317
1965
|
var parentQuery = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
2318
|
-
|
|
2319
1966
|
_toConsumableArray(this.findElements(parentQuery + ' .booking-error')).forEach(function (el) {
|
|
2320
1967
|
el.parentNode.removeChild(el);
|
|
2321
1968
|
});
|
|
@@ -2326,7 +1973,6 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2326
1973
|
_toConsumableArray(this.findElements('.recrasError')).forEach(function (el) {
|
|
2327
1974
|
el.parentNode.removeChild(el);
|
|
2328
1975
|
});
|
|
2329
|
-
|
|
2330
1976
|
_toConsumableArray(this.findElements('.recras-success')).forEach(function (el) {
|
|
2331
1977
|
el.parentNode.removeChild(el);
|
|
2332
1978
|
});
|
|
@@ -2339,12 +1985,10 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2339
1985
|
}, {
|
|
2340
1986
|
key: "showField",
|
|
2341
1987
|
value: function showField(field, idx) {
|
|
2342
|
-
var
|
|
2343
|
-
|
|
1988
|
+
var _this35 = this;
|
|
2344
1989
|
if (field.soort_invoer === 'header') {
|
|
2345
1990
|
return "<h3>".concat(field.naam, "</h3>");
|
|
2346
1991
|
}
|
|
2347
|
-
|
|
2348
1992
|
var today = RecrasDateHelper.toString(new Date());
|
|
2349
1993
|
var timePattern = '(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9])';
|
|
2350
1994
|
var label = this.showLabel(field, idx);
|
|
@@ -2353,30 +1997,25 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2353
1997
|
var html;
|
|
2354
1998
|
var placeholder;
|
|
2355
1999
|
var fixedAttributes = "id=\"contactformulier-".concat(idx, "\" name=\"contactformulier").concat(idx, "\" ").concat(attrRequired, " data-identifier=\"").concat(field.field_identifier, "\"");
|
|
2356
|
-
|
|
2357
2000
|
switch (field.soort_invoer) {
|
|
2358
2001
|
case 'contactpersoon.geslacht':
|
|
2359
2002
|
html = "<select ".concat(fixedAttributes, " autocomplete=\"sex\">");
|
|
2360
2003
|
Object.keys(this.GENDERS).forEach(function (key) {
|
|
2361
|
-
html += "<option value=\"".concat(key, "\">").concat(
|
|
2004
|
+
html += "<option value=\"".concat(key, "\">").concat(_this35.languageHelper.translate(_this35.GENDERS[key]));
|
|
2362
2005
|
});
|
|
2363
2006
|
html += '</select>';
|
|
2364
2007
|
return label + html;
|
|
2365
|
-
|
|
2366
2008
|
case 'keuze':
|
|
2367
2009
|
classes = ['checkboxGroup'];
|
|
2368
|
-
|
|
2369
2010
|
if (field.verplicht) {
|
|
2370
2011
|
classes.push('checkboxGroupRequired');
|
|
2371
2012
|
}
|
|
2372
|
-
|
|
2373
2013
|
html = "<div class=\"".concat(classes.join(' '), "\">");
|
|
2374
2014
|
field.mogelijke_keuzes.forEach(function (choice) {
|
|
2375
2015
|
html += "<label><input type=\"checkbox\" name=\"contactformulier".concat(idx, "\" value=\"").concat(choice, "\" data-identifier=\"").concat(field.field_identifier, "\">").concat(choice, "</label>");
|
|
2376
2016
|
});
|
|
2377
2017
|
html += '</div>';
|
|
2378
2018
|
return label + html;
|
|
2379
|
-
|
|
2380
2019
|
case 'keuze_enkel':
|
|
2381
2020
|
case 'contact.soort_klant':
|
|
2382
2021
|
html = "<div class=\"radioGroup\">";
|
|
@@ -2385,61 +2024,48 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2385
2024
|
});
|
|
2386
2025
|
html += "</div>";
|
|
2387
2026
|
return label + html;
|
|
2388
|
-
|
|
2389
2027
|
case 'veel_tekst':
|
|
2390
2028
|
return label + "<textarea ".concat(fixedAttributes, "></textarea>");
|
|
2391
|
-
|
|
2392
2029
|
case 'contactpersoon.telefoon1':
|
|
2393
2030
|
case 'contactpersoon.telefoon2':
|
|
2394
2031
|
return label + "<input type=\"tel\" ".concat(fixedAttributes, " autocomplete=\"tel\">");
|
|
2395
|
-
|
|
2396
2032
|
case 'contactpersoon.email1':
|
|
2397
2033
|
case 'contactpersoon.email2':
|
|
2398
2034
|
return label + "<input type=\"email\" ".concat(fixedAttributes, " autocomplete=\"email\">");
|
|
2399
|
-
|
|
2400
2035
|
case 'contactpersoon.nieuwsbrieven':
|
|
2401
2036
|
classes = ['checkboxGroup'];
|
|
2402
|
-
|
|
2403
2037
|
if (field.verplicht) {
|
|
2404
2038
|
classes.push('checkboxGroupRequired');
|
|
2405
2039
|
}
|
|
2406
|
-
|
|
2407
2040
|
html = "<div class=\"".concat(classes.join(' '), "\">");
|
|
2408
2041
|
Object.keys(field.newsletter_options).forEach(function (key) {
|
|
2409
2042
|
html += "<label><input type=\"checkbox\" name=\"contactformulier".concat(idx, "\" value=\"").concat(key, "\" data-identifier=\"").concat(field.field_identifier, "\">").concat(field.newsletter_options[key], "</label>");
|
|
2410
2043
|
});
|
|
2411
2044
|
html += '</div>';
|
|
2412
2045
|
return label + html;
|
|
2413
|
-
|
|
2414
2046
|
case 'contact.landcode':
|
|
2415
2047
|
html = "<select ".concat(fixedAttributes, " autocomplete=\"country\">");
|
|
2416
2048
|
Object.keys(this.countries).forEach(function (code) {
|
|
2417
|
-
var selectedText = code.toUpperCase() ===
|
|
2418
|
-
html += "<option value=\"".concat(code, "\" ").concat(selectedText, ">").concat(
|
|
2049
|
+
var selectedText = code.toUpperCase() === _this35.options.getDefaultCountry() ? 'selected' : '';
|
|
2050
|
+
html += "<option value=\"".concat(code, "\" ").concat(selectedText, ">").concat(_this35.countries[code]);
|
|
2419
2051
|
});
|
|
2420
2052
|
html += '</select>';
|
|
2421
2053
|
return label + html;
|
|
2422
|
-
|
|
2423
2054
|
case 'boeking.datum':
|
|
2424
2055
|
placeholder = this.languageHelper.translate('DATE_FORMAT');
|
|
2425
2056
|
return label + "<input type=\"text\" ".concat(fixedAttributes, " min=\"").concat(today, "\" placeholder=\"").concat(placeholder, "\" autocomplete=\"off\">");
|
|
2426
|
-
|
|
2427
2057
|
case 'boeking.groepsgrootte':
|
|
2428
2058
|
return label + "<input type=\"number\" ".concat(fixedAttributes, " min=\"1\">");
|
|
2429
|
-
|
|
2430
2059
|
case 'boeking.starttijd':
|
|
2431
2060
|
placeholder = this.languageHelper.translate('TIME_FORMAT');
|
|
2432
2061
|
return label + "<input type=\"time\" ".concat(fixedAttributes, " placeholder=\"").concat(placeholder, "\" pattern=\"").concat(timePattern, "\">");
|
|
2433
|
-
|
|
2434
2062
|
case 'boeking.arrangement':
|
|
2435
2063
|
var preFilledPackage = this.options.getPackageId();
|
|
2436
|
-
|
|
2437
2064
|
if (field.verplicht && this.packages.length === 1) {
|
|
2438
2065
|
var pack = this.packages[0];
|
|
2439
2066
|
html = "<select ".concat(fixedAttributes, ">\n <option value=\"").concat(pack.id, "\" selected>").concat(pack.arrangement, "\n </select>");
|
|
2440
2067
|
return label + html;
|
|
2441
2068
|
}
|
|
2442
|
-
|
|
2443
2069
|
html = "<select ".concat(fixedAttributes, ">");
|
|
2444
2070
|
html += "<option value=\"\">";
|
|
2445
2071
|
this.packages.forEach(function (pack) {
|
|
@@ -2448,30 +2074,24 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2448
2074
|
});
|
|
2449
2075
|
html += '</select>';
|
|
2450
2076
|
return label + html;
|
|
2451
|
-
|
|
2452
2077
|
case 'contact.extra':
|
|
2453
2078
|
switch (field.input_type) {
|
|
2454
2079
|
case 'number':
|
|
2455
2080
|
return label + "<input type=\"number\" ".concat(fixedAttributes, " autocomplete=\"off\">");
|
|
2456
|
-
|
|
2457
2081
|
case 'date':
|
|
2458
2082
|
case 'text':
|
|
2459
2083
|
return label + "<input type=\"text\" ".concat(fixedAttributes, " maxlength=\"200\">");
|
|
2460
|
-
|
|
2461
2084
|
case 'multiplechoice':
|
|
2462
2085
|
classes = ['checkboxGroup'];
|
|
2463
|
-
|
|
2464
2086
|
if (field.verplicht) {
|
|
2465
2087
|
classes.push('checkboxGroupRequired');
|
|
2466
2088
|
}
|
|
2467
|
-
|
|
2468
2089
|
html = "<div class=\"".concat(classes.join(' '), "\">");
|
|
2469
2090
|
field.mogelijke_keuzes.forEach(function (choice) {
|
|
2470
2091
|
html += "<label><input type=\"checkbox\" name=\"contactformulier".concat(idx, "\" value=\"").concat(choice, "\" data-identifier=\"").concat(field.field_identifier, "\">").concat(choice, "</label>");
|
|
2471
2092
|
});
|
|
2472
2093
|
html += '</div>';
|
|
2473
2094
|
return label + html;
|
|
2474
|
-
|
|
2475
2095
|
case 'singlechoice':
|
|
2476
2096
|
html = "<div class=\"radioGroup\">";
|
|
2477
2097
|
field.mogelijke_keuzes.forEach(function (choice) {
|
|
@@ -2479,14 +2099,12 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2479
2099
|
});
|
|
2480
2100
|
html += "</div>";
|
|
2481
2101
|
return label + html;
|
|
2482
|
-
|
|
2483
2102
|
default:
|
|
2484
2103
|
console.debug('Unknown type', field.input_type, field);
|
|
2485
2104
|
return label + "<input type=\"text\" ".concat(fixedAttributes, ">");
|
|
2486
2105
|
}
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2106
|
+
case 'contact.website':
|
|
2107
|
+
//TODO: type=url ?
|
|
2490
2108
|
default:
|
|
2491
2109
|
var autocomplete = this.AUTOCOMPLETE_OPTIONS[field.soort_invoer] ? this.AUTOCOMPLETE_OPTIONS[field.soort_invoer] : '';
|
|
2492
2110
|
return label + "<input type=\"text\" ".concat(fixedAttributes, " autocomplete=\"").concat(autocomplete, "\">");
|
|
@@ -2495,56 +2113,45 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2495
2113
|
}, {
|
|
2496
2114
|
key: "showForm",
|
|
2497
2115
|
value: function showForm() {
|
|
2498
|
-
var
|
|
2499
|
-
|
|
2116
|
+
var _this36 = this;
|
|
2500
2117
|
this.loadingIndicatorShow(this.element);
|
|
2501
2118
|
return this.getContactFormFields().then(function () {
|
|
2502
|
-
return
|
|
2119
|
+
return _this36.generateForm({
|
|
2503
2120
|
standalone: true
|
|
2504
2121
|
});
|
|
2505
2122
|
}).then(function (html) {
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
_toConsumableArray(_this38.findElements('.checkboxGroupRequired')).forEach(function (group) {
|
|
2123
|
+
_this36.appendHtml(html);
|
|
2124
|
+
_toConsumableArray(_this36.findElements('.checkboxGroupRequired')).forEach(function (group) {
|
|
2509
2125
|
_toConsumableArray(group.querySelectorAll('input')).forEach(function (el) {
|
|
2510
|
-
el.addEventListener('change',
|
|
2126
|
+
el.addEventListener('change', _this36.checkRequiredCheckboxes.bind(_this36));
|
|
2511
2127
|
});
|
|
2512
2128
|
});
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
if (_this38.hasBookingDateField()) {
|
|
2129
|
+
_this36.findElement('.recras-contactform').addEventListener('submit', _this36.submitForm.bind(_this36));
|
|
2130
|
+
if (_this36.hasBookingDateField()) {
|
|
2517
2131
|
var pikadayOptions = _extends(RecrasCalendarHelper.defaultOptions(), {
|
|
2518
|
-
field:
|
|
2519
|
-
i18n: RecrasCalendarHelper.i18n(
|
|
2132
|
+
field: _this36.findElement('[data-identifier="boeking.datum"]'),
|
|
2133
|
+
i18n: RecrasCalendarHelper.i18n(_this36.languageHelper),
|
|
2520
2134
|
numberOfMonths: 1,
|
|
2521
2135
|
parse: RecrasDateHelper.parseMDY
|
|
2522
2136
|
});
|
|
2523
|
-
|
|
2524
2137
|
new Pikaday(pikadayOptions);
|
|
2525
2138
|
}
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
var fields = _this38.getRelationExtraDateFields();
|
|
2529
|
-
|
|
2139
|
+
if (_this36.hasRelationDateField()) {
|
|
2140
|
+
var fields = _this36.getRelationExtraDateFields();
|
|
2530
2141
|
var thisYear = new Date().getFullYear();
|
|
2531
|
-
|
|
2532
2142
|
var _pikadayOptions = _extends(RecrasCalendarHelper.defaultOptions(), {
|
|
2533
|
-
i18n: RecrasCalendarHelper.i18n(
|
|
2143
|
+
i18n: RecrasCalendarHelper.i18n(_this36.languageHelper),
|
|
2534
2144
|
numberOfMonths: 1,
|
|
2535
2145
|
yearRange: [thisYear - 90, thisYear + 10]
|
|
2536
2146
|
});
|
|
2537
|
-
|
|
2538
2147
|
delete _pikadayOptions.minDate;
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
_pikadayOptions.field = _this38.findElement("[data-identifier=\"".concat(field.field_identifier, "\"]"));
|
|
2148
|
+
for (var _i16 = 0; _i16 < fields.length; _i16++) {
|
|
2149
|
+
var field = fields[_i16];
|
|
2150
|
+
_pikadayOptions.field = _this36.findElement("[data-identifier=\"".concat(field.field_identifier, "\"]"));
|
|
2543
2151
|
new Pikaday(_pikadayOptions);
|
|
2544
2152
|
}
|
|
2545
2153
|
}
|
|
2546
|
-
|
|
2547
|
-
_this38.loadingIndicatorHide();
|
|
2154
|
+
_this36.loadingIndicatorHide();
|
|
2548
2155
|
});
|
|
2549
2156
|
}
|
|
2550
2157
|
}, {
|
|
@@ -2556,47 +2163,37 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2556
2163
|
key: "showErrors",
|
|
2557
2164
|
value: function showErrors() {
|
|
2558
2165
|
var errors = [];
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
var el = _this$getEmptyRequire2[_i20];
|
|
2166
|
+
for (var _i18 = 0, _this$getEmptyRequire2 = this.getEmptyRequiredFields(); _i18 < _this$getEmptyRequire2.length; _i18++) {
|
|
2167
|
+
var el = _this$getEmptyRequire2[_i18];
|
|
2562
2168
|
var labelEl = el.parentNode.querySelector('label');
|
|
2563
2169
|
var requiredText = this.languageHelper.translate('CONTACT_FORM_FIELD_REQUIRED', {
|
|
2564
2170
|
FIELD_NAME: labelEl.innerText
|
|
2565
2171
|
});
|
|
2566
2172
|
errors.push(requiredText);
|
|
2567
2173
|
}
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
var _el = _this$getInvalidField2[_i22];
|
|
2571
|
-
|
|
2174
|
+
for (var _i20 = 0, _this$getInvalidField2 = this.getInvalidFields(); _i20 < _this$getInvalidField2.length; _i20++) {
|
|
2175
|
+
var _el = _this$getInvalidField2[_i20];
|
|
2572
2176
|
var parentEl = _el.closest('div');
|
|
2573
|
-
|
|
2574
2177
|
if (parentEl.classList.contains('radioGroup')) {
|
|
2575
2178
|
parentEl = parentEl.parentNode.closest('div');
|
|
2576
2179
|
}
|
|
2577
|
-
|
|
2578
2180
|
var _labelEl = parentEl.querySelector('label');
|
|
2579
|
-
|
|
2580
2181
|
console.log(_labelEl, parentEl.querySelectorAll('label'));
|
|
2581
2182
|
var invalidText = this.languageHelper.translate('CONTACT_FORM_FIELD_INVALID', {
|
|
2582
2183
|
FIELD_NAME: _labelEl.innerText
|
|
2583
2184
|
});
|
|
2584
2185
|
errors.push(invalidText);
|
|
2585
2186
|
}
|
|
2586
|
-
|
|
2587
2187
|
errors = _toConsumableArray(new Set(errors)); // Only unique text
|
|
2588
|
-
|
|
2589
2188
|
this.findElement('button[type="submit"]').insertAdjacentHTML('afterend', "<div class=\"booking-error\"><ul><li>".concat(errors.join('<li>'), "</ul></div>"));
|
|
2590
2189
|
}
|
|
2591
2190
|
}, {
|
|
2592
2191
|
key: "showLabel",
|
|
2593
2192
|
value: function showLabel(field, idx) {
|
|
2594
2193
|
var labelText = field.naam;
|
|
2595
|
-
|
|
2596
2194
|
if (field.verplicht) {
|
|
2597
2195
|
labelText += "<span class=\"recras-contactform-required\" title=\"".concat(this.languageHelper.translate('ATTR_REQUIRED'), "\"></span>");
|
|
2598
2196
|
}
|
|
2599
|
-
|
|
2600
2197
|
return "<label for=\"contactformulier-".concat(idx, "\">").concat(labelText, "</label>");
|
|
2601
2198
|
}
|
|
2602
2199
|
}, {
|
|
@@ -2607,12 +2204,10 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2607
2204
|
}, {
|
|
2608
2205
|
key: "submitForm",
|
|
2609
2206
|
value: function submitForm(e) {
|
|
2610
|
-
var
|
|
2611
|
-
|
|
2207
|
+
var _this37 = this;
|
|
2612
2208
|
e.preventDefault();
|
|
2613
2209
|
var submitButton = this.findElement('.submitForm');
|
|
2614
2210
|
this.removeErrors('.recras-contactform');
|
|
2615
|
-
|
|
2616
2211
|
if (this.isEmpty()) {
|
|
2617
2212
|
submitButton.parentNode.insertAdjacentHTML('beforeend', "<div class=\"booking-error\">".concat(this.languageHelper.translate('ERR_CONTACT_FORM_EMPTY'), "</div>"));
|
|
2618
2213
|
return false;
|
|
@@ -2620,49 +2215,39 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2620
2215
|
this.showErrors();
|
|
2621
2216
|
return false;
|
|
2622
2217
|
}
|
|
2623
|
-
|
|
2624
2218
|
if (!this.checkRequiredCheckboxes()) {
|
|
2625
2219
|
return false;
|
|
2626
2220
|
}
|
|
2627
|
-
|
|
2628
2221
|
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_CONTACT_FORM, RecrasEventHelper.EVENT_CONTACT_FORM_SUBMIT, null, this.options.getFormId());
|
|
2629
2222
|
this.loadingIndicatorHide();
|
|
2630
2223
|
this.loadingIndicatorShow(submitButton);
|
|
2631
2224
|
submitButton.setAttribute('disabled', 'disabled');
|
|
2632
2225
|
this.postJson('contactformulieren/' + this.options.getFormId() + '/opslaan', this.generateJson()).then(function (json) {
|
|
2633
2226
|
if (json.success) {
|
|
2634
|
-
if (
|
|
2635
|
-
window.top.location.href =
|
|
2227
|
+
if (_this37.options.getRedirectUrl()) {
|
|
2228
|
+
window.top.location.href = _this37.options.getRedirectUrl();
|
|
2636
2229
|
} else {
|
|
2637
|
-
|
|
2230
|
+
_this37.element.scrollIntoView({
|
|
2638
2231
|
behavior: 'smooth'
|
|
2639
2232
|
});
|
|
2640
|
-
|
|
2641
|
-
_this39.element.insertAdjacentHTML('afterbegin', "<p class=\"recras-success\">".concat(_this39.languageHelper.translate('CONTACT_FORM_SUBMIT_SUCCESS'), "</p>"));
|
|
2642
|
-
|
|
2233
|
+
_this37.element.insertAdjacentHTML('afterbegin', "<p class=\"recras-success\">".concat(_this37.languageHelper.translate('CONTACT_FORM_SUBMIT_SUCCESS'), "</p>"));
|
|
2643
2234
|
submitButton.parentNode.reset();
|
|
2644
2235
|
}
|
|
2645
2236
|
} else {
|
|
2646
|
-
|
|
2237
|
+
_this37.error(_this37.languageHelper.translate('CONTACT_FORM_SUBMIT_FAILED'));
|
|
2647
2238
|
}
|
|
2648
|
-
|
|
2649
2239
|
submitButton.removeAttribute('disabled');
|
|
2650
|
-
|
|
2651
|
-
_this39.loadingIndicatorHide();
|
|
2240
|
+
_this37.loadingIndicatorHide();
|
|
2652
2241
|
});
|
|
2653
2242
|
return false;
|
|
2654
2243
|
}
|
|
2655
2244
|
}]);
|
|
2656
|
-
|
|
2657
|
-
return RecrasContactForm;
|
|
2658
2245
|
}();
|
|
2659
|
-
|
|
2660
2246
|
var RecrasCSSHelper = /*#__PURE__*/function () {
|
|
2661
2247
|
function RecrasCSSHelper() {
|
|
2662
2248
|
_classCallCheck(this, RecrasCSSHelper);
|
|
2663
2249
|
}
|
|
2664
|
-
|
|
2665
|
-
_createClass(RecrasCSSHelper, null, [{
|
|
2250
|
+
return _createClass(RecrasCSSHelper, null, [{
|
|
2666
2251
|
key: "cssBooking",
|
|
2667
2252
|
value: function cssBooking() {
|
|
2668
2253
|
return "\n.recras-onlinebooking {\n max-width: 800px;\n}\n.recras-onlinebooking > form + form, .recras-finalise {\n border-top: 2px solid #dedede; /* Any love for Kirby out there? */\n}\n.recras-amountsform > div {\n display: grid;\n grid-template-columns: 1fr 5em 7em;\n}\n.recras-amountsform input {\n width: auto; /* Firefox fix */\n}\n.recras-input-invalid {\n border: 1px solid hsl(0, 50%, 50%);\n}\n.booking-error, .minimum-amount {\n color: hsl(0, 50%, 50%);\n}\n.recras-success {\n color: hsl(120, 40%, 40%);\n}\n.minimum-amount {\n padding-left: 0.5em;\n}\n.recras-datetime {\n display: grid;\n grid-template-columns: 30% 70%;\n}\n.recras-datetime > * {\n margin: 0.25em 0;\n}\n.recras-datetime label {\n display: block;\n}\n.recras-datetime input, .recras-datetime select {\n max-width: 12em;\n}\n.time-preview {\n padding-right: 0.5em;\n}\n.recrasUnitPrice {\n opacity: 0.5;\n}\n.recras-onlinebooking .recrasHidden {\n display: none;\n}\n";
|
|
@@ -2700,48 +2285,37 @@ var RecrasCSSHelper = /*#__PURE__*/function () {
|
|
|
2700
2285
|
value: function loadCSS(cssName) {
|
|
2701
2286
|
var inlineCss;
|
|
2702
2287
|
var url;
|
|
2703
|
-
|
|
2704
2288
|
switch (cssName) {
|
|
2705
2289
|
case 'booking':
|
|
2706
2290
|
inlineCss = this.cssBooking();
|
|
2707
2291
|
break;
|
|
2708
|
-
|
|
2709
2292
|
case 'global':
|
|
2710
2293
|
inlineCss = this.cssGlobal();
|
|
2711
2294
|
break;
|
|
2712
|
-
|
|
2713
2295
|
case 'pikaday':
|
|
2714
2296
|
url = 'https://cdnjs.cloudflare.com/ajax/libs/pikaday/1.8.2/css/pikaday.min.css';
|
|
2715
2297
|
break;
|
|
2716
|
-
|
|
2717
2298
|
default:
|
|
2718
2299
|
console.warn('Unknown CSS');
|
|
2719
2300
|
break;
|
|
2720
2301
|
}
|
|
2721
|
-
|
|
2722
2302
|
if (document.getElementById('recras-css-' + cssName)) {
|
|
2723
2303
|
return;
|
|
2724
2304
|
}
|
|
2725
|
-
|
|
2726
2305
|
if (inlineCss) {
|
|
2727
2306
|
RecrasCSSHelper.loadInlineCss(cssName, inlineCss);
|
|
2728
2307
|
}
|
|
2729
|
-
|
|
2730
2308
|
if (url) {
|
|
2731
2309
|
RecrasCSSHelper.loadExternalCss(cssName, url);
|
|
2732
2310
|
}
|
|
2733
2311
|
}
|
|
2734
2312
|
}]);
|
|
2735
|
-
|
|
2736
|
-
return RecrasCSSHelper;
|
|
2737
2313
|
}();
|
|
2738
|
-
|
|
2739
2314
|
var RecrasDateHelper = /*#__PURE__*/function () {
|
|
2740
2315
|
function RecrasDateHelper() {
|
|
2741
2316
|
_classCallCheck(this, RecrasDateHelper);
|
|
2742
2317
|
}
|
|
2743
|
-
|
|
2744
|
-
_createClass(RecrasDateHelper, null, [{
|
|
2318
|
+
return _createClass(RecrasDateHelper, null, [{
|
|
2745
2319
|
key: "clone",
|
|
2746
2320
|
value: function clone(date) {
|
|
2747
2321
|
return new Date(date.getTime());
|
|
@@ -2750,7 +2324,6 @@ var RecrasDateHelper = /*#__PURE__*/function () {
|
|
|
2750
2324
|
key: "datePartOnly",
|
|
2751
2325
|
value: function datePartOnly(date) {
|
|
2752
2326
|
var x = new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000); // Fix off-by-1 errors
|
|
2753
|
-
|
|
2754
2327
|
return x.toISOString().substr(0, 10); // Format as 2018-03-13
|
|
2755
2328
|
}
|
|
2756
2329
|
}, {
|
|
@@ -2759,12 +2332,11 @@ var RecrasDateHelper = /*#__PURE__*/function () {
|
|
|
2759
2332
|
// Handle DD-MM-YYYY pattern in code
|
|
2760
2333
|
var datePatternDMY = '(0[1-9]|1[0-9]|2[0-9]|3[01])-(0[1-9]|1[012])-([0-9]{4})';
|
|
2761
2334
|
var dmyMatches = date.match(datePatternDMY);
|
|
2762
|
-
|
|
2763
2335
|
if (dmyMatches) {
|
|
2764
2336
|
return dmyMatches[3] + '-' + dmyMatches[2] + '-' + dmyMatches[1];
|
|
2765
|
-
}
|
|
2766
|
-
|
|
2337
|
+
}
|
|
2767
2338
|
|
|
2339
|
+
// Let API handle the rest. That way, the user will get an error if the input is invalid
|
|
2768
2340
|
return date;
|
|
2769
2341
|
}
|
|
2770
2342
|
}, {
|
|
@@ -2791,24 +2363,18 @@ var RecrasDateHelper = /*#__PURE__*/function () {
|
|
|
2791
2363
|
key: "toString",
|
|
2792
2364
|
value: function toString(date) {
|
|
2793
2365
|
var x = new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000); // Fix off-by-1 errors
|
|
2794
|
-
|
|
2795
2366
|
x = x.toISOString();
|
|
2796
2367
|
return x.substr(8, 2) + '-' + x.substr(5, 2) + '-' + x.substr(0, 4);
|
|
2797
2368
|
}
|
|
2798
2369
|
}]);
|
|
2799
|
-
|
|
2800
|
-
return RecrasDateHelper;
|
|
2801
2370
|
}();
|
|
2802
|
-
|
|
2803
2371
|
var RecrasEventHelper = /*#__PURE__*/function () {
|
|
2804
2372
|
function RecrasEventHelper() {
|
|
2805
2373
|
_classCallCheck(this, RecrasEventHelper);
|
|
2806
|
-
|
|
2807
2374
|
this.analyticsEnabled = false;
|
|
2808
2375
|
this.eventsEnabled = RecrasEventHelper.allEvents();
|
|
2809
2376
|
}
|
|
2810
|
-
|
|
2811
|
-
_createClass(RecrasEventHelper, [{
|
|
2377
|
+
return _createClass(RecrasEventHelper, [{
|
|
2812
2378
|
key: "eventEnabled",
|
|
2813
2379
|
value: function eventEnabled(name) {
|
|
2814
2380
|
return this.eventsEnabled.includes(name);
|
|
@@ -2816,14 +2382,10 @@ var RecrasEventHelper = /*#__PURE__*/function () {
|
|
|
2816
2382
|
}, {
|
|
2817
2383
|
key: "ga4EventMap",
|
|
2818
2384
|
value: function ga4EventMap(action) {
|
|
2819
|
-
var
|
|
2820
|
-
|
|
2821
|
-
var map = (_map = {}, _defineProperty(_map, RecrasEventHelper.EVENT_BOOKING_PACKAGE_CHANGED, 'select_content'), _defineProperty(_map, RecrasEventHelper.EVENT_BOOKING_REDIRECT_PAYMENT, 'begin_checkout'), _defineProperty(_map, RecrasEventHelper.EVENT_VOUCHER_TEMPLATE_CHANGED, 'select_content'), _defineProperty(_map, RecrasEventHelper.EVENT_VOUCHER_REDIRECT_PAYMENT, 'begin_checkout'), _map);
|
|
2822
|
-
|
|
2385
|
+
var map = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, RecrasEventHelper.EVENT_BOOKING_PACKAGE_CHANGED, 'select_content'), RecrasEventHelper.EVENT_BOOKING_REDIRECT_PAYMENT, 'begin_checkout'), RecrasEventHelper.EVENT_VOUCHER_TEMPLATE_CHANGED, 'select_content'), RecrasEventHelper.EVENT_VOUCHER_REDIRECT_PAYMENT, 'begin_checkout');
|
|
2823
2386
|
if (map[action] === undefined) {
|
|
2824
2387
|
return false;
|
|
2825
2388
|
}
|
|
2826
|
-
|
|
2827
2389
|
return map[action];
|
|
2828
2390
|
}
|
|
2829
2391
|
}, {
|
|
@@ -2832,30 +2394,25 @@ var RecrasEventHelper = /*#__PURE__*/function () {
|
|
|
2832
2394
|
var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
2833
2395
|
var value = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
2834
2396
|
var ga4Value = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
|
|
2835
|
-
|
|
2836
2397
|
if (typeof window.gtag !== 'function') {
|
|
2837
2398
|
return;
|
|
2838
2399
|
}
|
|
2839
|
-
|
|
2840
2400
|
if (this.ga4EventMap(action) && ga4Value) {
|
|
2841
2401
|
// v4
|
|
2842
2402
|
window.gtag('event', this.ga4EventMap(action), ga4Value);
|
|
2843
2403
|
return;
|
|
2844
|
-
}
|
|
2845
|
-
|
|
2404
|
+
}
|
|
2846
2405
|
|
|
2406
|
+
// Global Site Tag (v3)
|
|
2847
2407
|
var eventData = {
|
|
2848
2408
|
event_category: RecrasEventHelper.PREFIX_GLOBAL + ':' + cat
|
|
2849
2409
|
};
|
|
2850
|
-
|
|
2851
2410
|
if (label) {
|
|
2852
2411
|
eventData.event_label = label;
|
|
2853
2412
|
}
|
|
2854
|
-
|
|
2855
2413
|
if (value) {
|
|
2856
2414
|
eventData.value = value;
|
|
2857
2415
|
}
|
|
2858
|
-
|
|
2859
2416
|
window.gtag('event', action, eventData);
|
|
2860
2417
|
}
|
|
2861
2418
|
}, {
|
|
@@ -2864,11 +2421,9 @@ var RecrasEventHelper = /*#__PURE__*/function () {
|
|
|
2864
2421
|
var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
2865
2422
|
var value = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
2866
2423
|
var ga4Value = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
|
|
2867
|
-
|
|
2868
2424
|
if (this.analyticsEnabled && this.eventEnabled(action)) {
|
|
2869
2425
|
this.sendAnalyticsEvent(cat, action, label, value, ga4Value);
|
|
2870
2426
|
}
|
|
2871
|
-
|
|
2872
2427
|
var event = new Event(RecrasEventHelper.PREFIX_GLOBAL + ':' + cat + ':' + action);
|
|
2873
2428
|
return document.dispatchEvent(event);
|
|
2874
2429
|
}
|
|
@@ -2888,56 +2443,34 @@ var RecrasEventHelper = /*#__PURE__*/function () {
|
|
|
2888
2443
|
return [RecrasEventHelper.EVENT_BOOKING_BOOKING_SUBMITTED, RecrasEventHelper.EVENT_BOOKING_CONTACT_FORM_SHOWN, RecrasEventHelper.EVENT_BOOKING_DATE_SELECTED, RecrasEventHelper.EVENT_BOOKING_PACKAGE_CHANGED, RecrasEventHelper.EVENT_BOOKING_PACKAGES_SHOWN, RecrasEventHelper.EVENT_BOOKING_PRODUCTS_SHOWN, RecrasEventHelper.EVENT_BOOKING_REDIRECT_PAYMENT, RecrasEventHelper.EVENT_BOOKING_RESET, RecrasEventHelper.EVENT_BOOKING_TIME_SELECTED, RecrasEventHelper.EVENT_CONTACT_FORM_SUBMIT, RecrasEventHelper.EVENT_VOUCHER_REDIRECT_PAYMENT, RecrasEventHelper.EVENT_VOUCHER_TEMPLATE_CHANGED, RecrasEventHelper.EVENT_VOUCHER_VOUCHER_SUBMITTED];
|
|
2889
2444
|
}
|
|
2890
2445
|
}]);
|
|
2891
|
-
|
|
2892
|
-
return RecrasEventHelper;
|
|
2893
2446
|
}();
|
|
2894
|
-
|
|
2895
2447
|
_defineProperty(RecrasEventHelper, "PREFIX_GLOBAL", 'Recras');
|
|
2896
|
-
|
|
2897
2448
|
_defineProperty(RecrasEventHelper, "PREFIX_BOOKING", 'Booking');
|
|
2898
|
-
|
|
2899
2449
|
_defineProperty(RecrasEventHelper, "PREFIX_CONTACT_FORM", 'ContactForm');
|
|
2900
|
-
|
|
2901
2450
|
_defineProperty(RecrasEventHelper, "PREFIX_VOUCHER", 'Voucher');
|
|
2902
|
-
|
|
2903
2451
|
_defineProperty(RecrasEventHelper, "EVENT_BOOKING_BOOKING_SUBMITTED", 'BuyInProgress');
|
|
2904
|
-
|
|
2905
2452
|
_defineProperty(RecrasEventHelper, "EVENT_BOOKING_CONTACT_FORM_SHOWN", 'ContactFormShown');
|
|
2906
|
-
|
|
2907
2453
|
_defineProperty(RecrasEventHelper, "EVENT_BOOKING_DATE_SELECTED", 'DateSelected');
|
|
2908
|
-
|
|
2909
2454
|
_defineProperty(RecrasEventHelper, "EVENT_BOOKING_PACKAGE_CHANGED", 'PackageChanged');
|
|
2910
|
-
|
|
2911
2455
|
_defineProperty(RecrasEventHelper, "EVENT_BOOKING_PACKAGES_SHOWN", 'PackagesShown');
|
|
2912
|
-
|
|
2913
2456
|
_defineProperty(RecrasEventHelper, "EVENT_BOOKING_PRODUCTS_SHOWN", 'ProductsShown');
|
|
2914
|
-
|
|
2915
2457
|
_defineProperty(RecrasEventHelper, "EVENT_BOOKING_REDIRECT_PAYMENT", 'RedirectToPayment');
|
|
2916
|
-
|
|
2917
2458
|
_defineProperty(RecrasEventHelper, "EVENT_BOOKING_RESET", 'Reset');
|
|
2918
|
-
|
|
2919
2459
|
_defineProperty(RecrasEventHelper, "EVENT_BOOKING_TIME_SELECTED", 'TimeSelected');
|
|
2920
|
-
|
|
2921
2460
|
_defineProperty(RecrasEventHelper, "EVENT_CONTACT_FORM_SUBMIT", 'Submit');
|
|
2922
|
-
|
|
2923
2461
|
_defineProperty(RecrasEventHelper, "EVENT_VOUCHER_REDIRECT_PAYMENT", 'RedirectToPayment');
|
|
2924
|
-
|
|
2925
2462
|
_defineProperty(RecrasEventHelper, "EVENT_VOUCHER_TEMPLATE_CHANGED", 'TemplateChanged');
|
|
2926
|
-
|
|
2927
2463
|
_defineProperty(RecrasEventHelper, "EVENT_VOUCHER_VOUCHER_SUBMITTED", 'BuyInProgress');
|
|
2928
|
-
|
|
2929
2464
|
var RecrasHttpHelper = /*#__PURE__*/function () {
|
|
2930
2465
|
function RecrasHttpHelper() {
|
|
2931
2466
|
_classCallCheck(this, RecrasHttpHelper);
|
|
2932
2467
|
}
|
|
2933
|
-
|
|
2934
|
-
_createClass(RecrasHttpHelper, null, [{
|
|
2468
|
+
return _createClass(RecrasHttpHelper, null, [{
|
|
2935
2469
|
key: "call",
|
|
2936
2470
|
value: function call(url, data, errorHandler) {
|
|
2937
2471
|
if (!url) {
|
|
2938
2472
|
throw new Error('ERR_FETCH_WITHOUT_URL'); //TODO: translate
|
|
2939
2473
|
}
|
|
2940
|
-
|
|
2941
2474
|
var lastResponse;
|
|
2942
2475
|
return fetch(url, data).then(function (response) {
|
|
2943
2476
|
lastResponse = response;
|
|
@@ -2948,7 +2481,6 @@ var RecrasHttpHelper = /*#__PURE__*/function () {
|
|
|
2948
2481
|
errorHandler(errorMsg);
|
|
2949
2482
|
return false;
|
|
2950
2483
|
}
|
|
2951
|
-
|
|
2952
2484
|
return json;
|
|
2953
2485
|
})["catch"](function (err) {
|
|
2954
2486
|
errorHandler(err);
|
|
@@ -2972,18 +2504,15 @@ var RecrasHttpHelper = /*#__PURE__*/function () {
|
|
|
2972
2504
|
}, errorHandler);
|
|
2973
2505
|
}
|
|
2974
2506
|
}]);
|
|
2975
|
-
|
|
2976
|
-
return RecrasHttpHelper;
|
|
2977
2507
|
}();
|
|
2978
|
-
|
|
2979
2508
|
var RecrasLanguageHelper = /*#__PURE__*/function () {
|
|
2980
2509
|
function RecrasLanguageHelper() {
|
|
2981
2510
|
_classCallCheck(this, RecrasLanguageHelper);
|
|
2982
|
-
|
|
2983
2511
|
this.defaultLocale = 'nl_NL';
|
|
2984
2512
|
this.locale = this.defaultLocale;
|
|
2985
|
-
this.options = null;
|
|
2513
|
+
this.options = null;
|
|
2986
2514
|
|
|
2515
|
+
//TODO: what is the best way to handle multiple locales?
|
|
2987
2516
|
this.i18n = {
|
|
2988
2517
|
de_DE: {
|
|
2989
2518
|
AGREE_ATTACHMENTS: 'Ich stimme den folgenden Unterlagen zu:',
|
|
@@ -3339,8 +2868,7 @@ var RecrasLanguageHelper = /*#__PURE__*/function () {
|
|
|
3339
2868
|
}
|
|
3340
2869
|
};
|
|
3341
2870
|
}
|
|
3342
|
-
|
|
3343
|
-
_createClass(RecrasLanguageHelper, [{
|
|
2871
|
+
return _createClass(RecrasLanguageHelper, [{
|
|
3344
2872
|
key: "error",
|
|
3345
2873
|
value: function error(msg) {
|
|
3346
2874
|
console.log('Error', msg); //TODO
|
|
@@ -3352,11 +2880,9 @@ var RecrasLanguageHelper = /*#__PURE__*/function () {
|
|
|
3352
2880
|
var regexPartMulticolumn = '((?:\\((?:\\w+)(?::[^)]*)?\\))*)';
|
|
3353
2881
|
var regex = new RegExp('{' + alphanumericWithUnderscore + '+' + regexPartMulticolumn + '}', 'g');
|
|
3354
2882
|
var tags = msg.match(regex);
|
|
3355
|
-
|
|
3356
2883
|
if (!Array.isArray(tags)) {
|
|
3357
2884
|
return [];
|
|
3358
2885
|
}
|
|
3359
|
-
|
|
3360
2886
|
return tags.map(function (tag) {
|
|
3361
2887
|
return tag.substring(1, tag.length - 1);
|
|
3362
2888
|
}); // Strip { and }
|
|
@@ -3365,11 +2891,9 @@ var RecrasLanguageHelper = /*#__PURE__*/function () {
|
|
|
3365
2891
|
key: "filterTags",
|
|
3366
2892
|
value: function filterTags(msg, packageID) {
|
|
3367
2893
|
var tags = this.extractTags(msg);
|
|
3368
|
-
|
|
3369
2894
|
if (tags.length === 0) {
|
|
3370
2895
|
return Promise.resolve(msg);
|
|
3371
2896
|
}
|
|
3372
|
-
|
|
3373
2897
|
return RecrasHttpHelper.postJson(this.options.getApiBase() + 'tagfilter', {
|
|
3374
2898
|
tags: tags,
|
|
3375
2899
|
context: {
|
|
@@ -3388,7 +2912,6 @@ var RecrasLanguageHelper = /*#__PURE__*/function () {
|
|
|
3388
2912
|
switch (what) {
|
|
3389
2913
|
case 'currency':
|
|
3390
2914
|
return this.locale.replace('_', '-').toUpperCase();
|
|
3391
|
-
|
|
3392
2915
|
default:
|
|
3393
2916
|
return this.locale;
|
|
3394
2917
|
}
|
|
@@ -3404,16 +2927,13 @@ var RecrasLanguageHelper = /*#__PURE__*/function () {
|
|
|
3404
2927
|
}, {
|
|
3405
2928
|
key: "setCurrency",
|
|
3406
2929
|
value: function setCurrency() {
|
|
3407
|
-
var
|
|
3408
|
-
|
|
2930
|
+
var _this38 = this;
|
|
3409
2931
|
var errorHandler = function errorHandler(err) {
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
_this40.error(err);
|
|
2932
|
+
_this38.currency = 'eur';
|
|
2933
|
+
_this38.error(err);
|
|
3413
2934
|
};
|
|
3414
|
-
|
|
3415
2935
|
return RecrasHttpHelper.fetchJson(this.options.getApiBase() + 'instellingen/currency', errorHandler).then(function (setting) {
|
|
3416
|
-
|
|
2936
|
+
_this38.currency = setting.waarde;
|
|
3417
2937
|
});
|
|
3418
2938
|
}
|
|
3419
2939
|
}, {
|
|
@@ -3432,7 +2952,6 @@ var RecrasLanguageHelper = /*#__PURE__*/function () {
|
|
|
3432
2952
|
value: function translate(string) {
|
|
3433
2953
|
var vars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3434
2954
|
var translated;
|
|
3435
|
-
|
|
3436
2955
|
if (this.i18n[this.locale] && this.i18n[this.locale][string]) {
|
|
3437
2956
|
translated = this.i18n[this.locale][string];
|
|
3438
2957
|
} else if (this.i18n.en_GB[string]) {
|
|
@@ -3441,13 +2960,11 @@ var RecrasLanguageHelper = /*#__PURE__*/function () {
|
|
|
3441
2960
|
translated = string;
|
|
3442
2961
|
console.warn('String not translated: ' + string);
|
|
3443
2962
|
}
|
|
3444
|
-
|
|
3445
2963
|
if (Object.keys(vars).length > 0) {
|
|
3446
2964
|
Object.keys(vars).forEach(function (key) {
|
|
3447
2965
|
translated = translated.replace('{' + key + '}', vars[key]);
|
|
3448
2966
|
});
|
|
3449
2967
|
}
|
|
3450
|
-
|
|
3451
2968
|
return translated;
|
|
3452
2969
|
}
|
|
3453
2970
|
}], [{
|
|
@@ -3456,42 +2973,31 @@ var RecrasLanguageHelper = /*#__PURE__*/function () {
|
|
|
3456
2973
|
return this.validLocales.indexOf(locale) > -1;
|
|
3457
2974
|
}
|
|
3458
2975
|
}]);
|
|
3459
|
-
|
|
3460
|
-
return RecrasLanguageHelper;
|
|
3461
2976
|
}();
|
|
3462
|
-
|
|
3463
2977
|
_defineProperty(RecrasLanguageHelper, "validLocales", ['de_DE', 'en_GB', 'nl_NL', 'sv_SE']);
|
|
3464
|
-
|
|
3465
2978
|
var RecrasOptions = /*#__PURE__*/function () {
|
|
3466
2979
|
function RecrasOptions(options) {
|
|
3467
2980
|
_classCallCheck(this, RecrasOptions);
|
|
3468
|
-
|
|
3469
2981
|
this.languageHelper = new RecrasLanguageHelper();
|
|
3470
2982
|
this.validate(options);
|
|
3471
2983
|
this.options = this.setOptions(options);
|
|
3472
2984
|
}
|
|
3473
|
-
|
|
3474
|
-
_createClass(RecrasOptions, [{
|
|
2985
|
+
return _createClass(RecrasOptions, [{
|
|
3475
2986
|
key: "getAnalyticsEvents",
|
|
3476
2987
|
value: function getAnalyticsEvents() {
|
|
3477
2988
|
if (!Array.isArray(this.options.analyticsEvents)) {
|
|
3478
2989
|
this.options.analyticsEvents = RecrasEventHelper.allEvents();
|
|
3479
2990
|
}
|
|
3480
|
-
|
|
3481
2991
|
this.options.analyticsEvents = this.options.analyticsEvents.filter(function (event) {
|
|
3482
2992
|
var eventExists = RecrasEventHelper.allEvents().includes(event);
|
|
3483
|
-
|
|
3484
2993
|
if (!eventExists) {
|
|
3485
2994
|
console.warn('Invalid event: ' + event);
|
|
3486
2995
|
}
|
|
3487
|
-
|
|
3488
2996
|
return eventExists;
|
|
3489
2997
|
});
|
|
3490
|
-
|
|
3491
2998
|
if (this.options.analyticsEvents.length === 0) {
|
|
3492
2999
|
this.options.analyticsEvents = RecrasEventHelper.allEvents();
|
|
3493
3000
|
}
|
|
3494
|
-
|
|
3495
3001
|
return this.options.analyticsEvents;
|
|
3496
3002
|
}
|
|
3497
3003
|
}, {
|
|
@@ -3515,7 +3021,6 @@ var RecrasOptions = /*#__PURE__*/function () {
|
|
|
3515
3021
|
if (this.options.defaultCountry !== undefined) {
|
|
3516
3022
|
return this.options.defaultCountry;
|
|
3517
3023
|
}
|
|
3518
|
-
|
|
3519
3024
|
return this.getLocale().substr(3, 2); // en_IE -> IE
|
|
3520
3025
|
}
|
|
3521
3026
|
}, {
|
|
@@ -3579,7 +3084,6 @@ var RecrasOptions = /*#__PURE__*/function () {
|
|
|
3579
3084
|
if (Array.isArray(this.options.package_id)) {
|
|
3580
3085
|
return this.options.package_id.length === 1;
|
|
3581
3086
|
}
|
|
3582
|
-
|
|
3583
3087
|
return !isNaN(parseInt(this.options.package_id, 10));
|
|
3584
3088
|
}
|
|
3585
3089
|
}, {
|
|
@@ -3599,15 +3103,12 @@ var RecrasOptions = /*#__PURE__*/function () {
|
|
|
3599
3103
|
if (!options.element) {
|
|
3600
3104
|
throw new Error(this.languageHelper.translate('ERR_NO_ELEMENT'));
|
|
3601
3105
|
}
|
|
3602
|
-
|
|
3603
3106
|
if (options.element instanceof Element === false) {
|
|
3604
3107
|
throw new Error(this.languageHelper.translate('ERR_INVALID_ELEMENT'));
|
|
3605
3108
|
}
|
|
3606
|
-
|
|
3607
3109
|
if (!options.recras_hostname) {
|
|
3608
3110
|
throw new Error(this.languageHelper.translate('ERR_NO_HOSTNAME'));
|
|
3609
3111
|
}
|
|
3610
|
-
|
|
3611
3112
|
if (options.redirect_url) {
|
|
3612
3113
|
if (options.redirect_url.indexOf('http://') === -1 && options.redirect_url.indexOf('https://') === -1) {
|
|
3613
3114
|
throw new Error(this.languageHelper.translate('ERR_INVALID_REDIRECT_URL'));
|
|
@@ -3615,40 +3116,28 @@ var RecrasOptions = /*#__PURE__*/function () {
|
|
|
3615
3116
|
}
|
|
3616
3117
|
}
|
|
3617
3118
|
}]);
|
|
3618
|
-
|
|
3619
|
-
return RecrasOptions;
|
|
3620
3119
|
}();
|
|
3621
|
-
|
|
3622
3120
|
var RecrasVoucher = /*#__PURE__*/function () {
|
|
3623
3121
|
function RecrasVoucher() {
|
|
3624
|
-
var
|
|
3625
|
-
|
|
3122
|
+
var _this39 = this;
|
|
3626
3123
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3627
|
-
|
|
3628
3124
|
_classCallCheck(this, RecrasVoucher);
|
|
3629
|
-
|
|
3630
3125
|
this.languageHelper = new RecrasLanguageHelper();
|
|
3631
|
-
|
|
3632
3126
|
if (options instanceof RecrasOptions === false) {
|
|
3633
3127
|
throw new Error(this.languageHelper.translate('ERR_OPTIONS_INVALID'));
|
|
3634
3128
|
}
|
|
3635
|
-
|
|
3636
3129
|
this.options = options;
|
|
3637
3130
|
this.eventHelper = new RecrasEventHelper();
|
|
3638
3131
|
this.eventHelper.setEvents(this.options.getAnalyticsEvents());
|
|
3639
3132
|
this.element = this.options.getElement();
|
|
3640
3133
|
this.element.classList.add('recras-buy-voucher');
|
|
3641
|
-
|
|
3642
3134
|
this.fetchJson = function (url) {
|
|
3643
|
-
return RecrasHttpHelper.fetchJson(url,
|
|
3135
|
+
return RecrasHttpHelper.fetchJson(url, _this39.error);
|
|
3644
3136
|
};
|
|
3645
|
-
|
|
3646
3137
|
this.postJson = function (url, data) {
|
|
3647
|
-
return RecrasHttpHelper.postJson(
|
|
3138
|
+
return RecrasHttpHelper.postJson(_this39.options.getApiBase() + url, data, _this39.error);
|
|
3648
3139
|
};
|
|
3649
|
-
|
|
3650
3140
|
RecrasCSSHelper.loadCSS('global');
|
|
3651
|
-
|
|
3652
3141
|
if (this.options.getLocale()) {
|
|
3653
3142
|
if (!RecrasLanguageHelper.isValid(this.options.getLocale())) {
|
|
3654
3143
|
console.warn(this.languageHelper.translate('ERR_INVALID_LOCALE', {
|
|
@@ -3658,19 +3147,17 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3658
3147
|
this.languageHelper.setLocale(this.options.getLocale());
|
|
3659
3148
|
}
|
|
3660
3149
|
}
|
|
3661
|
-
|
|
3662
3150
|
this.languageHelper.setOptions(options).then(function () {
|
|
3663
|
-
return
|
|
3151
|
+
return _this39.getVoucherTemplates();
|
|
3664
3152
|
}).then(function (templates) {
|
|
3665
|
-
if (
|
|
3666
|
-
|
|
3153
|
+
if (_this39.options.getVoucherTemplateId()) {
|
|
3154
|
+
_this39.changeTemplate(_this39.options.getVoucherTemplateId());
|
|
3667
3155
|
} else {
|
|
3668
|
-
|
|
3156
|
+
_this39.showTemplates(templates);
|
|
3669
3157
|
}
|
|
3670
3158
|
});
|
|
3671
3159
|
}
|
|
3672
|
-
|
|
3673
|
-
_createClass(RecrasVoucher, [{
|
|
3160
|
+
return _createClass(RecrasVoucher, [{
|
|
3674
3161
|
key: "appendHtml",
|
|
3675
3162
|
value: function appendHtml(msg) {
|
|
3676
3163
|
this.element.insertAdjacentHTML('beforeend', msg);
|
|
@@ -3687,14 +3174,11 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3687
3174
|
}, {
|
|
3688
3175
|
key: "buyTemplate",
|
|
3689
3176
|
value: function buyTemplate() {
|
|
3690
|
-
var
|
|
3691
|
-
|
|
3177
|
+
var _this40 = this;
|
|
3692
3178
|
var status = this.contactForm.checkRequiredCheckboxes();
|
|
3693
|
-
|
|
3694
3179
|
if (!status) {
|
|
3695
3180
|
return false;
|
|
3696
3181
|
}
|
|
3697
|
-
|
|
3698
3182
|
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_VOUCHER, RecrasEventHelper.EVENT_VOUCHER_VOUCHER_SUBMITTED, this.selectedTemplate.name, Math.round(this.totalPrice()));
|
|
3699
3183
|
this.findElement('.buyTemplate').setAttribute('disabled', 'disabled');
|
|
3700
3184
|
var payload = {
|
|
@@ -3702,25 +3186,21 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3702
3186
|
number_of_vouchers: parseInt(this.findElement('.number-of-vouchers').value, 10),
|
|
3703
3187
|
contact_form: this.contactForm.generateJson()
|
|
3704
3188
|
};
|
|
3705
|
-
|
|
3706
3189
|
if (this.options.getRedirectUrl()) {
|
|
3707
3190
|
payload.redirect_url = this.options.getRedirectUrl();
|
|
3708
3191
|
}
|
|
3709
|
-
|
|
3710
3192
|
this.postJson('vouchers/buy', payload).then(function (json) {
|
|
3711
3193
|
if (json.payment_url) {
|
|
3712
|
-
|
|
3713
|
-
currency:
|
|
3714
|
-
value:
|
|
3715
|
-
items:
|
|
3194
|
+
_this40.eventHelper.sendEvent(RecrasEventHelper.PREFIX_VOUCHER, RecrasEventHelper.EVENT_VOUCHER_REDIRECT_PAYMENT, null, Math.round(_this40.totalPrice()), {
|
|
3195
|
+
currency: _this40.languageHelper.currency,
|
|
3196
|
+
value: _this40.totalPrice(),
|
|
3197
|
+
items: _this40.formatGA4Item()
|
|
3716
3198
|
});
|
|
3717
|
-
|
|
3718
3199
|
window.top.location.href = json.payment_url;
|
|
3719
3200
|
} else {
|
|
3720
3201
|
console.log(json);
|
|
3721
3202
|
}
|
|
3722
|
-
|
|
3723
|
-
_this42.findElement('.buyTemplate').removeAttribute('disabled');
|
|
3203
|
+
_this40.findElement('.buyTemplate').removeAttribute('disabled');
|
|
3724
3204
|
});
|
|
3725
3205
|
}
|
|
3726
3206
|
}, {
|
|
@@ -3753,7 +3233,6 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3753
3233
|
_toConsumableArray(elements).forEach(function (el) {
|
|
3754
3234
|
el.parentNode.removeChild(el);
|
|
3755
3235
|
});
|
|
3756
|
-
|
|
3757
3236
|
this.maybeAddLatestErrorElement();
|
|
3758
3237
|
}
|
|
3759
3238
|
}, {
|
|
@@ -3780,25 +3259,23 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3780
3259
|
}, {
|
|
3781
3260
|
key: "getContactForm",
|
|
3782
3261
|
value: function getContactForm(template) {
|
|
3783
|
-
var
|
|
3784
|
-
|
|
3262
|
+
var _this41 = this;
|
|
3785
3263
|
this.options.setOption('form_id', template.contactform_id);
|
|
3786
3264
|
var contactForm = new RecrasContactForm(this.options);
|
|
3787
3265
|
return contactForm.getContactFormFields().then(function () {
|
|
3788
|
-
|
|
3266
|
+
_this41.contactForm = contactForm;
|
|
3789
3267
|
return contactForm;
|
|
3790
3268
|
});
|
|
3791
3269
|
}
|
|
3792
3270
|
}, {
|
|
3793
3271
|
key: "getVoucherTemplates",
|
|
3794
3272
|
value: function getVoucherTemplates() {
|
|
3795
|
-
var
|
|
3796
|
-
|
|
3273
|
+
var _this42 = this;
|
|
3797
3274
|
return this.fetchJson(this.options.getApiBase() + 'voucher_templates').then(function (templates) {
|
|
3798
3275
|
templates = templates.filter(function (template) {
|
|
3799
3276
|
return !!template.contactform_id;
|
|
3800
3277
|
});
|
|
3801
|
-
|
|
3278
|
+
_this42.templates = templates;
|
|
3802
3279
|
return templates;
|
|
3803
3280
|
});
|
|
3804
3281
|
}
|
|
@@ -3806,7 +3283,6 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3806
3283
|
key: "maybeAddLatestErrorElement",
|
|
3807
3284
|
value: function maybeAddLatestErrorElement() {
|
|
3808
3285
|
var errorEl = this.findElement('.latestError');
|
|
3809
|
-
|
|
3810
3286
|
if (!errorEl) {
|
|
3811
3287
|
this.appendHtml("<div class=\"latestError\"></div>");
|
|
3812
3288
|
}
|
|
@@ -3815,19 +3291,15 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3815
3291
|
key: "maybeDisableBuyButton",
|
|
3816
3292
|
value: function maybeDisableBuyButton() {
|
|
3817
3293
|
var button = this.findElement('.buyTemplate');
|
|
3818
|
-
|
|
3819
3294
|
if (!button) {
|
|
3820
3295
|
return false;
|
|
3821
3296
|
}
|
|
3822
|
-
|
|
3823
3297
|
var shouldDisable = false;
|
|
3824
3298
|
this.contactForm.removeErrors();
|
|
3825
|
-
|
|
3826
3299
|
if (this.contactForm.hasEmptyRequiredFields() || !this.contactForm.isValid() || !this.contactForm.checkRequiredCheckboxes()) {
|
|
3827
3300
|
this.contactForm.showErrors();
|
|
3828
3301
|
shouldDisable = true;
|
|
3829
3302
|
}
|
|
3830
|
-
|
|
3831
3303
|
if (shouldDisable) {
|
|
3832
3304
|
button.setAttribute('disabled', 'disabled');
|
|
3833
3305
|
} else {
|
|
@@ -3844,38 +3316,33 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3844
3316
|
}, {
|
|
3845
3317
|
key: "showContactForm",
|
|
3846
3318
|
value: function showContactForm(template) {
|
|
3847
|
-
var
|
|
3848
|
-
|
|
3319
|
+
var _this43 = this;
|
|
3849
3320
|
return this.getContactForm(template).then(function (form) {
|
|
3850
3321
|
return form.generateForm({
|
|
3851
3322
|
voucherQuantitySelector: true,
|
|
3852
|
-
quantityTerm:
|
|
3323
|
+
quantityTerm: _this43.selectedTemplate.quantity_term
|
|
3853
3324
|
});
|
|
3854
3325
|
}).then(function (html) {
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
_toConsumableArray(_this45.findElements('#number-of-vouchers, [name^="contactformulier"]')).forEach(function (el) {
|
|
3860
|
-
el.addEventListener('change', _this45.maybeDisableBuyButton.bind(_this45));
|
|
3326
|
+
_this43.appendHtml(html);
|
|
3327
|
+
_this43.showBuyButton();
|
|
3328
|
+
_toConsumableArray(_this43.findElements('#number-of-vouchers, [name^="contactformulier"]')).forEach(function (el) {
|
|
3329
|
+
el.addEventListener('change', _this43.maybeDisableBuyButton.bind(_this43));
|
|
3861
3330
|
});
|
|
3862
3331
|
});
|
|
3863
3332
|
}
|
|
3864
3333
|
}, {
|
|
3865
3334
|
key: "showTemplates",
|
|
3866
3335
|
value: function showTemplates(templates) {
|
|
3867
|
-
var
|
|
3868
|
-
|
|
3336
|
+
var _this44 = this;
|
|
3869
3337
|
var templateOptions = templates.map(function (template) {
|
|
3870
|
-
return "<option value=\"".concat(template.id, "\">").concat(template.name, " (").concat(
|
|
3338
|
+
return "<option value=\"".concat(template.id, "\">").concat(template.name, " (").concat(_this44.formatPrice(template.price), ")");
|
|
3871
3339
|
});
|
|
3872
3340
|
var html = "<select class=\"recrasVoucherTemplates\"><option>".concat(templateOptions.join(''), "</select>");
|
|
3873
3341
|
this.appendHtml("<div class=\"recras-voucher-templates\">".concat(html, "</div>"));
|
|
3874
3342
|
var voucherSelectEl = this.findElement('.recrasVoucherTemplates');
|
|
3875
3343
|
voucherSelectEl.addEventListener('change', function () {
|
|
3876
3344
|
var selectedTemplateId = parseInt(voucherSelectEl.value, 10);
|
|
3877
|
-
|
|
3878
|
-
_this46.changeTemplate(selectedTemplateId);
|
|
3345
|
+
_this44.changeTemplate(selectedTemplateId);
|
|
3879
3346
|
});
|
|
3880
3347
|
}
|
|
3881
3348
|
}, {
|
|
@@ -3884,6 +3351,4 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3884
3351
|
return this.selectedTemplate.price * this.findElement('#number-of-vouchers').value;
|
|
3885
3352
|
}
|
|
3886
3353
|
}]);
|
|
3887
|
-
|
|
3888
|
-
return RecrasVoucher;
|
|
3889
3354
|
}();
|