@recras/online-booking-js 1.10.1 → 1.11.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/README.md +10 -5
- package/changelog.md +10 -0
- package/dist/onlinebooking.js +192 -95
- package/dist/onlinebooking.min.js +1 -0
- package/docs/onlinebooking.html +1 -1
- package/package.json +20 -18
- package/src/booking.js +50 -4
- package/src/contactForm.js +9 -3
- package/src/eventHelper.js +32 -5
- package/src/vouchers.js +22 -3
- package/upgrading.md +3 -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 1.
|
|
53
|
+
* v 1.11.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];
|
|
@@ -1666,10 +1669,52 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1666
1669
|
});
|
|
1667
1670
|
return attachments;
|
|
1668
1671
|
}
|
|
1672
|
+
}, {
|
|
1673
|
+
key: "formatGA4Items",
|
|
1674
|
+
value: function formatGA4Items() {
|
|
1675
|
+
var _this28 = this;
|
|
1676
|
+
|
|
1677
|
+
var items = [];
|
|
1678
|
+
|
|
1679
|
+
if (this.bookingSize() > 0) {
|
|
1680
|
+
var pck = this.selectedPackage;
|
|
1681
|
+
items.push({
|
|
1682
|
+
item_name: pck.weergavenaam || pck.arrangement,
|
|
1683
|
+
price: this.bookingSizePrice(pck),
|
|
1684
|
+
quantity: this.bookingSize()
|
|
1685
|
+
});
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
var linesNoBookingSize = this.getLinesNoBookingSize(this.selectedPackage);
|
|
1689
|
+
linesNoBookingSize = linesNoBookingSize.filter(function (line) {
|
|
1690
|
+
var lineEl = _this28.findElement("[data-package-id=\"".concat(line.id, "\"]"));
|
|
1691
|
+
|
|
1692
|
+
if (!lineEl) {
|
|
1693
|
+
return false;
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
if (isNaN(parseInt(lineEl.value))) {
|
|
1697
|
+
return false;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
return parseInt(lineEl.value) > 0;
|
|
1701
|
+
});
|
|
1702
|
+
linesNoBookingSize = linesNoBookingSize.map(function (line) {
|
|
1703
|
+
var lineEl = _this28.findElement("[data-package-id=\"".concat(line.id, "\"]"));
|
|
1704
|
+
|
|
1705
|
+
return {
|
|
1706
|
+
item_name: line.beschrijving_templated,
|
|
1707
|
+
price: line.product.verkoop,
|
|
1708
|
+
quantity: parseInt(lineEl.value)
|
|
1709
|
+
};
|
|
1710
|
+
});
|
|
1711
|
+
items.push.apply(items, _toConsumableArray(linesNoBookingSize));
|
|
1712
|
+
return items;
|
|
1713
|
+
}
|
|
1669
1714
|
}, {
|
|
1670
1715
|
key: "submitBooking",
|
|
1671
1716
|
value: function submitBooking() {
|
|
1672
|
-
var
|
|
1717
|
+
var _this29 = this;
|
|
1673
1718
|
|
|
1674
1719
|
var productCounts = this.productCounts().map(function (line) {
|
|
1675
1720
|
return line.aantal;
|
|
@@ -1689,7 +1734,7 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1689
1734
|
return false;
|
|
1690
1735
|
}
|
|
1691
1736
|
|
|
1692
|
-
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_BOOKING_SUBMITTED, this.selectedPackage.arrangement, this.
|
|
1737
|
+
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_BOOKING_SUBMITTED, this.selectedPackage.arrangement, Math.round(this.getTotalPrice()));
|
|
1693
1738
|
var paymentMethod = this.paymentMethods(this.selectedPackage)[0];
|
|
1694
1739
|
var paymentMethodEl = this.findElement('[name="paymentMethod"]:checked');
|
|
1695
1740
|
|
|
@@ -1728,30 +1773,34 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1728
1773
|
|
|
1729
1774
|
return this.postJson('onlineboeking/reserveer', bookingParams).then(function (json) {
|
|
1730
1775
|
if (json.payment_url) {
|
|
1731
|
-
|
|
1776
|
+
_this29.eventHelper.sendEvent(RecrasEventHelper.PREFIX_BOOKING, RecrasEventHelper.EVENT_BOOKING_REDIRECT_PAYMENT, null, Math.round(_this29.getTotalPrice()), {
|
|
1777
|
+
currency: _this29.languageHelper.currency,
|
|
1778
|
+
value: _this29.getTotalPrice(),
|
|
1779
|
+
items: _this29.formatGA4Items()
|
|
1780
|
+
});
|
|
1732
1781
|
|
|
1733
1782
|
window.top.location.href = json.payment_url;
|
|
1734
1783
|
} else if (json.redirect) {
|
|
1735
1784
|
window.top.location.href = json.redirect;
|
|
1736
1785
|
} else if (json.message && json.status) {
|
|
1737
|
-
|
|
1786
|
+
_this29.findElement('.recras-amountsform').reset();
|
|
1738
1787
|
|
|
1739
|
-
|
|
1788
|
+
_this29.findElement('.recras-datetime').reset();
|
|
1740
1789
|
|
|
1741
|
-
|
|
1790
|
+
_this29.findElement('.recras-contactform').reset();
|
|
1742
1791
|
|
|
1743
|
-
|
|
1792
|
+
_this29.element.scrollIntoView({
|
|
1744
1793
|
behavior: 'smooth'
|
|
1745
1794
|
});
|
|
1746
1795
|
|
|
1747
|
-
|
|
1796
|
+
_this29.element.insertAdjacentHTML('afterbegin', "<p class=\"recras-success\">".concat(json.message, "</p>"));
|
|
1748
1797
|
} else {
|
|
1749
1798
|
console.log(json);
|
|
1750
1799
|
}
|
|
1751
1800
|
|
|
1752
|
-
|
|
1801
|
+
_this29.loadingIndicatorHide();
|
|
1753
1802
|
|
|
1754
|
-
|
|
1803
|
+
_this29.findElement('.bookPackage').removeAttribute('disabled');
|
|
1755
1804
|
});
|
|
1756
1805
|
}
|
|
1757
1806
|
}, {
|
|
@@ -1787,7 +1836,7 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1787
1836
|
}, {
|
|
1788
1837
|
key: "updateProductAmounts",
|
|
1789
1838
|
value: function updateProductAmounts() {
|
|
1790
|
-
var
|
|
1839
|
+
var _this30 = this;
|
|
1791
1840
|
|
|
1792
1841
|
this.loadingIndicatorHide();
|
|
1793
1842
|
this.availableDays = [];
|
|
@@ -1797,7 +1846,7 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1797
1846
|
var maxPromise = this.checkMaximumForPackage();
|
|
1798
1847
|
this.checkBookingSize(this.selectedPackage);
|
|
1799
1848
|
this.recheckVouchers().then(function () {
|
|
1800
|
-
|
|
1849
|
+
_this30.showTotalPrice();
|
|
1801
1850
|
});
|
|
1802
1851
|
this.showStandardAttachments();
|
|
1803
1852
|
var datePickerEl = this.findElement('.recras-onlinebooking-date');
|
|
@@ -1845,16 +1894,16 @@ var RecrasBooking = /*#__PURE__*/function () {
|
|
|
1845
1894
|
}, {
|
|
1846
1895
|
key: "getAvailableDaysInPeriod",
|
|
1847
1896
|
value: function getAvailableDaysInPeriod(packageId, startDate, endDate) {
|
|
1848
|
-
var
|
|
1897
|
+
var _this31 = this;
|
|
1849
1898
|
|
|
1850
1899
|
var datePickerEl = this.findElement('.recras-onlinebooking-date');
|
|
1851
1900
|
this.getAvailableDays(packageId, startDate, endDate).then(function (availableDays) {
|
|
1852
|
-
|
|
1901
|
+
_this31.loadingIndicatorHide();
|
|
1853
1902
|
|
|
1854
1903
|
if (datePickerEl.value && availableDays.indexOf(datePickerEl.value) === -1) {
|
|
1855
1904
|
datePickerEl.value = '';
|
|
1856
1905
|
|
|
1857
|
-
|
|
1906
|
+
_this31.clearTimes();
|
|
1858
1907
|
} else {
|
|
1859
1908
|
datePickerEl.removeAttribute('disabled');
|
|
1860
1909
|
}
|
|
@@ -1949,7 +1998,7 @@ var RecrasCalendarHelper = /*#__PURE__*/function () {
|
|
|
1949
1998
|
|
|
1950
1999
|
var RecrasContactForm = /*#__PURE__*/function () {
|
|
1951
2000
|
function RecrasContactForm() {
|
|
1952
|
-
var
|
|
2001
|
+
var _this32 = this;
|
|
1953
2002
|
|
|
1954
2003
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1955
2004
|
|
|
@@ -1967,6 +2016,7 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
1967
2016
|
throw new Error(this.languageHelper.translate('ERR_NO_FORM'));
|
|
1968
2017
|
}
|
|
1969
2018
|
|
|
2019
|
+
this.checkboxEventListeners = [];
|
|
1970
2020
|
this.eventHelper = new RecrasEventHelper();
|
|
1971
2021
|
this.eventHelper.setEvents(this.options.getAnalyticsEvents());
|
|
1972
2022
|
this.element = this.options.getElement();
|
|
@@ -1978,11 +2028,11 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
1978
2028
|
}
|
|
1979
2029
|
|
|
1980
2030
|
this.fetchJson = function (url) {
|
|
1981
|
-
return RecrasHttpHelper.fetchJson(url,
|
|
2031
|
+
return RecrasHttpHelper.fetchJson(url, _this32.error.bind(_this32));
|
|
1982
2032
|
};
|
|
1983
2033
|
|
|
1984
2034
|
this.postJson = function (url, data) {
|
|
1985
|
-
return RecrasHttpHelper.postJson(
|
|
2035
|
+
return RecrasHttpHelper.postJson(_this32.options.getApiBase() + url, data, _this32.error.bind(_this32));
|
|
1986
2036
|
};
|
|
1987
2037
|
|
|
1988
2038
|
RecrasCSSHelper.loadCSS('global');
|
|
@@ -2006,7 +2056,7 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2006
2056
|
_createClass(RecrasContactForm, [{
|
|
2007
2057
|
key: "checkRequiredCheckboxes",
|
|
2008
2058
|
value: function checkRequiredCheckboxes() {
|
|
2009
|
-
var
|
|
2059
|
+
var _this33 = this;
|
|
2010
2060
|
|
|
2011
2061
|
this.removeWarnings();
|
|
2012
2062
|
var isOkay = true;
|
|
@@ -2015,13 +2065,9 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2015
2065
|
var checked = group.querySelectorAll('input:checked');
|
|
2016
2066
|
|
|
2017
2067
|
if (checked.length === 0) {
|
|
2018
|
-
group.parentNode.querySelector('label').insertAdjacentHTML('beforeend', "<div class=\"recrasError\">".concat(
|
|
2068
|
+
group.parentNode.querySelector('label').insertAdjacentHTML('beforeend', "<div class=\"recrasError\">".concat(_this33.languageHelper.translate('CONTACT_FORM_CHECKBOX_REQUIRED'), "</div>"));
|
|
2019
2069
|
isOkay = false;
|
|
2020
2070
|
}
|
|
2021
|
-
|
|
2022
|
-
_toConsumableArray(group.querySelectorAll('input')).forEach(function (el) {
|
|
2023
|
-
el.addEventListener('change', _this32.checkRequiredCheckboxes.bind(_this32));
|
|
2024
|
-
});
|
|
2025
2071
|
});
|
|
2026
2072
|
|
|
2027
2073
|
return isOkay;
|
|
@@ -2060,7 +2106,7 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2060
2106
|
}, {
|
|
2061
2107
|
key: "generateForm",
|
|
2062
2108
|
value: function generateForm() {
|
|
2063
|
-
var
|
|
2109
|
+
var _this34 = this;
|
|
2064
2110
|
|
|
2065
2111
|
var extraOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2066
2112
|
var waitFor = [];
|
|
@@ -2075,21 +2121,21 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2075
2121
|
}
|
|
2076
2122
|
|
|
2077
2123
|
return Promise.all(waitFor).then(function () {
|
|
2078
|
-
var standalone =
|
|
2124
|
+
var standalone = _this34.isStandalone(extraOptions);
|
|
2079
2125
|
|
|
2080
2126
|
var validateText = standalone ? 'novalidate' : '';
|
|
2081
2127
|
var html = "<form class=\"recras-contactform\" ".concat(validateText, ">");
|
|
2082
2128
|
|
|
2083
2129
|
if (extraOptions.voucherQuantitySelector) {
|
|
2084
|
-
html +=
|
|
2130
|
+
html += _this34.quantitySelector(extraOptions.quantityTerm);
|
|
2085
2131
|
}
|
|
2086
2132
|
|
|
2087
|
-
|
|
2088
|
-
html += '<div>' +
|
|
2133
|
+
_this34.contactFormFields.forEach(function (field, idx) {
|
|
2134
|
+
html += '<div>' + _this34.showField(field, idx) + '</div>';
|
|
2089
2135
|
});
|
|
2090
2136
|
|
|
2091
2137
|
if (standalone) {
|
|
2092
|
-
html +=
|
|
2138
|
+
html += _this34.submitButtonHtml();
|
|
2093
2139
|
}
|
|
2094
2140
|
|
|
2095
2141
|
html += '</form>';
|
|
@@ -2124,22 +2170,22 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2124
2170
|
}, {
|
|
2125
2171
|
key: "getContactFormFields",
|
|
2126
2172
|
value: function getContactFormFields() {
|
|
2127
|
-
var
|
|
2173
|
+
var _this35 = this;
|
|
2128
2174
|
|
|
2129
2175
|
return this.fetchJson(this.options.getApiBase() + 'contactformulieren/' + this.options.getFormId() + '?embed=Velden').then(function (form) {
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
return
|
|
2176
|
+
_this35.contactFormFields = form.Velden;
|
|
2177
|
+
_this35.packages = _this35.sortPackages(form.Arrangementen);
|
|
2178
|
+
return _this35.contactFormFields;
|
|
2133
2179
|
});
|
|
2134
2180
|
}
|
|
2135
2181
|
}, {
|
|
2136
2182
|
key: "getCountryList",
|
|
2137
2183
|
value: function getCountryList() {
|
|
2138
|
-
var
|
|
2184
|
+
var _this36 = this;
|
|
2139
2185
|
|
|
2140
2186
|
return this.fetchJson('https://cdn.rawgit.com/umpirsky/country-list/ddabf3a8/data/' + this.languageHelper.locale + '/country.json').then(function (json) {
|
|
2141
|
-
|
|
2142
|
-
return
|
|
2187
|
+
_this36.countries = json;
|
|
2188
|
+
return _this36.countries;
|
|
2143
2189
|
});
|
|
2144
2190
|
}
|
|
2145
2191
|
}, {
|
|
@@ -2306,7 +2352,7 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2306
2352
|
}, {
|
|
2307
2353
|
key: "showField",
|
|
2308
2354
|
value: function showField(field, idx) {
|
|
2309
|
-
var
|
|
2355
|
+
var _this37 = this;
|
|
2310
2356
|
|
|
2311
2357
|
if (field.soort_invoer === 'header') {
|
|
2312
2358
|
return "<h3>".concat(field.naam, "</h3>");
|
|
@@ -2325,7 +2371,7 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2325
2371
|
case 'contactpersoon.geslacht':
|
|
2326
2372
|
html = "<select ".concat(fixedAttributes, " autocomplete=\"sex\">");
|
|
2327
2373
|
Object.keys(this.GENDERS).forEach(function (key) {
|
|
2328
|
-
html += "<option value=\"".concat(key, "\">").concat(
|
|
2374
|
+
html += "<option value=\"".concat(key, "\">").concat(_this37.languageHelper.translate(_this37.GENDERS[key]));
|
|
2329
2375
|
});
|
|
2330
2376
|
html += '</select>';
|
|
2331
2377
|
return label + html;
|
|
@@ -2381,8 +2427,8 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2381
2427
|
case 'contact.landcode':
|
|
2382
2428
|
html = "<select ".concat(fixedAttributes, " autocomplete=\"country\">");
|
|
2383
2429
|
Object.keys(this.countries).forEach(function (code) {
|
|
2384
|
-
var selectedText = code.toUpperCase() ===
|
|
2385
|
-
html += "<option value=\"".concat(code, "\" ").concat(selectedText, ">").concat(
|
|
2430
|
+
var selectedText = code.toUpperCase() === _this37.options.getDefaultCountry() ? 'selected' : '';
|
|
2431
|
+
html += "<option value=\"".concat(code, "\" ").concat(selectedText, ">").concat(_this37.countries[code]);
|
|
2386
2432
|
});
|
|
2387
2433
|
html += '</select>';
|
|
2388
2434
|
return label + html;
|
|
@@ -2462,35 +2508,41 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2462
2508
|
}, {
|
|
2463
2509
|
key: "showForm",
|
|
2464
2510
|
value: function showForm() {
|
|
2465
|
-
var
|
|
2511
|
+
var _this38 = this;
|
|
2466
2512
|
|
|
2467
2513
|
this.loadingIndicatorShow(this.element);
|
|
2468
2514
|
return this.getContactFormFields().then(function () {
|
|
2469
|
-
return
|
|
2515
|
+
return _this38.generateForm({
|
|
2470
2516
|
standalone: true
|
|
2471
2517
|
});
|
|
2472
2518
|
}).then(function (html) {
|
|
2473
|
-
|
|
2519
|
+
_this38.appendHtml(html);
|
|
2474
2520
|
|
|
2475
|
-
|
|
2521
|
+
_toConsumableArray(_this38.findElements('.checkboxGroupRequired')).forEach(function (group) {
|
|
2522
|
+
_toConsumableArray(group.querySelectorAll('input')).forEach(function (el) {
|
|
2523
|
+
el.addEventListener('change', _this38.checkRequiredCheckboxes.bind(_this38));
|
|
2524
|
+
});
|
|
2525
|
+
});
|
|
2476
2526
|
|
|
2477
|
-
|
|
2527
|
+
_this38.findElement('.recras-contactform').addEventListener('submit', _this38.submitForm.bind(_this38));
|
|
2528
|
+
|
|
2529
|
+
if (_this38.hasBookingDateField()) {
|
|
2478
2530
|
var pikadayOptions = _extends(RecrasCalendarHelper.defaultOptions(), {
|
|
2479
|
-
field:
|
|
2480
|
-
i18n: RecrasCalendarHelper.i18n(
|
|
2531
|
+
field: _this38.findElement('[data-identifier="boeking.datum"]'),
|
|
2532
|
+
i18n: RecrasCalendarHelper.i18n(_this38.languageHelper),
|
|
2481
2533
|
numberOfMonths: 1
|
|
2482
2534
|
});
|
|
2483
2535
|
|
|
2484
2536
|
new Pikaday(pikadayOptions);
|
|
2485
2537
|
}
|
|
2486
2538
|
|
|
2487
|
-
if (
|
|
2488
|
-
var fields =
|
|
2539
|
+
if (_this38.hasRelationDateField()) {
|
|
2540
|
+
var fields = _this38.getRelationExtraDateFields();
|
|
2489
2541
|
|
|
2490
2542
|
var thisYear = new Date().getFullYear();
|
|
2491
2543
|
|
|
2492
2544
|
var _pikadayOptions = _extends(RecrasCalendarHelper.defaultOptions(), {
|
|
2493
|
-
i18n: RecrasCalendarHelper.i18n(
|
|
2545
|
+
i18n: RecrasCalendarHelper.i18n(_this38.languageHelper),
|
|
2494
2546
|
numberOfMonths: 1,
|
|
2495
2547
|
yearRange: [thisYear - 90, thisYear + 10]
|
|
2496
2548
|
});
|
|
@@ -2499,12 +2551,12 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2499
2551
|
|
|
2500
2552
|
for (var _i18 = 0; _i18 < fields.length; _i18++) {
|
|
2501
2553
|
var field = fields[_i18];
|
|
2502
|
-
_pikadayOptions.field =
|
|
2554
|
+
_pikadayOptions.field = _this38.findElement("[data-identifier=\"".concat(field.field_identifier, "\"]"));
|
|
2503
2555
|
new Pikaday(_pikadayOptions);
|
|
2504
2556
|
}
|
|
2505
2557
|
}
|
|
2506
2558
|
|
|
2507
|
-
|
|
2559
|
+
_this38.loadingIndicatorHide();
|
|
2508
2560
|
});
|
|
2509
2561
|
}
|
|
2510
2562
|
}, {
|
|
@@ -2554,7 +2606,7 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2554
2606
|
}, {
|
|
2555
2607
|
key: "submitForm",
|
|
2556
2608
|
value: function submitForm(e) {
|
|
2557
|
-
var
|
|
2609
|
+
var _this39 = this;
|
|
2558
2610
|
|
|
2559
2611
|
e.preventDefault();
|
|
2560
2612
|
var submitButton = this.findElement('.submitForm');
|
|
@@ -2578,24 +2630,24 @@ var RecrasContactForm = /*#__PURE__*/function () {
|
|
|
2578
2630
|
submitButton.setAttribute('disabled', 'disabled');
|
|
2579
2631
|
this.postJson('contactformulieren/' + this.options.getFormId() + '/opslaan', this.generateJson()).then(function (json) {
|
|
2580
2632
|
if (json.success) {
|
|
2581
|
-
if (
|
|
2582
|
-
window.top.location.href =
|
|
2633
|
+
if (_this39.options.getRedirectUrl()) {
|
|
2634
|
+
window.top.location.href = _this39.options.getRedirectUrl();
|
|
2583
2635
|
} else {
|
|
2584
|
-
|
|
2636
|
+
_this39.element.scrollIntoView({
|
|
2585
2637
|
behavior: 'smooth'
|
|
2586
2638
|
});
|
|
2587
2639
|
|
|
2588
|
-
|
|
2640
|
+
_this39.element.insertAdjacentHTML('afterbegin', "<p class=\"recras-success\">".concat(_this39.languageHelper.translate('CONTACT_FORM_SUBMIT_SUCCESS'), "</p>"));
|
|
2589
2641
|
|
|
2590
2642
|
submitButton.parentNode.reset();
|
|
2591
2643
|
}
|
|
2592
2644
|
} else {
|
|
2593
|
-
|
|
2645
|
+
_this39.error(_this39.languageHelper.translate('CONTACT_FORM_SUBMIT_FAILED'));
|
|
2594
2646
|
}
|
|
2595
2647
|
|
|
2596
2648
|
submitButton.removeAttribute('disabled');
|
|
2597
2649
|
|
|
2598
|
-
|
|
2650
|
+
_this39.loadingIndicatorHide();
|
|
2599
2651
|
});
|
|
2600
2652
|
return false;
|
|
2601
2653
|
}
|
|
@@ -2751,11 +2803,31 @@ var RecrasEventHelper = /*#__PURE__*/function () {
|
|
|
2751
2803
|
value: function eventEnabled(name) {
|
|
2752
2804
|
return this.eventsEnabled.includes(name);
|
|
2753
2805
|
}
|
|
2806
|
+
}, {
|
|
2807
|
+
key: "ga4EventMap",
|
|
2808
|
+
value: function ga4EventMap(action) {
|
|
2809
|
+
var _map;
|
|
2810
|
+
|
|
2811
|
+
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);
|
|
2812
|
+
|
|
2813
|
+
if (map[action] === undefined) {
|
|
2814
|
+
return false;
|
|
2815
|
+
}
|
|
2816
|
+
|
|
2817
|
+
return map[action];
|
|
2818
|
+
}
|
|
2819
|
+
}, {
|
|
2820
|
+
key: "isGA4",
|
|
2821
|
+
value: function isGA4() {
|
|
2822
|
+
var fn = window[window.GoogleAnalyticsObject || 'ga'];
|
|
2823
|
+
return fn && fn.h && fn.h.gtm4;
|
|
2824
|
+
}
|
|
2754
2825
|
}, {
|
|
2755
2826
|
key: "sendEvent",
|
|
2756
2827
|
value: function sendEvent(cat, action) {
|
|
2757
2828
|
var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
2758
2829
|
var value = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
|
|
2830
|
+
var ga4Value = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;
|
|
2759
2831
|
var event;
|
|
2760
2832
|
|
|
2761
2833
|
try {
|
|
@@ -2767,8 +2839,11 @@ var RecrasEventHelper = /*#__PURE__*/function () {
|
|
|
2767
2839
|
}
|
|
2768
2840
|
|
|
2769
2841
|
if (this.analyticsEnabled && this.eventEnabled(action)) {
|
|
2770
|
-
if (
|
|
2771
|
-
//
|
|
2842
|
+
if (this.isGA4() && this.ga4EventMap(action) && ga4Value) {
|
|
2843
|
+
// v4
|
|
2844
|
+
this.sendGA4Event(this.ga4EventMap(action), ga4Value);
|
|
2845
|
+
} else if (typeof window.gtag === 'function') {
|
|
2846
|
+
// Global Site Tag (v3)
|
|
2772
2847
|
var eventData = {
|
|
2773
2848
|
event_category: RecrasEventHelper.PREFIX_GLOBAL + ':' + cat
|
|
2774
2849
|
};
|
|
@@ -2783,7 +2858,7 @@ var RecrasEventHelper = /*#__PURE__*/function () {
|
|
|
2783
2858
|
|
|
2784
2859
|
window.gtag('event', action, eventData);
|
|
2785
2860
|
} else if (typeof window.ga === 'function') {
|
|
2786
|
-
// "Old" Google Analytics
|
|
2861
|
+
// "Old" Google Analytics (v2) and Tag Manager
|
|
2787
2862
|
var _eventData = {
|
|
2788
2863
|
hitType: 'event',
|
|
2789
2864
|
eventCategory: RecrasEventHelper.PREFIX_GLOBAL + ':' + cat,
|
|
@@ -2813,6 +2888,12 @@ var RecrasEventHelper = /*#__PURE__*/function () {
|
|
|
2813
2888
|
|
|
2814
2889
|
return document.dispatchEvent(event);
|
|
2815
2890
|
}
|
|
2891
|
+
}, {
|
|
2892
|
+
key: "sendGA4Event",
|
|
2893
|
+
value: function sendGA4Event(action, data) {
|
|
2894
|
+
var fn = window[window.GoogleAnalyticsObject || 'ga'];
|
|
2895
|
+
fn('event', action, data);
|
|
2896
|
+
}
|
|
2816
2897
|
}, {
|
|
2817
2898
|
key: "setAnalytics",
|
|
2818
2899
|
value: function setAnalytics(bool) {
|
|
@@ -3345,16 +3426,16 @@ var RecrasLanguageHelper = /*#__PURE__*/function () {
|
|
|
3345
3426
|
}, {
|
|
3346
3427
|
key: "setCurrency",
|
|
3347
3428
|
value: function setCurrency() {
|
|
3348
|
-
var
|
|
3429
|
+
var _this40 = this;
|
|
3349
3430
|
|
|
3350
3431
|
var errorHandler = function errorHandler(err) {
|
|
3351
|
-
|
|
3432
|
+
_this40.currency = 'eur';
|
|
3352
3433
|
|
|
3353
|
-
|
|
3434
|
+
_this40.error(err);
|
|
3354
3435
|
};
|
|
3355
3436
|
|
|
3356
3437
|
return RecrasHttpHelper.fetchJson(this.options.getApiBase() + 'instellingen/currency', errorHandler).then(function (setting) {
|
|
3357
|
-
|
|
3438
|
+
_this40.currency = setting.waarde;
|
|
3358
3439
|
});
|
|
3359
3440
|
}
|
|
3360
3441
|
}, {
|
|
@@ -3578,7 +3659,7 @@ _defineProperty(RecrasOptions, "hostnamesDebug", ['nginx:8886', // Local develop
|
|
|
3578
3659
|
|
|
3579
3660
|
var RecrasVoucher = /*#__PURE__*/function () {
|
|
3580
3661
|
function RecrasVoucher() {
|
|
3581
|
-
var
|
|
3662
|
+
var _this41 = this;
|
|
3582
3663
|
|
|
3583
3664
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3584
3665
|
|
|
@@ -3597,11 +3678,11 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3597
3678
|
this.element.classList.add('recras-buy-voucher');
|
|
3598
3679
|
|
|
3599
3680
|
this.fetchJson = function (url) {
|
|
3600
|
-
return RecrasHttpHelper.fetchJson(url,
|
|
3681
|
+
return RecrasHttpHelper.fetchJson(url, _this41.error);
|
|
3601
3682
|
};
|
|
3602
3683
|
|
|
3603
3684
|
this.postJson = function (url, data) {
|
|
3604
|
-
return RecrasHttpHelper.postJson(
|
|
3685
|
+
return RecrasHttpHelper.postJson(_this41.options.getApiBase() + url, data, _this41.error);
|
|
3605
3686
|
};
|
|
3606
3687
|
|
|
3607
3688
|
RecrasCSSHelper.loadCSS('global');
|
|
@@ -3617,12 +3698,12 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3617
3698
|
}
|
|
3618
3699
|
|
|
3619
3700
|
this.languageHelper.setOptions(options).then(function () {
|
|
3620
|
-
return
|
|
3701
|
+
return _this41.getVoucherTemplates();
|
|
3621
3702
|
}).then(function (templates) {
|
|
3622
|
-
if (
|
|
3623
|
-
|
|
3703
|
+
if (_this41.options.getVoucherTemplateId()) {
|
|
3704
|
+
_this41.changeTemplate(_this41.options.getVoucherTemplateId());
|
|
3624
3705
|
} else {
|
|
3625
|
-
|
|
3706
|
+
_this41.showTemplates(templates);
|
|
3626
3707
|
}
|
|
3627
3708
|
});
|
|
3628
3709
|
}
|
|
@@ -3632,10 +3713,19 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3632
3713
|
value: function appendHtml(msg) {
|
|
3633
3714
|
this.element.insertAdjacentHTML('beforeend', msg);
|
|
3634
3715
|
}
|
|
3716
|
+
}, {
|
|
3717
|
+
key: "formatGA4Item",
|
|
3718
|
+
value: function formatGA4Item() {
|
|
3719
|
+
return [{
|
|
3720
|
+
item_name: this.selectedTemplate.name,
|
|
3721
|
+
price: this.selectedTemplate.price,
|
|
3722
|
+
quantity: parseInt(this.findElement('#number-of-vouchers').value)
|
|
3723
|
+
}];
|
|
3724
|
+
}
|
|
3635
3725
|
}, {
|
|
3636
3726
|
key: "buyTemplate",
|
|
3637
3727
|
value: function buyTemplate() {
|
|
3638
|
-
var
|
|
3728
|
+
var _this42 = this;
|
|
3639
3729
|
|
|
3640
3730
|
var status = this.contactForm.checkRequiredCheckboxes();
|
|
3641
3731
|
|
|
@@ -3643,7 +3733,7 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3643
3733
|
return false;
|
|
3644
3734
|
}
|
|
3645
3735
|
|
|
3646
|
-
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_VOUCHER, RecrasEventHelper.EVENT_VOUCHER_VOUCHER_SUBMITTED, this.selectedTemplate.name, this.
|
|
3736
|
+
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_VOUCHER, RecrasEventHelper.EVENT_VOUCHER_VOUCHER_SUBMITTED, this.selectedTemplate.name, Math.round(this.totalPrice()));
|
|
3647
3737
|
this.findElement('.buyTemplate').setAttribute('disabled', 'disabled');
|
|
3648
3738
|
var payload = {
|
|
3649
3739
|
voucher_template_id: this.selectedTemplate.id,
|
|
@@ -3657,14 +3747,18 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3657
3747
|
|
|
3658
3748
|
this.postJson('vouchers/buy', payload).then(function (json) {
|
|
3659
3749
|
if (json.payment_url) {
|
|
3660
|
-
|
|
3750
|
+
_this42.eventHelper.sendEvent(RecrasEventHelper.PREFIX_VOUCHER, RecrasEventHelper.EVENT_VOUCHER_REDIRECT_PAYMENT, null, Math.round(_this42.totalPrice()), {
|
|
3751
|
+
currency: _this42.languageHelper.currency,
|
|
3752
|
+
value: _this42.totalPrice(),
|
|
3753
|
+
items: _this42.formatGA4Item()
|
|
3754
|
+
});
|
|
3661
3755
|
|
|
3662
3756
|
window.top.location.href = json.payment_url;
|
|
3663
3757
|
} else {
|
|
3664
3758
|
console.log(json);
|
|
3665
3759
|
}
|
|
3666
3760
|
|
|
3667
|
-
|
|
3761
|
+
_this42.findElement('.buyTemplate').removeAttribute('disabled');
|
|
3668
3762
|
});
|
|
3669
3763
|
}
|
|
3670
3764
|
}, {
|
|
@@ -3675,7 +3769,10 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3675
3769
|
})[0];
|
|
3676
3770
|
this.clearAllExceptTemplateSelection();
|
|
3677
3771
|
this.showContactForm(this.selectedTemplate);
|
|
3678
|
-
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_VOUCHER, RecrasEventHelper.EVENT_VOUCHER_TEMPLATE_CHANGED, null, templateID
|
|
3772
|
+
this.eventHelper.sendEvent(RecrasEventHelper.PREFIX_VOUCHER, RecrasEventHelper.EVENT_VOUCHER_TEMPLATE_CHANGED, null, templateID, {
|
|
3773
|
+
content_type: 'voucher',
|
|
3774
|
+
item_id: templateID
|
|
3775
|
+
});
|
|
3679
3776
|
}
|
|
3680
3777
|
}, {
|
|
3681
3778
|
key: "clearAll",
|
|
@@ -3721,25 +3818,25 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3721
3818
|
}, {
|
|
3722
3819
|
key: "getContactForm",
|
|
3723
3820
|
value: function getContactForm(template) {
|
|
3724
|
-
var
|
|
3821
|
+
var _this43 = this;
|
|
3725
3822
|
|
|
3726
3823
|
this.options.setOption('form_id', template.contactform_id);
|
|
3727
3824
|
var contactForm = new RecrasContactForm(this.options);
|
|
3728
3825
|
return contactForm.getContactFormFields().then(function () {
|
|
3729
|
-
|
|
3826
|
+
_this43.contactForm = contactForm;
|
|
3730
3827
|
return contactForm;
|
|
3731
3828
|
});
|
|
3732
3829
|
}
|
|
3733
3830
|
}, {
|
|
3734
3831
|
key: "getVoucherTemplates",
|
|
3735
3832
|
value: function getVoucherTemplates() {
|
|
3736
|
-
var
|
|
3833
|
+
var _this44 = this;
|
|
3737
3834
|
|
|
3738
3835
|
return this.fetchJson(this.options.getApiBase() + 'voucher_templates').then(function (templates) {
|
|
3739
3836
|
templates = templates.filter(function (template) {
|
|
3740
3837
|
return !!template.contactform_id;
|
|
3741
3838
|
});
|
|
3742
|
-
|
|
3839
|
+
_this44.templates = templates;
|
|
3743
3840
|
return templates;
|
|
3744
3841
|
});
|
|
3745
3842
|
}
|
|
@@ -3785,30 +3882,30 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3785
3882
|
}, {
|
|
3786
3883
|
key: "showContactForm",
|
|
3787
3884
|
value: function showContactForm(template) {
|
|
3788
|
-
var
|
|
3885
|
+
var _this45 = this;
|
|
3789
3886
|
|
|
3790
3887
|
return this.getContactForm(template).then(function (form) {
|
|
3791
3888
|
return form.generateForm({
|
|
3792
3889
|
voucherQuantitySelector: true,
|
|
3793
|
-
quantityTerm:
|
|
3890
|
+
quantityTerm: _this45.selectedTemplate.quantity_term
|
|
3794
3891
|
});
|
|
3795
3892
|
}).then(function (html) {
|
|
3796
|
-
|
|
3893
|
+
_this45.appendHtml(html);
|
|
3797
3894
|
|
|
3798
|
-
|
|
3895
|
+
_this45.showBuyButton();
|
|
3799
3896
|
|
|
3800
|
-
_toConsumableArray(
|
|
3801
|
-
el.addEventListener('change',
|
|
3897
|
+
_toConsumableArray(_this45.findElements('#number-of-vouchers, [name^="contactformulier"]')).forEach(function (el) {
|
|
3898
|
+
el.addEventListener('change', _this45.maybeDisableBuyButton.bind(_this45));
|
|
3802
3899
|
});
|
|
3803
3900
|
});
|
|
3804
3901
|
}
|
|
3805
3902
|
}, {
|
|
3806
3903
|
key: "showTemplates",
|
|
3807
3904
|
value: function showTemplates(templates) {
|
|
3808
|
-
var
|
|
3905
|
+
var _this46 = this;
|
|
3809
3906
|
|
|
3810
3907
|
var templateOptions = templates.map(function (template) {
|
|
3811
|
-
return "<option value=\"".concat(template.id, "\">").concat(template.name, " (").concat(
|
|
3908
|
+
return "<option value=\"".concat(template.id, "\">").concat(template.name, " (").concat(_this46.formatPrice(template.price), ")");
|
|
3812
3909
|
});
|
|
3813
3910
|
var html = "<select class=\"recrasVoucherTemplates\"><option>".concat(templateOptions.join(''), "</select>");
|
|
3814
3911
|
this.appendHtml("<div class=\"recras-voucher-templates\">".concat(html, "</div>"));
|
|
@@ -3816,7 +3913,7 @@ var RecrasVoucher = /*#__PURE__*/function () {
|
|
|
3816
3913
|
voucherSelectEl.addEventListener('change', function () {
|
|
3817
3914
|
var selectedTemplateId = parseInt(voucherSelectEl.value, 10);
|
|
3818
3915
|
|
|
3819
|
-
|
|
3916
|
+
_this46.changeTemplate(selectedTemplateId);
|
|
3820
3917
|
});
|
|
3821
3918
|
}
|
|
3822
3919
|
}, {
|