@ons/design-system 67.2.0 → 68.0.1
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 +6 -0
- package/components/access-code/_macro.njk +1 -1
- package/components/access-code/_macro.spec.js +2 -10
- package/components/access-code/access-code.dom.js +1 -1
- package/components/access-code/access-code.spec.js +2 -2
- package/components/access-code/example-access-code-error.njk +9 -14
- package/components/access-code/example-access-code.njk +3 -5
- package/components/accordion/accordion.js +4 -4
- package/components/address-input/_macro.spec.js +3 -15
- package/components/address-input/autosuggest.address.dom.js +1 -1
- package/components/address-input/autosuggest.address.js +3 -2
- package/components/address-input/autosuggest.address.setter.js +3 -3
- package/components/address-input/autosuggest.address.spec.js +66 -69
- package/components/address-output/_macro.spec.js +6 -30
- package/components/autosuggest/_autosuggest.scss +1 -1
- package/components/autosuggest/autosuggest.dom.js +1 -1
- package/components/autosuggest/autosuggest.helpers.js +1 -1
- package/components/back-to-top/_back-to-top.scss +34 -0
- package/components/back-to-top/_macro.njk +17 -0
- package/components/back-to-top/_macro.spec.js +60 -0
- package/components/back-to-top/back-to-top.dom.js +12 -0
- package/components/back-to-top/back-to-top.js +58 -0
- package/components/back-to-top/back-to-top.spec.js +117 -0
- package/components/back-to-top/example-back-to-top.njk +37 -0
- package/components/back-to-top/example-full-page-back-to-top.njk +192 -0
- package/components/browser-banner/_macro.spec.js +4 -12
- package/components/button/_macro.njk +6 -6
- package/components/button/_macro.spec.js +1 -5
- package/components/button/button.js +7 -8
- package/components/button/button.spec.js +17 -39
- package/components/call-to-action/_macro.spec.js +2 -6
- package/components/card/_macro.njk +25 -25
- package/components/card/_macro.spec.js +10 -34
- package/components/char-check-limit/_macro.njk +1 -1
- package/components/char-check-limit/_macro.spec.js +3 -7
- package/components/char-check-limit/character-check.spec.js +24 -20
- package/components/checkboxes/_checkbox-macro.njk +1 -1
- package/components/checkboxes/_checkbox.scss +0 -3
- package/components/checkboxes/_macro.spec.js +1 -5
- package/components/checkboxes/checkbox-with-autoselect.js +3 -3
- package/components/checkboxes/checkbox-with-fieldset.js +2 -2
- package/components/checkboxes/checkboxes-with-reveal.js +4 -2
- package/components/checkboxes/checkboxes.dom.js +2 -2
- package/components/checkboxes/checkboxes.spec.js +13 -13
- package/components/content-pagination/_macro.spec.js +2 -2
- package/components/cookies-banner/cookies-banner.dom.js +1 -1
- package/components/cookies-banner/cookies-banner.js +1 -1
- package/components/cookies-banner/cookies-banner.spec.js +7 -7
- package/components/date-input/_macro.njk +71 -69
- package/components/date-input/_macro.spec.js +20 -5
- package/components/date-input/example-date-input-double-field.njk +27 -0
- package/components/date-input/example-date-input-single-field.njk +18 -0
- package/components/details/details.spec.js +12 -12
- package/components/details/example-details-with-warning.njk +5 -7
- package/components/document-list/_macro.spec.js +9 -27
- package/components/document-list/document-list.scss +1 -1
- package/components/document-list/example-document-list-downloads.njk +3 -3
- package/components/document-list/example-document-list-search-result-featured.njk +1 -1
- package/components/document-list/example-document-list-search-results.njk +3 -3
- package/components/download-resources/download-resources.js +54 -54
- package/components/download-resources/download-resources.spec.js +3 -1
- package/components/duration/_macro.njk +52 -48
- package/components/duration/_macro.spec.js +112 -4
- package/components/duration/example-duration-error-for-single-field.njk +1 -1
- package/components/duration/example-duration-single-field.njk +24 -0
- package/components/error/_macro.njk +1 -1
- package/components/error/_macro.spec.js +2 -6
- package/components/feedback/_macro.njk +1 -1
- package/components/feedback/_macro.spec.js +4 -20
- package/components/field/_field-group.scss +3 -4
- package/components/field/_macro.spec.js +1 -3
- package/components/fieldset/_fieldset.scss +1 -2
- package/components/fieldset/_macro.spec.js +3 -9
- package/components/footer/_footer.scss +8 -0
- package/components/footer/_macro.njk +8 -7
- package/components/footer/_macro.spec.js +14 -2
- package/components/header/_macro.njk +1 -1
- package/components/header/_macro.spec.js +1 -1
- package/components/helpers/grid.njk +15 -15
- package/components/icon/_macro.njk +17 -13
- package/components/icon/_macro.spec.js +8 -16
- package/components/image/_macro.spec.js +1 -5
- package/components/input/_macro.njk +22 -23
- package/components/input/_macro.spec.js +1 -1
- package/components/input/character-check.dom.js +1 -1
- package/components/input/input.spec.js +1 -4
- package/components/label/_label.scss +1 -0
- package/components/label/_macro.njk +3 -3
- package/components/label/_macro.spec.js +4 -13
- package/components/list/_macro.spec.js +4 -12
- package/components/message/_macro.njk +17 -17
- package/components/message/_macro.spec.js +9 -33
- package/components/message-list/_macro.spec.js +7 -39
- package/components/metadata/_macro.njk +10 -10
- package/components/modal/_macro.spec.js +3 -9
- package/components/modal/modal.dom.js +1 -1
- package/components/modal/modal.spec.js +5 -5
- package/components/multiple-input-fields/_macro.njk +49 -0
- package/components/mutually-exclusive/_macro.spec.js +2 -10
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +26 -26
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +128 -14
- package/components/mutually-exclusive/mutually-exclusive.dom.js +1 -1
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +129 -8
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +7 -7
- package/components/mutually-exclusive/mutually-exclusive.js +13 -13
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +29 -29
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +7 -7
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +8 -8
- package/components/navigation/navigation.spec.js +0 -2
- package/components/pagination/_macro.spec.js +11 -53
- package/components/panel/_macro.njk +17 -17
- package/components/panel/_macro.spec.js +25 -25
- package/components/panel/_panel.scss +10 -9
- package/components/panel/example-panel-bare.njk +3 -4
- package/components/panel/example-panel-with-announcement.njk +6 -10
- package/components/panel/example-panel-with-error-summary.njk +2 -2
- package/components/panel/example-panel-with-information.njk +0 -1
- package/components/panel/example-panel-with-success-message.njk +1 -1
- package/components/panel/example-panel-with-warning.njk +2 -3
- package/components/password/password.dom.js +1 -1
- package/components/phase-banner/_macro.spec.js +3 -9
- package/components/question/_macro.njk +1 -1
- package/components/question/_macro.spec.js +5 -19
- package/components/question/_question.scss +1 -4
- package/components/question/example-question-interviewer-note.njk +1 -1
- package/components/quote/_macro.spec.js +2 -10
- package/components/radios/clear-radios.js +3 -3
- package/components/radios/radio-with-fieldset.js +4 -4
- package/components/radios/radios.dom.js +1 -1
- package/components/radios/radios.spec.js +26 -26
- package/components/related-content/_macro.spec.js +2 -4
- package/components/related-content/_section-macro.spec.js +2 -8
- package/components/relationships/example-relationships-error.njk +16 -18
- package/components/relationships/relationships.dom.js +1 -1
- package/components/relationships/relationships.js +2 -2
- package/components/reply/_macro.spec.js +3 -3
- package/components/reply/reply.dom.js +1 -1
- package/components/reply/reply.spec.js +3 -3
- package/components/section-navigation/_macro.njk +12 -12
- package/components/section-navigation/_macro.spec.js +13 -21
- package/components/select/_macro.spec.js +6 -6
- package/components/share-page/_macro.spec.js +6 -14
- package/components/skip-to-content/_macro.spec.js +3 -11
- package/components/skip-to-content/skip-to-content.dom.js +1 -1
- package/components/skip-to-content/skip-to-content.js +1 -1
- package/components/skip-to-content/skip-to-content.spec.js +2 -2
- package/components/status/_macro.njk +2 -2
- package/components/status/_macro.spec.js +5 -9
- package/components/status/example-status-dead.njk +1 -1
- package/components/status/example-status-error.njk +1 -1
- package/components/status/example-status-pending.njk +1 -1
- package/components/status/example-status-small.njk +1 -1
- package/components/status/example-status-success.njk +1 -1
- package/components/summary/_macro.njk +7 -8
- package/components/summary/_macro.spec.js +27 -9
- package/components/table/_macro.spec.js +6 -10
- package/components/table/scrollable-table.dom.js +1 -1
- package/components/table/scrollable-table.js +1 -1
- package/components/table/sortable-table.js +4 -4
- package/components/table/table.spec.js +21 -17
- package/components/table-of-contents/_macro.njk +31 -31
- package/components/table-of-contents/_macro.spec.js +3 -11
- package/components/table-of-contents/toc.dom.js +1 -1
- package/components/table-of-contents/toc.spec.js +36 -32
- package/components/tabs/example-tabs-details.njk +1 -1
- package/components/tabs/tabs.dom.js +1 -1
- package/components/tabs/tabs.js +8 -8
- package/components/text-indent/_macro.spec.js +2 -6
- package/components/textarea/textarea.dom.js +1 -1
- package/components/textarea/textarea.spec.js +8 -8
- package/components/timeout-modal/_macro.spec.js +1 -3
- package/components/timeout-modal/timeout-modal.dom.js +1 -1
- package/components/timeout-modal/timeout-modal.spec.js +10 -10
- package/components/timeout-panel/_macro.njk +16 -17
- package/components/timeout-panel/_macro.spec.js +1 -1
- package/components/timeout-panel/timeout-panel.dom.js +1 -1
- package/components/timeout-panel/timeout-panel.spec.js +8 -8
- package/components/video/_macro.spec.js +1 -5
- package/components/video/video.dom.js +1 -1
- package/components/video/video.spec.js +16 -12
- package/css/main.css +1 -1
- package/favicons/safari-pinned-tab.svg +23 -23
- package/js/analytics.js +15 -14
- package/js/cookies-settings.dom.js +1 -1
- package/js/cookies-settings.spec.js +19 -19
- package/js/domready.js +1 -1
- package/js/fetch.js +1 -1
- package/js/inpagelink.js +3 -3
- package/js/main.js +1 -0
- package/js/print-button.js +1 -1
- package/js/timeout.js +1 -1
- package/package.json +2 -1
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/base/_typography.scss +8 -2
- package/scss/main.scss +1 -0
- package/scss/overrides/hcm.scss +8 -1
- package/scss/vars/_colors.scss +2 -1
- package/components/date-field-input/_macro.njk +0 -86
|
@@ -5,19 +5,19 @@ function Util() {}
|
|
|
5
5
|
Class manipulation functions
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
Util.hasClass = function(el, className) {
|
|
8
|
+
Util.hasClass = function (el, className) {
|
|
9
9
|
if (el.classList) return el.classList.contains(className);
|
|
10
10
|
else return !!el.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'));
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
Util.addClass = function(el, className) {
|
|
13
|
+
Util.addClass = function (el, className) {
|
|
14
14
|
let classList = className.split(' ');
|
|
15
15
|
if (el.classList) el.classList.add(classList[0]);
|
|
16
16
|
else if (!Util.hasClass(el, classList[0])) el.className += ' ' + classList[0];
|
|
17
17
|
if (classList.length > 1) Util.addClass(el, classList.slice(1).join(' '));
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
Util.removeClass = function(el, className) {
|
|
20
|
+
Util.removeClass = function (el, className) {
|
|
21
21
|
let classList = className.split(' ');
|
|
22
22
|
if (el.classList) el.classList.remove(classList[0]);
|
|
23
23
|
else if (Util.hasClass(el, classList[0])) {
|
|
@@ -27,12 +27,12 @@ Util.removeClass = function(el, className) {
|
|
|
27
27
|
if (classList.length > 1) Util.removeClass(el, classList.slice(1).join(' '));
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
Util.toggleClass = function(el, className, bool) {
|
|
30
|
+
Util.toggleClass = function (el, className, bool) {
|
|
31
31
|
if (bool) Util.addClass(el, className);
|
|
32
32
|
else Util.removeClass(el, className);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
Util.setAttributes = function(el, attrs) {
|
|
35
|
+
Util.setAttributes = function (el, attrs) {
|
|
36
36
|
for (let key in attrs) {
|
|
37
37
|
el.setAttribute(key, attrs[key]);
|
|
38
38
|
}
|
|
@@ -42,7 +42,7 @@ Util.setAttributes = function(el, attrs) {
|
|
|
42
42
|
DOM manipulation
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
|
-
Util.getChildrenByClassName = function(el, className) {
|
|
45
|
+
Util.getChildrenByClassName = function (el, className) {
|
|
46
46
|
let childrenByClass = [];
|
|
47
47
|
for (let i = 0; i < el.children.length; i++) {
|
|
48
48
|
if (Util.hasClass(el.children[i], className)) childrenByClass.push(el.children[i]);
|
|
@@ -50,7 +50,7 @@ Util.getChildrenByClassName = function(el, className) {
|
|
|
50
50
|
return childrenByClass;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
Util.is = function(elem, selector) {
|
|
53
|
+
Util.is = function (elem, selector) {
|
|
54
54
|
if (selector.nodeType) {
|
|
55
55
|
return elem === selector;
|
|
56
56
|
}
|
|
@@ -68,11 +68,11 @@ Util.is = function(elem, selector) {
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
// Animate height of an element
|
|
71
|
-
Util.setHeight = function(start, to, element, duration, cb) {
|
|
71
|
+
Util.setHeight = function (start, to, element, duration, cb) {
|
|
72
72
|
let change = to - start,
|
|
73
73
|
currentTime = null;
|
|
74
74
|
|
|
75
|
-
let animateHeight = function(timestamp) {
|
|
75
|
+
let animateHeight = function (timestamp) {
|
|
76
76
|
if (!currentTime) currentTime = timestamp;
|
|
77
77
|
let progress = timestamp - currentTime;
|
|
78
78
|
let val = parseInt((progress / duration) * change + start);
|
|
@@ -90,14 +90,14 @@ Util.setHeight = function(start, to, element, duration, cb) {
|
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
// Smooth Scroll
|
|
93
|
-
Util.scrollTo = function(final, duration, cb, scrollEl) {
|
|
93
|
+
Util.scrollTo = function (final, duration, cb, scrollEl) {
|
|
94
94
|
let element = scrollEl || window;
|
|
95
95
|
let start = element.scrollTop || document.documentElement.scrollTop,
|
|
96
96
|
currentTime = null;
|
|
97
97
|
|
|
98
98
|
if (!scrollEl) start = window.scrollY || document.documentElement.scrollTop;
|
|
99
99
|
|
|
100
|
-
let animateScroll = function(timestamp) {
|
|
100
|
+
let animateScroll = function (timestamp) {
|
|
101
101
|
if (!currentTime) currentTime = timestamp;
|
|
102
102
|
let progress = timestamp - currentTime;
|
|
103
103
|
if (progress > duration) progress = duration;
|
|
@@ -118,7 +118,7 @@ Util.scrollTo = function(final, duration, cb, scrollEl) {
|
|
|
118
118
|
*/
|
|
119
119
|
|
|
120
120
|
// Move focus to an element
|
|
121
|
-
Util.moveFocus = function(element) {
|
|
121
|
+
Util.moveFocus = function (element) {
|
|
122
122
|
if (!element) element = document.getElementsByTagName('body')[0];
|
|
123
123
|
element.focus();
|
|
124
124
|
if (document.activeElement !== element) {
|
|
@@ -128,15 +128,15 @@ Util.moveFocus = function(element) {
|
|
|
128
128
|
};
|
|
129
129
|
|
|
130
130
|
// Misc
|
|
131
|
-
Util.getIndexInArray = function(array, el) {
|
|
131
|
+
Util.getIndexInArray = function (array, el) {
|
|
132
132
|
return Array.prototype.indexOf.call(array, el);
|
|
133
133
|
};
|
|
134
134
|
|
|
135
|
-
Util.cssSupports = function(property, value) {
|
|
135
|
+
Util.cssSupports = function (property, value) {
|
|
136
136
|
if ('CSS' in window) {
|
|
137
137
|
return CSS.supports(property, value);
|
|
138
138
|
} else {
|
|
139
|
-
let jsProperty = property.replace(/-([a-z])/g, function(g) {
|
|
139
|
+
let jsProperty = property.replace(/-([a-z])/g, function (g) {
|
|
140
140
|
return g[1].toUpperCase();
|
|
141
141
|
});
|
|
142
142
|
return jsProperty in document.body.style;
|
|
@@ -146,7 +146,7 @@ Util.cssSupports = function(property, value) {
|
|
|
146
146
|
// Merge a set of user options into plugin defaults
|
|
147
147
|
// https://gomakethings.com/vanilla-javascript-version-of-jquery-extend/
|
|
148
148
|
|
|
149
|
-
Util.extend = function() {
|
|
149
|
+
Util.extend = function () {
|
|
150
150
|
// Variables
|
|
151
151
|
let extended = {};
|
|
152
152
|
let deep = false;
|
|
@@ -160,7 +160,7 @@ Util.extend = function() {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
// Merge the object into the extended object
|
|
163
|
-
let merge = function(obj) {
|
|
163
|
+
let merge = function (obj) {
|
|
164
164
|
for (let prop in obj) {
|
|
165
165
|
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
166
166
|
// If deep merge and property is an object, merge properties
|
|
@@ -183,7 +183,7 @@ Util.extend = function() {
|
|
|
183
183
|
};
|
|
184
184
|
|
|
185
185
|
// Check if Reduced Motion is enabled
|
|
186
|
-
Util.osHasReducedMotion = function() {
|
|
186
|
+
Util.osHasReducedMotion = function () {
|
|
187
187
|
if (!window.matchMedia) return false;
|
|
188
188
|
let matchMediaObj = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
189
189
|
if (matchMediaObj) return matchMediaObj.matches;
|
|
@@ -191,7 +191,7 @@ Util.osHasReducedMotion = function() {
|
|
|
191
191
|
};
|
|
192
192
|
|
|
193
193
|
/*
|
|
194
|
-
|
|
194
|
+
Polyfills
|
|
195
195
|
*/
|
|
196
196
|
|
|
197
197
|
// Closest() method
|
|
@@ -200,7 +200,7 @@ if (!Element.prototype.matches) {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
if (!Element.prototype.closest) {
|
|
203
|
-
Element.prototype.closest = function(s) {
|
|
203
|
+
Element.prototype.closest = function (s) {
|
|
204
204
|
let el = this;
|
|
205
205
|
if (!document.documentElement.contains(el)) return null;
|
|
206
206
|
do {
|
|
@@ -226,10 +226,10 @@ if (typeof window.CustomEvent !== 'function') {
|
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
/*
|
|
229
|
-
|
|
229
|
+
Animation curves
|
|
230
230
|
*/
|
|
231
231
|
|
|
232
|
-
Math.easeInOutQuad = function(t, b, c, d) {
|
|
232
|
+
Math.easeInOutQuad = function (t, b, c, d) {
|
|
233
233
|
t /= d / 2;
|
|
234
234
|
if (t < 1) return (c / 2) * t * t + b;
|
|
235
235
|
t--;
|
|
@@ -238,8 +238,8 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
238
238
|
|
|
239
239
|
// FILTERS
|
|
240
240
|
|
|
241
|
-
(function() {
|
|
242
|
-
let Filter = function(opts) {
|
|
241
|
+
(function () {
|
|
242
|
+
let Filter = function (opts) {
|
|
243
243
|
this.options = Util.extend(Filter.defaults, opts); // Used to store custom filter/sort functions
|
|
244
244
|
this.element = this.options.element;
|
|
245
245
|
this.elementId = this.element.getAttribute('id');
|
|
@@ -285,8 +285,8 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
285
285
|
filter.filterString[i] = ''; // Reset filtering
|
|
286
286
|
|
|
287
287
|
// Get proper filter/sorting string based on selected controllers
|
|
288
|
-
(function(i) {
|
|
289
|
-
filter.controllers[i].addEventListener('change', function(event) {
|
|
288
|
+
(function (i) {
|
|
289
|
+
filter.controllers[i].addEventListener('change', function (event) {
|
|
290
290
|
if (event.target.tagName.toLowerCase() == 'select') {
|
|
291
291
|
// Select elements
|
|
292
292
|
!event.target.getAttribute('data-filter')
|
|
@@ -310,7 +310,7 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
310
310
|
updateFilterArray(filter);
|
|
311
311
|
});
|
|
312
312
|
|
|
313
|
-
filter.controllers[i].addEventListener('click', function(event) {
|
|
313
|
+
filter.controllers[i].addEventListener('click', function (event) {
|
|
314
314
|
// Return if target is select/input elements
|
|
315
315
|
let filterEl = event.target.closest('[data-filter]');
|
|
316
316
|
let sortEl = event.target.closest('[data-sort]');
|
|
@@ -330,9 +330,9 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
// Handle resize - update grid coordinates in filter.itemsGrid
|
|
333
|
-
window.addEventListener('resize', function() {
|
|
333
|
+
window.addEventListener('resize', function () {
|
|
334
334
|
clearTimeout(filter.resizingId);
|
|
335
|
-
filter.resizingId = setTimeout(function() {
|
|
335
|
+
filter.resizingId = setTimeout(function () {
|
|
336
336
|
createGridInfo(filter);
|
|
337
337
|
}, 300);
|
|
338
338
|
});
|
|
@@ -341,7 +341,7 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
341
341
|
checkInitialFiltering(filter);
|
|
342
342
|
|
|
343
343
|
// Reset filtering results if filter selection was changed by an external control (e.g., form reset)
|
|
344
|
-
filter.element.addEventListener('update-filter-results', function() {
|
|
344
|
+
filter.element.addEventListener('update-filter-results', function () {
|
|
345
345
|
// Reset filters first
|
|
346
346
|
for (let i = 0; i < filter.controllers.length; i++) filter.filterString[i] = '';
|
|
347
347
|
filter.sortingString = '';
|
|
@@ -478,7 +478,7 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
478
478
|
// Custom sort function -> user takes care of it
|
|
479
479
|
filter.sortingList = filter.options[sortOptions[0]](filter.sortingList);
|
|
480
480
|
} else {
|
|
481
|
-
filter.sortingList.sort(function(left, right) {
|
|
481
|
+
filter.sortingList.sort(function (left, right) {
|
|
482
482
|
let leftVal = left[0].getAttribute('data-sort-' + sortOptions[0]),
|
|
483
483
|
rightVal = right[0].getAttribute('data-sort-' + sortOptions[0]);
|
|
484
484
|
if (sortOptions[2] == 'number') {
|
|
@@ -596,7 +596,7 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
596
596
|
}
|
|
597
597
|
}
|
|
598
598
|
|
|
599
|
-
setTimeout(function() {
|
|
599
|
+
setTimeout(function () {
|
|
600
600
|
for (let i = 0; i < filter.items.length; i++) {
|
|
601
601
|
if (filter.filterList[i] && filter.items[i].getAttribute('data-scale') == 'on') {
|
|
602
602
|
// Scale up item
|
|
@@ -635,7 +635,7 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
635
635
|
}, 50);
|
|
636
636
|
|
|
637
637
|
// Wait for the end of transition of visible elements
|
|
638
|
-
setTimeout(function() {
|
|
638
|
+
setTimeout(function () {
|
|
639
639
|
resetItems(filter);
|
|
640
640
|
}, filter.options.duration + 100);
|
|
641
641
|
}
|
|
@@ -688,12 +688,12 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
688
688
|
// Get offset first visible element
|
|
689
689
|
for (let i = 0; i < filter.items.length; i++) {
|
|
690
690
|
if (!Util.hasClass(filter.items[i], 'ons-u-hidden')) {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
691
|
+
itemStyle = window.getComputedStyle(filter.items[i]);
|
|
692
|
+
itemWidth = parseFloat(itemStyle.getPropertyValue('width'));
|
|
693
|
+
itemHeight = parseFloat(itemStyle.getPropertyValue('height'));
|
|
694
|
+
marginX = parseFloat(itemStyle.getPropertyValue('margin-left')) + parseFloat(itemStyle.getPropertyValue('margin-right'));
|
|
695
|
+
marginY = parseFloat(itemStyle.getPropertyValue('margin-bottom')) + parseFloat(itemStyle.getPropertyValue('margin-top'));
|
|
696
|
+
colNumber = parseInt((containerWidth + marginX) / (itemWidth + marginX));
|
|
697
697
|
filter.itemsGrid[0] = [filter.items[i].offsetLeft, filter.items[i].offsetTop]; // Left, top
|
|
698
698
|
break;
|
|
699
699
|
}
|
|
@@ -774,14 +774,14 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
774
774
|
})();
|
|
775
775
|
|
|
776
776
|
// ADVANCED FILTERS
|
|
777
|
-
(function() {
|
|
777
|
+
(function () {
|
|
778
778
|
// The Adv Filter object is used to handle:
|
|
779
779
|
|
|
780
780
|
// - number of results
|
|
781
781
|
// - form reset
|
|
782
782
|
// - filtering sections label (to show a preview of the option selected by the users)
|
|
783
783
|
|
|
784
|
-
let AdvFilter = function(element) {
|
|
784
|
+
let AdvFilter = function (element) {
|
|
785
785
|
this.element = element;
|
|
786
786
|
this.form = document.getElementsByClassName('ons-js-adv-filter__form');
|
|
787
787
|
this.resultsList = this.element.getElementsByClassName('ons-js-adv-filter__gallery')[0];
|
|
@@ -794,15 +794,15 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
794
794
|
function initAdvFilter(filter) {
|
|
795
795
|
if (filter.form.length > 0) {
|
|
796
796
|
// Reset form
|
|
797
|
-
filter.form[0].addEventListener('reset', function() {
|
|
798
|
-
setTimeout(function() {
|
|
797
|
+
filter.form[0].addEventListener('reset', function () {
|
|
798
|
+
setTimeout(function () {
|
|
799
799
|
resetFilters(filter);
|
|
800
800
|
resetGallery(filter);
|
|
801
801
|
});
|
|
802
802
|
});
|
|
803
803
|
|
|
804
804
|
// Update section labels on form change
|
|
805
|
-
filter.form[0].addEventListener('change', function(event) {
|
|
805
|
+
filter.form[0].addEventListener('change', function (event) {
|
|
806
806
|
let section = event.target.closest('.ons-js-adv-filter__item');
|
|
807
807
|
if (section) resetSelection(filter, section);
|
|
808
808
|
else if (Util.is(event.target, '.ons-js-adv-filter__form')) {
|
|
@@ -815,7 +815,7 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
815
815
|
|
|
816
816
|
// Reset results count
|
|
817
817
|
if (filter.resultsCount.length > 0) {
|
|
818
|
-
filter.resultsList.addEventListener('filter-selection-updated', function() {
|
|
818
|
+
filter.resultsList.addEventListener('filter-selection-updated', function () {
|
|
819
819
|
updateResultsCount(filter);
|
|
820
820
|
});
|
|
821
821
|
}
|
|
@@ -960,7 +960,7 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
960
960
|
let advFilter = document.getElementsByClassName('ons-js-adv-filter');
|
|
961
961
|
if (advFilter.length > 0) {
|
|
962
962
|
for (let i = 0; i < advFilter.length; i++) {
|
|
963
|
-
(function(i) {
|
|
963
|
+
(function (i) {
|
|
964
964
|
new AdvFilter(advFilter[i]);
|
|
965
965
|
})(i);
|
|
966
966
|
}
|
|
@@ -978,7 +978,7 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
978
978
|
element: gallery,
|
|
979
979
|
|
|
980
980
|
// This is your gallery element
|
|
981
|
-
priceRange: function(items) {
|
|
981
|
+
priceRange: function (items) {
|
|
982
982
|
// This is the price custom function
|
|
983
983
|
let filteredArray = [],
|
|
984
984
|
minVal = document.getElementById('slider-min-value').value,
|
|
@@ -989,7 +989,7 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
989
989
|
}
|
|
990
990
|
return filteredArray;
|
|
991
991
|
},
|
|
992
|
-
indexValue: function(items) {
|
|
992
|
+
indexValue: function (items) {
|
|
993
993
|
// This is the index custom function
|
|
994
994
|
let filteredArray = [],
|
|
995
995
|
value = document.getElementById('index-value').value;
|
|
@@ -1004,7 +1004,7 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
1004
1004
|
})();
|
|
1005
1005
|
|
|
1006
1006
|
// TOGGLE FILTERS
|
|
1007
|
-
(function() {
|
|
1007
|
+
(function () {
|
|
1008
1008
|
let filters = document.getElementsByClassName('ons-js-adv-filter');
|
|
1009
1009
|
|
|
1010
1010
|
if (filters.length > 0) {
|
|
@@ -1017,25 +1017,25 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
1017
1017
|
let page = document.getElementsByClassName('ons-page')[0];
|
|
1018
1018
|
|
|
1019
1019
|
// Detect click on filters trigger
|
|
1020
|
-
filtersTrigger.addEventListener('click', function(event) {
|
|
1020
|
+
filtersTrigger.addEventListener('click', function (event) {
|
|
1021
1021
|
event.preventDefault();
|
|
1022
1022
|
toggleFilters(!Util.hasClass(filtersPanel, 'ons-adv-filter__panel--is-visible'));
|
|
1023
1023
|
});
|
|
1024
1024
|
|
|
1025
1025
|
// Detect click on update
|
|
1026
|
-
filtersShow.addEventListener('click', function(event) {
|
|
1026
|
+
filtersShow.addEventListener('click', function (event) {
|
|
1027
1027
|
event.preventDefault();
|
|
1028
1028
|
filtersTrigger.click();
|
|
1029
1029
|
});
|
|
1030
1030
|
|
|
1031
1031
|
// Detect click on close
|
|
1032
|
-
filtersClose.addEventListener('click', function(event) {
|
|
1032
|
+
filtersClose.addEventListener('click', function (event) {
|
|
1033
1033
|
event.preventDefault();
|
|
1034
1034
|
filtersTrigger.click();
|
|
1035
1035
|
});
|
|
1036
1036
|
|
|
1037
1037
|
// Listen for key events
|
|
1038
|
-
window.addEventListener('keyup', function(event) {
|
|
1038
|
+
window.addEventListener('keyup', function (event) {
|
|
1039
1039
|
// Listen for ESC key
|
|
1040
1040
|
if ((event.keyCode && event.keyCode == 27) || (event.key && event.key.toLowerCase() == 'escape')) {
|
|
1041
1041
|
// Close filter panel on mobile if open
|
|
@@ -1048,7 +1048,7 @@ Math.easeInOutQuad = function(t, b, c, d) {
|
|
|
1048
1048
|
// Listen for resize
|
|
1049
1049
|
let resizingId = false;
|
|
1050
1050
|
|
|
1051
|
-
window.addEventListener('resize', function() {
|
|
1051
|
+
window.addEventListener('resize', function () {
|
|
1052
1052
|
clearTimeout(resizingId);
|
|
1053
1053
|
resizingId = setTimeout(doneResizing, 500);
|
|
1054
1054
|
});
|
|
@@ -4,6 +4,7 @@ import { renderComponent, renderTemplate, setTestPage } from '../../tests/helper
|
|
|
4
4
|
|
|
5
5
|
const iPhoneX = KnownDevices['iPhone X'];
|
|
6
6
|
|
|
7
|
+
/* eslint-disable indent */
|
|
7
8
|
const EXAMPLE_PAGE = `
|
|
8
9
|
<div class="ons-page">
|
|
9
10
|
<div class="ons-js-adv-filter">
|
|
@@ -179,7 +180,8 @@ const EXAMPLE_PAGE = `
|
|
|
179
180
|
</div>
|
|
180
181
|
</div>
|
|
181
182
|
</div>
|
|
182
|
-
|
|
183
|
+
`;
|
|
184
|
+
/* eslint-enable indent */
|
|
183
185
|
|
|
184
186
|
const RENDERED_EXAMPLE_PAGE = renderTemplate(EXAMPLE_PAGE);
|
|
185
187
|
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
{% from "components/
|
|
1
|
+
{% from "components/multiple-input-fields/_macro.njk" import onsMultipleInputFields %}
|
|
2
|
+
{% from "components/input/_macro.njk" import onsInput %}
|
|
2
3
|
|
|
3
4
|
{% macro onsDuration(params) %}
|
|
5
|
+
{% set exclusiveClass = " ons-js-exclusive-group-item" if params.mutuallyExclusive else "" %}
|
|
4
6
|
{% set numberOfFields = 0 %}
|
|
7
|
+
|
|
5
8
|
{% if params.field1 %}
|
|
6
9
|
{% set numberOfFields = numberOfFields + 1 %}
|
|
7
10
|
{% endif %}
|
|
@@ -10,54 +13,55 @@
|
|
|
10
13
|
{% set numberOfFields = numberOfFields + 1 %}
|
|
11
14
|
{% endif %}
|
|
12
15
|
|
|
13
|
-
{% set fields
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
16
|
+
{% set fields %}
|
|
17
|
+
{% if params.field1 %}
|
|
18
|
+
{{ onsInput({
|
|
19
|
+
"id": params.field1.id,
|
|
20
|
+
"type": "number",
|
|
21
|
+
"name": params.field1.name,
|
|
22
|
+
"classes": (" ons-input--error" if (params.error and params.field1.error) or (numberOfFields > 1 and params.error and not params.field1.error and not params.field2.error) else "") + exclusiveClass | default(""),
|
|
23
|
+
"width": "2",
|
|
24
|
+
"attributes": params.field1.attributes,
|
|
25
|
+
"value": params.field1.value,
|
|
26
|
+
"suffix": {
|
|
27
|
+
"text": params.field1.suffix.text,
|
|
28
|
+
"title": params.field1.suffix.title,
|
|
29
|
+
"id": params.field1.suffix.id
|
|
30
|
+
},
|
|
31
|
+
"label": {
|
|
32
|
+
"text": params.legendOrLabel if numberOfFields < 2,
|
|
33
|
+
"description": params.description if numberOfFields < 2
|
|
34
|
+
},
|
|
35
|
+
"fieldId": params.id if numberOfFields < 2,
|
|
36
|
+
"error": params.error if numberOfFields < 2
|
|
37
|
+
}) }}
|
|
38
|
+
{% endif %}
|
|
36
39
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
40
|
+
{% if params.field2 %}
|
|
41
|
+
{{ onsInput({
|
|
42
|
+
"id": params.field2.id,
|
|
43
|
+
"type": "number",
|
|
44
|
+
"name": params.field2.name,
|
|
45
|
+
"classes": (" ons-input--error" if (params.error and params.field2.error) or (numberOfFields > 1 and params.error and not params.field1.error and not params.field2.error) else "") + exclusiveClass | default(""),
|
|
46
|
+
"width": "2",
|
|
47
|
+
"attributes": params.field2.attributes,
|
|
48
|
+
"value": params.field2.value,
|
|
49
|
+
"suffix": {
|
|
50
|
+
"text": params.field2.suffix.text,
|
|
51
|
+
"title": params.field2.suffix.title,
|
|
52
|
+
"id": params.field2.suffix.id
|
|
53
|
+
},
|
|
54
|
+
"label": {
|
|
55
|
+
"text": params.legendOrLabel if numberOfFields < 2,
|
|
56
|
+
"description": params.description if numberOfFields < 2
|
|
57
|
+
},
|
|
58
|
+
"fieldId": params.id if numberOfFields < 2,
|
|
59
|
+
"error": params.error if numberOfFields < 2
|
|
60
|
+
}) }}
|
|
61
|
+
{% endif %}
|
|
62
|
+
{% endset %}
|
|
63
|
+
|
|
64
|
+
{{ onsMultipleInputFields({
|
|
61
65
|
"id": params.id,
|
|
62
66
|
"legendOrLabel": params.legendOrLabel,
|
|
63
67
|
"description": params.description,
|