@iamproperty/components 3.4.6 → 3.4.7
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/assets/css/components/accordion.css.map +1 -1
- package/assets/css/components/applied-filters.css +1 -0
- package/assets/css/components/applied-filters.css.map +1 -0
- package/assets/css/components/card.css +1 -1
- package/assets/css/components/card.css.map +1 -1
- package/assets/css/components/charts.css +1 -1
- package/assets/css/components/charts.css.map +1 -1
- package/assets/css/components/container.css +1 -1
- package/assets/css/components/container.css.map +1 -1
- package/assets/css/components/dialog.css +1 -0
- package/assets/css/components/dialog.css.map +1 -0
- package/assets/css/components/forms.css +1 -1
- package/assets/css/components/forms.css.map +1 -1
- package/assets/css/components/lists.css +1 -1
- package/assets/css/components/lists.css.map +1 -1
- package/assets/css/components/nav.css +1 -1
- package/assets/css/components/nav.css.map +1 -1
- package/assets/css/components/pagination.css +1 -0
- package/assets/css/components/pagination.css.map +1 -0
- package/assets/css/components/table.css +1 -0
- package/assets/css/components/table.css.map +1 -0
- 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/js/bundle.js +18 -11
- package/assets/js/components/accordion/accordion.component.js +6 -0
- package/assets/js/components/accordion/accordion.component.min.js +3 -3
- package/assets/js/components/accordion/accordion.component.min.js.map +1 -1
- package/assets/js/components/applied-filters/applied-filters.component.js +26 -0
- package/assets/js/components/card/card.component.js +91 -0
- package/assets/js/components/card/card.component.min.js +21 -0
- package/assets/js/components/card/card.component.min.js.map +1 -0
- package/assets/js/components/filterlist/filterlist.component.js +49 -0
- package/assets/js/components/filterlist/filterlist.component.min.js +23 -0
- package/assets/js/components/filterlist/filterlist.component.min.js.map +1 -0
- package/assets/js/components/header/header.component.js +6 -0
- package/assets/js/components/header/header.component.min.js +2 -2
- package/assets/js/components/header/header.component.min.js.map +1 -1
- package/assets/js/components/pagination/pagination.component.js +34 -0
- package/assets/js/components/table/table.component.js +104 -0
- package/assets/js/components/table/table.component.min.js +24 -0
- package/assets/js/components/table/table.component.min.js.map +1 -0
- package/assets/js/components/tabs/tabs.component.js +6 -0
- package/assets/js/components/tabs/tabs.component.min.js +17 -0
- package/assets/js/components/tabs/tabs.component.min.js.map +1 -0
- package/assets/js/dynamic.js +7 -18
- package/assets/js/dynamic.min.js +2 -53
- package/assets/js/dynamic.min.js.map +1 -1
- package/assets/js/flat-components.js +27 -9
- package/assets/js/modules/applied-filters.js +100 -0
- package/assets/js/modules/data-layer.js +45 -0
- package/assets/js/modules/filterlist.js +32 -0
- package/assets/js/modules/helpers.js +77 -49
- package/assets/js/modules/pagination.js +33 -0
- package/assets/js/modules/table.js +507 -420
- package/assets/js/modules/tabs.js +6 -0
- package/assets/js/modules/youtubevideo.js +53 -61
- package/assets/js/scripts.bundle.js +77 -62
- 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/js/tests/filterlist.spec.js +22 -0
- package/assets/js/tests/pagination.spec.js +15 -0
- package/assets/js/tests/table.spec.js +147 -0
- package/assets/sass/_components.scss +1 -2
- package/assets/sass/_corefiles.scss +5 -4
- package/assets/sass/_functions/utilities.scss +16 -0
- package/assets/sass/_functions/variables.scss +32 -18
- package/assets/sass/_tests/colours.spec.scss +1 -1
- package/assets/sass/components/applied-filters.scss +65 -0
- package/assets/sass/components/card.scss +177 -233
- package/assets/sass/components/charts.scss +4 -0
- package/assets/sass/components/container.scss +7 -2
- package/assets/sass/components/dialog.scss +202 -0
- package/assets/sass/components/forms.scss +37 -5
- package/assets/sass/components/lists.scss +15 -0
- package/assets/sass/components/nav.scss +5 -1
- package/assets/sass/components/pagination.scss +140 -0
- package/assets/sass/components/table.scss +419 -0
- package/assets/sass/foundations/icons.scss +1 -1
- package/assets/sass/{components → foundations}/links.scss +26 -0
- package/assets/sass/foundations/reboot.scss +19 -13
- package/assets/svg/illustrations/table.svg +165 -0
- package/assets/ts/bundle.ts +23 -12
- package/assets/ts/components/accordion/accordion.component.ts +7 -0
- package/assets/ts/components/applied-filters/README.md +5 -0
- package/assets/ts/components/applied-filters/applied-filters.component.ts +33 -0
- package/assets/ts/components/card/README.md +22 -0
- package/assets/ts/components/card/card.component.ts +117 -0
- package/assets/ts/components/filterlist/README.md +17 -0
- package/assets/ts/components/filterlist/filterlist.component.ts +60 -0
- package/assets/ts/components/header/header.component.ts +8 -0
- package/assets/ts/components/pagination/README.md +11 -0
- package/assets/ts/components/pagination/pagination.component.ts +45 -0
- package/assets/ts/components/table/README.md +23 -0
- package/assets/ts/components/table/table.component.ts +128 -0
- package/assets/ts/components/tabs/tabs.component.ts +7 -0
- package/assets/ts/dynamic.ts +12 -19
- package/assets/ts/flat-components.ts +37 -9
- package/assets/ts/modules/applied-filters.ts +146 -0
- package/assets/ts/modules/data-layer.ts +58 -0
- package/assets/ts/modules/filterlist.ts +46 -0
- package/assets/ts/modules/helpers.ts +90 -60
- package/assets/ts/modules/pagination.ts +44 -0
- package/assets/ts/modules/table.ts +598 -433
- package/assets/ts/modules/tabs.ts +8 -1
- package/assets/ts/modules/youtubevideo.ts +58 -63
- package/assets/ts/tests/filterlist.spec.ts +29 -0
- package/assets/ts/tests/pagination.spec.ts +21 -0
- package/assets/ts/tests/table.spec.ts +191 -0
- package/dist/components.es.js +1264 -1296
- package/dist/components.umd.js +70 -65
- package/dist/style.css +1 -1
- package/package.json +7 -5
- package/src/components/AppliedFilters/AppliedFilters.vue +20 -0
- package/src/components/AppliedFilters/README.md +5 -0
- package/src/components/Card/Card.vue +11 -112
- package/src/components/Card/README.md +16 -18
- package/src/components/Carousel/Carousel.vue +49 -10
- package/src/components/Chart/Chart.vue +46 -4
- package/src/components/Filterlist/Filterlist.vue +20 -0
- package/src/components/Filterlist/README.md +17 -0
- package/src/components/Pagination/Pagination.vue +30 -0
- package/src/components/Pagination/README.md +11 -0
- package/src/components/Table/README.md +29 -44
- package/src/components/Table/Table.spec.js +5 -37
- package/src/components/Table/Table.vue +16 -91
- package/src/foundations/YoutubeVideo/YoutubeVideo.vue +1 -1
- package/src/index.js +3 -2
- package/assets/css/components/cardDeck.css +0 -1
- package/assets/css/components/cardDeck.css.map +0 -1
- package/assets/css/components/links.css +0 -1
- package/assets/css/components/links.css.map +0 -1
- package/assets/css/components/modal.css +0 -1
- package/assets/css/components/modal.css.map +0 -1
- package/assets/css/components/tables.css +0 -1
- package/assets/css/components/tables.css.map +0 -1
- package/assets/js/modules/modal.js +0 -69
- package/assets/sass/components/cardDeck.scss +0 -108
- package/assets/sass/components/modal.scss +0 -136
- package/assets/sass/components/tables.scss +0 -291
- package/assets/ts/modules/modal.ts +0 -91
- package/src/components/CardDeck/CardDeck.spec.js +0 -99
- package/src/components/CardDeck/CardDeck.vue +0 -77
- package/src/components/CardDeck/README.md +0 -25
- package/src/components/Modal/Modal.spec.js +0 -22
- package/src/components/Modal/Modal.vue +0 -43
- package/src/components/Modal/README.md +0 -20
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import filterlist from "../../modules/filterlist";
|
|
3
|
+
|
|
4
|
+
// Data layer Web component created
|
|
5
|
+
window.dataLayer = window.dataLayer || [];
|
|
6
|
+
window.dataLayer.push({
|
|
7
|
+
"event": "customElementRegistered",
|
|
8
|
+
"element": "filterlist"
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
class iamFilterlist extends HTMLElement {
|
|
12
|
+
|
|
13
|
+
constructor(){
|
|
14
|
+
super();
|
|
15
|
+
this.attachShadow({ mode: 'open'});
|
|
16
|
+
|
|
17
|
+
const assetLocation = document.body.hasAttribute('data-assets-location') ? document.body.getAttribute('data-assets-location') : '/assets';
|
|
18
|
+
const template = document.createElement('template');
|
|
19
|
+
template.innerHTML = `
|
|
20
|
+
<style>
|
|
21
|
+
@import "${assetLocation}/css/core.min.css";
|
|
22
|
+
${this.hasAttribute('css') ? `@import "${this.getAttribute('css')}";` : ``}
|
|
23
|
+
|
|
24
|
+
:host {
|
|
25
|
+
margin-bottom: 3rem;
|
|
26
|
+
display:block;
|
|
27
|
+
}
|
|
28
|
+
</style>
|
|
29
|
+
<div class="form-control__wrapper">
|
|
30
|
+
<label for="search" class="visually-hidden">Search</label>
|
|
31
|
+
<span class="suffix" role="presentation"><slot name="icon"></slot></span>
|
|
32
|
+
<input name="search" id="search" type="text" class="form-control" autocomplete="off">
|
|
33
|
+
</div>
|
|
34
|
+
<div class="list__wrapper">
|
|
35
|
+
<slot></slot>
|
|
36
|
+
</div>
|
|
37
|
+
`;
|
|
38
|
+
this.shadowRoot.appendChild(template.content.cloneNode(true));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
connectedCallback() {
|
|
42
|
+
|
|
43
|
+
const maxHeights = {
|
|
44
|
+
"small": "12.5rem",
|
|
45
|
+
"medium": "25rem",
|
|
46
|
+
"large": "37.5rem"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let maxHeightClass = (this.hasAttribute('data-max-height') && maxHeights[this.getAttribute('data-max-height')] ? 'list__wrapper--'+this.getAttribute('data-max-height') : '');
|
|
50
|
+
|
|
51
|
+
this.shadowRoot.querySelector('.list__wrapper').classList.add(maxHeightClass);
|
|
52
|
+
|
|
53
|
+
if(!this.querySelector('i.fa-search'))
|
|
54
|
+
this.innerHTML += '<i class="fa fa-light fa-search" aria-hidden="true" slot="icon"></i>';
|
|
55
|
+
|
|
56
|
+
filterlist(this.querySelector('ul'),this.shadowRoot.querySelector('#search'));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default iamFilterlist;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
```
|
|
2
|
+
<iam-pagination data-total="12"></iam-pagination>
|
|
3
|
+
```
|
|
4
|
+
|
|
5
|
+
**Properties**
|
|
6
|
+
|
|
7
|
+
| Option | Type | Default Value | Description |
|
|
8
|
+
| ------ | ---- | ------------- | ----------- |
|
|
9
|
+
| data-total | int | 0 | The total amount is needed to work out how many pagination buttons are needed |
|
|
10
|
+
| data-page | int | 1 | Override the current page value |
|
|
11
|
+
| data-show | int | 15 | Update how many items can be shown per page |
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import createPaginationButttons from "../../modules/pagination";
|
|
3
|
+
|
|
4
|
+
class iamPagination extends HTMLElement {
|
|
5
|
+
|
|
6
|
+
constructor(){
|
|
7
|
+
super();
|
|
8
|
+
this.attachShadow({ mode: 'open'});
|
|
9
|
+
const assetLocation = document.body.hasAttribute('data-assets-location') ? document.body.getAttribute('data-assets-location') : '/assets';
|
|
10
|
+
|
|
11
|
+
const template = document.createElement('template');
|
|
12
|
+
template.innerHTML = `
|
|
13
|
+
<style>
|
|
14
|
+
@import "${assetLocation}/css/core.min.css";
|
|
15
|
+
</style>
|
|
16
|
+
<div class="pagination__wrapper d-none">
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
19
|
+
this.shadowRoot.appendChild(template.content.cloneNode(true));
|
|
20
|
+
|
|
21
|
+
// Set default attributes
|
|
22
|
+
const params = new URLSearchParams(window.location.search);
|
|
23
|
+
|
|
24
|
+
if(!this.hasAttribute('data-total'))
|
|
25
|
+
this.setAttribute('data-total', this.querySelectorAll('table tbody tr').length);
|
|
26
|
+
|
|
27
|
+
if(!this.hasAttribute('data-page'))
|
|
28
|
+
this.setAttribute('data-page', (params.has('page') ? params.get('page') : 1));
|
|
29
|
+
|
|
30
|
+
if(!this.hasAttribute('data-show'))
|
|
31
|
+
this.setAttribute('data-show', (params.has('show') ? params.get('show') : 15));
|
|
32
|
+
|
|
33
|
+
if(!this.hasAttribute('data-increment'))
|
|
34
|
+
this.setAttribute('data-increment', 15);
|
|
35
|
+
|
|
36
|
+
this.setAttribute('data-pages', Math.ceil(this.getAttribute('data-total') / this.getAttribute('data-show')));
|
|
37
|
+
createPaginationButttons(this,this.shadowRoot.querySelector('.pagination__wrapper'));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
connectedCallback() {
|
|
41
|
+
this.shadowRoot.querySelector('.pagination__wrapper').classList.remove('d-none');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default iamPagination;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
```
|
|
2
|
+
<iam-table class="container">
|
|
3
|
+
<table>
|
|
4
|
+
<thead>....</thead>
|
|
5
|
+
<tbody>...</tbody>
|
|
6
|
+
</table>
|
|
7
|
+
</iam-tabs>
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
**Properties**
|
|
11
|
+
|
|
12
|
+
| Option | Type | Default Value | Description |
|
|
13
|
+
| ------ | ---- | ------------- | ----------- |
|
|
14
|
+
| data-show | int | 15 | Update how many rows can be shown per page |
|
|
15
|
+
| data-filterby | string (form ID) | | Give an optional form ID to connect a form to the table and make it act like a filtering system |
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
**Class modifiers**
|
|
19
|
+
|
|
20
|
+
- Adding a class of **.table--cta** to the table component will fix the last column of the table in place (While on tablet or desktop).
|
|
21
|
+
- Adding a class of **.table--export** to the table component will create a button at the bottom of the table to export its contents out as a CSV file.
|
|
22
|
+
- Adding a class of **.table--fullwidth** to the table component will prevent it from becoming a stacked view on mobile.
|
|
23
|
+
- Adding a class of **.table--mh-small**,**.table--mh-medium** or **.table--mh-large** to the table component will give the table container a max height and the ability to scroll.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import * as tableModule from "../../modules/table";
|
|
3
|
+
import createPaginationButttons from "../../modules/pagination";
|
|
4
|
+
|
|
5
|
+
class iamTable extends HTMLElement {
|
|
6
|
+
|
|
7
|
+
constructor(){
|
|
8
|
+
super();
|
|
9
|
+
this.attachShadow({ mode: 'open'});
|
|
10
|
+
const assetLocation = document.body.hasAttribute('data-assets-location') ? document.body.getAttribute('data-assets-location') : '/assets';
|
|
11
|
+
|
|
12
|
+
const isCTA = this.classList.contains('table--cta');
|
|
13
|
+
const isExportable = this.classList.contains('table--export');
|
|
14
|
+
|
|
15
|
+
let classList = this.classList.toString();
|
|
16
|
+
|
|
17
|
+
classList = classList.replace('table--cta','');
|
|
18
|
+
|
|
19
|
+
const template = document.createElement('template');
|
|
20
|
+
template.innerHTML = `
|
|
21
|
+
<style>
|
|
22
|
+
@import "${assetLocation}/css/core.min.css";
|
|
23
|
+
</style>
|
|
24
|
+
${isCTA ? '<div class="table--cta">' : ''}
|
|
25
|
+
<div class="table__wrapper ${classList}">
|
|
26
|
+
<slot></slot>
|
|
27
|
+
</div>
|
|
28
|
+
${isCTA ? '</div>' : ''}
|
|
29
|
+
${isExportable ? '<button class="link" type="button" data-export>Export table as CSV</button>' : ''}
|
|
30
|
+
<div class="table__pagination"></div>
|
|
31
|
+
`;
|
|
32
|
+
this.shadowRoot.appendChild(template.content.cloneNode(true));
|
|
33
|
+
|
|
34
|
+
const params = new URLSearchParams(window.location.search)
|
|
35
|
+
// Set default attributes
|
|
36
|
+
if(!this.hasAttribute('data-total'))
|
|
37
|
+
this.setAttribute('data-total', this.querySelectorAll('table tbody tr').length);
|
|
38
|
+
|
|
39
|
+
if(!this.hasAttribute('data-page'))
|
|
40
|
+
this.setAttribute('data-page', (params.has('page') ? params.get('page') : 1));
|
|
41
|
+
|
|
42
|
+
if(!this.hasAttribute('data-show'))
|
|
43
|
+
this.setAttribute('data-show', 15);
|
|
44
|
+
|
|
45
|
+
this.setAttribute('data-pages', Math.ceil(this.getAttribute('data-total') / this.getAttribute('data-show')));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
connectedCallback() {
|
|
49
|
+
|
|
50
|
+
this.table = this.querySelector('table');
|
|
51
|
+
this.savedTableBody = this.querySelector('tbody').cloneNode(true);
|
|
52
|
+
this.pagination = this.shadowRoot.querySelector('.table__pagination');
|
|
53
|
+
|
|
54
|
+
// Set events on the filter table
|
|
55
|
+
this.form = document.createElement('form');
|
|
56
|
+
if(this.hasAttribute('data-filterby')){
|
|
57
|
+
|
|
58
|
+
this.form = document.querySelector(`#${this.getAttribute('data-filterby')}`);
|
|
59
|
+
|
|
60
|
+
// Create a data list if a search input is present
|
|
61
|
+
tableModule.createSearchDataList(this.table, this.form);
|
|
62
|
+
|
|
63
|
+
if(!this.form.querySelector('[data-page]')){
|
|
64
|
+
this.form.innerHTML += `<input name="page" type="hidden" value="${this.getAttribute('data-page')}" data-pagination="true" />`
|
|
65
|
+
}
|
|
66
|
+
if(!this.form.querySelector('[data-show]')){
|
|
67
|
+
this.form.innerHTML += `<input name="show" type="hidden" value="${this.getAttribute('data-show')}" data-show="true" />`
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
// Event listeners
|
|
73
|
+
tableModule.addTableEventListeners(this.table);
|
|
74
|
+
tableModule.addFilterEventListeners(this.table, this.form, this.pagination, this, this.savedTableBody);
|
|
75
|
+
tableModule.addPaginationEventListeners(this.table, this.form, this.pagination, this);
|
|
76
|
+
tableModule.addExportEventListeners(this.shadowRoot.querySelector('[data-export]'), this.table);
|
|
77
|
+
|
|
78
|
+
if(this.form.getAttribute('data-ajax')){
|
|
79
|
+
tableModule.loadAjaxTable(this.table, this.form, this.pagination, this);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
tableModule.makeTableFunctional(this.table, this.form, this.pagination, this);
|
|
83
|
+
tableModule.filterTable(this.table, this.form,this);
|
|
84
|
+
createPaginationButttons(this,this.pagination);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
static get observedAttributes() {
|
|
91
|
+
return ["data-total","data-pages","data-page","data-show"];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
attributeChangedCallback(attrName, oldVal, newVal) {
|
|
95
|
+
/*
|
|
96
|
+
switch (attrName) {
|
|
97
|
+
case "data-total": {
|
|
98
|
+
this.setAttribute('data-pages', Math.ceil(newVal / this.getAttribute('data-show')));
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case "data-show": {
|
|
102
|
+
this.setAttribute('data-pages', Math.ceil(this.getAttribute('data-total') / newVal));
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case "data-pages": {
|
|
106
|
+
console.log('create pagination');
|
|
107
|
+
|
|
108
|
+
tableModule.filterTable(this.table, this.form);
|
|
109
|
+
createPaginationButttons(this,this.pagination);
|
|
110
|
+
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case "data-page": {
|
|
114
|
+
|
|
115
|
+
let paginationInput = this.form.querySelector('[data-pagination]');
|
|
116
|
+
|
|
117
|
+
paginationInput.value = newVal;
|
|
118
|
+
|
|
119
|
+
//tableModule.filterTable(this.table, this.form);
|
|
120
|
+
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
*/
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default iamTable;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import tabs from "../../modules/tabs";
|
|
3
3
|
|
|
4
|
+
// Data layer Web component created
|
|
5
|
+
window.dataLayer = window.dataLayer || [];
|
|
6
|
+
window.dataLayer.push({
|
|
7
|
+
"event": "customElementRegistered",
|
|
8
|
+
"element": "tabs"
|
|
9
|
+
});
|
|
10
|
+
|
|
4
11
|
class iamTabs extends HTMLElement {
|
|
5
12
|
|
|
6
13
|
constructor(){
|
package/assets/ts/dynamic.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// Modules
|
|
3
3
|
import * as helpers from '../js/modules/helpers'
|
|
4
|
+
import createDataLayer from '../js/modules/data-layer'
|
|
4
5
|
import nav from '../js/modules/nav'
|
|
5
6
|
import table from '../js/modules/table'
|
|
6
7
|
//import accordion from './modules/accordion'
|
|
@@ -8,9 +9,8 @@ import testimonial from '../js/modules/testimonial'
|
|
|
8
9
|
import carousel from '../js/modules/carousel'
|
|
9
10
|
import form from '../js/modules/form'
|
|
10
11
|
import youtubeVideo from '../js/modules/youtubevideo'
|
|
11
|
-
import modal from '../js/modules/modal'
|
|
12
12
|
|
|
13
|
-
const components = ['accordion','header','tabs'];
|
|
13
|
+
const components = ['accordion','header','tabs', 'table','card','pagination','filterlist', 'applied-filters'];
|
|
14
14
|
const prefix = "iam"
|
|
15
15
|
const options = {
|
|
16
16
|
rootMargin: '50px',
|
|
@@ -21,6 +21,8 @@ const componentExt = ".component.js";
|
|
|
21
21
|
// Load components - Each component will load once the first of its type has been loaded
|
|
22
22
|
components.forEach((component) => {
|
|
23
23
|
|
|
24
|
+
console.log(component)
|
|
25
|
+
|
|
24
26
|
if(document.getElementsByTagName(`${prefix}-${component}`).length === 0)
|
|
25
27
|
return;
|
|
26
28
|
|
|
@@ -28,6 +30,8 @@ components.forEach((component) => {
|
|
|
28
30
|
entries.forEach((entry:any) => {
|
|
29
31
|
|
|
30
32
|
if(entry.intersectionRatio > 0){
|
|
33
|
+
|
|
34
|
+
console.log(component)
|
|
31
35
|
|
|
32
36
|
import(`./components/${component}/${component}${componentExt}`).then(module => {
|
|
33
37
|
if (!window.customElements.get(`${prefix}-${component}`))
|
|
@@ -49,28 +53,18 @@ components.forEach((component) => {
|
|
|
49
53
|
// Attach classes to dom elements
|
|
50
54
|
document.addEventListener("DOMContentLoaded", function() {
|
|
51
55
|
|
|
56
|
+
createDataLayer();
|
|
57
|
+
|
|
52
58
|
// Global stuff
|
|
53
59
|
helpers.addBodyClasses(document.body);
|
|
54
60
|
helpers.addGlobalEvents(document.body);
|
|
55
|
-
helpers.checkElements(document.body);
|
|
61
|
+
//helpers.checkElements(document.body);
|
|
56
62
|
|
|
57
63
|
// ANav
|
|
58
64
|
Array.from(document.querySelectorAll('.nav')).forEach((arrayElement) => {
|
|
59
65
|
nav(arrayElement);
|
|
60
66
|
});
|
|
61
67
|
|
|
62
|
-
// Advanced tables
|
|
63
|
-
Array.from(document.querySelectorAll('.table__wrapper')).forEach((arrayElement) => {
|
|
64
|
-
table(arrayElement);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// Accordions
|
|
68
|
-
/*
|
|
69
|
-
Array.from(document.querySelectorAll('.accordion')).forEach((arrayElement) => {
|
|
70
|
-
accordion(arrayElement);
|
|
71
|
-
});
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
68
|
// Testimonial
|
|
75
69
|
Array.from(document.querySelectorAll('.testimonial')).forEach((arrayElement) => {
|
|
76
70
|
testimonial(arrayElement);
|
|
@@ -83,12 +77,11 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
|
83
77
|
Array.from(document.querySelectorAll('form')).forEach((arrayElement) => {
|
|
84
78
|
form(arrayElement);
|
|
85
79
|
});
|
|
86
|
-
// Modal
|
|
87
|
-
Array.from(document.querySelectorAll('.modal')).forEach((arrayElement) => {
|
|
88
|
-
modal(arrayElement);
|
|
89
|
-
});
|
|
90
80
|
// YouTube videos
|
|
91
81
|
Array.from(document.querySelectorAll('.youtube-embed')).forEach((arrayElement) => {
|
|
82
|
+
|
|
83
|
+
console.log(arrayElement)
|
|
84
|
+
|
|
92
85
|
new youtubeVideo(arrayElement);
|
|
93
86
|
});
|
|
94
87
|
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// Modules
|
|
3
3
|
import * as helpers from '../js/modules/helpers'
|
|
4
|
+
import createDataLayer from '../js/modules/data-layer'
|
|
4
5
|
import nav from '../js/modules/nav'
|
|
5
|
-
import
|
|
6
|
+
import * as tableModule from './modules/table'
|
|
6
7
|
import accordion from './modules/accordion'
|
|
7
8
|
import testimonial from '../js/modules/testimonial'
|
|
8
9
|
import carousel from '../js/modules/carousel'
|
|
9
10
|
import form from '../js/modules/form'
|
|
10
11
|
import youtubeVideo from '../js/modules/youtubevideo'
|
|
11
|
-
import modal from '../js/modules/modal'
|
|
12
12
|
import tabs from '../js/modules/tabs'
|
|
13
|
+
import filterlist from '../js/modules/filterlist'
|
|
14
|
+
import createPaginationButttons from '../js/modules/pagination'
|
|
13
15
|
|
|
14
16
|
// Attach classes to dom elements
|
|
15
17
|
document.addEventListener("DOMContentLoaded", function() {
|
|
16
18
|
|
|
19
|
+
createDataLayer();
|
|
20
|
+
|
|
17
21
|
// Global stuff
|
|
18
22
|
helpers.addBodyClasses(document.body);
|
|
19
23
|
helpers.addGlobalEvents(document.body);
|
|
20
|
-
helpers.checkElements(document.body);
|
|
24
|
+
//helpers.checkElements(document.body);
|
|
21
25
|
|
|
22
26
|
// ANav
|
|
23
27
|
Array.from(document.querySelectorAll('.nav')).forEach((arrayElement) => {
|
|
@@ -25,8 +29,18 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
|
25
29
|
});
|
|
26
30
|
|
|
27
31
|
// Advanced tables
|
|
28
|
-
Array.from(document.querySelectorAll('
|
|
29
|
-
|
|
32
|
+
Array.from(document.querySelectorAll('table')).forEach((arrayElement) => {
|
|
33
|
+
|
|
34
|
+
tableModule.addTableEventListeners(arrayElement);
|
|
35
|
+
tableModule.createMobileButton(arrayElement);
|
|
36
|
+
tableModule.addDataAttributes(arrayElement);
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if(arrayElement.closest('.table--cta')){
|
|
40
|
+
|
|
41
|
+
const largestWidth = tableModule.getLargestLastColWidth(arrayElement);
|
|
42
|
+
arrayElement.closest('.table--cta').style.setProperty("--cta-width", `${largestWidth}rem`);
|
|
43
|
+
}
|
|
30
44
|
});
|
|
31
45
|
|
|
32
46
|
// Accordions
|
|
@@ -46,10 +60,6 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
|
46
60
|
Array.from(document.querySelectorAll('form')).forEach((arrayElement) => {
|
|
47
61
|
form(arrayElement);
|
|
48
62
|
});
|
|
49
|
-
// Modal
|
|
50
|
-
Array.from(document.querySelectorAll('.modal')).forEach((arrayElement) => {
|
|
51
|
-
modal(arrayElement);
|
|
52
|
-
});
|
|
53
63
|
// YouTube videos
|
|
54
64
|
Array.from(document.querySelectorAll('.youtube-embed')).forEach((arrayElement) => {
|
|
55
65
|
new youtubeVideo(arrayElement);
|
|
@@ -59,6 +69,24 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
|
59
69
|
tabs(arrayElement);
|
|
60
70
|
});
|
|
61
71
|
|
|
72
|
+
// filterlist
|
|
73
|
+
Array.from(document.querySelectorAll('.iam-filterlist')).forEach((arrayElement) => {
|
|
74
|
+
if(arrayElement.hasAttribute('data-input') && document.querySelector(arrayElement.getAttribute('data-input')))
|
|
75
|
+
filterlist(arrayElement.querySelector('ul'),document.querySelector(arrayElement.getAttribute('data-input')));
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
Array.from(document.querySelectorAll('.pagination__wrapper')).forEach((arrayElement) => {
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
const params = new URLSearchParams(window.location.search);
|
|
82
|
+
arrayElement.setAttribute('data-page', (params.has('page') ? params.get('page') : 1));
|
|
83
|
+
arrayElement.setAttribute('data-show', (params.has('show') ? params.get('show') : 15));
|
|
84
|
+
arrayElement.setAttribute('data-increment', 15);
|
|
85
|
+
arrayElement.setAttribute('data-pages', Math.ceil(arrayElement.getAttribute('data-total') / arrayElement.getAttribute('data-show')));
|
|
86
|
+
|
|
87
|
+
createPaginationButttons(arrayElement,arrayElement);
|
|
88
|
+
});
|
|
89
|
+
|
|
62
90
|
|
|
63
91
|
window.addEventListener('hashchange', function() {
|
|
64
92
|
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
function createAppliedFilters(container,filters) {
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function addFilterButton (filters, input){
|
|
6
|
+
let shouldRemoveFilter = false;
|
|
7
|
+
let inputName = input.getAttribute('name');
|
|
8
|
+
|
|
9
|
+
if(inputName.includes('[]'))
|
|
10
|
+
inputName = inputName.replace('[]',`[${input.value}]`);
|
|
11
|
+
|
|
12
|
+
let filter = filters.querySelector(`[data-name="${inputName}"]`);
|
|
13
|
+
|
|
14
|
+
if(filter && input.getAttribute('type') == 'checkbox')
|
|
15
|
+
shouldRemoveFilter = true;
|
|
16
|
+
|
|
17
|
+
let filterText = input.getAttribute('data-filter-text');
|
|
18
|
+
|
|
19
|
+
if(!filter) {
|
|
20
|
+
filter = document.createElement('button');
|
|
21
|
+
filters.appendChild(filter);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
filter.setAttribute('type','button')
|
|
25
|
+
filter.classList.add('filter');
|
|
26
|
+
filter.setAttribute('data-name',inputName);
|
|
27
|
+
|
|
28
|
+
filter.innerHTML = filterText.replace('$value', input.value);
|
|
29
|
+
|
|
30
|
+
// If the value
|
|
31
|
+
if(!input.value || shouldRemoveFilter)
|
|
32
|
+
filter.remove();
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// If input has an ancestor with data-filter and all of inputs in that parent have been filled in then we need to transform the filter
|
|
37
|
+
if(input.parentNode.closest('[data-filter-text]')){
|
|
38
|
+
let parent = input.parentNode.closest('[data-filter-text]');
|
|
39
|
+
let allValuesSet = true;
|
|
40
|
+
inputName = "";
|
|
41
|
+
|
|
42
|
+
parent.querySelectorAll('input').forEach((element,index) => {
|
|
43
|
+
|
|
44
|
+
let name = element.getAttribute('name');
|
|
45
|
+
|
|
46
|
+
// create a joined inputname for the parent filter
|
|
47
|
+
inputName += `${index!=0?',':''}${name}`;
|
|
48
|
+
|
|
49
|
+
if(filters.querySelector(`[data-name="${name}"]`))
|
|
50
|
+
filters.querySelector(`[data-name="${name}"]`).remove();
|
|
51
|
+
|
|
52
|
+
if(element.value){
|
|
53
|
+
|
|
54
|
+
let childFilter = document.createElement('button');
|
|
55
|
+
childFilter.setAttribute('type','button')
|
|
56
|
+
childFilter.classList.add('filter');
|
|
57
|
+
childFilter.setAttribute('data-name',name);
|
|
58
|
+
childFilter.innerHTML = filterText.replace('$value', element.value);
|
|
59
|
+
filters.appendChild(childFilter);
|
|
60
|
+
}
|
|
61
|
+
else
|
|
62
|
+
allValuesSet = false;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if(filters.querySelector(`[data-name="${inputName}"]`))
|
|
66
|
+
filters.querySelector(`[data-name="${inputName}"]`).remove();
|
|
67
|
+
|
|
68
|
+
if(allValuesSet){
|
|
69
|
+
|
|
70
|
+
let newFilterText = parent.getAttribute('data-filter-text');
|
|
71
|
+
parent.querySelectorAll('input').forEach((element,index) => {
|
|
72
|
+
|
|
73
|
+
let name = element.getAttribute('name');
|
|
74
|
+
|
|
75
|
+
// Remove all the child filter tags
|
|
76
|
+
if(filters.querySelector(`[data-name="${name}"]`))
|
|
77
|
+
filters.querySelector(`[data-name="${name}"]`).remove();
|
|
78
|
+
|
|
79
|
+
newFilterText = newFilterText.replace(`$${index+1}`,element.value);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
let parentFilter = document.createElement('button');
|
|
83
|
+
parentFilter.setAttribute('type','button')
|
|
84
|
+
parentFilter.classList.add('filter');
|
|
85
|
+
parentFilter.setAttribute('data-name',inputName);
|
|
86
|
+
parentFilter.innerHTML = newFilterText;
|
|
87
|
+
filters.appendChild(parentFilter);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// check for inputs on load
|
|
96
|
+
Array.from(container.querySelectorAll('input[type="checkbox"]:checked')).forEach((input, index) => {
|
|
97
|
+
addFilterButton(filters, input)
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
container.addEventListener('change', function(event){
|
|
101
|
+
|
|
102
|
+
if (event && event.target instanceof HTMLElement && event.target.closest('input[data-filter-text]')){
|
|
103
|
+
|
|
104
|
+
let input = event.target.closest('input[data-filter-text]');
|
|
105
|
+
|
|
106
|
+
addFilterButton (filters, input)
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
}, false);
|
|
110
|
+
|
|
111
|
+
filters.addEventListener('click', function(event){
|
|
112
|
+
|
|
113
|
+
if (event && event.target instanceof HTMLElement && event.target.closest('.filter')){
|
|
114
|
+
let filter = event.target.closest('.filter');
|
|
115
|
+
let names = filter.getAttribute('data-name').split(',')
|
|
116
|
+
|
|
117
|
+
for(var t=0;t<names.length;t++){
|
|
118
|
+
let name = names[t];
|
|
119
|
+
let selector = `[name="${name}"]`;
|
|
120
|
+
|
|
121
|
+
if(name.match(/\[(.*)\]/)){
|
|
122
|
+
let newName = name.replace(/\[(.*)\]/,`[]`);
|
|
123
|
+
let value = name.replace(/.*\[(.*)\]/,`$1`);
|
|
124
|
+
selector = `[name="${newName}"][value="${value}"]`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let inputs = container.querySelectorAll(selector);
|
|
128
|
+
for(var i=0;i<inputs.length;i++){
|
|
129
|
+
let input = inputs[i];
|
|
130
|
+
|
|
131
|
+
if(input.getAttribute('type') != 'radio' && input.getAttribute('type') != 'checkbox')
|
|
132
|
+
inputs[i].value = "";
|
|
133
|
+
|
|
134
|
+
inputs[i].checked = false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
filter.remove();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}, false);
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export default createAppliedFilters;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
type WindowWithDataLayer = Window & {
|
|
2
|
+
dataLayer: Record<string, any>[];
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
declare const window: WindowWithDataLayer;
|
|
6
|
+
|
|
7
|
+
function createDataLayer () {
|
|
8
|
+
|
|
9
|
+
window.dataLayer = window.dataLayer || [];
|
|
10
|
+
window.dataLayer.push({
|
|
11
|
+
"event": "Pageview",
|
|
12
|
+
"pageTitle": document.title
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Global events to track
|
|
16
|
+
document.addEventListener('click', (event) => {
|
|
17
|
+
|
|
18
|
+
if (event && event.target instanceof HTMLElement && event.target.closest('[open] summary')){
|
|
19
|
+
window.dataLayer.push({
|
|
20
|
+
"event": "closeDetails",
|
|
21
|
+
// @ts-ignore: Object is possibly 'null'.
|
|
22
|
+
"detailsTitle": event.target.closest('summary').textContent
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else if (event && event.target instanceof HTMLElement && event.target.closest('summary')){
|
|
26
|
+
|
|
27
|
+
window.dataLayer.push({
|
|
28
|
+
"event": "openDetails",
|
|
29
|
+
// @ts-ignore: Object is possibly 'null'.
|
|
30
|
+
"detailsTitle": event.target.closest('summary').textContent
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (event && event.target instanceof HTMLElement && event.target.closest('a')){
|
|
35
|
+
window.dataLayer.push({
|
|
36
|
+
"event": "linkClicked",
|
|
37
|
+
// @ts-ignore: Object is possibly 'null'.
|
|
38
|
+
"linkText": event.target.closest('a').hasAttribute('title') ? event.target.closest('a').getAttribute('title') : event.target.closest('a').textContent,
|
|
39
|
+
// @ts-ignore: Object is possibly 'null'.
|
|
40
|
+
"class": (event.target.closest('a').hasAttribute('class') ? event.target.closest('a').getAttribute('class') : ''),
|
|
41
|
+
// @ts-ignore: Object is possibly 'null'.
|
|
42
|
+
"href": event.target.closest('a').getAttribute('href')
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (event && event.target instanceof HTMLElement && event.target.closest('button')){
|
|
46
|
+
window.dataLayer.push({
|
|
47
|
+
"event": "buttonClicked",
|
|
48
|
+
// @ts-ignore: Object is possibly 'null'.
|
|
49
|
+
"buttonText": event.target.closest('button').textContent,
|
|
50
|
+
// @ts-ignore: Object is possibly 'null'.
|
|
51
|
+
"class": (event.target.closest('button').hasAttribute('class') ? event.target.closest('button').getAttribute('class') : '')
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default createDataLayer;
|