@iamproperty/components 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +141 -16
- package/assets/.DS_Store +0 -0
- package/assets/css/core.min.css +1 -1
- package/assets/css/core.min.css.map +1 -1
- package/assets/css/email.min.css +1 -1
- package/assets/css/email.min.css.map +1 -1
- package/assets/css/error.min.css +1 -1
- package/assets/css/error.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 +32 -32
- package/assets/js/modules/alert.js +56 -56
- package/assets/js/modules/carousel.js +101 -101
- package/assets/js/modules/chart.js +218 -218
- package/assets/js/modules/drawer.js +15 -15
- package/assets/js/modules/file-upload.js +48 -0
- package/assets/js/modules/form.js +168 -159
- package/assets/js/modules/helpers.js +119 -119
- package/assets/js/modules/modal.js +89 -89
- package/assets/js/modules/nav.js +28 -28
- package/assets/js/modules/orderablelist.js +122 -0
- package/assets/js/modules/table.js +585 -585
- package/assets/js/modules/testimonial.js +82 -82
- package/assets/js/modules/youtubevideo.js +145 -145
- package/assets/js/scripts.bundle.js +256 -242
- package/assets/js/scripts.bundle.js.map +1 -1
- package/assets/js/scripts.bundle.min.js +2 -2
- 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 +9 -9
- 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 -250
- package/assets/sass/_functions/variables.scss +467 -467
- package/assets/sass/_print.scss +61 -61
- package/assets/sass/_tests/colours.spec.scss +44 -44
- package/assets/sass/_tests/func.spec.scss +232 -232
- package/assets/sass/_tests/mixins.spec.scss +194 -194
- package/assets/sass/_tests/sass.spec.js +9 -9
- 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/components/cardDeck.scss +107 -107
- package/assets/sass/components/carousel.scss +234 -234
- package/assets/sass/components/charts.scss +569 -569
- package/assets/sass/components/drawer.scss +46 -46
- package/assets/sass/components/header.scss +63 -63
- package/assets/sass/components/modal.scss +136 -136
- package/assets/sass/components/nav.scss +960 -918
- 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/components/tabs.scss +87 -87
- package/assets/sass/components/testimonial.scss +132 -132
- package/assets/sass/components/timeline.scss +95 -95
- package/assets/sass/core.scss +6 -6
- package/assets/sass/elements/buttons.scss +251 -209
- package/assets/sass/elements/card.scss +289 -177
- package/assets/sass/elements/container.scss +236 -225
- package/assets/sass/elements/forms.scss +262 -194
- package/assets/sass/elements/links.scss +97 -96
- package/assets/sass/elements/lists.scss +159 -112
- package/assets/sass/elements/panel.scss +161 -161
- package/assets/sass/elements/tables.scss +290 -290
- package/assets/sass/elements/tooltips.scss +84 -84
- package/assets/sass/elements/type.scss +136 -136
- 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 -72
- package/assets/sass/foundations/media.scss +50 -50
- package/assets/sass/foundations/reboot.scss +130 -130
- package/assets/sass/foundations/root.scss +125 -106
- 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.js +56 -56
- package/assets/ts/main.ts +68 -68
- package/assets/ts/modules/accordion.js +32 -32
- package/assets/ts/modules/accordion.ts +43 -43
- package/dist/components.es.js +393 -379
- package/dist/components.umd.js +16 -16
- package/dist/style.css +1 -1
- package/package.json +96 -108
- package/src/.DS_Store +0 -0
- package/src/components/Accordion/Accordion.screenshot.vue +57 -57
- 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/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/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/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/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/elements/Card/Card.vue +122 -113
- package/src/elements/Card/README.md +24 -24
- package/src/elements/FileUploads/FileUploads.vue +48 -48
- package/src/elements/FileUploads/README.md +24 -24
- package/src/elements/Input/Input.vue +272 -268
- package/src/elements/Input/README.md +19 -19
- package/src/elements/Table/README.md +62 -62
- package/src/elements/Table/Table.spec.js +90 -90
- package/src/elements/Table/Table.vue +129 -129
- 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
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const drawer = (element) => {
|
|
2
|
-
|
|
3
|
-
const observer = new IntersectionObserver(
|
|
4
|
-
|
|
5
|
-
function([e]){
|
|
6
|
-
e.target.classList.toggle("in-view", e.intersectionRatio > 0)
|
|
7
|
-
document.getElementById('showDrawer').checked = false
|
|
8
|
-
},
|
|
9
|
-
{ threshold: [1] }
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
const el = document.getElementById('drawer-end')
|
|
13
|
-
observer.observe(el);
|
|
14
|
-
}
|
|
15
|
-
|
|
1
|
+
const drawer = (element) => {
|
|
2
|
+
|
|
3
|
+
const observer = new IntersectionObserver(
|
|
4
|
+
|
|
5
|
+
function([e]){
|
|
6
|
+
e.target.classList.toggle("in-view", e.intersectionRatio > 0)
|
|
7
|
+
document.getElementById('showDrawer').checked = false
|
|
8
|
+
},
|
|
9
|
+
{ threshold: [1] }
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const el = document.getElementById('drawer-end')
|
|
13
|
+
observer.observe(el);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
16
|
export default drawer
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function fileupload(form, callback) {
|
|
2
|
+
|
|
3
|
+
const input = form.querySelector('[type="file"]');
|
|
4
|
+
const label = form.querySelector(`[for="${input.getAttribute('id')}"]`);
|
|
5
|
+
const add = form.querySelector('.file-upload__add');
|
|
6
|
+
|
|
7
|
+
form.querySelector('button').remove()
|
|
8
|
+
|
|
9
|
+
input.addEventListener("change", function( e ) {
|
|
10
|
+
// prevent default to allow drop
|
|
11
|
+
|
|
12
|
+
let url = form.getAttribute('action');
|
|
13
|
+
let formData = new FormData(form);
|
|
14
|
+
|
|
15
|
+
input.setAttribute('disabled', 'disabled');
|
|
16
|
+
|
|
17
|
+
fetch(url, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
body: formData
|
|
20
|
+
})
|
|
21
|
+
.then(() => {
|
|
22
|
+
|
|
23
|
+
form.classList.add('file-uploaded')
|
|
24
|
+
label.innerHTML = 'File uploaded';
|
|
25
|
+
|
|
26
|
+
if(typeof callback == "function")
|
|
27
|
+
callback();
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
}, false);
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
form.addEventListener("submit", function( e ) {
|
|
35
|
+
// prevent default to allow drop
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
}, false);
|
|
38
|
+
|
|
39
|
+
add.addEventListener("click", function( e ) {
|
|
40
|
+
|
|
41
|
+
form.classList.remove('file-uploaded')
|
|
42
|
+
label.innerHTML = 'Select a file to upload';
|
|
43
|
+
input.removeAttribute('disabled');
|
|
44
|
+
|
|
45
|
+
}, false);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default fileupload;
|
|
@@ -1,159 +1,168 @@
|
|
|
1
|
-
// Create a link between two input/selects with one acting as setting a minimum value and the second a maximum
|
|
2
|
-
// The link between the two will prevent the max input field form setting a lower value than the min and vice versa
|
|
3
|
-
function inputRange(inputWrapper){
|
|
4
|
-
|
|
5
|
-
inputWrapper.addEventListener('change', function(e){
|
|
6
|
-
|
|
7
|
-
var min = parseInt(inputWrapper.querySelector('[data-min] select,[data-min] input').value);
|
|
8
|
-
var max = parseInt(inputWrapper.querySelector('[data-max] select,[data-max] input').value);
|
|
9
|
-
|
|
10
|
-
// Set attributes for input fields
|
|
11
|
-
Array.from(inputWrapper.querySelectorAll('[data-min] input')).forEach((input, index) => {
|
|
12
|
-
|
|
13
|
-
input.setAttribute('max',max);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
Array.from(inputWrapper.querySelectorAll('[data-max] input')).forEach((input, index) => {
|
|
17
|
-
|
|
18
|
-
input.setAttribute('min',min);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// Hide select options if they are higher or lower than the min and max values
|
|
22
|
-
Array.from(inputWrapper.querySelectorAll('[data-min] select option')).forEach((option, index) => {
|
|
23
|
-
|
|
24
|
-
if(parseInt(option.getAttribute('value')) > max)
|
|
25
|
-
option.classList.add('d-none');
|
|
26
|
-
else
|
|
27
|
-
option.classList.remove('d-none');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
Array.from(inputWrapper.querySelectorAll('[data-max] select option')).forEach((option, index) => {
|
|
31
|
-
|
|
32
|
-
if(parseInt(option.getAttribute('value')) < min)
|
|
33
|
-
option.classList.add('d-none');
|
|
34
|
-
else
|
|
35
|
-
option.classList.remove('d-none');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
}, false);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function inputRedirect(inputWrapper){
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
1
|
+
// Create a link between two input/selects with one acting as setting a minimum value and the second a maximum
|
|
2
|
+
// The link between the two will prevent the max input field form setting a lower value than the min and vice versa
|
|
3
|
+
function inputRange(inputWrapper){
|
|
4
|
+
|
|
5
|
+
inputWrapper.addEventListener('change', function(e){
|
|
6
|
+
|
|
7
|
+
var min = parseInt(inputWrapper.querySelector('[data-min] select,[data-min] input').value);
|
|
8
|
+
var max = parseInt(inputWrapper.querySelector('[data-max] select,[data-max] input').value);
|
|
9
|
+
|
|
10
|
+
// Set attributes for input fields
|
|
11
|
+
Array.from(inputWrapper.querySelectorAll('[data-min] input')).forEach((input, index) => {
|
|
12
|
+
|
|
13
|
+
input.setAttribute('max',max);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
Array.from(inputWrapper.querySelectorAll('[data-max] input')).forEach((input, index) => {
|
|
17
|
+
|
|
18
|
+
input.setAttribute('min',min);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Hide select options if they are higher or lower than the min and max values
|
|
22
|
+
Array.from(inputWrapper.querySelectorAll('[data-min] select option')).forEach((option, index) => {
|
|
23
|
+
|
|
24
|
+
if(parseInt(option.getAttribute('value')) > max)
|
|
25
|
+
option.classList.add('d-none');
|
|
26
|
+
else
|
|
27
|
+
option.classList.remove('d-none');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
Array.from(inputWrapper.querySelectorAll('[data-max] select option')).forEach((option, index) => {
|
|
31
|
+
|
|
32
|
+
if(parseInt(option.getAttribute('value')) < min)
|
|
33
|
+
option.classList.add('d-none');
|
|
34
|
+
else
|
|
35
|
+
option.classList.remove('d-none');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
}, false);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function inputRedirect(inputWrapper){
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
inputWrapper.addEventListener('change', function(e){
|
|
45
|
+
|
|
46
|
+
if(inputWrapper.matches('[data-value-if]')) {
|
|
47
|
+
|
|
48
|
+
const url = inputWrapper.getAttribute('data-redirect');
|
|
49
|
+
const desiredValue = inputWrapper.getAttribute('data-value-if');
|
|
50
|
+
|
|
51
|
+
if(inputWrapper.value == desiredValue)
|
|
52
|
+
document.location.href = url;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
|
|
56
|
+
if(typeof inputWrapper.value != "undefined")
|
|
57
|
+
document.location.href = inputWrapper.value;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}, false);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//
|
|
64
|
+
function multipleFileUploads(wrapper){
|
|
65
|
+
|
|
66
|
+
const fileTenplate = wrapper.querySelector('.row');
|
|
67
|
+
const clone = fileTenplate.cloneNode(true);
|
|
68
|
+
const addButton = wrapper.querySelector('[data-add]');
|
|
69
|
+
|
|
70
|
+
wrapper.addEventListener('click', function(e){
|
|
71
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
72
|
+
if (target.matches('[data-add]')) { // Add a new row upload file input fields
|
|
73
|
+
|
|
74
|
+
const tempClone = clone.cloneNode(true);
|
|
75
|
+
wrapper.insertBefore(tempClone,target);
|
|
76
|
+
|
|
77
|
+
if(addButton.matches('[data-maxfiles]') && Array.from(wrapper.querySelectorAll(':scope > .row')).length >= addButton.dataset.maxfiles)
|
|
78
|
+
addButton.setAttribute('disabled','disabled');
|
|
79
|
+
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
if (target.matches('[data-delete]')) { // Delete the current row
|
|
83
|
+
|
|
84
|
+
let row = target.closest('.row');
|
|
85
|
+
row.remove();
|
|
86
|
+
|
|
87
|
+
if(addButton.matches('[data-maxfiles]') && Array.from(wrapper.querySelectorAll(':scope > .row')).length < addButton.dataset.maxfiles)
|
|
88
|
+
addButton.removeAttribute('disabled');
|
|
89
|
+
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}, false);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Acts as an overall initialise function to trigger other functions.
|
|
98
|
+
function form(formElement) {
|
|
99
|
+
|
|
100
|
+
// Check for input range groups
|
|
101
|
+
Array.from(formElement.querySelectorAll('[data-input-range]')).forEach((arrayElement, index) => {
|
|
102
|
+
inputRange(arrayElement);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
Array.from(formElement.querySelectorAll('[data-redirect]')).forEach((arrayElement, index) => {
|
|
106
|
+
inputRedirect(arrayElement);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
Array.from(formElement.querySelectorAll('.multiple-file-uploads')).forEach((arrayElement, index) => {
|
|
110
|
+
multipleFileUploads(arrayElement);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
// Check the file size of a file when uploaded in case it exceeds the max file size set
|
|
115
|
+
formElement.addEventListener('change', function(e){
|
|
116
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
117
|
+
if (target.matches('[type="file"][data-filesize]') && target.files && target.files[0]) {
|
|
118
|
+
|
|
119
|
+
const maxAllowedSize = target.dataset.filesize;
|
|
120
|
+
if (target.files[0].size > maxAllowedSize) {
|
|
121
|
+
|
|
122
|
+
target.value = '';
|
|
123
|
+
alert('File too large');
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}, false);
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
// When a form is updated we may want to update some of the existing input fields; setting active fields when some data is selected.
|
|
132
|
+
formElement.addEventListener('change', function(e){
|
|
133
|
+
|
|
134
|
+
// Remove disabled attribute when a pre-selected input field equals a certain value
|
|
135
|
+
Array.from(formElement.querySelectorAll('select[data-activeif][data-equals],input[data-activeif][data-equals]')).forEach((arrayElement, index) => {
|
|
136
|
+
|
|
137
|
+
let group = arrayElement.closest('[data-group]') ? arrayElement.closest('[data-group]') : formElement;
|
|
138
|
+
let selector = arrayElement.dataset.activeif;
|
|
139
|
+
let value = arrayElement.dataset.equals;
|
|
140
|
+
let testElement = group.querySelector(`select[data-id="${selector}"],input[data-id="${selector}"]`);
|
|
141
|
+
|
|
142
|
+
if(testElement.value == value){
|
|
143
|
+
arrayElement.removeAttribute('disabled');
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
arrayElement.setAttribute('disabled','disabled');
|
|
147
|
+
arrayElement.value = '';
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Show this input wrapper when a pre-selected input field equals a certain value
|
|
152
|
+
Array.from(formElement.querySelectorAll('.form-control__wrapper[data-displayif][data-equals]')).forEach((arrayElement, index) => {
|
|
153
|
+
|
|
154
|
+
let group = arrayElement.closest('[data-group]') ? arrayElement.closest('[data-group]') : formElement;
|
|
155
|
+
let selector = arrayElement.dataset.activeif;
|
|
156
|
+
let value = arrayElement.dataset.equals;
|
|
157
|
+
let testElement = group.querySelector(`select[data-id="${selector}"],input[data-id="${selector}"]`);
|
|
158
|
+
|
|
159
|
+
if(testElement.value == value)
|
|
160
|
+
arrayElement.classList.remove('d-none');
|
|
161
|
+
else
|
|
162
|
+
arrayElement.classList.add('d-none');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
}, false);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export default form
|
|
@@ -1,119 +1,119 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Global helper functions to help maintain and enhance framework elements.
|
|
3
|
-
* @module Helpers
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Add global classes used by the CSS and later JavaScript.
|
|
8
|
-
* @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
|
|
9
|
-
*/
|
|
10
|
-
export const addBodyClasses = (body) => {
|
|
11
|
-
|
|
12
|
-
body.classList.add("js-enabled");
|
|
13
|
-
|
|
14
|
-
if(navigator.userAgent.indexOf('MSIE')!==-1 || navigator.appVersion.indexOf('Trident/') > 0){
|
|
15
|
-
|
|
16
|
-
body.classList.add("ie");
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return null
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Add global events.
|
|
24
|
-
* @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
|
|
25
|
-
*/
|
|
26
|
-
export const addGlobalEvents = (body) => {
|
|
27
|
-
|
|
28
|
-
window.addEventListener('hashchange', function() {
|
|
29
|
-
|
|
30
|
-
const hash = location.hash.replace('#','');
|
|
31
|
-
const label = document.querySelector(`label[for="${hash}"]`);
|
|
32
|
-
const detail = document.querySelector(`details[id="${hash}"]:not([open])`);
|
|
33
|
-
|
|
34
|
-
if(label)
|
|
35
|
-
label.click();
|
|
36
|
-
else if(detail)
|
|
37
|
-
detail.setAttribute('open','open');
|
|
38
|
-
|
|
39
|
-
}, false);
|
|
40
|
-
|
|
41
|
-
return null
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 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.
|
|
46
|
-
* @param {HTMLElement} element Dom element, this doesn't have to be the body but it is recommended.
|
|
47
|
-
*/
|
|
48
|
-
export const checkElements = (element) => {
|
|
49
|
-
|
|
50
|
-
// Tables
|
|
51
|
-
Array.from(element.querySelectorAll('table')).forEach((table, index) => {
|
|
52
|
-
|
|
53
|
-
tableStacked(table);
|
|
54
|
-
tableWrap(table);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Wrap tables with a table wrapper div to help maintain its responsive design.
|
|
60
|
-
* @param {HTMLElement} table Dom table element
|
|
61
|
-
*/
|
|
62
|
-
export const tableWrap = (table) => {
|
|
63
|
-
|
|
64
|
-
if(!table.parentNode.classList.contains('table__wrapper')){
|
|
65
|
-
|
|
66
|
-
const tableHTML = table.outerHTML;
|
|
67
|
-
|
|
68
|
-
table.outerHTML = `<div class="table__wrapper">${tableHTML}</div>`;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Creates data attributes to be used by the CSS for mobile views.
|
|
74
|
-
* @param {HTMLElement} table Dom table element
|
|
75
|
-
*/
|
|
76
|
-
export const tableStacked = (table) => {
|
|
77
|
-
|
|
78
|
-
const colHeadings = Array.from(table.querySelectorAll('thead th'));
|
|
79
|
-
const colRows = Array.from(table.querySelectorAll('tbody tr'));
|
|
80
|
-
|
|
81
|
-
colRows.forEach((row, index) => {
|
|
82
|
-
|
|
83
|
-
const cells = Array.from(row.querySelectorAll('th, td'));
|
|
84
|
-
|
|
85
|
-
cells.forEach((cell, cellIndex) => {
|
|
86
|
-
|
|
87
|
-
const heading = colHeadings[cellIndex];
|
|
88
|
-
if(typeof heading != "undefined"){
|
|
89
|
-
|
|
90
|
-
let tempDiv = document.createElement("div");
|
|
91
|
-
tempDiv.innerHTML = heading.innerHTML;
|
|
92
|
-
let headingText = tempDiv.textContent || tempDiv.innerText || "";
|
|
93
|
-
cell.setAttribute('data-label',headingText);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
export const isNumeric = function(str) {
|
|
101
|
-
if (typeof str != "string") return false // we only process strings!
|
|
102
|
-
return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
|
|
103
|
-
!isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export const zeroPad = (num, places) => String(num).padStart(places, '0')
|
|
107
|
-
|
|
108
|
-
export const ucfirst = (str) => str.charAt(0).toUpperCase() + str.slice(1)
|
|
109
|
-
export const ucwords = (str) => str.split(' ').map(s => ucfirst(s)).join(' ')
|
|
110
|
-
export const unsnake = (str) => str.replace(/_/g, ' ')
|
|
111
|
-
export const snake = (str) => str.replace(/ /g, '_')
|
|
112
|
-
export const safeID = function(str){
|
|
113
|
-
|
|
114
|
-
str = str.toLowerCase();
|
|
115
|
-
str = snake(str);
|
|
116
|
-
str = str.replace(/\W/g,'');
|
|
117
|
-
|
|
118
|
-
return str;
|
|
119
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Global helper functions to help maintain and enhance framework elements.
|
|
3
|
+
* @module Helpers
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Add global classes used by the CSS and later JavaScript.
|
|
8
|
+
* @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
|
|
9
|
+
*/
|
|
10
|
+
export const addBodyClasses = (body) => {
|
|
11
|
+
|
|
12
|
+
body.classList.add("js-enabled");
|
|
13
|
+
|
|
14
|
+
if(navigator.userAgent.indexOf('MSIE')!==-1 || navigator.appVersion.indexOf('Trident/') > 0){
|
|
15
|
+
|
|
16
|
+
body.classList.add("ie");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Add global events.
|
|
24
|
+
* @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
|
|
25
|
+
*/
|
|
26
|
+
export const addGlobalEvents = (body) => {
|
|
27
|
+
|
|
28
|
+
window.addEventListener('hashchange', function() {
|
|
29
|
+
|
|
30
|
+
const hash = location.hash.replace('#','');
|
|
31
|
+
const label = document.querySelector(`label[for="${hash}"]`);
|
|
32
|
+
const detail = document.querySelector(`details[id="${hash}"]:not([open])`);
|
|
33
|
+
|
|
34
|
+
if(label)
|
|
35
|
+
label.click();
|
|
36
|
+
else if(detail)
|
|
37
|
+
detail.setAttribute('open','open');
|
|
38
|
+
|
|
39
|
+
}, false);
|
|
40
|
+
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 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.
|
|
46
|
+
* @param {HTMLElement} element Dom element, this doesn't have to be the body but it is recommended.
|
|
47
|
+
*/
|
|
48
|
+
export const checkElements = (element) => {
|
|
49
|
+
|
|
50
|
+
// Tables
|
|
51
|
+
Array.from(element.querySelectorAll('table')).forEach((table, index) => {
|
|
52
|
+
|
|
53
|
+
tableStacked(table);
|
|
54
|
+
tableWrap(table);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Wrap tables with a table wrapper div to help maintain its responsive design.
|
|
60
|
+
* @param {HTMLElement} table Dom table element
|
|
61
|
+
*/
|
|
62
|
+
export const tableWrap = (table) => {
|
|
63
|
+
|
|
64
|
+
if(!table.parentNode.classList.contains('table__wrapper')){
|
|
65
|
+
|
|
66
|
+
const tableHTML = table.outerHTML;
|
|
67
|
+
|
|
68
|
+
table.outerHTML = `<div class="table__wrapper">${tableHTML}</div>`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Creates data attributes to be used by the CSS for mobile views.
|
|
74
|
+
* @param {HTMLElement} table Dom table element
|
|
75
|
+
*/
|
|
76
|
+
export const tableStacked = (table) => {
|
|
77
|
+
|
|
78
|
+
const colHeadings = Array.from(table.querySelectorAll('thead th'));
|
|
79
|
+
const colRows = Array.from(table.querySelectorAll('tbody tr'));
|
|
80
|
+
|
|
81
|
+
colRows.forEach((row, index) => {
|
|
82
|
+
|
|
83
|
+
const cells = Array.from(row.querySelectorAll('th, td'));
|
|
84
|
+
|
|
85
|
+
cells.forEach((cell, cellIndex) => {
|
|
86
|
+
|
|
87
|
+
const heading = colHeadings[cellIndex];
|
|
88
|
+
if(typeof heading != "undefined"){
|
|
89
|
+
|
|
90
|
+
let tempDiv = document.createElement("div");
|
|
91
|
+
tempDiv.innerHTML = heading.innerHTML;
|
|
92
|
+
let headingText = tempDiv.textContent || tempDiv.innerText || "";
|
|
93
|
+
cell.setAttribute('data-label',headingText);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
export const isNumeric = function(str) {
|
|
101
|
+
if (typeof str != "string") return false // we only process strings!
|
|
102
|
+
return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
|
|
103
|
+
!isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const zeroPad = (num, places) => String(num).padStart(places, '0')
|
|
107
|
+
|
|
108
|
+
export const ucfirst = (str) => str.charAt(0).toUpperCase() + str.slice(1)
|
|
109
|
+
export const ucwords = (str) => str.split(' ').map(s => ucfirst(s)).join(' ')
|
|
110
|
+
export const unsnake = (str) => str.replace(/_/g, ' ')
|
|
111
|
+
export const snake = (str) => str.replace(/ /g, '_')
|
|
112
|
+
export const safeID = function(str){
|
|
113
|
+
|
|
114
|
+
str = str.toLowerCase();
|
|
115
|
+
str = snake(str);
|
|
116
|
+
str = str.replace(/\W/g,'');
|
|
117
|
+
|
|
118
|
+
return str;
|
|
119
|
+
}
|