@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
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { ucfirst, unsnake } from './helpers'
|
|
3
|
+
|
|
4
|
+
function chart(chartElement,min,max,type) {
|
|
5
|
+
|
|
6
|
+
let chartKey = chartElement.querySelector('.chart__key');
|
|
7
|
+
let chartYaxis = chartElement.querySelector('.chart__yaxis');
|
|
8
|
+
let chartGuidelines = chartElement.querySelector('.chart__guidelines');
|
|
9
|
+
|
|
10
|
+
// Chart key
|
|
11
|
+
if(chartKey && chartKey.childElementCount == 0){
|
|
12
|
+
createChartKey(chartElement);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Y Axis and Guidelines
|
|
16
|
+
if(chartYaxis && chartYaxis.childElementCount == 0){
|
|
17
|
+
createChartYaxis(chartElement);
|
|
18
|
+
}
|
|
19
|
+
if(chartGuidelines && chartGuidelines.childElementCount == 0){
|
|
20
|
+
createChartGuidelines(chartElement);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Create lines for line graph
|
|
24
|
+
if(type == "line")
|
|
25
|
+
createLines(chartElement,min,max);
|
|
26
|
+
|
|
27
|
+
// Create pies
|
|
28
|
+
if(type == "pie")
|
|
29
|
+
createPies(chartElement);
|
|
30
|
+
|
|
31
|
+
// Add css vars to cells
|
|
32
|
+
Array.from(chartElement.querySelectorAll('tbody tr')).forEach((tr, index) => {
|
|
33
|
+
|
|
34
|
+
let group = tr.querySelector('td:first-child, th:first-child') ? tr.querySelector('td:first-child, th:first-child').innerHTML : '';
|
|
35
|
+
|
|
36
|
+
Array.from(tr.querySelectorAll('td[data-numeric]:not([data-numeric="0"]):not(:first-child)')).forEach((td, index) => {
|
|
37
|
+
|
|
38
|
+
const value = Number.parseFloat(td.getAttribute('data-numeric'));
|
|
39
|
+
let percent = ((value - min)/(max)) * 100;
|
|
40
|
+
const content = td.innerHTML;
|
|
41
|
+
const label = td.getAttribute('data-label');
|
|
42
|
+
let bottom = 0;
|
|
43
|
+
|
|
44
|
+
// If the value is negative the position below the 0 line
|
|
45
|
+
if(min < 0){
|
|
46
|
+
bottom = Math.abs((min)/(max)*100);
|
|
47
|
+
if(value < 0){
|
|
48
|
+
bottom = bottom - percent;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
td.setAttribute("style",`--bottom:${bottom}%;--percent:${percent}%;`);
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
td.innerHTML = `<span data-group="${group}" data-label="${label}">${content}</span>`;
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const createChartKey = function(chartElement){
|
|
60
|
+
|
|
61
|
+
let chartKey = chartElement.querySelector('.chart__key');
|
|
62
|
+
|
|
63
|
+
Array.from(chartElement.querySelectorAll('thead th')).forEach((arrayElement, index) => {
|
|
64
|
+
|
|
65
|
+
chartKey.innerHTML += `<div class="key">${arrayElement.innerText}</div>`;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const createChartGuidelines = function(chartElement){
|
|
70
|
+
|
|
71
|
+
let chartGuidelines = chartElement.querySelector('.chart__guidelines');
|
|
72
|
+
const max = chartElement.getAttribute('data-max');
|
|
73
|
+
const min = chartElement.getAttribute('data-min');
|
|
74
|
+
|
|
75
|
+
chartGuidelines.innerHTML += `<div style="--value: 0;--percent:0%;" class="axis__point"><span>0</span></div>`;
|
|
76
|
+
chartGuidelines.innerHTML += `<div style="--value: ${max};--percent:100%;" class="axis__point"><span>${max}</span></div>`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const createChartYaxis = function(chartElement){
|
|
80
|
+
|
|
81
|
+
let chartYaxis = chartElement.querySelector('.chart__yaxis');
|
|
82
|
+
const max = chartElement.getAttribute('data-max');
|
|
83
|
+
const min = chartElement.getAttribute('data-min');
|
|
84
|
+
|
|
85
|
+
chartYaxis.innerHTML += `<div style="--value: 0;--percent:0%;" class="axis__point"><span>0</span></div>`;
|
|
86
|
+
chartYaxis.innerHTML += `<div style="--value: ${max};--percent:100%;" class="axis__point"><span>${max}</span></div>`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function getCoordinatesForPercent(percent) {
|
|
90
|
+
const x = Math.cos(2 * Math.PI * percent);
|
|
91
|
+
const y = Math.sin(2 * Math.PI * percent);
|
|
92
|
+
return [x*100, y*100];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const createPies = function(chartElement){
|
|
96
|
+
|
|
97
|
+
let returnString = '';
|
|
98
|
+
let pieWrapper = chartElement.querySelector('.pies');
|
|
99
|
+
|
|
100
|
+
Array.from(chartElement.querySelectorAll('tbody tr')).forEach((item, index) => {
|
|
101
|
+
|
|
102
|
+
let paths = '';
|
|
103
|
+
let tooltips = '';
|
|
104
|
+
|
|
105
|
+
let cumulativePercent = 0;
|
|
106
|
+
|
|
107
|
+
let total = 0;
|
|
108
|
+
|
|
109
|
+
let titleKey = item.querySelectorAll('td')[0]
|
|
110
|
+
let title = titleKey.innerHTML;
|
|
111
|
+
|
|
112
|
+
Array.from(item.querySelectorAll('td')).forEach((cell, subindex) => {
|
|
113
|
+
|
|
114
|
+
if(subindex != 0){
|
|
115
|
+
|
|
116
|
+
let value = cell.getAttribute('data-numeric');
|
|
117
|
+
|
|
118
|
+
value = value.replace('£','');
|
|
119
|
+
value = value.replace('%','');
|
|
120
|
+
value = Number.parseInt(value);
|
|
121
|
+
|
|
122
|
+
total += value;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
Array.from(item.querySelectorAll('td')).forEach((cell, subindex) => {
|
|
127
|
+
|
|
128
|
+
if(subindex != 0){
|
|
129
|
+
|
|
130
|
+
let value = cell.getAttribute('data-numeric');
|
|
131
|
+
|
|
132
|
+
value = value.replace('£','');
|
|
133
|
+
value = value.replace('%','');
|
|
134
|
+
value = Number.parseInt(value);
|
|
135
|
+
|
|
136
|
+
let percent = value/total;
|
|
137
|
+
|
|
138
|
+
//lines[subindex-1] += `${command} ${spacer * index} ${100-percent} `;
|
|
139
|
+
const [startX, startY] = getCoordinatesForPercent(cumulativePercent);
|
|
140
|
+
|
|
141
|
+
// each slice starts where the last slice ended, so keep a cumulative percent
|
|
142
|
+
cumulativePercent += percent;
|
|
143
|
+
|
|
144
|
+
const [endX, endY] = getCoordinatesForPercent(cumulativePercent);
|
|
145
|
+
|
|
146
|
+
// if the slice is more than 50%, take the large arc (the long way around)
|
|
147
|
+
const largeArcFlag = percent > .5 ? 1 : 0;
|
|
148
|
+
|
|
149
|
+
// create an array and join it just for code readability
|
|
150
|
+
const pathData = [
|
|
151
|
+
`M ${startX} ${startY}`, // Move
|
|
152
|
+
`A 100 100 0 ${largeArcFlag} 1 ${endX} ${endY}`, // Arc
|
|
153
|
+
`L 0 0`, // Line
|
|
154
|
+
].join(' ');
|
|
155
|
+
|
|
156
|
+
paths += `<path d="${pathData}"></path>`;
|
|
157
|
+
tooltips += `<foreignObject x="-70" y="-70" width="140" height="140" style="transform: rotate(90deg)"><div><span class="h5 mb-0"><span class="total d-block">${ucfirst(unsnake(title))}</span> ${ucfirst(unsnake(cell.getAttribute('data-label')))}<br/> ${cell.innerHTML}</span></div></foreignObject>`;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
returnString += `<div class="pie"><svg viewBox="-105 -105 210 210" style="transform: rotate(-90deg)" preserveAspectRatio="none">${paths}<foreignObject x="-70" y="-70" width="140" height="140" style="transform: rotate(90deg)"><div><span class="h5 mb-0">${title}</span></div></foreignObject>${tooltips}</svg></div>`
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
pieWrapper.innerHTML = returnString;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export const createLines = function(chartElement,min,max){
|
|
168
|
+
|
|
169
|
+
let returnString = '';
|
|
170
|
+
let linesWrapper = chartElement.querySelector('.lines');
|
|
171
|
+
|
|
172
|
+
let items = Array.from(chartElement.querySelectorAll('tbody tr'));
|
|
173
|
+
|
|
174
|
+
let lines = Array();
|
|
175
|
+
let spacer = 200/(items.length - 1);
|
|
176
|
+
|
|
177
|
+
// Creates the lines array from the fields array
|
|
178
|
+
Array.from(chartElement.querySelectorAll('thead th')).forEach((field, index) => {
|
|
179
|
+
|
|
180
|
+
if(index != 0){
|
|
181
|
+
|
|
182
|
+
lines[index-1] = '';
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// populate the lines array from the items array
|
|
187
|
+
Array.from(chartElement.querySelectorAll('tbody tr')).forEach((item, index) => {
|
|
188
|
+
|
|
189
|
+
Array.from(item.querySelectorAll('td')).forEach((cell, subindex) => {
|
|
190
|
+
|
|
191
|
+
if(subindex != 0){
|
|
192
|
+
|
|
193
|
+
let value = cell.getAttribute('data-numeric');
|
|
194
|
+
|
|
195
|
+
value = value.replace('£','');
|
|
196
|
+
value = value.replace('%','');
|
|
197
|
+
value = Number.parseFloat(value) - min;
|
|
198
|
+
|
|
199
|
+
const percent = (value/max) * 100;
|
|
200
|
+
|
|
201
|
+
let command = index == 0 ? 'M' : 'L';
|
|
202
|
+
|
|
203
|
+
lines[subindex-1] += `${command} ${spacer * index} ${100-percent} `;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
lines.forEach((line, index) => {
|
|
209
|
+
|
|
210
|
+
returnString += `
|
|
211
|
+
<svg viewBox="0 0 200 100" class="line" preserveAspectRatio="none">
|
|
212
|
+
<path fill="none" d="${line}"></path>
|
|
213
|
+
</svg>`
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
linesWrapper.innerHTML = returnString;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export default chart
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
const drawer = (element) => {
|
|
3
|
+
|
|
4
|
+
const observer = new IntersectionObserver(
|
|
5
|
+
|
|
6
|
+
function([e]){
|
|
7
|
+
e.target.classList.toggle("in-view", e.intersectionRatio > 0)
|
|
8
|
+
document.getElementById('showDrawer').checked = false
|
|
9
|
+
},
|
|
10
|
+
{ threshold: [1] }
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const el = document.getElementById('drawer-end')
|
|
14
|
+
observer.observe(el);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default drawer
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
function fileupload(form, callback) {
|
|
3
|
+
|
|
4
|
+
const input = form.querySelector('[type="file"]');
|
|
5
|
+
const label = form.querySelector(`[for="${input.getAttribute('id')}"]`);
|
|
6
|
+
const add = form.querySelector('.file-upload__add');
|
|
7
|
+
|
|
8
|
+
form.querySelector('button').remove()
|
|
9
|
+
|
|
10
|
+
input.addEventListener("change", function( e ) {
|
|
11
|
+
// prevent default to allow drop
|
|
12
|
+
|
|
13
|
+
let url = form.getAttribute('action');
|
|
14
|
+
let formData = new FormData(form);
|
|
15
|
+
|
|
16
|
+
input.setAttribute('disabled', 'disabled');
|
|
17
|
+
|
|
18
|
+
fetch(url, {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
body: formData
|
|
21
|
+
})
|
|
22
|
+
.then(() => {
|
|
23
|
+
|
|
24
|
+
form.classList.add('file-uploaded')
|
|
25
|
+
label.innerHTML = 'File uploaded';
|
|
26
|
+
|
|
27
|
+
if(typeof callback == "function")
|
|
28
|
+
callback();
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
}, false);
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
form.addEventListener("submit", function( e ) {
|
|
36
|
+
// prevent default to allow drop
|
|
37
|
+
e.preventDefault();
|
|
38
|
+
}, false);
|
|
39
|
+
|
|
40
|
+
add.addEventListener("click", function( e ) {
|
|
41
|
+
|
|
42
|
+
form.classList.remove('file-uploaded')
|
|
43
|
+
label.innerHTML = 'Select a file to upload';
|
|
44
|
+
input.removeAttribute('disabled');
|
|
45
|
+
|
|
46
|
+
}, false);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default fileupload;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Create a link between two input/selects with one acting as setting a minimum value and the second a maximum
|
|
3
|
+
// The link between the two will prevent the max input field form setting a lower value than the min and vice versa
|
|
4
|
+
function inputRange(inputWrapper){
|
|
5
|
+
|
|
6
|
+
inputWrapper.addEventListener('change', function(e){
|
|
7
|
+
|
|
8
|
+
var min = parseInt(inputWrapper.querySelector('[data-min] select,[data-min] input').value);
|
|
9
|
+
var max = parseInt(inputWrapper.querySelector('[data-max] select,[data-max] input').value);
|
|
10
|
+
|
|
11
|
+
// Set attributes for input fields
|
|
12
|
+
Array.from(inputWrapper.querySelectorAll('[data-min] input')).forEach((input, index) => {
|
|
13
|
+
|
|
14
|
+
input.setAttribute('max',max);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
Array.from(inputWrapper.querySelectorAll('[data-max] input')).forEach((input, index) => {
|
|
18
|
+
|
|
19
|
+
input.setAttribute('min',min);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Hide select options if they are higher or lower than the min and max values
|
|
23
|
+
Array.from(inputWrapper.querySelectorAll('[data-min] select option')).forEach((option, index) => {
|
|
24
|
+
|
|
25
|
+
if(parseInt(option.getAttribute('value')) > max)
|
|
26
|
+
option.classList.add('d-none');
|
|
27
|
+
else
|
|
28
|
+
option.classList.remove('d-none');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
Array.from(inputWrapper.querySelectorAll('[data-max] select option')).forEach((option, index) => {
|
|
32
|
+
|
|
33
|
+
if(parseInt(option.getAttribute('value')) < min)
|
|
34
|
+
option.classList.add('d-none');
|
|
35
|
+
else
|
|
36
|
+
option.classList.remove('d-none');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
}, false);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function inputRedirect(inputWrapper){
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
inputWrapper.addEventListener('change', function(e){
|
|
46
|
+
|
|
47
|
+
if(inputWrapper.matches('[data-value-if]')) {
|
|
48
|
+
|
|
49
|
+
const url = inputWrapper.getAttribute('data-redirect');
|
|
50
|
+
const desiredValue = inputWrapper.getAttribute('data-value-if');
|
|
51
|
+
|
|
52
|
+
if(inputWrapper.value == desiredValue)
|
|
53
|
+
document.location.href = url;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
|
|
57
|
+
if(typeof inputWrapper.value != "undefined")
|
|
58
|
+
document.location.href = inputWrapper.value;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}, false);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//
|
|
65
|
+
function multipleFileUploads(wrapper){
|
|
66
|
+
|
|
67
|
+
const fileTenplate = wrapper.querySelector('.row');
|
|
68
|
+
const clone = fileTenplate.cloneNode(true);
|
|
69
|
+
const addButton = wrapper.querySelector('[data-add]');
|
|
70
|
+
|
|
71
|
+
wrapper.addEventListener('click', function(e){
|
|
72
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
73
|
+
if (target.matches('[data-add]')) { // Add a new row upload file input fields
|
|
74
|
+
|
|
75
|
+
const tempClone = clone.cloneNode(true);
|
|
76
|
+
wrapper.insertBefore(tempClone,target);
|
|
77
|
+
|
|
78
|
+
if(addButton.matches('[data-maxfiles]') && Array.from(wrapper.querySelectorAll(':scope > .row')).length >= addButton.dataset.maxfiles)
|
|
79
|
+
addButton.setAttribute('disabled','disabled');
|
|
80
|
+
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
if (target.matches('[data-delete]')) { // Delete the current row
|
|
84
|
+
|
|
85
|
+
let row = target.closest('.row');
|
|
86
|
+
row.remove();
|
|
87
|
+
|
|
88
|
+
if(addButton.matches('[data-maxfiles]') && Array.from(wrapper.querySelectorAll(':scope > .row')).length < addButton.dataset.maxfiles)
|
|
89
|
+
addButton.removeAttribute('disabled');
|
|
90
|
+
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
}, false);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Acts as an overall initialise function to trigger other functions.
|
|
99
|
+
function form(formElement) {
|
|
100
|
+
|
|
101
|
+
// Check for input range groups
|
|
102
|
+
Array.from(formElement.querySelectorAll('[data-input-range]')).forEach((arrayElement, index) => {
|
|
103
|
+
inputRange(arrayElement);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
Array.from(formElement.querySelectorAll('[data-redirect]')).forEach((arrayElement, index) => {
|
|
107
|
+
inputRedirect(arrayElement);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
Array.from(formElement.querySelectorAll('.multiple-file-uploads')).forEach((arrayElement, index) => {
|
|
111
|
+
multipleFileUploads(arrayElement);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
// Check the file size of a file when uploaded in case it exceeds the max file size set
|
|
116
|
+
formElement.addEventListener('change', function(e){
|
|
117
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
118
|
+
if (target.matches('[type="file"][data-filesize]') && target.files && target.files[0]) {
|
|
119
|
+
|
|
120
|
+
const maxAllowedSize = target.dataset.filesize;
|
|
121
|
+
if (target.files[0].size > maxAllowedSize) {
|
|
122
|
+
|
|
123
|
+
target.value = '';
|
|
124
|
+
alert('File too large');
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}, false);
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
// When a form is updated we may want to update some of the existing input fields; setting active fields when some data is selected.
|
|
133
|
+
formElement.addEventListener('change', function(e){
|
|
134
|
+
|
|
135
|
+
// Remove disabled attribute when a pre-selected input field equals a certain value
|
|
136
|
+
Array.from(formElement.querySelectorAll('select[data-activeif][data-equals],input[data-activeif][data-equals]')).forEach((arrayElement, index) => {
|
|
137
|
+
|
|
138
|
+
let group = arrayElement.closest('[data-group]') ? arrayElement.closest('[data-group]') : formElement;
|
|
139
|
+
let selector = arrayElement.dataset.activeif;
|
|
140
|
+
let value = arrayElement.dataset.equals;
|
|
141
|
+
let testElement = group.querySelector(`select[data-id="${selector}"],input[data-id="${selector}"]`);
|
|
142
|
+
|
|
143
|
+
if(testElement.value == value){
|
|
144
|
+
arrayElement.removeAttribute('disabled');
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
arrayElement.setAttribute('disabled','disabled');
|
|
148
|
+
arrayElement.value = '';
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// Show this input wrapper when a pre-selected input field equals a certain value
|
|
153
|
+
Array.from(formElement.querySelectorAll('.form-control__wrapper[data-displayif][data-equals]')).forEach((arrayElement, index) => {
|
|
154
|
+
|
|
155
|
+
let group = arrayElement.closest('[data-group]') ? arrayElement.closest('[data-group]') : formElement;
|
|
156
|
+
let selector = arrayElement.dataset.activeif;
|
|
157
|
+
let value = arrayElement.dataset.equals;
|
|
158
|
+
let testElement = group.querySelector(`select[data-id="${selector}"],input[data-id="${selector}"]`);
|
|
159
|
+
|
|
160
|
+
if(testElement.value == value)
|
|
161
|
+
arrayElement.classList.remove('d-none');
|
|
162
|
+
else
|
|
163
|
+
arrayElement.classList.add('d-none');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
}, false);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export default form
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Global helper functions to help maintain and enhance framework elements.
|
|
4
|
+
* @module Helpers
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Add global classes used by the CSS and later JavaScript.
|
|
9
|
+
* @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
|
|
10
|
+
*/
|
|
11
|
+
export const addBodyClasses = (body) => {
|
|
12
|
+
|
|
13
|
+
body.classList.add("js-enabled");
|
|
14
|
+
|
|
15
|
+
if(navigator.userAgent.indexOf('MSIE')!==-1 || navigator.appVersion.indexOf('Trident/') > 0){
|
|
16
|
+
|
|
17
|
+
body.classList.add("ie");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Add global events.
|
|
25
|
+
* @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
|
|
26
|
+
*/
|
|
27
|
+
export const addGlobalEvents = (body) => {
|
|
28
|
+
|
|
29
|
+
window.addEventListener('hashchange', function() {
|
|
30
|
+
|
|
31
|
+
const hash = location.hash.replace('#','');
|
|
32
|
+
const label = document.querySelector(`label[for="${hash}"]`);
|
|
33
|
+
const detail = document.querySelector(`details[id="${hash}"]:not([open])`);
|
|
34
|
+
|
|
35
|
+
if(label)
|
|
36
|
+
label.click();
|
|
37
|
+
else if(detail)
|
|
38
|
+
detail.setAttribute('open','open');
|
|
39
|
+
|
|
40
|
+
}, false);
|
|
41
|
+
|
|
42
|
+
return null
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 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.
|
|
47
|
+
* @param {HTMLElement} element Dom element, this doesn't have to be the body but it is recommended.
|
|
48
|
+
*/
|
|
49
|
+
export const checkElements = (element) => {
|
|
50
|
+
|
|
51
|
+
// Tables
|
|
52
|
+
Array.from(element.querySelectorAll('table')).forEach((table, index) => {
|
|
53
|
+
|
|
54
|
+
tableStacked(table);
|
|
55
|
+
tableWrap(table);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Wrap tables with a table wrapper div to help maintain its responsive design.
|
|
61
|
+
* @param {HTMLElement} table Dom table element
|
|
62
|
+
*/
|
|
63
|
+
export const tableWrap = (table) => {
|
|
64
|
+
|
|
65
|
+
if(!table.parentNode.classList.contains('table__wrapper')){
|
|
66
|
+
|
|
67
|
+
const tableHTML = table.outerHTML;
|
|
68
|
+
|
|
69
|
+
table.outerHTML = `<div class="table__wrapper">${tableHTML}</div>`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Creates data attributes to be used by the CSS for mobile views.
|
|
75
|
+
* @param {HTMLElement} table Dom table element
|
|
76
|
+
*/
|
|
77
|
+
export const tableStacked = (table) => {
|
|
78
|
+
|
|
79
|
+
const colHeadings = Array.from(table.querySelectorAll('thead th'));
|
|
80
|
+
const colRows = Array.from(table.querySelectorAll('tbody tr'));
|
|
81
|
+
|
|
82
|
+
colRows.forEach((row, index) => {
|
|
83
|
+
|
|
84
|
+
const cells = Array.from(row.querySelectorAll('th, td'));
|
|
85
|
+
|
|
86
|
+
cells.forEach((cell, cellIndex) => {
|
|
87
|
+
|
|
88
|
+
const heading = colHeadings[cellIndex];
|
|
89
|
+
if(typeof heading != "undefined"){
|
|
90
|
+
|
|
91
|
+
let tempDiv = document.createElement("div");
|
|
92
|
+
tempDiv.innerHTML = heading.innerHTML;
|
|
93
|
+
let headingText = tempDiv.textContent || tempDiv.innerText || "";
|
|
94
|
+
cell.setAttribute('data-label',headingText);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
export const isNumeric = function(str) {
|
|
102
|
+
if (typeof str != "string") return false // we only process strings!
|
|
103
|
+
return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
|
|
104
|
+
!isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const zeroPad = (num, places) => String(num).padStart(places, '0')
|
|
108
|
+
|
|
109
|
+
export const ucfirst = (str) => str.charAt(0).toUpperCase() + str.slice(1)
|
|
110
|
+
export const ucwords = (str) => str.split(' ').map(s => ucfirst(s)).join(' ')
|
|
111
|
+
export const unsnake = (str) => str.replace(/_/g, ' ')
|
|
112
|
+
export const snake = (str) => str.replace(/ /g, '_')
|
|
113
|
+
export const safeID = function(str){
|
|
114
|
+
|
|
115
|
+
str = str.toLowerCase();
|
|
116
|
+
str = snake(str);
|
|
117
|
+
str = str.replace(/\W/g,'');
|
|
118
|
+
|
|
119
|
+
return str;
|
|
120
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
const modal = (element) => {
|
|
3
|
+
|
|
4
|
+
const links = element.querySelectorAll('.modal__outer a, .modal__outer button');
|
|
5
|
+
const firstLink = links[0]
|
|
6
|
+
const lastLink = links[links.length - 1]
|
|
7
|
+
const modalID = element.getAttribute('id');
|
|
8
|
+
|
|
9
|
+
const closeModal = function(){
|
|
10
|
+
const button = document.querySelector('[href="'+window.location.hash+'"]');
|
|
11
|
+
button.focus();
|
|
12
|
+
window.location.hash = "close";
|
|
13
|
+
history.replaceState("", document.title, window.location.pathname + window.location.search);
|
|
14
|
+
|
|
15
|
+
// If there is more than one video lets make sure there is only one playing at a time.
|
|
16
|
+
if(typeof window.player != "undefined" && typeof window.player.pauseVideo == "function")
|
|
17
|
+
window.player.pauseVideo();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Trap the tab focus inside
|
|
21
|
+
element.addEventListener('keydown', function(e){
|
|
22
|
+
|
|
23
|
+
if(e.key === "Tab" && e.shiftKey && document.activeElement == firstLink){
|
|
24
|
+
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
lastLink.focus();
|
|
27
|
+
}
|
|
28
|
+
else if(e.key === "Tab" && !e.shiftKey && document.activeElement == lastLink) {
|
|
29
|
+
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
firstLink.focus();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// ESC will close the open modal
|
|
36
|
+
document.addEventListener("keydown", function(e){
|
|
37
|
+
if (e.key === "Escape" && document.querySelector('.modal:target'))
|
|
38
|
+
closeModal();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
element.addEventListener('click', function(e){
|
|
42
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
43
|
+
|
|
44
|
+
// Close links will close the model by default but we want to remove the hash link also
|
|
45
|
+
if (target.matches('[href="#close"]')) {
|
|
46
|
+
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
closeModal();
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
// Dock the modal to the right or left to make the content behind readable
|
|
52
|
+
else if (target.matches('.modal__dock--right')) {
|
|
53
|
+
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
if(!element.classList.contains('modal--left'))
|
|
56
|
+
element.classList.add('modal--right');
|
|
57
|
+
|
|
58
|
+
element.classList.remove('modal--left');
|
|
59
|
+
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
else if (target.matches('.modal__dock--left')) {
|
|
63
|
+
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
|
|
66
|
+
if(!element.classList.contains('modal--right'))
|
|
67
|
+
element.classList.add('modal--left');
|
|
68
|
+
|
|
69
|
+
element.classList.remove('modal--right');
|
|
70
|
+
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
function locationHashChanged() {
|
|
77
|
+
if (location.hash === '#'+modalID) {
|
|
78
|
+
console.log("Modal is now open");
|
|
79
|
+
const videoButton = document.querySelector('.modal:target .modal__inner > .youtube-embed:first-child:last-child a');
|
|
80
|
+
|
|
81
|
+
console.log(videoButton)
|
|
82
|
+
if (videoButton){
|
|
83
|
+
videoButton.click();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
window.onhashchange = locationHashChanged;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default modal
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
const navbar = (element) => {
|
|
3
|
+
|
|
4
|
+
Array.from(element.querySelectorAll('details')).forEach((detail, index) => {
|
|
5
|
+
|
|
6
|
+
detail.addEventListener('mouseenter', function(e){
|
|
7
|
+
|
|
8
|
+
if(window.matchMedia('(min-width: 62em)').matches)
|
|
9
|
+
detail.setAttribute('open','true')
|
|
10
|
+
}, false);
|
|
11
|
+
|
|
12
|
+
detail.addEventListener('mouseleave', function(e){
|
|
13
|
+
|
|
14
|
+
if(window.matchMedia('(min-width: 62em)').matches)
|
|
15
|
+
detail.removeAttribute('open')
|
|
16
|
+
}, false);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if ('IntersectionObserver' in window) {
|
|
20
|
+
const observer = new IntersectionObserver(
|
|
21
|
+
([e]) => e.target.classList.toggle("is-stuck", e.intersectionRatio < 1),
|
|
22
|
+
{ threshold: [1] }
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
observer.observe(element);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default navbar
|