@iamproperty/components 3.1.0 → 3.4.4
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 +141 -16
- package/assets/css/core.min.css +1 -1
- package/assets/css/core.min.css.map +1 -1
- package/assets/css/style.min.css +1 -1
- package/assets/css/style.min.css.map +1 -1
- package/assets/favicons/manifest.json +31 -31
- package/assets/js/main.js +57 -57
- package/assets/js/modules/accordion.js +33 -32
- package/assets/js/modules/alert.js +41 -57
- package/assets/js/modules/carousel.js +76 -102
- package/assets/js/modules/chart.js +151 -218
- package/assets/js/modules/drawer.js +10 -16
- package/assets/js/modules/file-upload.js +33 -48
- package/assets/js/modules/form.js +122 -168
- package/assets/js/modules/helpers.js +90 -119
- package/assets/js/modules/modal.js +69 -90
- package/assets/js/modules/nav.js +18 -28
- package/assets/js/modules/orderablelist.js +91 -122
- package/assets/js/modules/table.js +451 -585
- package/assets/js/modules/testimonial.js +64 -83
- package/assets/js/modules/youtubevideo.js +114 -145
- package/assets/js/scripts.bundle.js +895 -955
- package/assets/js/scripts.bundle.js.map +1 -1
- package/assets/js/scripts.bundle.min.js +3 -3
- package/assets/js/scripts.bundle.min.js.map +1 -1
- package/assets/sass/_components.scss +14 -14
- package/assets/sass/_corefiles.scss +40 -40
- package/assets/sass/_fonts.scss +16 -16
- package/assets/sass/_forms.scss +10 -10
- package/assets/sass/_func.scss +12 -12
- package/assets/sass/_functions/functions.scss +141 -141
- package/assets/sass/_functions/mixins.scss +170 -170
- package/assets/sass/_functions/utilities.scss +143 -143
- package/assets/sass/_functions/variables.scss +467 -467
- package/assets/sass/_print.scss +61 -61
- package/assets/sass/_tests/{sass.spec.js → colours.spec.js} +9 -9
- package/assets/sass/_tests/colours.spec.scss +44 -44
- package/assets/sass/_tests/func.spec.js +9 -0
- package/assets/sass/_tests/func.spec.scss +232 -232
- package/assets/sass/_tests/mixins.spec.js +9 -0
- package/assets/sass/_tests/mixins.spec.scss +194 -194
- package/assets/sass/_tests/typography.spec.js +9 -0
- package/assets/sass/_tests/typography.spec.scss +35 -35
- package/assets/sass/components/accordion.scss +197 -197
- package/assets/sass/components/alert.scss +98 -98
- package/assets/sass/{elements → components}/buttons.scss +251 -251
- package/assets/sass/{elements → components}/card.scss +288 -288
- package/assets/sass/components/cardDeck.scss +107 -107
- package/assets/sass/components/carousel.scss +234 -234
- package/assets/sass/components/charts.scss +569 -569
- package/assets/sass/{elements → components}/container.scss +236 -236
- package/assets/sass/components/drawer.scss +46 -46
- package/assets/sass/{elements → components}/forms.scss +261 -261
- package/assets/sass/components/header.scss +63 -63
- package/assets/sass/{elements → components}/links.scss +97 -97
- package/assets/sass/{elements → components}/lists.scss +159 -159
- package/assets/sass/components/modal.scss +136 -136
- package/assets/sass/components/nav.scss +960 -960
- package/assets/sass/{elements → components}/panel.scss +161 -161
- package/assets/sass/components/property-searchbar.scss +143 -143
- package/assets/sass/components/snapshot.scss +70 -70
- package/assets/sass/components/stepper.scss +164 -164
- package/assets/sass/{elements → components}/tables.scss +290 -290
- package/assets/sass/components/tabs.scss +87 -87
- package/assets/sass/components/testimonial.scss +132 -132
- package/assets/sass/components/timeline.scss +95 -95
- package/assets/sass/{elements → components}/tooltips.scss +84 -84
- package/assets/sass/core.scss +6 -6
- package/assets/sass/email.scss +65 -65
- package/assets/sass/error.scss +4 -4
- package/assets/sass/foundations/brand.scss +76 -72
- package/assets/sass/foundations/circles.scss +74 -74
- package/assets/sass/foundations/icons.scss +80 -80
- package/assets/sass/foundations/media.scss +50 -50
- package/assets/sass/foundations/reboot.scss +130 -130
- package/assets/sass/foundations/root.scss +125 -125
- package/assets/sass/{elements → foundations}/type.scss +136 -136
- package/assets/sass/main.scss +7 -7
- package/assets/svg/icons.svg +598 -598
- package/assets/svg/logo.svg +49 -43
- package/assets/ts/main.ts +68 -68
- package/assets/ts/modules/accordion.ts +44 -43
- package/assets/ts/modules/alert.ts +58 -0
- package/assets/ts/modules/carousel.ts +103 -0
- package/assets/ts/modules/chart.ts +219 -0
- package/assets/ts/modules/drawer.ts +17 -0
- package/assets/ts/modules/file-upload.ts +49 -0
- package/assets/ts/modules/form.ts +169 -0
- package/assets/ts/modules/helpers.ts +120 -0
- package/assets/ts/modules/modal.ts +91 -0
- package/assets/ts/modules/nav.ts +29 -0
- package/assets/ts/modules/orderablelist.ts +123 -0
- package/assets/ts/modules/table.ts +586 -0
- package/assets/ts/modules/testimonial.ts +84 -0
- package/assets/ts/modules/youtubevideo.ts +146 -0
- package/dist/components.es.js +493 -509
- package/dist/components.umd.js +15 -15
- package/package.json +109 -108
- package/src/components/Accordion/Accordion.spec.js +63 -63
- package/src/components/Accordion/Accordion.vue +22 -22
- package/src/components/Accordion/AccordionItem.vue +52 -52
- package/src/components/Accordion/README.md +34 -34
- package/src/components/Alert/Alert.spec.js +49 -49
- package/src/components/Alert/Alert.vue +39 -39
- package/src/components/Alert/README.md +28 -28
- package/src/components/Banner/Banner.spec.js +28 -28
- package/src/components/Banner/Banner.vue +38 -38
- package/src/components/Banner/README.md +23 -23
- package/src/{elements → components}/Card/Card.vue +122 -122
- package/src/{elements/FileUploads → components/Card}/README.md +24 -24
- package/src/components/CardDeck/CardDeck.spec.js +99 -99
- package/src/components/CardDeck/CardDeck.vue +77 -77
- package/src/components/CardDeck/README.md +24 -24
- package/src/components/Carousel/Carousel.spec.js +45 -45
- package/src/components/Carousel/Carousel.vue +85 -85
- package/src/components/Carousel/README.md +19 -19
- package/src/components/Chart/Chart.spec.js +201 -201
- package/src/components/Chart/Chart.vue +88 -88
- package/src/components/Chart/README.md +17 -17
- package/src/components/Drawer/Drawer.vue +53 -53
- package/src/components/Drawer/README.md +22 -22
- package/src/{elements → components}/FileUploads/FileUploads.vue +48 -48
- package/src/{elements/Card → components/FileUploads}/README.md +24 -24
- package/src/components/Header/Header.spec.js +33 -33
- package/src/components/Header/Header.vue +38 -38
- package/src/components/Header/README.md +27 -27
- package/src/{elements → components}/Input/Input.vue +272 -272
- package/src/{elements → components}/Input/README.md +19 -19
- package/src/components/Modal/Modal.spec.js +22 -22
- package/src/components/Modal/Modal.vue +43 -43
- package/src/components/Modal/README.md +19 -19
- package/src/components/Nav/Nav.spec.js +35 -35
- package/src/components/Nav/Nav.vue +215 -215
- package/src/components/Nav/README.md +22 -22
- package/src/components/NoteFeed/NoteFeed.vue +79 -79
- package/src/components/NoteFeed/README.md +16 -16
- package/src/components/PropertySearchbar/PropertySearchbar.vue +204 -204
- package/src/components/PropertySearchbar/README.md +25 -25
- package/src/components/Snapshot/README.md +20 -20
- package/src/components/Snapshot/Snapshot.vue +32 -32
- package/src/components/Stepper/README.md +32 -32
- package/src/components/Stepper/Step.vue +28 -28
- package/src/components/Stepper/Stepper.spec.js +99 -99
- package/src/components/Stepper/Stepper.vue +33 -33
- package/src/{elements → components}/Table/README.md +62 -62
- package/src/{elements → components}/Table/Table.spec.js +90 -90
- package/src/{elements → components}/Table/Table.vue +129 -129
- package/src/components/Tabs/README.md +27 -27
- package/src/components/Tabs/Tab.vue +32 -32
- package/src/components/Tabs/Tabs.vue +77 -77
- package/src/components/Testimonial/README.md +25 -25
- package/src/components/Testimonial/Testimonial.spec.js +57 -57
- package/src/components/Testimonial/Testimonial.vue +60 -60
- package/src/components/Timeline/README.md +18 -18
- package/src/components/Timeline/Timeline.spec.js +17 -17
- package/src/components/Timeline/Timeline.vue +24 -24
- package/src/foundations/Icon/Icon.spec.js +24 -24
- package/src/foundations/Icon/Icon.vue +24 -24
- package/src/foundations/Icon/README.md +11 -11
- package/src/foundations/Logo/Logo.spec.js +56 -56
- package/src/foundations/Logo/Logo.vue +39 -39
- package/src/foundations/Logo/README.md +20 -20
- package/src/foundations/YoutubeVideo/README.md +11 -11
- package/src/foundations/YoutubeVideo/YoutubeVideo.vue +24 -24
- package/src/helpers/strings.js +12 -12
- package/src/index.js +27 -27
- package/src/vue-shim.d.ts +6 -6
- package/assets/css/email.min.css +0 -1
- package/assets/css/email.min.css.map +0 -1
- package/assets/css/error.min.css +0 -1
- package/assets/css/error.min.css.map +0 -1
- package/assets/ts/main.js +0 -57
- package/assets/ts/main.js.map +0 -1
- package/assets/ts/modules/accordion.js +0 -33
- package/assets/ts/modules/accordion.js.map +0 -1
- package/src/components/Accordion/Accordion.screenshot.vue +0 -57
- package/src/components/Accordion/__screenshots__/win32/laptop/Accordion.png +0 -0
- package/src/components/Accordion/__screenshots__/win32/mobile/Accordion.png +0 -0
- package/src/components/Accordion/__screenshots__/win32/tablet/Accordion.png +0 -0
|
@@ -1,1048 +1,988 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Bootstrap v3.
|
|
3
|
-
* Copyright 2011-
|
|
2
|
+
* Bootstrap [object Object] v3.4.4
|
|
3
|
+
* Copyright 2011-2023 [object Object]
|
|
4
4
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
5
5
|
*/
|
|
6
6
|
(function (factory) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
8
|
+
factory();
|
|
9
9
|
})((function () { 'use strict';
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var label = document.querySelector("label[for=\"".concat(hash, "\"]"));
|
|
38
|
-
var detail = document.querySelector("details[id=\"".concat(hash, "\"]:not([open])"));
|
|
39
|
-
if (label) label.click();else if (detail) detail.setAttribute('open', 'open');
|
|
40
|
-
}, false);
|
|
41
|
-
return null;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Check if an element contains certain elements that needs enhancing with the JavaScript helpers, it is recommended to do this on the page body after the dom is loaded. Elements that are loaded via ajax should also run this function.
|
|
45
|
-
* @param {HTMLElement} element Dom element, this doesn't have to be the body but it is recommended.
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
var checkElements = element => {
|
|
49
|
-
// Tables
|
|
50
|
-
Array.from(element.querySelectorAll('table')).forEach((table, index) => {
|
|
51
|
-
tableStacked(table);
|
|
52
|
-
tableWrap(table);
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Wrap tables with a table wrapper div to help maintain its responsive design.
|
|
57
|
-
* @param {HTMLElement} table Dom table element
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
var tableWrap = table => {
|
|
61
|
-
if (!table.parentNode.classList.contains('table__wrapper')) {
|
|
62
|
-
var tableHTML = table.outerHTML;
|
|
63
|
-
table.outerHTML = "<div class=\"table__wrapper\">".concat(tableHTML, "</div>");
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Creates data attributes to be used by the CSS for mobile views.
|
|
68
|
-
* @param {HTMLElement} table Dom table element
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
var tableStacked = table => {
|
|
72
|
-
var colHeadings = Array.from(table.querySelectorAll('thead th'));
|
|
73
|
-
var colRows = Array.from(table.querySelectorAll('tbody tr'));
|
|
74
|
-
colRows.forEach((row, index) => {
|
|
75
|
-
var cells = Array.from(row.querySelectorAll('th, td'));
|
|
76
|
-
cells.forEach((cell, cellIndex) => {
|
|
77
|
-
var heading = colHeadings[cellIndex];
|
|
78
|
-
|
|
79
|
-
if (typeof heading != "undefined") {
|
|
80
|
-
var tempDiv = document.createElement("div");
|
|
81
|
-
tempDiv.innerHTML = heading.innerHTML;
|
|
82
|
-
var headingText = tempDiv.textContent || tempDiv.innerText || "";
|
|
83
|
-
cell.setAttribute('data-label', headingText);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
var isNumeric = function isNumeric(str) {
|
|
89
|
-
if (typeof str != "string") return false; // we only process strings!
|
|
90
|
-
|
|
91
|
-
return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
|
|
92
|
-
!isNaN(parseFloat(str)); // ...and ensure strings of whitespace fail
|
|
93
|
-
};
|
|
94
|
-
var zeroPad = (num, places) => String(num).padStart(places, '0');
|
|
95
|
-
|
|
96
|
-
var navbar = element => {
|
|
97
|
-
Array.from(element.querySelectorAll('details')).forEach((detail, index) => {
|
|
98
|
-
detail.addEventListener('mouseenter', function (e) {
|
|
99
|
-
if (window.matchMedia('(min-width: 62em)').matches) detail.setAttribute('open', 'true');
|
|
100
|
-
}, false);
|
|
101
|
-
detail.addEventListener('mouseleave', function (e) {
|
|
102
|
-
if (window.matchMedia('(min-width: 62em)').matches) detail.removeAttribute('open');
|
|
11
|
+
// @ts-nocheck
|
|
12
|
+
/**
|
|
13
|
+
* Global helper functions to help maintain and enhance framework elements.
|
|
14
|
+
* @module Helpers
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Add global classes used by the CSS and later JavaScript.
|
|
18
|
+
* @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
|
|
19
|
+
*/
|
|
20
|
+
var addBodyClasses = body => {
|
|
21
|
+
body.classList.add("js-enabled");
|
|
22
|
+
if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
|
|
23
|
+
body.classList.add("ie");
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Add global events.
|
|
29
|
+
* @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
|
|
30
|
+
*/
|
|
31
|
+
var addGlobalEvents = body => {
|
|
32
|
+
window.addEventListener('hashchange', function () {
|
|
33
|
+
var hash = location.hash.replace('#', '');
|
|
34
|
+
var label = document.querySelector("label[for=\"".concat(hash, "\"]"));
|
|
35
|
+
var detail = document.querySelector("details[id=\"".concat(hash, "\"]:not([open])"));
|
|
36
|
+
if (label) label.click();else if (detail) detail.setAttribute('open', 'open');
|
|
103
37
|
}, false);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
function table(tableElement) {
|
|
118
|
-
if (typeof tableElement != "object") return false;
|
|
119
|
-
var thead = tableElement.querySelector('thead');
|
|
120
|
-
var tbody = tableElement.querySelector('tbody');
|
|
121
|
-
var storedData = tbody.cloneNode(true);
|
|
122
|
-
var sortedEvent = new Event('sorted');
|
|
123
|
-
var filteredEvent = new Event('filtered');
|
|
124
|
-
var reorderedEvent = new Event('reordered');
|
|
125
|
-
var randID = 'table_' + Math.random().toString(36).substr(2, 9); // Random to make sure IDs created are unique
|
|
126
|
-
|
|
127
|
-
var draggedRow;
|
|
128
|
-
tableElement.setAttribute('id', randID); // #region Sortable
|
|
129
|
-
|
|
130
|
-
var sortTable = function sortTable(sortBy, sort) {
|
|
131
|
-
// Create an array from the table rows, the index created is then used to sort the array
|
|
132
|
-
var tableArr = [];
|
|
133
|
-
Array.from(tbody.querySelectorAll('tr')).forEach((tableRow, index) => {
|
|
134
|
-
var rowIndex = tableRow.querySelector('td[data-label="' + sortBy + '"], th[data-label="' + sortBy + '"]').textContent;
|
|
135
|
-
if (isNumeric(rowIndex)) rowIndex = zeroPad(rowIndex, 10);
|
|
136
|
-
var dataRow = {
|
|
137
|
-
index: rowIndex,
|
|
138
|
-
row: tableRow
|
|
139
|
-
};
|
|
140
|
-
tableArr.push(dataRow);
|
|
141
|
-
}); // Sort array
|
|
142
|
-
|
|
143
|
-
tableArr.sort((a, b) => a.index > b.index ? 1 : -1); // Reverse if descending
|
|
144
|
-
|
|
145
|
-
if (sort == "descending") tableArr = tableArr.reverse(); // Create a string to return and populate the tbody
|
|
146
|
-
|
|
147
|
-
var strTbody = '';
|
|
148
|
-
tableArr.forEach((tableRow, index) => {
|
|
149
|
-
strTbody += tableRow.row.outerHTML;
|
|
38
|
+
return null;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Check if an element contains certain elements that needs enhancing with the JavaScript helpers, it is recommended to do this on the page body after the dom is loaded. Elements that are loaded via ajax should also run this function.
|
|
42
|
+
* @param {HTMLElement} element Dom element, this doesn't have to be the body but it is recommended.
|
|
43
|
+
*/
|
|
44
|
+
var checkElements = element => {
|
|
45
|
+
// Tables
|
|
46
|
+
Array.from(element.querySelectorAll('table')).forEach((table, index) => {
|
|
47
|
+
tableStacked(table);
|
|
48
|
+
tableWrap(table);
|
|
150
49
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
// Get current sort order
|
|
161
|
-
var sort = target.getAttribute('aria-sort') == "ascending" ? "descending" : "ascending"; // unset sort attributes
|
|
162
|
-
|
|
163
|
-
Array.from(tableElement.querySelectorAll('[data-sortable]')).forEach((col, index) => {
|
|
164
|
-
col.setAttribute('aria-sort', 'none');
|
|
165
|
-
}); // Set the sort order attribute
|
|
166
|
-
|
|
167
|
-
target.setAttribute('aria-sort', sort); // Save the sort options on the table element so that it can be re-sorted later
|
|
168
|
-
|
|
169
|
-
tableElement.setAttribute('data-sort', sort);
|
|
170
|
-
tableElement.setAttribute('data-sortBy', target.textContent); // Sort the table
|
|
171
|
-
|
|
172
|
-
sortTable(target.textContent, sort);
|
|
173
|
-
Array.from(tableElement.querySelectorAll('tr[draggable]')).forEach((tableRow, index) => {
|
|
174
|
-
tableRow.removeAttribute('draggable');
|
|
175
|
-
});
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Wrap tables with a table wrapper div to help maintain its responsive design.
|
|
53
|
+
* @param {HTMLElement} table Dom table element
|
|
54
|
+
*/
|
|
55
|
+
var tableWrap = table => {
|
|
56
|
+
if (!table.parentNode.classList.contains('table__wrapper')) {
|
|
57
|
+
var tableHTML = table.outerHTML;
|
|
58
|
+
table.outerHTML = "<div class=\"table__wrapper\">".concat(tableHTML, "</div>");
|
|
178
59
|
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Creates data attributes to be used by the CSS for mobile views.
|
|
63
|
+
* @param {HTMLElement} table Dom table element
|
|
64
|
+
*/
|
|
65
|
+
var tableStacked = table => {
|
|
66
|
+
var colHeadings = Array.from(table.querySelectorAll('thead th'));
|
|
67
|
+
var colRows = Array.from(table.querySelectorAll('tbody tr'));
|
|
68
|
+
colRows.forEach((row, index) => {
|
|
69
|
+
var cells = Array.from(row.querySelectorAll('th, td'));
|
|
70
|
+
cells.forEach((cell, cellIndex) => {
|
|
71
|
+
var heading = colHeadings[cellIndex];
|
|
72
|
+
if (typeof heading != "undefined") {
|
|
73
|
+
var tempDiv = document.createElement("div");
|
|
74
|
+
tempDiv.innerHTML = heading.innerHTML;
|
|
75
|
+
var headingText = tempDiv.textContent || tempDiv.innerText || "";
|
|
76
|
+
cell.setAttribute('data-label', headingText);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
188
79
|
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
//
|
|
195
|
-
|
|
196
|
-
form.classList.add('table__filters');
|
|
197
|
-
form.classList.add('row');
|
|
198
|
-
form.classList.add('pt-1');
|
|
199
|
-
form.classList.add('pb-3'); // Create the filter options array
|
|
80
|
+
};
|
|
81
|
+
var isNumeric = function isNumeric(str) {
|
|
82
|
+
if (typeof str != "string") return false; // we only process strings!
|
|
83
|
+
return !isNaN(str) &&
|
|
84
|
+
// use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
|
|
85
|
+
!isNaN(parseFloat(str)); // ...and ensure strings of whitespace fail
|
|
86
|
+
};
|
|
200
87
|
|
|
201
|
-
|
|
88
|
+
var zeroPad = (num, places) => String(num).padStart(places, '0');
|
|
202
89
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
90
|
+
// @ts-nocheck
|
|
91
|
+
var navbar = element => {
|
|
92
|
+
Array.from(element.querySelectorAll('details')).forEach((detail, index) => {
|
|
93
|
+
detail.addEventListener('mouseenter', function (e) {
|
|
94
|
+
if (window.matchMedia('(min-width: 62em)').matches) detail.setAttribute('open', 'true');
|
|
95
|
+
}, false);
|
|
96
|
+
detail.addEventListener('mouseleave', function (e) {
|
|
97
|
+
if (window.matchMedia('(min-width: 62em)').matches) detail.removeAttribute('open');
|
|
98
|
+
}, false);
|
|
99
|
+
});
|
|
100
|
+
if ('IntersectionObserver' in window) {
|
|
101
|
+
var observer = new IntersectionObserver(_ref => {
|
|
102
|
+
var [e] = _ref;
|
|
103
|
+
return e.target.classList.toggle("is-stuck", e.intersectionRatio < 1);
|
|
104
|
+
}, {
|
|
105
|
+
threshold: [1]
|
|
207
106
|
});
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
var filterTitle = filterColumns.length == 1 ? "Filter by " + filterColumns[0].textContent : "Filter"; // Update title if only one filter is chosen
|
|
211
|
-
|
|
212
|
-
var checkboxClass = filterColumns.length == 1 ? "d-none" : "d-sm-flex"; // Hide controls when only one filter is chosen
|
|
213
|
-
|
|
214
|
-
form.innerHTML = "<div class=\"col-sm-6 col-md-4 pb-3\">\n <div class=\"form-control__wrapper form-control-inline mb-0\">\n <label for=\"".concat(randID, "_filter\" class=\"form-label\">").concat(filterTitle, ":</label>\n <input type=\"search\" name=\"").concat(randID, "_filter\" id=\"").concat(randID, "_filter\" class=\"form-control form-control-sm\" placeholder=\"\" list=\"").concat(randID, "_list\" />\n </div>\n <datalist id=\"").concat(randID, "_list\">\n ").concat(Object.keys(searchableTerms).map(term => "<option value=\"".concat(term, "\"></option>")).join(""), "\n </datalist>\n</div>\n<div class=\"col-md-8 align-items-center pb-3 ").concat(checkboxClass, "\">\n ").concat("<span class=\"pe-3 text-nowrap h5 mb-0\">Filter by: </span>" + filterColumns.map(column => "<div class=\"form-check pe-3 mt-0 mb-0\"><input class=\"form-check-input\" type=\"checkbox\" id=\"".concat(randID, "_").concat(column.textContent.replace(' ', '_').toLowerCase(), "\" checked=\"checked\" /><label class=\"form-check-label text-nowrap\" for=\"").concat(randID, "_").concat(column.textContent.replace(' ', '_').toLowerCase(), "\">").concat(column.textContent, "</label></div>")).join(""), "\n</div>"); // Add before the actual table
|
|
215
|
-
|
|
216
|
-
tableElement.prepend(form);
|
|
107
|
+
observer.observe(element);
|
|
108
|
+
}
|
|
217
109
|
};
|
|
218
110
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
111
|
+
// @ts-nocheck
|
|
112
|
+
function table(tableElement) {
|
|
113
|
+
if (typeof tableElement != "object") return false;
|
|
114
|
+
var thead = tableElement.querySelector('thead');
|
|
115
|
+
var tbody = tableElement.querySelector('tbody');
|
|
116
|
+
var storedData = tbody.cloneNode(true);
|
|
117
|
+
var sortedEvent = new Event('sorted');
|
|
118
|
+
var filteredEvent = new Event('filtered');
|
|
119
|
+
var reorderedEvent = new Event('reordered');
|
|
120
|
+
var randID = 'table_' + Math.random().toString(36).substr(2, 9); // Random to make sure IDs created are unique
|
|
121
|
+
var draggedRow;
|
|
122
|
+
tableElement.setAttribute('id', randID);
|
|
123
|
+
// #region Sortable
|
|
124
|
+
var sortTable = function sortTable(sortBy, sort) {
|
|
125
|
+
// Create an array from the table rows, the index created is then used to sort the array
|
|
126
|
+
var tableArr = [];
|
|
127
|
+
Array.from(tbody.querySelectorAll('tr')).forEach((tableRow, index) => {
|
|
128
|
+
var rowIndex = tableRow.querySelector('td[data-label="' + sortBy + '"], th[data-label="' + sortBy + '"]').textContent;
|
|
129
|
+
if (isNumeric(rowIndex)) rowIndex = zeroPad(rowIndex, 10);
|
|
230
130
|
var dataRow = {
|
|
131
|
+
index: rowIndex,
|
|
231
132
|
row: tableRow
|
|
232
133
|
};
|
|
233
134
|
tableArr.push(dataRow);
|
|
234
|
-
}
|
|
235
|
-
}); // Create a string to return and populate the tbody
|
|
236
|
-
|
|
237
|
-
var strTbody = '';
|
|
238
|
-
tableArr.forEach((tableRow, index) => {
|
|
239
|
-
strTbody += tableRow.row.outerHTML;
|
|
240
|
-
});
|
|
241
|
-
tbody.innerHTML = strTbody; // Dispatch the filter event.
|
|
242
|
-
|
|
243
|
-
tableElement.dispatchEvent(filteredEvent);
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
var createFilterList = function createFilterList() {
|
|
247
|
-
// Check which options are checked
|
|
248
|
-
var filterOptions = [];
|
|
249
|
-
Array.from(tableElement.querySelectorAll('[type="checkbox"]:checked + label')).forEach((label, index) => {
|
|
250
|
-
filterOptions.push(label.textContent);
|
|
251
|
-
}); // Build up the list of searchable terms
|
|
252
|
-
|
|
253
|
-
var searchableTerms = [];
|
|
254
|
-
filterOptions.forEach((option, index) => {
|
|
255
|
-
Array.from(tableElement.querySelectorAll('td[data-label="' + option + '"]')).forEach((label, index) => {
|
|
256
|
-
searchableTerms[label.textContent] = label.textContent;
|
|
257
135
|
});
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
filterTable(searchTerm);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
tableElement.addEventListener('change', function (e) {
|
|
136
|
+
// Sort array
|
|
137
|
+
tableArr.sort((a, b) => a.index > b.index ? 1 : -1);
|
|
138
|
+
// Reverse if descending
|
|
139
|
+
if (sort == "descending") tableArr = tableArr.reverse();
|
|
140
|
+
// Create a string to return and populate the tbody
|
|
141
|
+
var strTbody = '';
|
|
142
|
+
tableArr.forEach((tableRow, index) => {
|
|
143
|
+
strTbody += tableRow.row.outerHTML;
|
|
144
|
+
});
|
|
145
|
+
tbody.innerHTML = strTbody;
|
|
146
|
+
// Dispatch the sortable event
|
|
147
|
+
tableElement.dispatchEvent(sortedEvent);
|
|
148
|
+
};
|
|
149
|
+
// Declare event handlers
|
|
150
|
+
tableElement.addEventListener('click', function (e) {
|
|
278
151
|
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
279
|
-
if (target.matches('
|
|
280
|
-
|
|
281
|
-
|
|
152
|
+
if (target.matches('[data-sortable]')) {
|
|
153
|
+
// Get current sort order
|
|
154
|
+
var sort = target.getAttribute('aria-sort') == "ascending" ? "descending" : "ascending";
|
|
155
|
+
// unset sort attributes
|
|
156
|
+
Array.from(tableElement.querySelectorAll('[data-sortable]')).forEach((col, index) => {
|
|
157
|
+
col.setAttribute('aria-sort', 'none');
|
|
158
|
+
});
|
|
159
|
+
// Set the sort order attribute
|
|
160
|
+
target.setAttribute('aria-sort', sort);
|
|
161
|
+
// Save the sort options on the table element so that it can be re-sorted later
|
|
162
|
+
tableElement.setAttribute('data-sort', sort);
|
|
163
|
+
tableElement.setAttribute('data-sortBy', target.textContent);
|
|
164
|
+
// Sort the table
|
|
165
|
+
sortTable(target.textContent, sort);
|
|
166
|
+
Array.from(tableElement.querySelectorAll('tr[draggable]')).forEach((tableRow, index) => {
|
|
167
|
+
tableRow.removeAttribute('draggable');
|
|
168
|
+
});
|
|
169
|
+
break;
|
|
282
170
|
}
|
|
283
171
|
}
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
172
|
+
}, false);
|
|
173
|
+
// On page load check if the table should be pre-sorted, if so trigger a click
|
|
174
|
+
if (tableElement.getAttribute('data-sortBy')) {
|
|
175
|
+
var sort = tableElement.getAttribute('data-sort') == "ascending" ? "descending" : "ascending";
|
|
176
|
+
Array.from(tableElement.querySelectorAll('[data-sortable]')).forEach((col, index) => {
|
|
177
|
+
if (col.textContent == tableElement.getAttribute('data-sortBy')) {
|
|
178
|
+
col.setAttribute('aria-sort', sort);
|
|
179
|
+
col.click();
|
|
291
180
|
}
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
} // #endregion Filters
|
|
295
|
-
// #region Pagination
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
var paginateRows = function paginateRows(show, page) {
|
|
299
|
-
// Create some inline CSS to control what is viewed on the table, unline the filters we are just hiding the rable rows not removing them from the DOM.
|
|
300
|
-
var style = document.getElementById(randID + '_style');
|
|
301
|
-
|
|
302
|
-
if (style == null) {
|
|
303
|
-
style = document.createElement("style");
|
|
304
|
-
style.setAttribute('id', randID + '_style');
|
|
181
|
+
});
|
|
305
182
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
var
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
183
|
+
// #endregion Sortable
|
|
184
|
+
// #region Filters
|
|
185
|
+
var createFilterForm = function createFilterForm(count) {
|
|
186
|
+
// Create wrapper div
|
|
187
|
+
var form = document.createElement("div");
|
|
188
|
+
form.classList.add('table__filters');
|
|
189
|
+
form.classList.add('row');
|
|
190
|
+
form.classList.add('pt-1');
|
|
191
|
+
form.classList.add('pb-3');
|
|
192
|
+
// Create the filter options array
|
|
193
|
+
var filterColumns = Array.from(tableElement.querySelectorAll('th[data-filterable]'));
|
|
194
|
+
// Populate a list of searchable terms from the cells of the columns that could be used as a filter
|
|
195
|
+
var searchableTerms = {};
|
|
196
|
+
filterColumns.forEach((columnHeading, index) => {
|
|
197
|
+
Array.from(tableElement.querySelectorAll('td[data-label="' + columnHeading.textContent + '"]')).forEach((label, index) => {
|
|
198
|
+
searchableTerms[label.textContent] = label.textContent;
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
// Create the form
|
|
202
|
+
var filterTitle = filterColumns.length == 1 ? "Filter by " + filterColumns[0].textContent : "Filter"; // Update title if only one filter is chosen
|
|
203
|
+
var checkboxClass = filterColumns.length == 1 ? "d-none" : "d-sm-flex"; // Hide controls when only one filter is chosen
|
|
204
|
+
form.innerHTML = "<div class=\"col-sm-6 col-md-4 pb-3\">\n <div class=\"form-control__wrapper form-control-inline mb-0\">\n <label for=\"".concat(randID, "_filter\" class=\"form-label\">").concat(filterTitle, ":</label>\n <input type=\"search\" name=\"").concat(randID, "_filter\" id=\"").concat(randID, "_filter\" class=\"form-control form-control-sm\" placeholder=\"\" list=\"").concat(randID, "_list\" />\n </div>\n <datalist id=\"").concat(randID, "_list\">\n ").concat(Object.keys(searchableTerms).map(term => "<option value=\"".concat(term, "\"></option>")).join(""), "\n </datalist>\n</div>\n<div class=\"col-md-8 align-items-center pb-3 ").concat(checkboxClass, "\">\n ").concat("<span class=\"pe-3 text-nowrap h5 mb-0\">Filter by: </span>" + filterColumns.map(column => "<div class=\"form-check pe-3 mt-0 mb-0\"><input class=\"form-check-input\" type=\"checkbox\" id=\"".concat(randID, "_").concat(column.textContent.replace(' ', '_').toLowerCase(), "\" checked=\"checked\" /><label class=\"form-check-label text-nowrap\" for=\"").concat(randID, "_").concat(column.textContent.replace(' ', '_').toLowerCase(), "\">").concat(column.textContent, "</label></div>")).join(""), "\n</div>");
|
|
205
|
+
// Add before the actual table
|
|
206
|
+
tableElement.prepend(form);
|
|
207
|
+
};
|
|
208
|
+
var filterTable = function filterTable(searchTerm) {
|
|
209
|
+
// Create an array of rows that match the search term
|
|
210
|
+
var tableArr = [];
|
|
211
|
+
Array.from(storedData.querySelectorAll('tr')).forEach((tableRow, index) => {
|
|
212
|
+
// We want one long search string per row including each filterable table cell
|
|
213
|
+
var rowSearchString = '';
|
|
214
|
+
Array.from(tableElement.querySelectorAll('[type="checkbox"]:checked + label')).forEach((label, index) => {
|
|
215
|
+
rowSearchString += tableRow.querySelector('td[data-label="' + label.textContent + '"]').textContent + ' | ';
|
|
216
|
+
});
|
|
217
|
+
// Check if the table row search string contains the search term
|
|
218
|
+
if (rowSearchString.indexOf(searchTerm) >= 0) {
|
|
219
|
+
var dataRow = {
|
|
220
|
+
row: tableRow
|
|
221
|
+
};
|
|
222
|
+
tableArr.push(dataRow);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
// Create a string to return and populate the tbody
|
|
226
|
+
var strTbody = '';
|
|
227
|
+
tableArr.forEach((tableRow, index) => {
|
|
228
|
+
strTbody += tableRow.row.outerHTML;
|
|
229
|
+
});
|
|
230
|
+
tbody.innerHTML = strTbody;
|
|
231
|
+
// Dispatch the filter event.
|
|
232
|
+
tableElement.dispatchEvent(filteredEvent);
|
|
233
|
+
};
|
|
234
|
+
var createFilterList = function createFilterList() {
|
|
235
|
+
// Check which options are checked
|
|
236
|
+
var filterOptions = [];
|
|
237
|
+
Array.from(tableElement.querySelectorAll('[type="checkbox"]:checked + label')).forEach((label, index) => {
|
|
238
|
+
filterOptions.push(label.textContent);
|
|
239
|
+
});
|
|
240
|
+
// Build up the list of searchable terms
|
|
241
|
+
var searchableTerms = [];
|
|
242
|
+
filterOptions.forEach((option, index) => {
|
|
243
|
+
Array.from(tableElement.querySelectorAll('td[data-label="' + option + '"]')).forEach((label, index) => {
|
|
244
|
+
searchableTerms[label.textContent] = label.textContent;
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
// Rebuild the list
|
|
248
|
+
var dataList = tableElement.querySelector('datalist');
|
|
249
|
+
dataList.innerHTML = Object.keys(searchableTerms).map(term => "<option value=\"".concat(term, "\"></option>")).join("");
|
|
250
|
+
};
|
|
251
|
+
// On page load check if filters are needed
|
|
252
|
+
if (Array.from(tableElement.querySelectorAll('[data-filterable]')).length) {
|
|
253
|
+
// Create the filter options
|
|
254
|
+
createFilterForm(tableElement, Array.from(tableElement.querySelectorAll('[data-filterable]')).length);
|
|
255
|
+
// Add event handlers for the filter options
|
|
256
|
+
tableElement.addEventListener('keyup', function (e) {
|
|
324
257
|
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
325
|
-
if (target.matches('
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
tableElement.setAttribute('data-show', target.value);
|
|
258
|
+
if (target.matches('input[type="search"]')) {
|
|
259
|
+
var searchTerm = target.value;
|
|
260
|
+
filterTable(searchTerm);
|
|
329
261
|
}
|
|
330
262
|
}
|
|
331
263
|
});
|
|
332
|
-
tableElement.addEventListener('
|
|
264
|
+
tableElement.addEventListener('change', function (e) {
|
|
333
265
|
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
334
|
-
if (target.matches('
|
|
335
|
-
|
|
336
|
-
|
|
266
|
+
if (target.matches('input[type="search"]')) {
|
|
267
|
+
var searchTerm = target.value;
|
|
268
|
+
filterTable(searchTerm);
|
|
337
269
|
}
|
|
338
270
|
}
|
|
339
|
-
}
|
|
271
|
+
});
|
|
340
272
|
tableElement.addEventListener('change', function (e) {
|
|
341
273
|
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
342
|
-
if (target.matches('
|
|
343
|
-
|
|
344
|
-
|
|
274
|
+
if (target.matches('input[type="checkbox"]')) {
|
|
275
|
+
var searchTerm = tableElement.querySelector('input[type="search"]').value;
|
|
276
|
+
filterTable(searchTerm);
|
|
277
|
+
createFilterList();
|
|
345
278
|
}
|
|
346
279
|
}
|
|
347
280
|
});
|
|
348
281
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
e.target.classList.add('tr--dragging');
|
|
358
|
-
} // Create the order column and event handler for rows
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
var setReorderRows = function setReorderRows() {
|
|
362
|
-
Array.from(tbody.querySelectorAll('tr')).forEach((tableRow, index) => {
|
|
363
|
-
// Create column if not already created
|
|
364
|
-
if (tableRow.querySelector('[data-label="Order"]') == null) {
|
|
365
|
-
var orderColumn = document.createElement('th');
|
|
366
|
-
orderColumn.innerHTML = index + 1;
|
|
367
|
-
orderColumn.setAttribute('data-label', 'Order');
|
|
368
|
-
tableRow.prepend(orderColumn);
|
|
369
|
-
} // Make draggable
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
tableRow.setAttribute('id', randID + '_row_' + (index + 1));
|
|
373
|
-
tableRow.setAttribute('data-order', index + 1);
|
|
374
|
-
tableRow.setAttribute('draggable', 'true');
|
|
375
|
-
tableRow.addEventListener("dragstart", setDraggedRow);
|
|
376
|
-
});
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
if (tableElement.getAttribute('data-reorder') && tableElement.getAttribute('data-reorder') != "false") {
|
|
380
|
-
// Add column heading
|
|
381
|
-
var orderHeading = document.createElement('th');
|
|
382
|
-
orderHeading.innerHTML = 'Order';
|
|
383
|
-
orderHeading.title = 'Click here to enable re-ordering via drag and drop';
|
|
384
|
-
orderHeading.classList.add('table-order-reset');
|
|
385
|
-
thead.querySelector('tr').prepend(orderHeading);
|
|
386
|
-
setReorderRows(); // Reset order button
|
|
387
|
-
|
|
388
|
-
tableElement.addEventListener('click', function (e) {
|
|
389
|
-
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
390
|
-
if (target.matches('.table-order-reset')) {
|
|
391
|
-
// unset sort attributes
|
|
392
|
-
Array.from(tableElement.querySelectorAll('[data-sortable]')).forEach((col, index) => {
|
|
393
|
-
col.setAttribute('aria-sort', 'none');
|
|
394
|
-
}); // Save the sort options on the table element so that it can be re-sorted later
|
|
395
|
-
|
|
396
|
-
tableElement.removeAttribute('data-sort');
|
|
397
|
-
tableElement.removeAttribute('data-sortBy'); // Sort the table
|
|
398
|
-
|
|
399
|
-
sortTable('Order', 'ascending');
|
|
400
|
-
Array.from(tableElement.querySelectorAll('tbody tr')).forEach((tableRow, index) => {
|
|
401
|
-
tableRow.setAttribute('draggable', 'true');
|
|
402
|
-
});
|
|
403
|
-
break;
|
|
404
|
-
}
|
|
282
|
+
// #endregion Filters
|
|
283
|
+
// #region Pagination
|
|
284
|
+
var paginateRows = function paginateRows(show, page) {
|
|
285
|
+
// Create some inline CSS to control what is viewed on the table, unline the filters we are just hiding the rable rows not removing them from the DOM.
|
|
286
|
+
var style = document.getElementById(randID + '_style');
|
|
287
|
+
if (style == null) {
|
|
288
|
+
style = document.createElement("style");
|
|
289
|
+
style.setAttribute('id', randID + '_style');
|
|
405
290
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
291
|
+
var startShowing = show * (page - 1) + 1;
|
|
292
|
+
var stopShowing = show * page;
|
|
293
|
+
style.innerHTML = "\n #".concat(randID, " tbody tr {\n display: none;\n }\n #").concat(randID, " tbody tr:nth-child(").concat(startShowing, "),\n #").concat(randID, " tbody tr:nth-child(").concat(startShowing, ") ~ tr{\n display: block;\n }\n @media screen and (min-width: 36em) {\n #").concat(randID, " tbody tr:nth-child(").concat(startShowing, "),\n #").concat(randID, " tbody tr:nth-child(").concat(startShowing, ") ~ tr{\n display: table-row;\n }\n }\n #").concat(randID, " tbody tr:nth-child(").concat(stopShowing, ") ~ tr{\n display: none;\n }\n ");
|
|
294
|
+
tableElement.append(style);
|
|
295
|
+
};
|
|
296
|
+
// On page load check if the table should be paginated
|
|
297
|
+
if (tableElement.getAttribute('data-show')) {
|
|
298
|
+
var show = parseInt(tableElement.getAttribute('data-show'));
|
|
299
|
+
var page = parseInt(tableElement.getAttribute('data-page')) ? parseInt(tableElement.getAttribute('data-page')) : 1;
|
|
300
|
+
var totalRows = tableElement.querySelectorAll('tbody tr').length;
|
|
301
|
+
if (show < totalRows) {
|
|
302
|
+
paginateRows(show, page);
|
|
303
|
+
createPaginationForm(randID, tableElement, show, page, totalRows);
|
|
304
|
+
createPaginationButttons(randID, tableElement, show, page, totalRows);
|
|
305
|
+
tableElement.addEventListener('change', function (e) {
|
|
306
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
307
|
+
if (target.matches('.table__pagination input[type="number"]')) {
|
|
308
|
+
paginateRows(target.value, page);
|
|
309
|
+
createPaginationButttons(randID, tableElement, target.value, page, totalRows);
|
|
310
|
+
tableElement.setAttribute('data-show', target.value);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
tableElement.addEventListener('click', function (e) {
|
|
315
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
316
|
+
if (target.matches('.page-item:not(.active):not(.disabled) .page-link')) {
|
|
317
|
+
paginateRows(tableElement.getAttribute('data-show'), target.getAttribute('data-page'));
|
|
318
|
+
createPaginationButttons(randID, tableElement, tableElement.getAttribute('data-show'), target.getAttribute('data-page'), totalRows);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}, false);
|
|
322
|
+
tableElement.addEventListener('change', function (e) {
|
|
323
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
324
|
+
if (target.matches('.table__pagination select')) {
|
|
325
|
+
paginateRows(tableElement.getAttribute('data-show'), target.value);
|
|
326
|
+
createPaginationButttons(randID, tableElement, tableElement.getAttribute('data-show'), target.value, totalRows);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
});
|
|
420
330
|
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
331
|
+
}
|
|
332
|
+
// #endregion Pagination
|
|
333
|
+
// #region Reorderable
|
|
334
|
+
// Set the row thats being dragged and copy the row
|
|
335
|
+
function setDraggedRow(e) {
|
|
336
|
+
e.dataTransfer.setData("text/plain", e.target.id);
|
|
337
|
+
draggedRow = e.target;
|
|
338
|
+
e.target.classList.add('tr--dragging');
|
|
339
|
+
}
|
|
340
|
+
// Create the order column and event handler for rows
|
|
341
|
+
var setReorderRows = function setReorderRows() {
|
|
342
|
+
Array.from(tbody.querySelectorAll('tr')).forEach((tableRow, index) => {
|
|
343
|
+
// Create column if not already created
|
|
344
|
+
if (tableRow.querySelector('[data-label="Order"]') == null) {
|
|
345
|
+
var orderColumn = document.createElement('th');
|
|
346
|
+
orderColumn.innerHTML = index + 1;
|
|
347
|
+
orderColumn.setAttribute('data-label', 'Order');
|
|
348
|
+
tableRow.prepend(orderColumn);
|
|
429
349
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
350
|
+
// Make draggable
|
|
351
|
+
tableRow.setAttribute('id', randID + '_row_' + (index + 1));
|
|
352
|
+
tableRow.setAttribute('data-order', index + 1);
|
|
353
|
+
tableRow.setAttribute('draggable', 'true');
|
|
354
|
+
tableRow.addEventListener("dragstart", setDraggedRow);
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
if (tableElement.getAttribute('data-reorder') && tableElement.getAttribute('data-reorder') != "false") {
|
|
358
|
+
// Add column heading
|
|
359
|
+
var orderHeading = document.createElement('th');
|
|
360
|
+
orderHeading.innerHTML = 'Order';
|
|
361
|
+
orderHeading.title = 'Click here to enable re-ordering via drag and drop';
|
|
362
|
+
orderHeading.classList.add('table-order-reset');
|
|
363
|
+
thead.querySelector('tr').prepend(orderHeading);
|
|
364
|
+
setReorderRows();
|
|
365
|
+
// Reset order button
|
|
366
|
+
tableElement.addEventListener('click', function (e) {
|
|
367
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
368
|
+
if (target.matches('.table-order-reset')) {
|
|
369
|
+
// unset sort attributes
|
|
370
|
+
Array.from(tableElement.querySelectorAll('[data-sortable]')).forEach((col, index) => {
|
|
371
|
+
col.setAttribute('aria-sort', 'none');
|
|
372
|
+
});
|
|
373
|
+
// Save the sort options on the table element so that it can be re-sorted later
|
|
374
|
+
tableElement.removeAttribute('data-sort');
|
|
375
|
+
tableElement.removeAttribute('data-sortBy');
|
|
376
|
+
// Sort the table
|
|
377
|
+
sortTable('Order', 'ascending');
|
|
378
|
+
Array.from(tableElement.querySelectorAll('tbody tr')).forEach((tableRow, index) => {
|
|
379
|
+
tableRow.setAttribute('draggable', 'true');
|
|
446
380
|
});
|
|
447
|
-
|
|
381
|
+
break;
|
|
448
382
|
}
|
|
449
|
-
|
|
450
|
-
break;
|
|
451
383
|
}
|
|
384
|
+
}, false);
|
|
385
|
+
document.addEventListener("dragover", function (e) {
|
|
386
|
+
// prevent default to allow drop
|
|
387
|
+
e.preventDefault();
|
|
388
|
+
}, false);
|
|
389
|
+
document.addEventListener("dragenter", function (e) {
|
|
390
|
+
// prevent default to allow drop
|
|
391
|
+
e.preventDefault();
|
|
392
|
+
e.dataTransfer.dropEffect = "move";
|
|
393
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
394
|
+
if (target.matches('[data-reorder] tbody tr')) {
|
|
395
|
+
target.classList.add('tr--dropable');
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}, false);
|
|
399
|
+
document.addEventListener("dragleave", function (e) {
|
|
400
|
+
// prevent default to allow drop
|
|
401
|
+
e.preventDefault();
|
|
402
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
403
|
+
if (target.matches('[data-reorder] tbody tr')) {
|
|
404
|
+
target.classList.remove('tr--dropable');
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}, false);
|
|
408
|
+
document.addEventListener("drop", function (e) {
|
|
409
|
+
e.preventDefault();
|
|
410
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
411
|
+
if (target.matches('[data-reorder] tbody tr')) {
|
|
412
|
+
if (target.parentNode != null && draggedRow.parentNode != null && target != draggedRow) {
|
|
413
|
+
draggedRow.parentNode.removeChild(draggedRow);
|
|
414
|
+
if (draggedRow.getAttribute('data-order') > target.getAttribute('data-order')) target.parentNode.insertBefore(draggedRow, target);else target.parentNode.insertBefore(draggedRow, target.nextElementSibling);
|
|
415
|
+
// Re label the rows
|
|
416
|
+
Array.from(tbody.querySelectorAll('tr')).forEach((tableRowOrder, index) => {
|
|
417
|
+
tableRowOrder.classList.remove('tr--dragging');
|
|
418
|
+
tableRowOrder.classList.remove('tr--dropable');
|
|
419
|
+
tableRowOrder.querySelector('th').innerHTML = index + 1;
|
|
420
|
+
tableRowOrder.setAttribute('data-order', index + 1);
|
|
421
|
+
});
|
|
422
|
+
tableElement.dispatchEvent(reorderedEvent);
|
|
423
|
+
}
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}, false);
|
|
428
|
+
}
|
|
429
|
+
// #endregion Reorderable
|
|
430
|
+
// Watch for the filterable event and re-sort the tbody
|
|
431
|
+
tableElement.addEventListener('filtered', function (e) {
|
|
432
|
+
if (tableElement.getAttribute('data-sortBy') && tableElement.getAttribute('data-sort')) sortTable(tableElement.getAttribute('data-sortBy'), tableElement.getAttribute('data-sort'));
|
|
433
|
+
if (tableElement.getAttribute('data-show')) {
|
|
434
|
+
var _show = parseInt(tableElement.getAttribute('data-show'));
|
|
435
|
+
var _totalRows = tableElement.querySelectorAll('tbody tr').length;
|
|
436
|
+
var tablePagination = tableElement.querySelector('.table__pagination');
|
|
437
|
+
if (tablePagination != null) tablePagination.remove();
|
|
438
|
+
if (_show < _totalRows) {
|
|
439
|
+
paginateRows(_show, 1);
|
|
440
|
+
createPaginationForm(randID, tableElement, _show, 1, _totalRows);
|
|
441
|
+
createPaginationButttons(randID, tableElement, _show, 1, _totalRows);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (tableElement.getAttribute('data-reorder')) {
|
|
445
|
+
setReorderRows();
|
|
452
446
|
}
|
|
453
447
|
}, false);
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
var _show = parseInt(tableElement.getAttribute('data-show'));
|
|
463
|
-
|
|
464
|
-
var _totalRows = tableElement.querySelectorAll('tbody tr').length;
|
|
448
|
+
tableElement.addEventListener('sorted', function (e) {
|
|
449
|
+
if (tableElement.getAttribute('data-reorder')) {
|
|
450
|
+
setReorderRows();
|
|
451
|
+
}
|
|
452
|
+
}, false);
|
|
453
|
+
tableElement.addEventListener('populated', function (e) {
|
|
454
|
+
var tableFilter = tableElement.querySelector('.table__filters');
|
|
455
|
+
tableFilter.remove();
|
|
465
456
|
var tablePagination = tableElement.querySelector('.table__pagination');
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
457
|
+
tablePagination.remove();
|
|
458
|
+
var newTable = tableElement.cloneNode(true);
|
|
459
|
+
tableElement.parentNode.replaceChild(newTable, tableElement);
|
|
460
|
+
table(newTable);
|
|
461
|
+
}, false);
|
|
462
|
+
}
|
|
463
|
+
var createPaginationForm = function createPaginationForm(randID, tableElement, show, page, totalRows) {
|
|
464
|
+
var form = document.createElement("div");
|
|
465
|
+
form.classList.add('table__pagination');
|
|
466
|
+
form.classList.add('row');
|
|
467
|
+
form.classList.add('pt-3');
|
|
468
|
+
form.classList.add('pb-3');
|
|
469
|
+
// Create the form and create a container div to hold the pagination buttons
|
|
470
|
+
form.innerHTML = "<div class=\"col mw-fit-content mb-3\">\n<div class=\"form-control__wrapper form-control-inline mb-0\">\n <label for=\"".concat(randID, "_showing\" class=\"form-label\">Showing:</label>\n <input type=\"number\" name=\"").concat(randID, "_showing\" id=\"").concat(randID, "_showing\" class=\"form-control form-control-sm showing-input-field\" placeholder=\"\" list=\"").concat(randID, "_pagination\" value=\"").concat(show, "\" min=\"1\" max=\"").concat(totalRows, "\" />\n</div>\n<datalist id=\"").concat(randID, "_pagination\">\n<option value=\"5\">5</option>\n").concat(totalRows > 10 ? "<option value=\"10\">10</option>" : '', "\n").concat(totalRows > 20 ? "<option value=\"20\">20</option>" : '', "\n<option value=\"").concat(totalRows, "\">").concat(totalRows, "</option>\n</datalist>\n</div>\n<div class=\"col mw-fit-content me-auto d-flex align-items-center mb-3\"><span class=\"label\">per page</span></div>\n<div class=\"col mw-fit-content d-sm-flex justify-content-end align-items-center\" id=\"").concat(randID, "_paginationBtns\"></div>");
|
|
471
|
+
// Add after the actual table
|
|
472
|
+
tableElement.append(form);
|
|
473
|
+
};
|
|
474
|
+
var createPaginationButttons = function createPaginationButttons(randID, tableElement, show, page, totalRows) {
|
|
475
|
+
var paginationButtonsWrapper = document.getElementById(randID + '_paginationBtns');
|
|
476
|
+
if (paginationButtonsWrapper == null) return false;
|
|
477
|
+
var numberPages = Math.ceil(totalRows / show);
|
|
478
|
+
if (numberPages == 1) {
|
|
479
|
+
// Remore the buttons or dont display any if we dont need them
|
|
480
|
+
paginationButtonsWrapper.innerHTML = '';
|
|
481
|
+
} else if (numberPages < 5) {
|
|
482
|
+
// If less than 5 pages (which fits comfortably on mobile) we display buttons
|
|
483
|
+
var strButtons = '';
|
|
484
|
+
for (var i = 1; i <= numberPages; i++) {
|
|
485
|
+
if (i == page) strButtons += "<li class=\"page-item active\" aria-current=\"page\"><span class=\"page-link\">".concat(i, "</span></li>");else strButtons += "<li class=\"page-item\"><button class=\"page-link\" data-page=\"".concat(i, "\">").concat(i, "</button></li>");
|
|
472
486
|
}
|
|
487
|
+
paginationButtonsWrapper.innerHTML = "<span class=\"pe-2 mb-3\">Page: </span><ul class=\"pagination mb-3\">\n ".concat(page == 1 ? "<li class=\"page-item disabled\"><span class=\"page-link\">Previous</span></li>" : "<li class=\"page-item\"><button class=\"page-link\" data-page=\"".concat(parseInt(page) - 1, "\">Previous</button></li>"), "\n ").concat(strButtons, "\n ").concat(page == numberPages ? "<li class=\"page-item disabled\"><span class=\"page-link\">Next</span></li>" : "<li class=\"page-item\"><button class=\"page-link\" data-page=\"".concat(parseInt(page) + 1, "\">Next</button></li>"), "\n </ul>");
|
|
488
|
+
} else {
|
|
489
|
+
// If more than 5 lets show a select field instead so that we dont have loads and loads of buttons
|
|
490
|
+
var strOptions = '';
|
|
491
|
+
for (var _i = 1; _i <= numberPages; _i++) {
|
|
492
|
+
if (_i == page) strOptions += "<option value=\"".concat(_i, "\" selected>Page ").concat(_i, "</option>");else strOptions += "<option value=\"".concat(_i, "\">Page ").concat(_i, "</option>");
|
|
493
|
+
}
|
|
494
|
+
paginationButtonsWrapper.innerHTML = "\n<div class=\"form-control__wrapper page-number mb-2\">\n<select class=\"form-select\">\n".concat(strOptions, "\n</select>\n</div>\n ");
|
|
473
495
|
}
|
|
496
|
+
};
|
|
474
497
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
var newTable = tableElement.cloneNode(true);
|
|
490
|
-
tableElement.parentNode.replaceChild(newTable, tableElement);
|
|
491
|
-
table(newTable);
|
|
492
|
-
}, false);
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
var createPaginationForm = function createPaginationForm(randID, tableElement, show, page, totalRows) {
|
|
496
|
-
var form = document.createElement("div");
|
|
497
|
-
form.classList.add('table__pagination');
|
|
498
|
-
form.classList.add('row');
|
|
499
|
-
form.classList.add('pt-3');
|
|
500
|
-
form.classList.add('pb-3'); // Create the form and create a container div to hold the pagination buttons
|
|
501
|
-
|
|
502
|
-
form.innerHTML = "<div class=\"col mw-fit-content mb-3\">\n<div class=\"form-control__wrapper form-control-inline mb-0\">\n <label for=\"".concat(randID, "_showing\" class=\"form-label\">Showing:</label>\n <input type=\"number\" name=\"").concat(randID, "_showing\" id=\"").concat(randID, "_showing\" class=\"form-control form-control-sm showing-input-field\" placeholder=\"\" list=\"").concat(randID, "_pagination\" value=\"").concat(show, "\" min=\"1\" max=\"").concat(totalRows, "\" />\n</div>\n<datalist id=\"").concat(randID, "_pagination\">\n<option value=\"5\">5</option>\n").concat(totalRows > 10 ? "<option value=\"10\">10</option>" : '', "\n").concat(totalRows > 20 ? "<option value=\"20\">20</option>" : '', "\n<option value=\"").concat(totalRows, "\">").concat(totalRows, "</option>\n</datalist>\n</div>\n<div class=\"col mw-fit-content me-auto d-flex align-items-center mb-3\"><span class=\"label\">per page</span></div>\n<div class=\"col mw-fit-content d-sm-flex justify-content-end align-items-center\" id=\"").concat(randID, "_paginationBtns\"></div>"); // Add after the actual table
|
|
503
|
-
|
|
504
|
-
tableElement.append(form);
|
|
505
|
-
};
|
|
506
|
-
var createPaginationButttons = function createPaginationButttons(randID, tableElement, show, page, totalRows) {
|
|
507
|
-
var paginationButtonsWrapper = document.getElementById(randID + '_paginationBtns');
|
|
508
|
-
if (paginationButtonsWrapper == null) return false;
|
|
509
|
-
var numberPages = Math.ceil(totalRows / show);
|
|
510
|
-
|
|
511
|
-
if (numberPages == 1) {
|
|
512
|
-
// Remore the buttons or dont display any if we dont need them
|
|
513
|
-
paginationButtonsWrapper.innerHTML = '';
|
|
514
|
-
} else if (numberPages < 5) {
|
|
515
|
-
// If less than 5 pages (which fits comfortably on mobile) we display buttons
|
|
516
|
-
var strButtons = '';
|
|
517
|
-
|
|
518
|
-
for (var i = 1; i <= numberPages; i++) {
|
|
519
|
-
if (i == page) strButtons += "<li class=\"page-item active\" aria-current=\"page\"><span class=\"page-link\">".concat(i, "</span></li>");else strButtons += "<li class=\"page-item\"><button class=\"page-link\" data-page=\"".concat(i, "\">").concat(i, "</button></li>");
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
paginationButtonsWrapper.innerHTML = "<span class=\"pe-2 mb-3\">Page: </span><ul class=\"pagination mb-3\">\n ".concat(page == 1 ? "<li class=\"page-item disabled\"><span class=\"page-link\">Previous</span></li>" : "<li class=\"page-item\"><button class=\"page-link\" data-page=\"".concat(parseInt(page) - 1, "\">Previous</button></li>"), "\n ").concat(strButtons, "\n ").concat(page == numberPages ? "<li class=\"page-item disabled\"><span class=\"page-link\">Next</span></li>" : "<li class=\"page-item\"><button class=\"page-link\" data-page=\"".concat(parseInt(page) + 1, "\">Next</button></li>"), "\n </ul>");
|
|
523
|
-
} else {
|
|
524
|
-
// If more than 5 lets show a select field instead so that we dont have loads and loads of buttons
|
|
525
|
-
var strOptions = '';
|
|
526
|
-
|
|
527
|
-
for (var _i = 1; _i <= numberPages; _i++) {
|
|
528
|
-
if (_i == page) strOptions += "<option value=\"".concat(_i, "\" selected>Page ").concat(_i, "</option>");else strOptions += "<option value=\"".concat(_i, "\">Page ").concat(_i, "</option>");
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
paginationButtonsWrapper.innerHTML = "\n<div class=\"form-control__wrapper page-number mb-2\">\n<select class=\"form-select\">\n".concat(strOptions, "\n</select>\n</div>\n ");
|
|
532
|
-
}
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
function accordion(accordionElement) {
|
|
536
|
-
// Fetch all the details element.
|
|
537
|
-
if (!accordionElement.classList.contains('accordion--keep-open')) {
|
|
538
|
-
var details = accordionElement.querySelectorAll(":scope > details"); // Add the onclick listeners.
|
|
539
|
-
|
|
540
|
-
details.forEach(targetDetail => {
|
|
541
|
-
targetDetail.addEventListener("click", () => {
|
|
542
|
-
// Close all the details that are not targetDetail.
|
|
543
|
-
details.forEach(detail => {
|
|
544
|
-
if (detail !== targetDetail) {
|
|
545
|
-
detail.removeAttribute("open");
|
|
546
|
-
}
|
|
498
|
+
// @ts-nocheck
|
|
499
|
+
function accordion(accordionElement) {
|
|
500
|
+
// Fetch all the details element.
|
|
501
|
+
if (!accordionElement.classList.contains('accordion--keep-open')) {
|
|
502
|
+
var details = accordionElement.querySelectorAll(":scope > details");
|
|
503
|
+
// Add the onclick listeners.
|
|
504
|
+
details.forEach(targetDetail => {
|
|
505
|
+
targetDetail.addEventListener("click", () => {
|
|
506
|
+
// Close all the details that are not targetDetail.
|
|
507
|
+
details.forEach(detail => {
|
|
508
|
+
if (detail !== targetDetail) {
|
|
509
|
+
detail.removeAttribute("open");
|
|
510
|
+
}
|
|
511
|
+
});
|
|
547
512
|
});
|
|
548
513
|
});
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
if (window.location.hash && document.querySelector(window.location.hash + ':not([open]) summary')) {
|
|
553
|
-
var detail = document.querySelector(window.location.hash + ' summary');
|
|
554
|
-
|
|
555
|
-
if (detail instanceof HTMLElement) {
|
|
556
|
-
detail.click();
|
|
557
514
|
}
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
var _detail = document.querySelector(window.location.hash + ' summary');
|
|
563
|
-
|
|
564
|
-
if (_detail instanceof HTMLElement) {
|
|
565
|
-
_detail.click();
|
|
515
|
+
if (window.location.hash && document.querySelector(window.location.hash + ':not([open]) summary')) {
|
|
516
|
+
var detail = document.querySelector(window.location.hash + ' summary');
|
|
517
|
+
if (detail instanceof HTMLElement) {
|
|
518
|
+
detail.click();
|
|
566
519
|
}
|
|
567
520
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
if (itemCount == 1) {
|
|
577
|
-
return false;
|
|
521
|
+
window.addEventListener('hashchange', function () {
|
|
522
|
+
if (window.location.hash && document.querySelector(window.location.hash + ' summary')) {
|
|
523
|
+
var _detail = document.querySelector(window.location.hash + ' summary');
|
|
524
|
+
if (_detail instanceof HTMLElement) {
|
|
525
|
+
_detail.click();
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
});
|
|
578
529
|
}
|
|
579
530
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
var
|
|
584
|
-
var
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
setButtons(scrollTo);
|
|
605
|
-
}, 300);
|
|
606
|
-
}, false); // when the buttons are used we need to make sure the carousel scrolls to the correct place
|
|
607
|
-
|
|
608
|
-
testimonialElement.addEventListener('click', function (e) {
|
|
609
|
-
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
610
|
-
if (target.matches('[data-go]')) {
|
|
611
|
-
var scrollTo = parseInt(target.getAttribute('data-go'));
|
|
612
|
-
var scrollDown = 0;
|
|
613
|
-
var scrollLeft = 0;
|
|
531
|
+
// @ts-nocheck
|
|
532
|
+
function testimonial(testimonialElement) {
|
|
533
|
+
var scrollTimeout;
|
|
534
|
+
var imagesCarousel = testimonialElement.querySelector('.testimonial__images');
|
|
535
|
+
var itemCount = imagesCarousel.querySelectorAll('img').length;
|
|
536
|
+
// If we only have 1 item lets not bother doing anything else
|
|
537
|
+
if (itemCount == 1) {
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
testimonialElement.classList.add('testimonial--multi');
|
|
541
|
+
// Set where the buttons go to
|
|
542
|
+
var setButtons = function setButtons(scrollTo) {
|
|
543
|
+
var nextButton = testimonialElement.querySelector('.btn-next');
|
|
544
|
+
var prevButton = testimonialElement.querySelector('.btn-prev');
|
|
545
|
+
nextButton.setAttribute('data-go', scrollTo + 1);
|
|
546
|
+
prevButton.setAttribute('data-go', scrollTo - 1);
|
|
547
|
+
nextButton.removeAttribute('disabled');
|
|
548
|
+
prevButton.removeAttribute('disabled');
|
|
549
|
+
if (scrollTo == 1) prevButton.setAttribute('disabled', true);else if (scrollTo == itemCount) nextButton.setAttribute('disabled', true);
|
|
550
|
+
};
|
|
551
|
+
// On scroll we need to make sure the buttons get corrected and the next testimonial is shown
|
|
552
|
+
imagesCarousel.addEventListener('scroll', function (e) {
|
|
553
|
+
clearTimeout(scrollTimeout);
|
|
554
|
+
scrollTimeout = setTimeout(function () {
|
|
614
555
|
var scrollWidth = imagesCarousel.scrollWidth;
|
|
615
556
|
var scrollHeight = imagesCarousel.scrollHeight;
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
557
|
+
var scrollLeft = imagesCarousel.scrollLeft;
|
|
558
|
+
var scrollDown = imagesCarousel.scrollTop;
|
|
559
|
+
var scrollTo = Math.round(scrollLeft / scrollWidth * itemCount) + 1;
|
|
560
|
+
// Change in scroll direction
|
|
561
|
+
if (scrollLeft == 0 && scrollDown != 0) scrollTo = Math.round(scrollDown / scrollHeight * itemCount) + 1;
|
|
562
|
+
testimonialElement.setAttribute('data-show', scrollTo);
|
|
563
|
+
setButtons(scrollTo);
|
|
564
|
+
}, 300);
|
|
565
|
+
}, false);
|
|
566
|
+
// when the buttons are used we need to make sure the carousel scrolls to the correct place
|
|
567
|
+
testimonialElement.addEventListener('click', function (e) {
|
|
568
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
569
|
+
if (target.matches('[data-go]')) {
|
|
570
|
+
var scrollTo = parseInt(target.getAttribute('data-go'));
|
|
571
|
+
var scrollDown = 0;
|
|
572
|
+
var scrollLeft = 0;
|
|
573
|
+
var scrollWidth = imagesCarousel.scrollWidth;
|
|
574
|
+
var scrollHeight = imagesCarousel.scrollHeight;
|
|
575
|
+
if (scrollWidth > scrollHeight) scrollLeft = Math.floor(scrollWidth * ((scrollTo - 1) / itemCount));else scrollDown = Math.floor(scrollHeight * ((scrollTo - 1) / itemCount));
|
|
576
|
+
// Trigger the scroll
|
|
577
|
+
imagesCarousel.scroll({
|
|
578
|
+
top: scrollDown,
|
|
579
|
+
left: scrollLeft,
|
|
580
|
+
behavior: 'smooth'
|
|
581
|
+
});
|
|
582
|
+
break;
|
|
583
|
+
}
|
|
624
584
|
}
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
function carousel(carouselElement) {
|
|
630
|
-
var scrollTimeout;
|
|
631
|
-
var carouselInner = carouselElement.querySelector('.carousel__inner');
|
|
632
|
-
var itemCount = carouselElement.querySelectorAll('.carousel__item').length;
|
|
633
|
-
carouselElement.getAttribute('data-cols');
|
|
634
|
-
var smCols = carouselElement.getAttribute('data-sm-cols');
|
|
635
|
-
var mdCols = carouselElement.getAttribute('data-md-cols');
|
|
636
|
-
carouselElement.querySelector('.carousel__controls a').classList.add('active'); // On scroll we need to make sure the buttons get corrected and the next testimonial is shown
|
|
637
|
-
|
|
638
|
-
carouselInner.addEventListener('scroll', function (e) {
|
|
639
|
-
clearTimeout(scrollTimeout);
|
|
640
|
-
scrollTimeout = setTimeout(function () {
|
|
641
|
-
var scrollArea = carouselInner.clientWidth;
|
|
642
|
-
var scrollWidth = carouselInner.scrollWidth;
|
|
643
|
-
var scrollLeft = carouselInner.scrollLeft;
|
|
644
|
-
var targetSlide = Math.round(scrollLeft / scrollWidth * itemCount) + 1;
|
|
645
|
-
var lastItemOffset = carouselElement.querySelector('.carousel__item:last-child').offsetLeft;
|
|
646
|
-
Array.from(carouselElement.querySelectorAll('.carousel__controls a')).forEach((link, index) => {
|
|
647
|
-
link.classList.remove('active');
|
|
648
|
-
});
|
|
649
|
-
carouselElement.querySelector('.control-' + targetSlide).classList.add('active'); // Disable the previous button
|
|
650
|
-
|
|
651
|
-
if (targetSlide == 1) carouselElement.querySelector('.btn-prev').setAttribute('disabled', 'disabled');else carouselElement.querySelector('.btn-prev').removeAttribute('disabled'); // Disable the next button if the last item is in view
|
|
652
|
-
|
|
653
|
-
if (carouselInner.scrollLeft + scrollArea > lastItemOffset) carouselElement.querySelector('.btn-next').setAttribute('disabled', 'disabled');else carouselElement.querySelector('.btn-next').removeAttribute('disabled');
|
|
654
|
-
}, 100);
|
|
655
|
-
}, false); // when the buttons are used we need to make sure the carousel scrolls to the correct place
|
|
585
|
+
}, false);
|
|
586
|
+
}
|
|
656
587
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
588
|
+
// @ts-nocheck
|
|
589
|
+
function carousel(carouselElement) {
|
|
590
|
+
var scrollTimeout;
|
|
591
|
+
var carouselInner = carouselElement.querySelector('.carousel__inner');
|
|
592
|
+
var itemCount = carouselElement.querySelectorAll('.carousel__item').length;
|
|
593
|
+
carouselElement.getAttribute('data-cols');
|
|
594
|
+
var smCols = carouselElement.getAttribute('data-sm-cols');
|
|
595
|
+
var mdCols = carouselElement.getAttribute('data-md-cols');
|
|
596
|
+
carouselElement.querySelector('.carousel__controls a').classList.add('active');
|
|
597
|
+
// On scroll we need to make sure the buttons get corrected and the next testimonial is shown
|
|
598
|
+
carouselInner.addEventListener('scroll', function (e) {
|
|
599
|
+
clearTimeout(scrollTimeout);
|
|
600
|
+
scrollTimeout = setTimeout(function () {
|
|
601
|
+
var scrollArea = carouselInner.clientWidth;
|
|
602
|
+
var scrollWidth = carouselInner.scrollWidth;
|
|
603
|
+
var scrollLeft = carouselInner.scrollLeft;
|
|
604
|
+
var targetSlide = Math.round(scrollLeft / scrollWidth * itemCount) + 1;
|
|
605
|
+
var lastItemOffset = carouselElement.querySelector('.carousel__item:last-child').offsetLeft;
|
|
661
606
|
Array.from(carouselElement.querySelectorAll('.carousel__controls a')).forEach((link, index) => {
|
|
662
607
|
link.classList.remove('active');
|
|
663
608
|
});
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
609
|
+
carouselElement.querySelector('.control-' + targetSlide).classList.add('active');
|
|
610
|
+
// Disable the previous button
|
|
611
|
+
if (targetSlide == 1) carouselElement.querySelector('.btn-prev').setAttribute('disabled', 'disabled');else carouselElement.querySelector('.btn-prev').removeAttribute('disabled');
|
|
612
|
+
// Disable the next button if the last item is in view
|
|
613
|
+
if (carouselInner.scrollLeft + scrollArea > lastItemOffset) carouselElement.querySelector('.btn-next').setAttribute('disabled', 'disabled');else carouselElement.querySelector('.btn-next').removeAttribute('disabled');
|
|
614
|
+
}, 100);
|
|
615
|
+
}, false);
|
|
616
|
+
// when the buttons are used we need to make sure the carousel scrolls to the correct place
|
|
617
|
+
carouselElement.addEventListener('click', function (e) {
|
|
618
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
619
|
+
if (target.matches('.carousel__controls a')) {
|
|
620
|
+
e.preventDefault();
|
|
621
|
+
Array.from(carouselElement.querySelectorAll('.carousel__controls a')).forEach((link, index) => {
|
|
622
|
+
link.classList.remove('active');
|
|
623
|
+
});
|
|
624
|
+
target.classList.add('active');
|
|
625
|
+
var el = document.querySelector(target.getAttribute('href'));
|
|
626
|
+
carouselInner.scroll({
|
|
627
|
+
top: 0,
|
|
628
|
+
left: el.offsetLeft,
|
|
629
|
+
behavior: 'smooth'
|
|
630
|
+
});
|
|
631
|
+
break;
|
|
632
|
+
}
|
|
672
633
|
}
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
634
|
+
}, false);
|
|
635
|
+
carouselElement.addEventListener('click', function (e) {
|
|
636
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
637
|
+
if (target.matches('.btn-next, .btn-prev')) {
|
|
638
|
+
e.preventDefault();
|
|
639
|
+
var scrollTo = target.classList.contains('btn-prev') ? carouselInner.scrollLeft - carouselInner.clientWidth : carouselInner.scrollLeft + carouselInner.clientWidth;
|
|
640
|
+
carouselInner.scroll({
|
|
641
|
+
top: 0,
|
|
642
|
+
left: scrollTo,
|
|
643
|
+
behavior: 'smooth'
|
|
644
|
+
});
|
|
645
|
+
break;
|
|
646
|
+
}
|
|
686
647
|
}
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
// Create a link between two input/selects with one acting as setting a minimum value and the second a maximum
|
|
696
|
-
// The link between the two will prevent the max input field form setting a lower value than the min and vice versa
|
|
697
|
-
function inputRange(inputWrapper) {
|
|
698
|
-
inputWrapper.addEventListener('change', function (e) {
|
|
699
|
-
var min = parseInt(inputWrapper.querySelector('[data-min] select,[data-min] input').value);
|
|
700
|
-
var max = parseInt(inputWrapper.querySelector('[data-max] select,[data-max] input').value); // Set attributes for input fields
|
|
648
|
+
}, false);
|
|
649
|
+
// Add responsive hide button classes
|
|
650
|
+
if (itemCount == 1) carouselElement.classList.add('hide-btns');
|
|
651
|
+
if (smCols >= itemCount) carouselElement.classList.add('hide-sm-btns');
|
|
652
|
+
if (mdCols >= itemCount) carouselElement.classList.add('hide-md-btns');
|
|
653
|
+
}
|
|
701
654
|
|
|
702
|
-
|
|
703
|
-
|
|
655
|
+
// @ts-nocheck
|
|
656
|
+
// Create a link between two input/selects with one acting as setting a minimum value and the second a maximum
|
|
657
|
+
// The link between the two will prevent the max input field form setting a lower value than the min and vice versa
|
|
658
|
+
function inputRange(inputWrapper) {
|
|
659
|
+
inputWrapper.addEventListener('change', function (e) {
|
|
660
|
+
var min = parseInt(inputWrapper.querySelector('[data-min] select,[data-min] input').value);
|
|
661
|
+
var max = parseInt(inputWrapper.querySelector('[data-max] select,[data-max] input').value);
|
|
662
|
+
// Set attributes for input fields
|
|
663
|
+
Array.from(inputWrapper.querySelectorAll('[data-min] input')).forEach((input, index) => {
|
|
664
|
+
input.setAttribute('max', max);
|
|
665
|
+
});
|
|
666
|
+
Array.from(inputWrapper.querySelectorAll('[data-max] input')).forEach((input, index) => {
|
|
667
|
+
input.setAttribute('min', min);
|
|
668
|
+
});
|
|
669
|
+
// Hide select options if they are higher or lower than the min and max values
|
|
670
|
+
Array.from(inputWrapper.querySelectorAll('[data-min] select option')).forEach((option, index) => {
|
|
671
|
+
if (parseInt(option.getAttribute('value')) > max) option.classList.add('d-none');else option.classList.remove('d-none');
|
|
672
|
+
});
|
|
673
|
+
Array.from(inputWrapper.querySelectorAll('[data-max] select option')).forEach((option, index) => {
|
|
674
|
+
if (parseInt(option.getAttribute('value')) < min) option.classList.add('d-none');else option.classList.remove('d-none');
|
|
675
|
+
});
|
|
676
|
+
}, false);
|
|
677
|
+
}
|
|
678
|
+
function inputRedirect(inputWrapper) {
|
|
679
|
+
inputWrapper.addEventListener('change', function (e) {
|
|
680
|
+
if (inputWrapper.matches('[data-value-if]')) {
|
|
681
|
+
var url = inputWrapper.getAttribute('data-redirect');
|
|
682
|
+
var desiredValue = inputWrapper.getAttribute('data-value-if');
|
|
683
|
+
if (inputWrapper.value == desiredValue) document.location.href = url;
|
|
684
|
+
} else {
|
|
685
|
+
if (typeof inputWrapper.value != "undefined") document.location.href = inputWrapper.value;
|
|
686
|
+
}
|
|
687
|
+
}, false);
|
|
688
|
+
}
|
|
689
|
+
//
|
|
690
|
+
function multipleFileUploads(wrapper) {
|
|
691
|
+
var fileTenplate = wrapper.querySelector('.row');
|
|
692
|
+
var clone = fileTenplate.cloneNode(true);
|
|
693
|
+
var addButton = wrapper.querySelector('[data-add]');
|
|
694
|
+
wrapper.addEventListener('click', function (e) {
|
|
695
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
696
|
+
if (target.matches('[data-add]')) {
|
|
697
|
+
// Add a new row upload file input fields
|
|
698
|
+
var tempClone = clone.cloneNode(true);
|
|
699
|
+
wrapper.insertBefore(tempClone, target);
|
|
700
|
+
if (addButton.matches('[data-maxfiles]') && Array.from(wrapper.querySelectorAll(':scope > .row')).length >= addButton.dataset.maxfiles) addButton.setAttribute('disabled', 'disabled');
|
|
701
|
+
break;
|
|
702
|
+
}
|
|
703
|
+
if (target.matches('[data-delete]')) {
|
|
704
|
+
// Delete the current row
|
|
705
|
+
var row = target.closest('.row');
|
|
706
|
+
row.remove();
|
|
707
|
+
if (addButton.matches('[data-maxfiles]') && Array.from(wrapper.querySelectorAll(':scope > .row')).length < addButton.dataset.maxfiles) addButton.removeAttribute('disabled');
|
|
708
|
+
break;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}, false);
|
|
712
|
+
}
|
|
713
|
+
// Acts as an overall initialise function to trigger other functions.
|
|
714
|
+
function form(formElement) {
|
|
715
|
+
// Check for input range groups
|
|
716
|
+
Array.from(formElement.querySelectorAll('[data-input-range]')).forEach((arrayElement, index) => {
|
|
717
|
+
inputRange(arrayElement);
|
|
704
718
|
});
|
|
705
|
-
Array.from(
|
|
706
|
-
|
|
707
|
-
}); // Hide select options if they are higher or lower than the min and max values
|
|
708
|
-
|
|
709
|
-
Array.from(inputWrapper.querySelectorAll('[data-min] select option')).forEach((option, index) => {
|
|
710
|
-
if (parseInt(option.getAttribute('value')) > max) option.classList.add('d-none');else option.classList.remove('d-none');
|
|
719
|
+
Array.from(formElement.querySelectorAll('[data-redirect]')).forEach((arrayElement, index) => {
|
|
720
|
+
inputRedirect(arrayElement);
|
|
711
721
|
});
|
|
712
|
-
Array.from(
|
|
713
|
-
|
|
722
|
+
Array.from(formElement.querySelectorAll('.multiple-file-uploads')).forEach((arrayElement, index) => {
|
|
723
|
+
multipleFileUploads(arrayElement);
|
|
714
724
|
});
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
if (typeof inputWrapper.value != "undefined") document.location.href = inputWrapper.value;
|
|
726
|
-
}
|
|
727
|
-
}, false);
|
|
728
|
-
} //
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
function multipleFileUploads(wrapper) {
|
|
732
|
-
var fileTenplate = wrapper.querySelector('.row');
|
|
733
|
-
var clone = fileTenplate.cloneNode(true);
|
|
734
|
-
var addButton = wrapper.querySelector('[data-add]');
|
|
735
|
-
wrapper.addEventListener('click', function (e) {
|
|
736
|
-
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
737
|
-
if (target.matches('[data-add]')) {
|
|
738
|
-
// Add a new row upload file input fields
|
|
739
|
-
var tempClone = clone.cloneNode(true);
|
|
740
|
-
wrapper.insertBefore(tempClone, target);
|
|
741
|
-
if (addButton.matches('[data-maxfiles]') && Array.from(wrapper.querySelectorAll(':scope > .row')).length >= addButton.dataset.maxfiles) addButton.setAttribute('disabled', 'disabled');
|
|
742
|
-
break;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
if (target.matches('[data-delete]')) {
|
|
746
|
-
// Delete the current row
|
|
747
|
-
var row = target.closest('.row');
|
|
748
|
-
row.remove();
|
|
749
|
-
if (addButton.matches('[data-maxfiles]') && Array.from(wrapper.querySelectorAll(':scope > .row')).length < addButton.dataset.maxfiles) addButton.removeAttribute('disabled');
|
|
750
|
-
break;
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
}, false);
|
|
754
|
-
} // Acts as an overall initialise function to trigger other functions.
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
function form(formElement) {
|
|
758
|
-
// Check for input range groups
|
|
759
|
-
Array.from(formElement.querySelectorAll('[data-input-range]')).forEach((arrayElement, index) => {
|
|
760
|
-
inputRange(arrayElement);
|
|
761
|
-
});
|
|
762
|
-
Array.from(formElement.querySelectorAll('[data-redirect]')).forEach((arrayElement, index) => {
|
|
763
|
-
inputRedirect(arrayElement);
|
|
764
|
-
});
|
|
765
|
-
Array.from(formElement.querySelectorAll('.multiple-file-uploads')).forEach((arrayElement, index) => {
|
|
766
|
-
multipleFileUploads(arrayElement);
|
|
767
|
-
}); // Check the file size of a file when uploaded in case it exceeds the max file size set
|
|
768
|
-
|
|
769
|
-
formElement.addEventListener('change', function (e) {
|
|
770
|
-
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
771
|
-
if (target.matches('[type="file"][data-filesize]') && target.files && target.files[0]) {
|
|
772
|
-
var maxAllowedSize = target.dataset.filesize;
|
|
773
|
-
|
|
774
|
-
if (target.files[0].size > maxAllowedSize) {
|
|
775
|
-
target.value = '';
|
|
776
|
-
alert('File too large');
|
|
725
|
+
// Check the file size of a file when uploaded in case it exceeds the max file size set
|
|
726
|
+
formElement.addEventListener('change', function (e) {
|
|
727
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
728
|
+
if (target.matches('[type="file"][data-filesize]') && target.files && target.files[0]) {
|
|
729
|
+
var maxAllowedSize = target.dataset.filesize;
|
|
730
|
+
if (target.files[0].size > maxAllowedSize) {
|
|
731
|
+
target.value = '';
|
|
732
|
+
alert('File too large');
|
|
733
|
+
}
|
|
734
|
+
break;
|
|
777
735
|
}
|
|
778
|
-
|
|
779
|
-
break;
|
|
780
736
|
}
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
737
|
+
}, false);
|
|
738
|
+
// When a form is updated we may want to update some of the existing input fields; setting active fields when some data is selected.
|
|
739
|
+
formElement.addEventListener('change', function (e) {
|
|
740
|
+
// Remove disabled attribute when a pre-selected input field equals a certain value
|
|
741
|
+
Array.from(formElement.querySelectorAll('select[data-activeif][data-equals],input[data-activeif][data-equals]')).forEach((arrayElement, index) => {
|
|
742
|
+
var group = arrayElement.closest('[data-group]') ? arrayElement.closest('[data-group]') : formElement;
|
|
743
|
+
var selector = arrayElement.dataset.activeif;
|
|
744
|
+
var value = arrayElement.dataset.equals;
|
|
745
|
+
var testElement = group.querySelector("select[data-id=\"".concat(selector, "\"],input[data-id=\"").concat(selector, "\"]"));
|
|
746
|
+
if (testElement.value == value) {
|
|
747
|
+
arrayElement.removeAttribute('disabled');
|
|
748
|
+
} else {
|
|
749
|
+
arrayElement.setAttribute('disabled', 'disabled');
|
|
750
|
+
arrayElement.value = '';
|
|
751
|
+
}
|
|
752
|
+
});
|
|
753
|
+
// Show this input wrapper when a pre-selected input field equals a certain value
|
|
754
|
+
Array.from(formElement.querySelectorAll('.form-control__wrapper[data-displayif][data-equals]')).forEach((arrayElement, index) => {
|
|
755
|
+
var group = arrayElement.closest('[data-group]') ? arrayElement.closest('[data-group]') : formElement;
|
|
756
|
+
var selector = arrayElement.dataset.activeif;
|
|
757
|
+
var value = arrayElement.dataset.equals;
|
|
758
|
+
var testElement = group.querySelector("select[data-id=\"".concat(selector, "\"],input[data-id=\"").concat(selector, "\"]"));
|
|
759
|
+
if (testElement.value == value) arrayElement.classList.remove('d-none');else arrayElement.classList.add('d-none');
|
|
760
|
+
});
|
|
761
|
+
}, false);
|
|
762
|
+
}
|
|
791
763
|
|
|
792
|
-
|
|
793
|
-
|
|
764
|
+
// @ts-nocheck
|
|
765
|
+
/**
|
|
766
|
+
* Integrate YouTube videos as a way of hosting videos without the overhead and worry surrounding hosting vides. i.e. file sizes, performance and accessibility.
|
|
767
|
+
*/
|
|
768
|
+
class youtubeVideo {
|
|
769
|
+
/** @param {Element} embed dom element */
|
|
770
|
+
constructor(embed) {
|
|
771
|
+
var createEmbed = this.createEmbed;
|
|
772
|
+
// If the scripts is already loaded then lets just create the embed
|
|
773
|
+
if (document.body.classList.contains('youtubeLoaded')) {
|
|
774
|
+
embed.addEventListener('click', function (e) {
|
|
775
|
+
// loop parent nodes from the target to the delegation node
|
|
776
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
777
|
+
if (target.matches('a:not([data-modal-youtube]')) {
|
|
778
|
+
e.preventDefault();
|
|
779
|
+
createEmbed(embed, target);
|
|
780
|
+
break;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}, false);
|
|
794
784
|
} else {
|
|
795
|
-
|
|
796
|
-
arrayElement.value = '';
|
|
785
|
+
this.loadScripts(embed, this.createEmbed);
|
|
797
786
|
}
|
|
798
|
-
}); // Show this input wrapper when a pre-selected input field equals a certain value
|
|
799
|
-
|
|
800
|
-
Array.from(formElement.querySelectorAll('.form-control__wrapper[data-displayif][data-equals]')).forEach((arrayElement, index) => {
|
|
801
|
-
var group = arrayElement.closest('[data-group]') ? arrayElement.closest('[data-group]') : formElement;
|
|
802
|
-
var selector = arrayElement.dataset.activeif;
|
|
803
|
-
var value = arrayElement.dataset.equals;
|
|
804
|
-
var testElement = group.querySelector("select[data-id=\"".concat(selector, "\"],input[data-id=\"").concat(selector, "\"]"));
|
|
805
|
-
if (testElement.value == value) arrayElement.classList.remove('d-none');else arrayElement.classList.add('d-none');
|
|
806
|
-
});
|
|
807
|
-
}, false);
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
/**
|
|
811
|
-
* Integrate YouTube videos as a way of hosting videos without the overhead and worry surrounding hosting vides. i.e. file sizes, performance and accessibility.
|
|
812
|
-
*/
|
|
813
|
-
class youtubeVideo {
|
|
814
|
-
/** @param {Element} embed dom element */
|
|
815
|
-
constructor(embed) {
|
|
816
|
-
var createEmbed = this.createEmbed; // If the scripts is already loaded then lets just create the embed
|
|
817
|
-
|
|
818
|
-
if (document.body.classList.contains('youtubeLoaded')) {
|
|
819
|
-
embed.addEventListener('click', function (e) {
|
|
820
|
-
// loop parent nodes from the target to the delegation node
|
|
821
|
-
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
822
|
-
if (target.matches('a:not([data-modal-youtube]')) {
|
|
823
|
-
e.preventDefault();
|
|
824
|
-
createEmbed(embed, target);
|
|
825
|
-
break;
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
}, false);
|
|
829
|
-
} else {
|
|
830
|
-
this.loadScripts(embed, this.createEmbed);
|
|
831
787
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
e.preventDefault();
|
|
859
|
-
createEmbed(embed, target);
|
|
860
|
-
break;
|
|
788
|
+
/**
|
|
789
|
+
* Load the YouTube scripts before trying to create the embed
|
|
790
|
+
* @param {HTMLElement} embed dom element
|
|
791
|
+
* @param {Function} createEmbed function to create the embed after script loaded.
|
|
792
|
+
*/
|
|
793
|
+
loadScripts(embed, createEmbed) {
|
|
794
|
+
return new Promise((resolve, reject) => {
|
|
795
|
+
var image = new Image();
|
|
796
|
+
image.onload = function () {
|
|
797
|
+
// This code loads the IFrame Player API code asynchronously.
|
|
798
|
+
var tag = document.createElement('script');
|
|
799
|
+
tag.src = "https://www.youtube.com/iframe_api";
|
|
800
|
+
var firstScriptTag = document.getElementsByTagName('script')[0];
|
|
801
|
+
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
|
|
802
|
+
document.body.classList.add('youtubeLoaded');
|
|
803
|
+
resolve(true);
|
|
804
|
+
// script has loaded, you can now use it safely
|
|
805
|
+
tag.onload = () => {
|
|
806
|
+
embed.addEventListener('click', function (e) {
|
|
807
|
+
// loop parent nodes from the target to the delegation node
|
|
808
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
809
|
+
if (target.matches('a:not([data-modal-youtube]')) {
|
|
810
|
+
e.preventDefault();
|
|
811
|
+
createEmbed(embed, target);
|
|
812
|
+
break;
|
|
813
|
+
}
|
|
861
814
|
}
|
|
862
|
-
}
|
|
863
|
-
}
|
|
815
|
+
}, false);
|
|
816
|
+
};
|
|
864
817
|
};
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
};
|
|
870
|
-
|
|
871
|
-
image.src = "https://youtube.com/favicon.ico";
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
|
-
/**
|
|
875
|
-
* Create the YouTube embed after the user has clicked on it.
|
|
876
|
-
* @param {HTMLElement} embed dom element
|
|
877
|
-
*/
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
createEmbed(embed, target) {
|
|
881
|
-
// If there is more than one video lets make sure there is only one playing at a time.
|
|
882
|
-
if (typeof window.player != "undefined" && typeof window.player.pauseVideo == "function") window.player.pauseVideo();
|
|
883
|
-
var video_id = target.getAttribute('data-id');
|
|
884
|
-
var link_id = target.getAttribute('id'); // create an id to pass t the script if one isn't present
|
|
885
|
-
|
|
886
|
-
if (typeof link_id == 'undefined' || link_id == null) {
|
|
887
|
-
var randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26));
|
|
888
|
-
link_id = randLetter + Date.now();
|
|
889
|
-
target.setAttribute('id', link_id);
|
|
890
|
-
} // This function creates an <iframe> (and YouTube player) after the API code downloads.
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
function onYouTubeIframeAPIReady() {
|
|
894
|
-
window.player = new YT.Player(link_id, {
|
|
895
|
-
height: '100%',
|
|
896
|
-
width: '100%',
|
|
897
|
-
videoId: video_id,
|
|
898
|
-
playerVars: {
|
|
899
|
-
'modestbranding': 1,
|
|
900
|
-
'playsinline': 1,
|
|
901
|
-
'rel': 0,
|
|
902
|
-
'showinfo': 0
|
|
903
|
-
},
|
|
904
|
-
events: {
|
|
905
|
-
'onReady': onPlayerReady,
|
|
906
|
-
'onStateChange': onPlayerStateChange
|
|
907
|
-
}
|
|
818
|
+
image.onerror = function () {
|
|
819
|
+
reject(false);
|
|
820
|
+
};
|
|
821
|
+
image.src = "https://youtube.com/favicon.ico";
|
|
908
822
|
});
|
|
909
823
|
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
824
|
+
/**
|
|
825
|
+
* Create the YouTube embed after the user has clicked on it.
|
|
826
|
+
* @param {HTMLElement} embed dom element
|
|
827
|
+
*/
|
|
828
|
+
createEmbed(embed, target) {
|
|
829
|
+
// If there is more than one video lets make sure there is only one playing at a time.
|
|
830
|
+
if (typeof window.player != "undefined" && typeof window.player.pauseVideo == "function") window.player.pauseVideo();
|
|
831
|
+
var video_id = target.getAttribute('data-id');
|
|
832
|
+
var link_id = target.getAttribute('id');
|
|
833
|
+
// create an id to pass t the script if one isn't present
|
|
834
|
+
if (typeof link_id == 'undefined' || link_id == null) {
|
|
835
|
+
var randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26));
|
|
836
|
+
link_id = randLetter + Date.now();
|
|
837
|
+
target.setAttribute('id', link_id);
|
|
838
|
+
}
|
|
839
|
+
// This function creates an <iframe> (and YouTube player) after the API code downloads.
|
|
840
|
+
function onYouTubeIframeAPIReady() {
|
|
841
|
+
window.player = new YT.Player(link_id, {
|
|
842
|
+
height: '100%',
|
|
843
|
+
width: '100%',
|
|
844
|
+
videoId: video_id,
|
|
845
|
+
playerVars: {
|
|
846
|
+
'modestbranding': 1,
|
|
847
|
+
'playsinline': 1,
|
|
848
|
+
'rel': 0,
|
|
849
|
+
'showinfo': 0
|
|
850
|
+
},
|
|
851
|
+
events: {
|
|
852
|
+
'onReady': onPlayerReady,
|
|
853
|
+
'onStateChange': onPlayerStateChange
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
onYouTubeIframeAPIReady();
|
|
858
|
+
// The API will call this function when the video player is ready.
|
|
859
|
+
function onPlayerReady(event) {
|
|
860
|
+
// Play the video straight away
|
|
861
|
+
event.target.playVideo();
|
|
862
|
+
}
|
|
863
|
+
// The API calls this function when the player's state changes.
|
|
864
|
+
// The function indicates that when playing a video (state=1)
|
|
865
|
+
var done = false;
|
|
866
|
+
function onPlayerStateChange(event) {
|
|
867
|
+
if (event.data == YT.PlayerState.PLAYING && !done) {
|
|
868
|
+
var link = document.getElementById(link_id);
|
|
869
|
+
link.classList.add('player-ready');
|
|
870
|
+
done = true;
|
|
871
|
+
}
|
|
927
872
|
}
|
|
928
873
|
}
|
|
929
874
|
}
|
|
930
875
|
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
element.addEventListener('keydown', function (e) {
|
|
950
|
-
if (e.key === "Tab" && e.shiftKey && document.activeElement == firstLink) {
|
|
951
|
-
e.preventDefault();
|
|
952
|
-
lastLink.focus();
|
|
953
|
-
} else if (e.key === "Tab" && !e.shiftKey && document.activeElement == lastLink) {
|
|
954
|
-
e.preventDefault();
|
|
955
|
-
firstLink.focus();
|
|
956
|
-
}
|
|
957
|
-
}); // ESC will close the open modal
|
|
958
|
-
|
|
959
|
-
document.addEventListener("keydown", function (e) {
|
|
960
|
-
if (e.key === "Escape" && document.querySelector('.modal:target')) closeModal();
|
|
961
|
-
});
|
|
962
|
-
element.addEventListener('click', function (e) {
|
|
963
|
-
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
964
|
-
// Close links will close the model by default but we want to remove the hash link also
|
|
965
|
-
if (target.matches('[href="#close"]')) {
|
|
966
|
-
e.preventDefault();
|
|
967
|
-
closeModal();
|
|
968
|
-
break;
|
|
969
|
-
} // Dock the modal to the right or left to make the content behind readable
|
|
970
|
-
else if (target.matches('.modal__dock--right')) {
|
|
876
|
+
// @ts-nocheck
|
|
877
|
+
var modal = element => {
|
|
878
|
+
var links = element.querySelectorAll('.modal__outer a, .modal__outer button');
|
|
879
|
+
var firstLink = links[0];
|
|
880
|
+
var lastLink = links[links.length - 1];
|
|
881
|
+
var modalID = element.getAttribute('id');
|
|
882
|
+
var closeModal = function closeModal() {
|
|
883
|
+
var button = document.querySelector('[href="' + window.location.hash + '"]');
|
|
884
|
+
button.focus();
|
|
885
|
+
window.location.hash = "close";
|
|
886
|
+
history.replaceState("", document.title, window.location.pathname + window.location.search);
|
|
887
|
+
// If there is more than one video lets make sure there is only one playing at a time.
|
|
888
|
+
if (typeof window.player != "undefined" && typeof window.player.pauseVideo == "function") window.player.pauseVideo();
|
|
889
|
+
};
|
|
890
|
+
// Trap the tab focus inside
|
|
891
|
+
element.addEventListener('keydown', function (e) {
|
|
892
|
+
if (e.key === "Tab" && e.shiftKey && document.activeElement == firstLink) {
|
|
971
893
|
e.preventDefault();
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
break;
|
|
975
|
-
} else if (target.matches('.modal__dock--left')) {
|
|
894
|
+
lastLink.focus();
|
|
895
|
+
} else if (e.key === "Tab" && !e.shiftKey && document.activeElement == lastLink) {
|
|
976
896
|
e.preventDefault();
|
|
977
|
-
|
|
978
|
-
element.classList.remove('modal--right');
|
|
979
|
-
break;
|
|
897
|
+
firstLink.focus();
|
|
980
898
|
}
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
var
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
899
|
+
});
|
|
900
|
+
// ESC will close the open modal
|
|
901
|
+
document.addEventListener("keydown", function (e) {
|
|
902
|
+
if (e.key === "Escape" && document.querySelector('.modal:target')) closeModal();
|
|
903
|
+
});
|
|
904
|
+
element.addEventListener('click', function (e) {
|
|
905
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
906
|
+
// Close links will close the model by default but we want to remove the hash link also
|
|
907
|
+
if (target.matches('[href="#close"]')) {
|
|
908
|
+
e.preventDefault();
|
|
909
|
+
closeModal();
|
|
910
|
+
break;
|
|
911
|
+
}
|
|
912
|
+
// Dock the modal to the right or left to make the content behind readable
|
|
913
|
+
else if (target.matches('.modal__dock--right')) {
|
|
914
|
+
e.preventDefault();
|
|
915
|
+
if (!element.classList.contains('modal--left')) element.classList.add('modal--right');
|
|
916
|
+
element.classList.remove('modal--left');
|
|
917
|
+
break;
|
|
918
|
+
} else if (target.matches('.modal__dock--left')) {
|
|
919
|
+
e.preventDefault();
|
|
920
|
+
if (!element.classList.contains('modal--right')) element.classList.add('modal--left');
|
|
921
|
+
element.classList.remove('modal--right');
|
|
922
|
+
break;
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
function locationHashChanged() {
|
|
927
|
+
if (location.hash === '#' + modalID) {
|
|
928
|
+
console.log("Modal is now open");
|
|
929
|
+
var videoButton = document.querySelector('.modal:target .modal__inner > .youtube-embed:first-child:last-child a');
|
|
930
|
+
console.log(videoButton);
|
|
931
|
+
if (videoButton) {
|
|
932
|
+
videoButton.click();
|
|
933
|
+
}
|
|
992
934
|
}
|
|
993
935
|
}
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
window.onhashchange = locationHashChanged;
|
|
997
|
-
};
|
|
936
|
+
window.onhashchange = locationHashChanged;
|
|
937
|
+
};
|
|
998
938
|
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
addBodyClasses(document.body);
|
|
1003
|
-
addGlobalEvents();
|
|
1004
|
-
checkElements(document.body);
|
|
1005
|
-
console.log('test.js');
|
|
1006
|
-
// ANav
|
|
1007
|
-
Array.from(document.querySelectorAll('.nav')).forEach(
|
|
1008
|
-
|
|
1009
|
-
});
|
|
1010
|
-
// Advanced tables
|
|
1011
|
-
Array.from(document.querySelectorAll('.table__wrapper')).forEach(
|
|
1012
|
-
|
|
1013
|
-
});
|
|
1014
|
-
// Accordions
|
|
1015
|
-
Array.from(document.querySelectorAll('.accordion')).forEach(
|
|
1016
|
-
|
|
1017
|
-
});
|
|
1018
|
-
// Testimonial
|
|
1019
|
-
Array.from(document.querySelectorAll('.testimonial')).forEach(
|
|
1020
|
-
|
|
1021
|
-
});
|
|
1022
|
-
// Carousel
|
|
1023
|
-
Array.from(document.querySelectorAll('.carousel')).forEach(
|
|
1024
|
-
|
|
1025
|
-
});
|
|
1026
|
-
// Form
|
|
1027
|
-
Array.from(document.querySelectorAll('form')).forEach(
|
|
1028
|
-
|
|
1029
|
-
});
|
|
1030
|
-
// Modal
|
|
1031
|
-
Array.from(document.querySelectorAll('.modal')).forEach(
|
|
1032
|
-
|
|
1033
|
-
});
|
|
1034
|
-
// YouTube videos
|
|
1035
|
-
Array.from(document.querySelectorAll('.youtube-embed')).forEach(
|
|
1036
|
-
|
|
1037
|
-
});
|
|
1038
|
-
window.addEventListener('hashchange', function () {
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
}, false);
|
|
1045
|
-
|
|
939
|
+
// @ts-nocheck
|
|
940
|
+
// Attach classes to dom elements
|
|
941
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
942
|
+
addBodyClasses(document.body);
|
|
943
|
+
addGlobalEvents();
|
|
944
|
+
checkElements(document.body);
|
|
945
|
+
console.log('test.js');
|
|
946
|
+
// ANav
|
|
947
|
+
Array.from(document.querySelectorAll('.nav')).forEach(arrayElement => {
|
|
948
|
+
navbar(arrayElement);
|
|
949
|
+
});
|
|
950
|
+
// Advanced tables
|
|
951
|
+
Array.from(document.querySelectorAll('.table__wrapper')).forEach(arrayElement => {
|
|
952
|
+
table(arrayElement);
|
|
953
|
+
});
|
|
954
|
+
// Accordions
|
|
955
|
+
Array.from(document.querySelectorAll('.accordion')).forEach(arrayElement => {
|
|
956
|
+
accordion(arrayElement);
|
|
957
|
+
});
|
|
958
|
+
// Testimonial
|
|
959
|
+
Array.from(document.querySelectorAll('.testimonial')).forEach(arrayElement => {
|
|
960
|
+
testimonial(arrayElement);
|
|
961
|
+
});
|
|
962
|
+
// Carousel
|
|
963
|
+
Array.from(document.querySelectorAll('.carousel')).forEach(arrayElement => {
|
|
964
|
+
carousel(arrayElement);
|
|
965
|
+
});
|
|
966
|
+
// Form
|
|
967
|
+
Array.from(document.querySelectorAll('form')).forEach(arrayElement => {
|
|
968
|
+
form(arrayElement);
|
|
969
|
+
});
|
|
970
|
+
// Modal
|
|
971
|
+
Array.from(document.querySelectorAll('.modal')).forEach(arrayElement => {
|
|
972
|
+
modal(arrayElement);
|
|
973
|
+
});
|
|
974
|
+
// YouTube videos
|
|
975
|
+
Array.from(document.querySelectorAll('.youtube-embed')).forEach(arrayElement => {
|
|
976
|
+
new youtubeVideo(arrayElement);
|
|
977
|
+
});
|
|
978
|
+
window.addEventListener('hashchange', function () {
|
|
979
|
+
var hash = location.hash.replace('#', '');
|
|
980
|
+
var label = document.querySelector("label[for=\"".concat(hash, "\"]"));
|
|
981
|
+
if (label instanceof HTMLElement) {
|
|
982
|
+
label.click();
|
|
983
|
+
}
|
|
984
|
+
}, false);
|
|
985
|
+
});
|
|
1046
986
|
|
|
1047
987
|
}));
|
|
1048
988
|
//# sourceMappingURL=scripts.bundle.js.map
|