@recras/online-booking-js 1.10.3 → 2.0.1
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/README.md +7 -2
- package/changelog.md +12 -0
- package/dist/onlinebooking.js +199 -152
- package/dist/onlinebooking.min.js +1 -0
- package/docs/onlinebooking.html +2 -5
- package/package.json +20 -18
- package/src/booking.js +50 -14
- package/src/contactForm.js +0 -4
- package/src/cssHelper.js +0 -29
- package/src/eventHelper.js +39 -43
- package/src/vouchers.js +21 -2
- package/test/js-unit/recrasOptionsSpec.js +0 -3
- package/upgrading.md +5 -0
package/dist/onlinebooking.js
CHANGED
|
@@ -46,11 +46,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
46
46
|
|
|
47
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
48
|
|
|
49
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
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
50
|
|
|
51
51
|
/*******************************
|
|
52
52
|
* Recras integration library *
|
|
53
|
-
* v
|
|
53
|
+
* v 2.0.0 *
|
|
54
54
|
*******************************/
|
|
55
55
|
var RecrasBooking = /*#__PURE__*/function () {
|
|
56
56
|
function RecrasBooking() {
|
|
@@ -438,7 +438,10 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
438
438
|
return Promise.resolve(false);
|
|
439
439
|
} else {
|
|
440
440
|
this.clearAllExceptPackageSelection();
|
|
441
|
-
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_PACKAGE_CHANGED, selectedPackage[0].arrangement, selectedPackage[0].id
|
|
441
|
+
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_PACKAGE_CHANGED, selectedPackage[0].arrangement, selectedPackage[0].id, {
|
|
442
|
+
content_type: 'package',
|
|
443
|
+
item_id: selectedPackage[0].id
|
|
444
|
+
});
|
|
442
445
|
}
|
|
443
446
|
|
|
444
447
|
this.selectedPackage = selectedPackage[0];
|
|
@@ -1195,17 +1198,7 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1195
1198
|
}
|
|
1196
1199
|
|
|
1197
1200
|
this.findElement('#recras-onlinebooking-time option[value]').selected = true;
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
try {
|
|
1201
|
-
event = new Event('change');
|
|
1202
|
-
} catch (e) {
|
|
1203
|
-
// IE
|
|
1204
|
-
event = document.createEvent('Event');
|
|
1205
|
-
event.initEvent('change', true, true);
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
this.findElement('#recras-onlinebooking-time').dispatchEvent(event);
|
|
1201
|
+
this.findElement('#recras-onlinebooking-time').dispatchEvent(new Event('change'));
|
|
1209
1202
|
}
|
|
1210
1203
|
}, {
|
|
1211
1204
|
key: "setDiscountStatus",
|
|
@@ -1666,10 +1659,52 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1666
1659
|
});
|
|
1667
1660
|
return attachments;
|
|
1668
1661
|
}
|
|
1662
|
+
}, {
|
|
1663
|
+
key: "formatGA4Items",
|
|
1664
|
+
value: function formatGA4Items() {
|
|
1665
|
+
var _this28 = this;
|
|
1666
|
+
|
|
1667
|
+
var items = [];
|
|
1668
|
+
|
|
1669
|
+
if (this.bookingSize() > 0) {
|
|
1670
|
+
var pck = this.selectedPackage;
|
|
1671
|
+
items.push({
|
|
1672
|
+
item_name: pck.weergavenaam || pck.arrangement,
|
|
1673
|
+
price: this.bookingSizePrice(pck),
|
|
1674
|
+
quantity: this.bookingSize()
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
var linesNoBookingSize = this.getLinesNoBookingSize(this.selectedPackage);
|
|
1679
|
+
linesNoBookingSize = linesNoBookingSize.filter(function (line) {
|
|
1680
|
+
var lineEl = _this28.findElement("[data-package-id=\"".concat(line.id, "\"]"));
|
|
1681
|
+
|
|
1682
|
+
if (!lineEl) {
|
|
1683
|
+
return false;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
if (isNaN(parseInt(lineEl.value))) {
|
|
1687
|
+
return false;
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
return parseInt(lineEl.value) > 0;
|
|
1691
|
+
});
|
|
1692
|
+
linesNoBookingSize = linesNoBookingSize.map(function (line) {
|
|
1693
|
+
var lineEl = _this28.findElement("[data-package-id=\"".concat(line.id, "\"]"));
|
|
1694
|
+
|
|
1695
|
+
return {
|
|
1696
|
+
item_name: line.beschrijving_templated,
|
|
1697
|
+
price: line.product.verkoop,
|
|
1698
|
+
quantity: parseInt(lineEl.value)
|
|
1699
|
+
};
|
|
1700
|
+
});
|
|
1701
|
+
items.push.apply(items, _toConsumableArray(linesNoBookingSize));
|
|
1702
|
+
return items;
|
|
1703
|
+
}
|
|
1669
1704
|
}, {
|
|
1670
1705
|
key: "submitBooking",
|
|
1671
1706
|
value: function submitBooking() {
|
|
1672
|
-
var
|
|
1707
|
+
var _this29 = this;
|
|
1673
1708
|
|
|
1674
1709
|
var productCounts = this.productCounts().map(function (line) {
|
|
1675
1710
|
return line.aantal;
|
|
@@ -1728,30 +1763,34 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1728
1763
|
|
|
1729
1764
|
return this.postJson('onlineboeking/reserveer', bookingParams).then(function (json) {
|
|
1730
1765
|
if (json.payment_url) {
|
|
1731
|
-
|
|
1766
|
+
_this29.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_REDIRECT_PAYMENT, null, Math.round(_this29.getTotalPrice()), {
|
|
1767
|
+
currency: _this29.languageHelper.currency,
|
|
1768
|
+
value: _this29.getTotalPrice(),
|
|
1769
|
+
items: _this29.formatGA4Items()
|
|
1770
|
+
});
|
|
1732
1771
|
|
|
1733
1772
|
window.top.location.href = json.payment_url;
|
|
1734
1773
|
} else if (json.redirect) {
|
|
1735
1774
|
window.top.location.href = json.redirect;
|
|
1736
1775
|
} else if (json.message && json.status) {
|
|
1737
|
-
|
|
1776
|
+
_this29.findElement('.recras-amountsform').reset();
|
|
1738
1777
|
|
|
1739
|
-
|
|
1778
|
+
_this29.findElement('.recras-datetime').reset();
|
|
1740
1779
|
|
|
1741
|
-
|
|
1780
|
+
_this29.findElement('.recras-contactform').reset();
|
|
1742
1781
|
|
|
1743
|
-
|
|
1782
|
+
_this29.element.scrollIntoView({
|
|
1744
1783
|
behavior: 'smooth'
|
|
1745
1784
|
});
|
|
1746
1785
|
|
|
1747
|
-
|
|
1786
|
+
_this29.element.insertAdjacentHTML('afterbegin', "<p class=\"recras-success\">".concat(json.message, "</p>"));
|
|
1748
1787
|
} else {
|
|
1749
1788
|
console.log(json);
|
|
1750
1789
|
}
|
|
1751
1790
|
|
|
1752
|
-
|
|
1791
|
+
_this29.loadingIndicatorHide();
|
|
1753
1792
|
|
|
1754
|
-
|
|
1793
|
+
_this29.findElement('.bookPackage').removeAttribute('disabled');
|
|
1755
1794
|
});
|
|
1756
1795
|
}
|
|
1757
1796
|
}, {
|
|
@@ -1787,7 +1826,7 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1787
1826
|
}, {
|
|
1788
1827
|
key: "updateProductAmounts",
|
|
1789
1828
|
value: function updateProductAmounts() {
|
|
1790
|
-
var
|
|
1829
|
+
var _this30 = this;
|
|
1791
1830
|
|
|
1792
1831
|
this.loadingIndicatorHide();
|
|
1793
1832
|
this.availableDays = [];
|
|
@@ -1797,7 +1836,7 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1797
1836
|
var maxPromise = this.checkMaximumForPackage();
|
|
1798
1837
|
this.checkBookingSize(this.selectedPackage);
|
|
1799
1838
|
this.recheckVouchers().then(function () {
|
|
1800
|
-
|
|
1839
|
+
_this30.showTotalPrice();
|
|
1801
1840
|
});
|
|
1802
1841
|
this.showStandardAttachments();
|
|
1803
1842
|
var datePickerEl = this.findElement('.recras-onlinebooking-date');
|
|
@@ -1845,16 +1884,16 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1845
1884
|
}, {
|
|
1846
1885
|
key: "getAvailableDaysInPeriod",
|
|
1847
1886
|
value: function getAvailableDaysInPeriod(packageId, startDate, endDate) {
|
|
1848
|
-
var
|
|
1887
|
+
var _this31 = this;
|
|
1849
1888
|
|
|
1850
1889
|
var datePickerEl = this.findElement('.recras-onlinebooking-date');
|
|
1851
1890
|
this.getAvailableDays(packageId, startDate, endDate).then(function (availableDays) {
|
|
1852
|
-
|
|
1891
|
+
_this31.loadingIndicatorHide();
|
|
1853
1892
|
|
|
1854
1893
|
if (datePickerEl.value && availableDays.indexOf(datePickerEl.value) === -1) {
|
|
1855
1894
|
datePickerEl.value = '';
|
|
1856
1895
|
|
|
1857
|
-
|
|
1896
|
+
_this31.clearTimes();
|
|
1858
1897
|
} else {
|
|
1859
1898
|
datePickerEl.removeAttribute('disabled');
|
|
1860
1899
|
}
|
|
@@ -1949,7 +1988,7 @@ var RecrasCalendarHelper = /*#__PURE__*/function () {
|
|
|
1949
1988
|
|
|
1950
1989
|
var RecrasContactForm = /*#__PURE__*/function () {
|
|
1951
1990
|
function RecrasContactForm() {
|
|
1952
|
-
var
|
|
1991
|
+
var _this32 = this;
|
|
1953
1992
|
|
|
1954
1993
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1955
1994
|
|
|
@@ -1979,11 +2018,11 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
1979
2018
|
}
|
|
1980
2019
|
|
|
1981
2020
|
this.fetchJson = function (url) {
|
|
1982
|
-
return RecrasHttpHelper.fetchJson(url,
|
|
2021
|
+
return RecrasHttpHelper.fetchJson(url, _this32.error.bind(_this32));
|
|
1983
2022
|
};
|
|
1984
2023
|
|
|
1985
2024
|
this.postJson = function (url, data) {
|
|
1986
|
-
return RecrasHttpHelper.postJson(
|
|
2025
|
+
return RecrasHttpHelper.postJson(_this32.options.getApiBase() + url, data, _this32.error.bind(_this32));
|
|
1987
2026
|
};
|
|
1988
2027
|
|
|
1989
2028
|
RecrasCSSHelper.loadCSS('global');
|
|
@@ -2007,7 +2046,7 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2007
2046
|
_createClass(RecrasContactForm, [{
|
|
2008
2047
|
key: "checkRequiredCheckboxes",
|
|
2009
2048
|
value: function checkRequiredCheckboxes() {
|
|
2010
|
-
var
|
|
2049
|
+
var _this33 = this;
|
|
2011
2050
|
|
|
2012
2051
|
this.removeWarnings();
|
|
2013
2052
|
var isOkay = true;
|
|
@@ -2016,7 +2055,7 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2016
2055
|
var checked = group.querySelectorAll('input:checked');
|
|
2017
2056
|
|
|
2018
2057
|
if (checked.length === 0) {
|
|
2019
|
-
group.parentNode.querySelector('label').insertAdjacentHTML('beforeend', "<div class=\"recrasError\">".concat(
|
|
2058
|
+
group.parentNode.querySelector('label').insertAdjacentHTML('beforeend', "<div class=\"recrasError\">".concat(_this33.languageHelper.translate('CONTACT_FORM_CHECKBOX_REQUIRED'), "</div>"));
|
|
2020
2059
|
isOkay = false;
|
|
2021
2060
|
}
|
|
2022
2061
|
});
|
|
@@ -2047,17 +2086,12 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2047
2086
|
}, {
|
|
2048
2087
|
key: "isStandalone",
|
|
2049
2088
|
value: function isStandalone(options) {
|
|
2050
|
-
if (options.showSubmit) {
|
|
2051
|
-
console.warn('Option "showSubmit" was renamed to "standalone". Please update your code.');
|
|
2052
|
-
options.standalone = true;
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
2089
|
return !!options.standalone;
|
|
2056
2090
|
}
|
|
2057
2091
|
}, {
|
|
2058
2092
|
key: "generateForm",
|
|
2059
2093
|
value: function generateForm() {
|
|
2060
|
-
var
|
|
2094
|
+
var _this34 = this;
|
|
2061
2095
|
|
|
2062
2096
|
var extraOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2063
2097
|
var waitFor = [];
|
|
@@ -2072,21 +2106,21 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2072
2106
|
}
|
|
2073
2107
|
|
|
2074
2108
|
return Promise.all(waitFor).then(function () {
|
|
2075
|
-
var standalone =
|
|
2109
|
+
var standalone = _this34.isStandalone(extraOptions);
|
|
2076
2110
|
|
|
2077
2111
|
var validateText = standalone ? 'novalidate' : '';
|
|
2078
2112
|
var html = "<form class=\"recras-contactform\" ".concat(validateText, ">");
|
|
2079
2113
|
|
|
2080
2114
|
if (extraOptions.voucherQuantitySelector) {
|
|
2081
|
-
html +=
|
|
2115
|
+
html += _this34.quantitySelector(extraOptions.quantityTerm);
|
|
2082
2116
|
}
|
|
2083
2117
|
|
|
2084
|
-
|
|
2085
|
-
html += '<div>' +
|
|
2118
|
+
_this34.contactFormFields.forEach(function (field, idx) {
|
|
2119
|
+
html += '<div>' + _this34.showField(field, idx) + '</div>';
|
|
2086
2120
|
});
|
|
2087
2121
|
|
|
2088
2122
|
if (standalone) {
|
|
2089
|
-
html +=
|
|
2123
|
+
html += _this34.submitButtonHtml();
|
|
2090
2124
|
}
|
|
2091
2125
|
|
|
2092
2126
|
html += '</form>';
|
|
@@ -2121,22 +2155,22 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2121
2155
|
}, {
|
|
2122
2156
|
key: "getContactFormFields",
|
|
2123
2157
|
value: function getContactFormFields() {
|
|
2124
|
-
var
|
|
2158
|
+
var _this35 = this;
|
|
2125
2159
|
|
|
2126
2160
|
return this.fetchJson(this.options.getApiBase() + 'contactformulieren/' + this.options.getFormId() + '?embed=Velden').then(function (form) {
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
return
|
|
2161
|
+
_this35.contactFormFields = form.Velden;
|
|
2162
|
+
_this35.packages = _this35.sortPackages(form.Arrangementen);
|
|
2163
|
+
return _this35.contactFormFields;
|
|
2130
2164
|
});
|
|
2131
2165
|
}
|
|
2132
2166
|
}, {
|
|
2133
2167
|
key: "getCountryList",
|
|
2134
2168
|
value: function getCountryList() {
|
|
2135
|
-
var
|
|
2169
|
+
var _this36 = this;
|
|
2136
2170
|
|
|
2137
2171
|
return this.fetchJson('https://cdn.rawgit.com/umpirsky/country-list/ddabf3a8/data/' + this.languageHelper.locale + '/country.json').then(function (json) {
|
|
2138
|
-
|
|
2139
|
-
return
|
|
2172
|
+
_this36.countries = json;
|
|
2173
|
+
return _this36.countries;
|
|
2140
2174
|
});
|
|
2141
2175
|
}
|
|
2142
2176
|
}, {
|
|
@@ -2303,7 +2337,7 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2303
2337
|
}, {
|
|
2304
2338
|
key: "showField",
|
|
2305
2339
|
value: function showField(field, idx) {
|
|
2306
|
-
var
|
|
2340
|
+
var _this37 = this;
|
|
2307
2341
|
|
|
2308
2342
|
if (field.soort_invoer === 'header') {
|
|
2309
2343
|
return "<h3>".concat(field.naam, "</h3>");
|
|
@@ -2322,7 +2356,7 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2322
2356
|
case 'contactpersoon.geslacht':
|
|
2323
2357
|
html = "<select ".concat(fixedAttributes, " autocomplete=\"sex\">");
|
|
2324
2358
|
Object.keys(this.GENDERS).forEach(function (key) {
|
|
2325
|
-
html += "<option value=\"".concat(key, "\">").concat(
|
|
2359
|
+
html += "<option value=\"".concat(key, "\">").concat(_this37.languageHelper.translate(_this37.GENDERS[key]));
|
|
2326
2360
|
});
|
|
2327
2361
|
html += '</select>';
|
|
2328
2362
|
return label + html;
|
|
@@ -2378,8 +2412,8 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2378
2412
|
case 'contact.landcode':
|
|
2379
2413
|
html = "<select ".concat(fixedAttributes, " autocomplete=\"country\">");
|
|
2380
2414
|
Object.keys(this.countries).forEach(function (code) {
|
|
2381
|
-
var selectedText = code.toUpperCase() ===
|
|
2382
|
-
html += "<option value=\"".concat(code, "\" ").concat(selectedText, ">").concat(
|
|
2415
|
+
var selectedText = code.toUpperCase() === _this37.options.getDefaultCountry() ? 'selected' : '';
|
|
2416
|
+
html += "<option value=\"".concat(code, "\" ").concat(selectedText, ">").concat(_this37.countries[code]);
|
|
2383
2417
|
});
|
|
2384
2418
|
html += '</select>';
|
|
2385
2419
|
return label + html;
|
|
@@ -2459,41 +2493,41 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2459
2493
|
}, {
|
|
2460
2494
|
key: "showForm",
|
|
2461
2495
|
value: function showForm() {
|
|
2462
|
-
var
|
|
2496
|
+
var _this38 = this;
|
|
2463
2497
|
|
|
2464
2498
|
this.loadingIndicatorShow(this.element);
|
|
2465
2499
|
return this.getContactFormFields().then(function () {
|
|
2466
|
-
return
|
|
2500
|
+
return _this38.generateForm({
|
|
2467
2501
|
standalone: true
|
|
2468
2502
|
});
|
|
2469
2503
|
}).then(function (html) {
|
|
2470
|
-
|
|
2504
|
+
_this38.appendHtml(html);
|
|
2471
2505
|
|
|
2472
|
-
_toConsumableArray(
|
|
2506
|
+
_toConsumableArray(_this38.findElements('.checkboxGroupRequired')).forEach(function (group) {
|
|
2473
2507
|
_toConsumableArray(group.querySelectorAll('input')).forEach(function (el) {
|
|
2474
|
-
el.addEventListener('change',
|
|
2508
|
+
el.addEventListener('change', _this38.checkRequiredCheckboxes.bind(_this38));
|
|
2475
2509
|
});
|
|
2476
2510
|
});
|
|
2477
2511
|
|
|
2478
|
-
|
|
2512
|
+
_this38.findElement('.recras-contactform').addEventListener('submit', _this38.submitForm.bind(_this38));
|
|
2479
2513
|
|
|
2480
|
-
if (
|
|
2514
|
+
if (_this38.hasBookingDateField()) {
|
|
2481
2515
|
var pikadayOptions = _extends(RecrasCalendarHelper.defaultOptions(), {
|
|
2482
|
-
field:
|
|
2483
|
-
i18n: RecrasCalendarHelper.i18n(
|
|
2516
|
+
field: _this38.findElement('[data-identifier="boeking.datum"]'),
|
|
2517
|
+
i18n: RecrasCalendarHelper.i18n(_this38.languageHelper),
|
|
2484
2518
|
numberOfMonths: 1
|
|
2485
2519
|
});
|
|
2486
2520
|
|
|
2487
2521
|
new Pikaday(pikadayOptions);
|
|
2488
2522
|
}
|
|
2489
2523
|
|
|
2490
|
-
if (
|
|
2491
|
-
var fields =
|
|
2524
|
+
if (_this38.hasRelationDateField()) {
|
|
2525
|
+
var fields = _this38.getRelationExtraDateFields();
|
|
2492
2526
|
|
|
2493
2527
|
var thisYear = new Date().getFullYear();
|
|
2494
2528
|
|
|
2495
2529
|
var _pikadayOptions = _extends(RecrasCalendarHelper.defaultOptions(), {
|
|
2496
|
-
i18n: RecrasCalendarHelper.i18n(
|
|
2530
|
+
i18n: RecrasCalendarHelper.i18n(_this38.languageHelper),
|
|
2497
2531
|
numberOfMonths: 1,
|
|
2498
2532
|
yearRange: [thisYear - 90, thisYear + 10]
|
|
2499
2533
|
});
|
|
@@ -2502,12 +2536,12 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2502
2536
|
|
|
2503
2537
|
for (var _i18 = 0; _i18 < fields.length; _i18++) {
|
|
2504
2538
|
var field = fields[_i18];
|
|
2505
|
-
_pikadayOptions.field =
|
|
2539
|
+
_pikadayOptions.field = _this38.findElement("[data-identifier=\"".concat(field.field_identifier, "\"]"));
|
|
2506
2540
|
new Pikaday(_pikadayOptions);
|
|
2507
2541
|
}
|
|
2508
2542
|
}
|
|
2509
2543
|
|
|
2510
|
-
|
|
2544
|
+
_this38.loadingIndicatorHide();
|
|
2511
2545
|
});
|
|
2512
2546
|
}
|
|
2513
2547
|
}, {
|
|
@@ -2557,7 +2591,7 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2557
2591
|
}, {
|
|
2558
2592
|
key: "submitForm",
|
|
2559
2593
|
value: function submitForm(e) {
|
|
2560
|
-
var
|
|
2594
|
+
var _this39 = this;
|
|
2561
2595
|
|
|
2562
2596
|
e.preventDefault();
|
|
2563
2597
|
var submitButton = this.findElement('.submitForm');
|
|
@@ -2581,24 +2615,24 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2581
2615
|
submitButton.setAttribute('disabled', 'disabled');
|
|
2582
2616
|
this.postJson('contactformulieren/' + this.options.getFormId() + '/opslaan', this.generateJson()).then(function (json) {
|
|
2583
2617
|
if (json.success) {
|
|
2584
|
-
if (
|
|
2585
|
-
window.top.location.href =
|
|
2618
|
+
if (_this39.options.getRedirectUrl()) {
|
|
2619
|
+
window.top.location.href = _this39.options.getRedirectUrl();
|
|
2586
2620
|
} else {
|
|
2587
|
-
|
|
2621
|
+
_this39.element.scrollIntoView({
|
|
2588
2622
|
behavior: 'smooth'
|
|
2589
2623
|
});
|
|
2590
2624
|
|
|
2591
|
-
|
|
2625
|
+
_this39.element.insertAdjacentHTML('afterbegin', "<p class=\"recras-success\">".concat(_this39.languageHelper.translate('CONTACT_FORM_SUBMIT_SUCCESS'), "</p>"));
|
|
2592
2626
|
|
|
2593
2627
|
submitButton.parentNode.reset();
|
|
2594
2628
|
}
|
|
2595
2629
|
} else {
|
|
2596
|
-
|
|
2630
|
+
_this39.error(_this39.languageHelper.translate('CONTACT_FORM_SUBMIT_FAILED'));
|
|
2597
2631
|
}
|
|
2598
2632
|
|
|
2599
2633
|
submitButton.removeAttribute('disabled');
|
|
2600
2634
|
|
|
2601
|
-
|
|
2635
|
+
_this39.loadingIndicatorHide();
|
|
2602
2636
|
});
|
|
2603
2637
|
return false;
|
|
2604
2638
|
}
|
|
@@ -2615,12 +2649,12 @@ var RecrasCSSHelper = /*#__PURE__*/function () {
|
|
|
2615
2649
|
_createClass(RecrasCSSHelper, null, [{
|
|
2616
2650
|
key: "cssBooking",
|
|
2617
2651
|
value: function cssBooking() {
|
|
2618
|
-
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:
|
|
2652
|
+
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";
|
|
2619
2653
|
}
|
|
2620
2654
|
}, {
|
|
2621
2655
|
key: "cssGlobal",
|
|
2622
2656
|
value: function cssGlobal() {
|
|
2623
|
-
return "\n.latestError, .recrasError {\n color: hsl(0, 50%, 50%);\n}\n.recras-onlinebooking > *:not(.latestError):not(.recrasLoadingIndicator) {\n padding: 1em 0;\n}\n.recras-datetime, .recras-discounts > div, .recras-contactform > div {\n display:
|
|
2657
|
+
return "\n.latestError, .recrasError {\n color: hsl(0, 50%, 50%);\n}\n.recras-onlinebooking > *:not(.latestError):not(.recrasLoadingIndicator) {\n padding: 1em 0;\n}\n.recras-datetime, .recras-discounts > div, .recras-contactform > div {\n display: grid;\n grid-template-columns: 1fr 12em;\n}\n.recras-contactform > div {\n padding-bottom: 0.25em;\n padding-top: 0.25em;\n}\n.recras-contactform label {\n display: block;\n}\n.recras-amountsform .recras-full-width {\n display: block;\n}\n\n.recrasLoadingIndicator {\n animation: recrasSpinner 1.1s infinite linear;\n border: 0.2em solid rgba(0, 0, 0, 0.2);\n border-left-color: rgba(0, 0, 0, 0.5);\n border-radius: 50%;\n display: inline-block;\n height: 2em;\n overflow: hidden;\n text-indent: -100vw;\n width: 2em;\n}\n@keyframes recrasSpinner {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\nbutton .recrasLoadingIndicator, label .recrasLoadingIndicator {\n height: 1em;\n vertical-align: middle;\n width: 1em;\n}\nbutton .recrasLoadingIndicator {\n margin-left: 0.5em;\n}\n.bookPackage, .submitForm, .buyTemplate {\n font: inherit;\n font-weight: bold;\n padding: 0.5em 2em;\n}\n@media (max-width: 520px) {\n .pika-single {\n max-width: 256px; /* Single month is 240px + 2x8px margin */\n }\n}\n";
|
|
2624
2658
|
}
|
|
2625
2659
|
}, {
|
|
2626
2660
|
key: "insertIntoHead",
|
|
@@ -2755,65 +2789,62 @@ var RecrasEventHelper = /*#__PURE__*/function () {
|
|
|
2755
2789
|
return this.eventsEnabled.includes(name);
|
|
2756
2790
|
}
|
|
2757
2791
|
}, {
|
|
2758
|
-
key: "
|
|
2759
|
-
value: function
|
|
2760
|
-
var
|
|
2761
|
-
var value = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
2762
|
-
var event;
|
|
2792
|
+
key: "ga4EventMap",
|
|
2793
|
+
value: function ga4EventMap(action) {
|
|
2794
|
+
var _map;
|
|
2763
2795
|
|
|
2764
|
-
|
|
2765
|
-
event = new Event(RecrasEventHelper.PREFIX_GLOBAL + ':' + cat + ':' + action);
|
|
2766
|
-
} catch (e) {
|
|
2767
|
-
// IE
|
|
2768
|
-
event = document.createEvent('Event');
|
|
2769
|
-
event.initEvent(action, true, true);
|
|
2770
|
-
}
|
|
2796
|
+
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);
|
|
2771
2797
|
|
|
2772
|
-
if (
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
var eventData = {
|
|
2776
|
-
event_category: RecrasEventHelper.PREFIX_GLOBAL + ':' + cat
|
|
2777
|
-
};
|
|
2798
|
+
if (map[action] === undefined) {
|
|
2799
|
+
return false;
|
|
2800
|
+
}
|
|
2778
2801
|
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2802
|
+
return map[action];
|
|
2803
|
+
}
|
|
2804
|
+
}, {
|
|
2805
|
+
key: "sendAnalyticsEvent",
|
|
2806
|
+
value: function sendAnalyticsEvent(cat, action) {
|
|
2807
|
+
var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
2808
|
+
var value = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
2809
|
+
var ga4Value = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
|
|
2782
2810
|
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2811
|
+
if (typeof window.gtag !== 'function') {
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2786
2814
|
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
eventCategory: RecrasEventHelper.PREFIX_GLOBAL + ':' + cat,
|
|
2793
|
-
eventAction: action
|
|
2794
|
-
};
|
|
2815
|
+
if (this.ga4EventMap(action) && ga4Value) {
|
|
2816
|
+
// v4
|
|
2817
|
+
window.gtag('event', this.ga4EventMap(action), ga4Value);
|
|
2818
|
+
return;
|
|
2819
|
+
} // Global Site Tag (v3)
|
|
2795
2820
|
|
|
2796
|
-
if (label) {
|
|
2797
|
-
_eventData.eventLabel = label;
|
|
2798
|
-
}
|
|
2799
2821
|
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2822
|
+
var eventData = {
|
|
2823
|
+
event_category: RecrasEventHelper.PREFIX_GLOBAL + ':' + cat
|
|
2824
|
+
};
|
|
2803
2825
|
|
|
2826
|
+
if (label) {
|
|
2827
|
+
eventData.event_label = label;
|
|
2828
|
+
}
|
|
2804
2829
|
|
|
2805
|
-
|
|
2806
|
-
|
|
2830
|
+
if (value) {
|
|
2831
|
+
eventData.value = value;
|
|
2832
|
+
}
|
|
2807
2833
|
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2834
|
+
window.gtag('event', action, eventData);
|
|
2835
|
+
}
|
|
2836
|
+
}, {
|
|
2837
|
+
key: "sendEvent",
|
|
2838
|
+
value: function sendEvent(cat, action) {
|
|
2839
|
+
var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
2840
|
+
var value = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
2841
|
+
var ga4Value = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
|
|
2811
2842
|
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
}
|
|
2843
|
+
if (this.analyticsEnabled && this.eventEnabled(action)) {
|
|
2844
|
+
this.sendAnalyticsEvent(cat, action, label, value, ga4Value);
|
|
2815
2845
|
}
|
|
2816
2846
|
|
|
2847
|
+
var event = new Event(RecrasEventHelper.PREFIX_GLOBAL + ':' + cat + ':' + action);
|
|
2817
2848
|
return document.dispatchEvent(event);
|
|
2818
2849
|
}
|
|
2819
2850
|
}, {
|
|
@@ -3348,16 +3379,16 @@ var RecrasLanguageHelper = /*#__PURE__*/function () {
|
|
|
3348
3379
|
}, {
|
|
3349
3380
|
key: "setCurrency",
|
|
3350
3381
|
value: function setCurrency() {
|
|
3351
|
-
var
|
|
3382
|
+
var _this40 = this;
|
|
3352
3383
|
|
|
3353
3384
|
var errorHandler = function errorHandler(err) {
|
|
3354
|
-
|
|
3385
|
+
_this40.currency = 'eur';
|
|
3355
3386
|
|
|
3356
|
-
|
|
3387
|
+
_this40.error(err);
|
|
3357
3388
|
};
|
|
3358
3389
|
|
|
3359
3390
|
return RecrasHttpHelper.fetchJson(this.options.getApiBase() + 'instellingen/currency', errorHandler).then(function (setting) {
|
|
3360
|
-
|
|
3391
|
+
_this40.currency = setting.waarde;
|
|
3361
3392
|
});
|
|
3362
3393
|
}
|
|
3363
3394
|
}, {
|
|
@@ -3581,7 +3612,7 @@ _defineProperty(RecrasOptions, "hostnamesDebug", ['nginx:8886', // Local develop
|
|
|
3581
3612
|
|
|
3582
3613
|
var RecrasVoucher = /*#__PURE__*/function () {
|
|
3583
3614
|
function RecrasVoucher() {
|
|
3584
|
-
var
|
|
3615
|
+
var _this41 = this;
|
|
3585
3616
|
|
|
3586
3617
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3587
3618
|
|
|
@@ -3600,11 +3631,11 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3600
3631
|
this.element.classList.add('recras-buy-voucher');
|
|
3601
3632
|
|
|
3602
3633
|
this.fetchJson = function (url) {
|
|
3603
|
-
return RecrasHttpHelper.fetchJson(url,
|
|
3634
|
+
return RecrasHttpHelper.fetchJson(url, _this41.error);
|
|
3604
3635
|
};
|
|
3605
3636
|
|
|
3606
3637
|
this.postJson = function (url, data) {
|
|
3607
|
-
return RecrasHttpHelper.postJson(
|
|
3638
|
+
return RecrasHttpHelper.postJson(_this41.options.getApiBase() + url, data, _this41.error);
|
|
3608
3639
|
};
|
|
3609
3640
|
|
|
3610
3641
|
RecrasCSSHelper.loadCSS('global');
|
|
@@ -3620,12 +3651,12 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3620
3651
|
}
|
|
3621
3652
|
|
|
3622
3653
|
this.languageHelper.setOptions(options).then(function () {
|
|
3623
|
-
return
|
|
3654
|
+
return _this41.getVoucherTemplates();
|
|
3624
3655
|
}).then(function (templates) {
|
|
3625
|
-
if (
|
|
3626
|
-
|
|
3656
|
+
if (_this41.options.getVoucherTemplateId()) {
|
|
3657
|
+
_this41.changeTemplate(_this41.options.getVoucherTemplateId());
|
|
3627
3658
|
} else {
|
|
3628
|
-
|
|
3659
|
+
_this41.showTemplates(templates);
|
|
3629
3660
|
}
|
|
3630
3661
|
});
|
|
3631
3662
|
}
|
|
@@ -3635,10 +3666,19 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3635
3666
|
value: function appendHtml(msg) {
|
|
3636
3667
|
this.element.insertAdjacentHTML('beforeend', msg);
|
|
3637
3668
|
}
|
|
3669
|
+
}, {
|
|
3670
|
+
key: "formatGA4Item",
|
|
3671
|
+
value: function formatGA4Item() {
|
|
3672
|
+
return [{
|
|
3673
|
+
item_name: this.selectedTemplate.name,
|
|
3674
|
+
price: this.selectedTemplate.price,
|
|
3675
|
+
quantity: parseInt(this.findElement('#number-of-vouchers').value)
|
|
3676
|
+
}];
|
|
3677
|
+
}
|
|
3638
3678
|
}, {
|
|
3639
3679
|
key: "buyTemplate",
|
|
3640
3680
|
value: function buyTemplate() {
|
|
3641
|
-
var
|
|
3681
|
+
var _this42 = this;
|
|
3642
3682
|
|
|
3643
3683
|
var status = this.contactForm.checkRequiredCheckboxes();
|
|
3644
3684
|
|
|
@@ -3660,14 +3700,18 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3660
3700
|
|
|
3661
3701
|
this.postJson('vouchers/buy', payload).then(function (json) {
|
|
3662
3702
|
if (json.payment_url) {
|
|
3663
|
-
|
|
3703
|
+
_this42.eventHelper.sendEvent(RecrasEventHelper.PREFIX_VOUCHER, RecrasEventHelper.EVENT_VOUCHER_REDIRECT_PAYMENT, null, Math.round(_this42.totalPrice()), {
|
|
3704
|
+
currency: _this42.languageHelper.currency,
|
|
3705
|
+
value: _this42.totalPrice(),
|
|
3706
|
+
items: _this42.formatGA4Item()
|
|
3707
|
+
});
|
|
3664
3708
|
|
|
3665
3709
|
window.top.location.href = json.payment_url;
|
|
3666
3710
|
} else {
|
|
3667
3711
|
console.log(json);
|
|
3668
3712
|
}
|
|
3669
3713
|
|
|
3670
|
-
|
|
3714
|
+
_this42.findElement('.buyTemplate').removeAttribute('disabled');
|
|
3671
3715
|
});
|
|
3672
3716
|
}
|
|
3673
3717
|
}, {
|
|
@@ -3678,7 +3722,10 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3678
3722
|
})[0];
|
|
3679
3723
|
this.clearAllExceptTemplateSelection();
|
|
3680
3724
|
this.showContactForm(this.selectedTemplate);
|
|
3681
|
-
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_VOUCHER, RecrasEventHelper.EVENT_VOUCHER_TEMPLATE_CHANGED, null, templateID
|
|
3725
|
+
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_VOUCHER, RecrasEventHelper.EVENT_VOUCHER_TEMPLATE_CHANGED, null, templateID, {
|
|
3726
|
+
content_type: 'voucher',
|
|
3727
|
+
item_id: templateID
|
|
3728
|
+
});
|
|
3682
3729
|
}
|
|
3683
3730
|
}, {
|
|
3684
3731
|
key: "clearAll",
|
|
@@ -3724,25 +3771,25 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3724
3771
|
}, {
|
|
3725
3772
|
key: "getContactForm",
|
|
3726
3773
|
value: function getContactForm(template) {
|
|
3727
|
-
var
|
|
3774
|
+
var _this43 = this;
|
|
3728
3775
|
|
|
3729
3776
|
this.options.setOption('form_id', template.contactform_id);
|
|
3730
3777
|
var contactForm = new RecrasContactForm(this.options);
|
|
3731
3778
|
return contactForm.getContactFormFields().then(function () {
|
|
3732
|
-
|
|
3779
|
+
_this43.contactForm = contactForm;
|
|
3733
3780
|
return contactForm;
|
|
3734
3781
|
});
|
|
3735
3782
|
}
|
|
3736
3783
|
}, {
|
|
3737
3784
|
key: "getVoucherTemplates",
|
|
3738
3785
|
value: function getVoucherTemplates() {
|
|
3739
|
-
var
|
|
3786
|
+
var _this44 = this;
|
|
3740
3787
|
|
|
3741
3788
|
return this.fetchJson(this.options.getApiBase() + 'voucher_templates').then(function (templates) {
|
|
3742
3789
|
templates = templates.filter(function (template) {
|
|
3743
3790
|
return !!template.contactform_id;
|
|
3744
3791
|
});
|
|
3745
|
-
|
|
3792
|
+
_this44.templates = templates;
|
|
3746
3793
|
return templates;
|
|
3747
3794
|
});
|
|
3748
3795
|
}
|
|
@@ -3788,30 +3835,30 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3788
3835
|
}, {
|
|
3789
3836
|
key: "showContactForm",
|
|
3790
3837
|
value: function showContactForm(template) {
|
|
3791
|
-
var
|
|
3838
|
+
var _this45 = this;
|
|
3792
3839
|
|
|
3793
3840
|
return this.getContactForm(template).then(function (form) {
|
|
3794
3841
|
return form.generateForm({
|
|
3795
3842
|
voucherQuantitySelector: true,
|
|
3796
|
-
quantityTerm:
|
|
3843
|
+
quantityTerm: _this45.selectedTemplate.quantity_term
|
|
3797
3844
|
});
|
|
3798
3845
|
}).then(function (html) {
|
|
3799
|
-
|
|
3846
|
+
_this45.appendHtml(html);
|
|
3800
3847
|
|
|
3801
|
-
|
|
3848
|
+
_this45.showBuyButton();
|
|
3802
3849
|
|
|
3803
|
-
_toConsumableArray(
|
|
3804
|
-
el.addEventListener('change',
|
|
3850
|
+
_toConsumableArray(_this45.findElements('#number-of-vouchers, [name^="contactformulier"]')).forEach(function (el) {
|
|
3851
|
+
el.addEventListener('change', _this45.maybeDisableBuyButton.bind(_this45));
|
|
3805
3852
|
});
|
|
3806
3853
|
});
|
|
3807
3854
|
}
|
|
3808
3855
|
}, {
|
|
3809
3856
|
key: "showTemplates",
|
|
3810
3857
|
value: function showTemplates(templates) {
|
|
3811
|
-
var
|
|
3858
|
+
var _this46 = this;
|
|
3812
3859
|
|
|
3813
3860
|
var templateOptions = templates.map(function (template) {
|
|
3814
|
-
return "<option value=\"".concat(template.id, "\">").concat(template.name, " (").concat(
|
|
3861
|
+
return "<option value=\"".concat(template.id, "\">").concat(template.name, " (").concat(_this46.formatPrice(template.price), ")");
|
|
3815
3862
|
});
|
|
3816
3863
|
var html = "<select class=\"recrasVoucherTemplates\"><option>".concat(templateOptions.join(''), "</select>");
|
|
3817
3864
|
this.appendHtml("<div class=\"recras-voucher-templates\">".concat(html, "</div>"));
|
|
@@ -3819,7 +3866,7 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3819
3866
|
voucherSelectEl.addEventListener('change', function () {
|
|
3820
3867
|
var selectedTemplateId = parseInt(voucherSelectEl.value, 10);
|
|
3821
3868
|
|
|
3822
|
-
|
|
3869
|
+
_this46.changeTemplate(selectedTemplateId);
|
|
3823
3870
|
});
|
|
3824
3871
|
}
|
|
3825
3872
|
}, {
|