@ons/design-system 70.0.7 → 70.0.9
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 +11 -17
- package/components/access-code/_macro.njk +31 -25
- package/components/access-code/_macro.spec.js +145 -145
- package/components/access-code/access-code.dom.js +5 -5
- package/components/access-code/access-code.js +16 -16
- package/components/access-code/access-code.scss +22 -22
- package/components/access-code/access-code.spec.js +17 -17
- package/components/access-code/example-access-code-error.njk +49 -37
- package/components/access-code/example-access-code.njk +40 -30
- package/components/accordion/_macro.njk +7 -6
- package/components/accordion/_macro.spec.js +154 -154
- package/components/accordion/accordion.dom.js +10 -10
- package/components/accordion/accordion.js +50 -50
- package/components/accordion/accordion.spec.js +104 -104
- package/components/accordion/example-accordion-open.njk +0 -1
- package/components/address-input/_macro.njk +23 -11
- package/components/address-input/_macro.spec.js +420 -420
- package/components/address-input/autosuggest.address.dom.js +5 -5
- package/components/address-input/autosuggest.address.error.js +77 -77
- package/components/address-input/autosuggest.address.js +354 -359
- package/components/address-input/autosuggest.address.setter.js +95 -95
- package/components/address-input/autosuggest.address.spec.js +668 -651
- package/components/address-input/example-address-input-editable.njk +52 -50
- package/components/address-input/example-address-input-manual.njk +23 -21
- package/components/address-input/example-address-input.njk +40 -38
- package/components/address-output/_address-output.scss +3 -3
- package/components/address-output/_macro.njk +6 -6
- package/components/address-output/_macro.spec.js +84 -84
- package/components/autosuggest/_autosuggest.scss +114 -114
- package/components/autosuggest/_macro.njk +57 -37
- package/components/autosuggest/_macro.spec.js +255 -255
- package/components/autosuggest/autosuggest.dom.js +5 -5
- package/components/autosuggest/autosuggest.helpers.js +11 -11
- package/components/autosuggest/autosuggest.helpers.spec.js +73 -73
- package/components/autosuggest/autosuggest.js +20 -20
- package/components/autosuggest/autosuggest.spec.js +542 -536
- package/components/autosuggest/autosuggest.ui.js +478 -475
- package/components/autosuggest/example-autosuggest-country-multiple.njk +26 -26
- package/components/autosuggest/example-autosuggest-country.njk +24 -24
- package/components/autosuggest/fuse-config.js +17 -17
- package/components/back-to-top/_back-to-top.scss +27 -27
- package/components/back-to-top/_macro.spec.js +49 -49
- package/components/back-to-top/back-to-top.dom.js +5 -5
- package/components/back-to-top/back-to-top.js +52 -52
- package/components/back-to-top/back-to-top.spec.js +106 -106
- package/components/back-to-top/example-back-to-top.njk +183 -6
- package/components/back-to-top/example-full-page-back-to-top.njk +135 -123
- package/components/breadcrumbs/_breadcrumbs.scss +63 -65
- package/components/breadcrumbs/_macro.njk +12 -4
- package/components/breadcrumbs/_macro.spec.js +91 -91
- package/components/browser-banner/_browser-banner.scss +23 -23
- package/components/browser-banner/_macro.njk +6 -3
- package/components/browser-banner/_macro.spec.js +92 -92
- package/components/button/_button.scss +525 -491
- package/components/button/_macro.njk +63 -62
- package/components/button/_macro.spec.js +363 -363
- package/components/button/button.dom.js +15 -15
- package/components/button/button.js +53 -53
- package/components/button/button.spec.js +248 -240
- package/components/button/example-button-ghost.njk +1 -0
- package/components/call-to-action/_call-to-action.scss +5 -5
- package/components/call-to-action/_macro.njk +7 -5
- package/components/call-to-action/_macro.spec.js +28 -28
- package/components/call-to-action/example-call-to-action-default.njk +3 -2
- package/components/card/_card.scss +23 -23
- package/components/card/_macro.njk +26 -10
- package/components/card/_macro.spec.js +180 -180
- package/components/card/example-card-set-with-images.njk +31 -29
- package/components/card/example-card-set-with-lists.njk +58 -56
- package/components/card/example-card-set.njk +28 -26
- package/components/card/example-card.njk +9 -7
- package/components/char-check-limit/_macro.njk +1 -3
- package/components/char-check-limit/_macro.spec.js +48 -48
- package/components/char-check-limit/character-check.js +58 -58
- package/components/char-check-limit/character-check.spec.js +173 -173
- package/components/char-check-limit/character-limit.js +40 -40
- package/components/checkboxes/_checkbox-macro.njk +19 -15
- package/components/checkboxes/_checkbox-macro.spec.js +355 -355
- package/components/checkboxes/_checkbox.scss +180 -180
- package/components/checkboxes/_checkboxes.scss +37 -27
- package/components/checkboxes/_macro.njk +81 -72
- package/components/checkboxes/_macro.spec.js +261 -261
- package/components/checkboxes/checkbox-with-autoselect.js +32 -32
- package/components/checkboxes/checkbox-with-fieldset.js +21 -21
- package/components/checkboxes/checkboxes-with-reveal.js +10 -10
- package/components/checkboxes/checkboxes.dom.js +27 -27
- package/components/checkboxes/checkboxes.spec.js +183 -183
- package/components/checkboxes/example-checkboxes-disabled.njk +30 -30
- package/components/checkboxes/example-checkboxes-error.njk +0 -1
- package/components/checkboxes/example-checkboxes-with-descriptions.njk +7 -5
- package/components/checkboxes/example-checkboxes-with-hidden-label.njk +162 -170
- package/components/checkboxes/example-checkboxes-with-revealed-checkboxes-expanded.njk +81 -81
- package/components/checkboxes/example-checkboxes-with-revealed-checkboxes.njk +79 -79
- package/components/checkboxes/example-checkboxes-with-revealed-select-expanded.njk +7 -5
- package/components/checkboxes/example-checkboxes-with-revealed-select.njk +7 -5
- package/components/checkboxes/example-checkboxes-with-revealed-text-input-expanded.njk +7 -5
- package/components/checkboxes/example-checkboxes-with-revealed-text-input.njk +7 -5
- package/components/checkboxes/example-checkboxes-with-select-all-button.njk +7 -5
- package/components/checkboxes/example-checkboxes-with-visible-text-input.njk +7 -5
- package/components/checkboxes/example-checkboxes.njk +7 -5
- package/components/content-pagination/_content-pagination.scss +41 -41
- package/components/content-pagination/_macro.njk +34 -32
- package/components/content-pagination/_macro.spec.js +159 -159
- package/components/content-pagination/example-content-pagination.njk +17 -17
- package/components/cookies-banner/_cookies-banner.scss +22 -22
- package/components/cookies-banner/_macro.njk +19 -6
- package/components/cookies-banner/_macro.spec.js +177 -177
- package/components/cookies-banner/cookies-banner.dom.js +7 -7
- package/components/cookies-banner/cookies-banner.js +76 -76
- package/components/cookies-banner/cookies-banner.spec.js +72 -68
- package/components/cookies-banner/example-cookies-banner-cymraeg.njk +2 -1
- package/components/cookies-banner/example-cookies-banner.njk +3 -4
- package/components/date-input/_macro.njk +71 -63
- package/components/date-input/_macro.spec.js +338 -338
- package/components/date-input/example-date-input-error-for-single-field.njk +0 -1
- package/components/date-input/example-date-input-error.njk +0 -1
- package/components/description-list/_description-list.scss +23 -23
- package/components/description-list/_macro.njk +20 -11
- package/components/description-list/_macro.spec.js +144 -144
- package/components/details/_details.scss +109 -109
- package/components/details/_macro.njk +18 -11
- package/components/details/_macro.spec.js +132 -132
- package/components/details/details.dom.js +6 -6
- package/components/details/details.js +60 -60
- package/components/details/details.spec.js +106 -106
- package/components/details/example-details-with-warning.njk +15 -10
- package/components/document-list/_macro.njk +102 -93
- package/components/document-list/_macro.spec.js +444 -444
- package/components/document-list/document-list.scss +145 -149
- package/components/document-list/example-document-list-article-featured.njk +27 -25
- package/components/document-list/example-document-list-articles.njk +55 -53
- package/components/document-list/example-document-list-downloads.njk +49 -47
- package/components/document-list/example-document-list-search-result-featured.njk +19 -17
- package/components/document-list/example-document-list-search-results.njk +60 -58
- package/components/download-resources/_download-resources.scss +109 -108
- package/components/download-resources/download-resources.js +907 -900
- package/components/download-resources/download-resources.spec.js +461 -461
- package/components/duration/_macro.njk +61 -55
- package/components/duration/_macro.spec.js +291 -291
- package/components/duration/example-duration-error-for-single-field.njk +28 -26
- package/components/duration/example-duration-single-field.njk +23 -19
- package/components/duration/example-duration.njk +33 -29
- package/components/error/_macro.njk +8 -6
- package/components/error/_macro.spec.js +72 -72
- package/components/external-link/_external-link.scss +19 -19
- package/components/external-link/_macro.njk +7 -5
- package/components/external-link/_macro.spec.js +68 -68
- package/components/external-link/example-external-link.njk +9 -6
- package/components/feedback/_feedback.scss +31 -31
- package/components/feedback/_macro.njk +7 -5
- package/components/feedback/_macro.spec.js +72 -72
- package/components/field/_field-group.scss +10 -10
- package/components/field/_field.scss +16 -16
- package/components/field/_macro.njk +2 -2
- package/components/field/_macro.spec.js +80 -80
- package/components/fieldset/_fieldset.scss +27 -27
- package/components/fieldset/_macro.njk +23 -16
- package/components/fieldset/_macro.spec.js +161 -161
- package/components/footer/_footer.scss +45 -45
- package/components/footer/_macro.njk +28 -21
- package/components/footer/_macro.spec.js +452 -452
- package/components/footer/example-footer-cymraeg.njk +2 -1
- package/components/footer/example-footer-default.njk +3 -4
- package/components/footer/example-footer-transactional.njk +2 -1
- package/components/footer/example-footer-warning.njk +2 -1
- package/components/footer/example-footer-with-alternative-organisation.njk +2 -1
- package/components/footer/example-footer-with-coat-of-arms.njk +2 -1
- package/components/footer/example-footer-with-copyright.njk +2 -1
- package/components/footer/example-footer.njk +2 -1
- package/components/header/_header.scss +207 -202
- package/components/header/_macro.njk +183 -141
- package/components/header/_macro.spec.js +833 -829
- package/components/header/example-header-default.njk +2 -1
- package/components/header/example-header-external-for-survey-with-description.njk +2 -1
- package/components/header/example-header-external-for-surveys.njk +2 -1
- package/components/header/example-header-external-welsh.njk +7 -7
- package/components/header/example-header-external-with-navigation-and-search.njk +3 -2
- package/components/header/example-header-external-with-navigation.njk +2 -1
- package/components/header/example-header-external-with-service-links.njk +2 -1
- package/components/header/example-header-external-with-sub-navigation-removed.njk +2 -1
- package/components/header/example-header-external-with-sub-navigation.njk +3 -2
- package/components/header/example-header-internal.njk +2 -1
- package/components/header/example-header-multiple-logos.njk +2 -1
- package/components/header/{example-header-neutral-for-multicoloured-logo.njk → example-header-neutral.njk} +2 -1
- package/components/helpers/_grid.scss +4 -4
- package/components/helpers/grid.njk +17 -16
- package/components/hero/_hero.scss +48 -48
- package/components/hero/_macro.njk +6 -11
- package/components/hero/_macro.spec.js +59 -59
- package/components/hero/example-hero-dark.njk +2 -1
- package/components/hero/example-hero-default.njk +2 -1
- package/components/icon/_icon.scss +44 -44
- package/components/icon/_macro.njk +601 -168
- package/components/icon/_macro.spec.js +110 -110
- package/components/image/_image.scss +11 -11
- package/components/image/_macro.njk +7 -5
- package/components/image/_macro.spec.js +81 -81
- package/components/input/_input-type.scss +86 -89
- package/components/input/_input.scss +123 -124
- package/components/input/_macro.njk +114 -95
- package/components/input/_macro.spec.js +604 -604
- package/components/input/character-check.dom.js +5 -5
- package/components/input/example-input-search-with-character-check.njk +1 -1
- package/components/input/example-input-search-with-placeholder.njk +1 -1
- package/components/input/example-input-search.njk +1 -1
- package/components/input/input.dom.js +5 -5
- package/components/input/input.js +10 -10
- package/components/input/input.spec.js +18 -18
- package/components/label/_label.scss +24 -24
- package/components/label/_macro.njk +32 -26
- package/components/label/_macro.spec.js +173 -170
- package/components/language-selector/_macro.njk +11 -2
- package/components/language-selector/_macro.spec.js +97 -97
- package/components/language-selector/language.scss +7 -7
- package/components/list/_list.scss +110 -97
- package/components/list/_macro.njk +93 -73
- package/components/list/_macro.spec.js +583 -583
- package/components/message/_macro.njk +20 -7
- package/components/message/_macro.spec.js +74 -74
- package/components/message/_message.scss +39 -39
- package/components/message-list/_macro.njk +26 -20
- package/components/message-list/_macro.spec.js +86 -86
- package/components/message-list/_message-list.scss +16 -16
- package/components/modal/_macro.njk +11 -12
- package/components/modal/_macro.spec.js +69 -69
- package/components/modal/_modal.scss +36 -36
- package/components/modal/modal.dom.js +6 -6
- package/components/modal/modal.js +89 -89
- package/components/modal/modal.spec.js +50 -50
- package/components/multiple-input-fields/_macro.njk +30 -28
- package/components/mutually-exclusive/_macro.njk +20 -13
- package/components/mutually-exclusive/_macro.spec.js +140 -140
- package/components/mutually-exclusive/example-mutually-exclusive-checkboxes.njk +6 -4
- package/components/mutually-exclusive/example-mutually-exclusive-date.njk +7 -5
- package/components/mutually-exclusive/example-mutually-exclusive-duration.njk +44 -40
- package/components/mutually-exclusive/example-mutually-exclusive-email.njk +7 -5
- package/components/mutually-exclusive/example-mutually-exclusive-multiple-options.njk +6 -4
- package/components/mutually-exclusive/example-mutually-exclusive-number.njk +6 -4
- package/components/mutually-exclusive/example-mutually-exclusive-textarea.njk +6 -4
- package/components/mutually-exclusive/mutually-exclusive.checkboxes.spec.js +188 -188
- package/components/mutually-exclusive/mutually-exclusive.date.spec.js +211 -211
- package/components/mutually-exclusive/mutually-exclusive.dom.js +5 -5
- package/components/mutually-exclusive/mutually-exclusive.duration.spec.js +210 -210
- package/components/mutually-exclusive/mutually-exclusive.email.spec.js +90 -90
- package/components/mutually-exclusive/mutually-exclusive.js +137 -137
- package/components/mutually-exclusive/mutually-exclusive.multiple-options.checkboxes.spec.js +197 -197
- package/components/mutually-exclusive/mutually-exclusive.number.spec.js +96 -96
- package/components/mutually-exclusive/mutually-exclusive.textarea.spec.js +102 -102
- package/components/navigation/_macro.njk +133 -67
- package/components/navigation/_macro.spec.js +360 -354
- package/components/navigation/_navigation.scss +112 -122
- package/components/navigation/navigation.dom.js +35 -35
- package/components/navigation/navigation.js +49 -49
- package/components/navigation/navigation.spec.js +249 -249
- package/components/pagination/_macro.njk +42 -20
- package/components/pagination/_macro.spec.js +342 -335
- package/components/pagination/_pagination.scss +58 -58
- package/components/panel/_macro.njk +27 -16
- package/components/panel/_macro.spec.js +372 -372
- package/components/panel/_panel.scss +200 -199
- package/components/panel/example-panel-bare.njk +6 -4
- package/components/panel/example-panel-with-announcement.njk +7 -4
- package/components/panel/example-panel-with-error-summary.njk +6 -4
- package/components/panel/example-panel-with-warning.njk +5 -3
- package/components/password/_macro.njk +7 -5
- package/components/password/_macro.spec.js +95 -95
- package/components/password/password.dom.js +5 -5
- package/components/password/password.js +10 -10
- package/components/password/password.spec.js +26 -26
- package/components/phase-banner/_macro.njk +3 -3
- package/components/phase-banner/_macro.spec.js +86 -86
- package/components/phase-banner/_phase-banner.scss +16 -16
- package/components/phase-banner/example-phase-banner-alpha.njk +2 -1
- package/components/phase-banner/example-phase-banner-beta.njk +4 -3
- package/components/question/_macro.njk +62 -47
- package/components/question/_macro.spec.js +235 -235
- package/components/question/_question.scss +24 -24
- package/components/question/example-question-ccs.njk +40 -35
- package/components/question/example-question-fieldset.njk +84 -80
- package/components/question/example-question-interviewer-note.njk +27 -24
- package/components/question/example-question-no-fieldset.njk +39 -33
- package/components/quote/_macro.njk +3 -1
- package/components/quote/_macro.spec.js +52 -52
- package/components/quote/_quote.scss +24 -24
- package/components/radios/_macro.njk +54 -36
- package/components/radios/_macro.spec.js +545 -524
- package/components/radios/_radio.scss +49 -48
- package/components/radios/_radios.scss +14 -20
- package/components/radios/check-radios.js +21 -21
- package/components/radios/clear-radios.js +45 -45
- package/components/radios/example-radios-with-clear-button-expanded.njk +6 -4
- package/components/radios/example-radios-with-clear-button.njk +6 -4
- package/components/radios/example-radios-with-descriptions.njk +7 -5
- package/components/radios/example-radios-with-revealed-select-expanded.njk +6 -4
- package/components/radios/example-radios-with-revealed-select.njk +6 -4
- package/components/radios/example-radios-with-revealed-text-area-expanded.njk +7 -5
- package/components/radios/example-radios-with-revealed-text-area.njk +7 -5
- package/components/radios/example-radios-with-revealed-text-input-expanded.njk +7 -5
- package/components/radios/example-radios-with-revealed-text-input.njk +7 -5
- package/components/radios/example-radios-with-separator.njk +6 -4
- package/components/radios/example-radios-with-visible-text-input.njk +7 -5
- package/components/radios/example-radios-without-border.njk +0 -1
- package/components/radios/example-radios.njk +7 -5
- package/components/radios/radio-with-fieldset.js +22 -22
- package/components/radios/radios.dom.js +32 -32
- package/components/radios/radios.spec.js +251 -251
- package/components/related-content/_macro.njk +10 -11
- package/components/related-content/_macro.spec.js +109 -109
- package/components/related-content/_related-content.scss +12 -12
- package/components/related-content/_section-macro.njk +7 -7
- package/components/related-content/_section-macro.spec.js +20 -20
- package/components/related-content/example-related-content-general.njk +5 -3
- package/components/related-content/example-related-content-multiple-rows-of-links.njk +51 -49
- package/components/related-content/example-related-content-social-media.njk +40 -38
- package/components/relationships/_macro.njk +10 -8
- package/components/relationships/_macro.spec.js +94 -94
- package/components/relationships/_relationships.scss +9 -9
- package/components/relationships/example-relationships-error.njk +176 -168
- package/components/relationships/example-relationships-you.njk +169 -163
- package/components/relationships/example-relationships.njk +167 -161
- package/components/relationships/relationships.dom.js +5 -5
- package/components/relationships/relationships.js +18 -18
- package/components/relationships/relationships.spec.js +71 -71
- package/components/reply/_macro.spec.js +47 -47
- package/components/reply/reply-input.js +15 -15
- package/components/reply/reply.dom.js +5 -5
- package/components/reply/reply.spec.js +57 -57
- package/components/section-navigation/_macro.njk +34 -12
- package/components/section-navigation/_macro.spec.js +210 -210
- package/components/section-navigation/_section-navigation.scss +76 -76
- package/components/select/_macro.njk +21 -18
- package/components/select/_macro.spec.js +166 -166
- package/components/share-page/_macro.njk +10 -5
- package/components/share-page/_macro.spec.js +68 -68
- package/components/skip-to-content/_macro.njk +1 -1
- package/components/skip-to-content/_macro.spec.js +54 -54
- package/components/skip-to-content/_skip.scss +30 -30
- package/components/skip-to-content/example-skip-to-content.njk +1 -0
- package/components/skip-to-content/skip-to-content.dom.js +6 -6
- package/components/skip-to-content/skip-to-content.js +7 -7
- package/components/skip-to-content/skip-to-content.spec.js +21 -21
- package/components/status/_macro.njk +1 -1
- package/components/status/_macro.spec.js +53 -53
- package/components/status/_status.scss +32 -32
- package/components/summary/_macro.njk +53 -23
- package/components/summary/_macro.spec.js +551 -535
- package/components/summary/_summary.scss +191 -195
- package/components/summary/example-summary-household-no-rows.njk +18 -16
- package/components/summary/example-summary-household.njk +75 -73
- package/components/summary/example-summary-hub-minimal.njk +74 -72
- package/components/summary/example-summary-hub.njk +169 -167
- package/components/table/_macro.njk +72 -45
- package/components/table/_macro.spec.js +499 -499
- package/components/table/_table.scss +204 -201
- package/components/table/scrollable-table.dom.js +5 -5
- package/components/table/scrollable-table.js +60 -60
- package/components/table/sortable-table.dom.js +5 -5
- package/components/table/sortable-table.js +135 -135
- package/components/table/table.spec.js +144 -140
- package/components/table-of-contents/_macro.njk +34 -32
- package/components/table-of-contents/_macro.spec.js +125 -125
- package/components/table-of-contents/_toc.scss +9 -9
- package/components/table-of-contents/example-table-of-contents-grouped.njk +1 -1
- package/components/table-of-contents/example-table-of-contents-single.njk +1 -1
- package/components/table-of-contents/example-table-of-contents-sticky-full-page.njk +79 -38
- package/components/table-of-contents/example-table-of-contents-sticky.njk +50 -13
- package/components/table-of-contents/toc.dom.js +5 -5
- package/components/table-of-contents/toc.js +30 -30
- package/components/table-of-contents/toc.spec.js +88 -88
- package/components/tabs/_macro.njk +12 -6
- package/components/tabs/_macro.spec.js +92 -92
- package/components/tabs/_tabs.scss +120 -115
- package/components/tabs/example-tabs-details.njk +5 -6
- package/components/tabs/tabs.dom.js +5 -5
- package/components/tabs/tabs.js +266 -266
- package/components/tabs/tabs.spec.js +268 -268
- package/components/text-indent/_macro.njk +1 -3
- package/components/text-indent/_macro.spec.js +33 -33
- package/components/text-indent/_text-indent.scss +3 -3
- package/components/textarea/_macro.njk +49 -46
- package/components/textarea/_macro.spec.js +227 -238
- package/components/textarea/textarea.dom.js +5 -5
- package/components/textarea/textarea.spec.js +78 -74
- package/components/timeline/_macro.njk +4 -6
- package/components/timeline/_macro.spec.js +83 -83
- package/components/timeline/_timeline.scss +26 -26
- package/components/timeout-modal/_macro.njk +21 -19
- package/components/timeout-modal/_macro.spec.js +47 -47
- package/components/timeout-modal/example-timeout-modal.njk +16 -14
- package/components/timeout-modal/timeout-modal.dom.js +9 -9
- package/components/timeout-modal/timeout-modal.js +66 -66
- package/components/timeout-modal/timeout-modal.spec.js +157 -157
- package/components/timeout-panel/_macro.njk +19 -17
- package/components/timeout-panel/_macro.spec.js +41 -41
- package/components/timeout-panel/example-panel-with-timeout-warning.njk +13 -11
- package/components/timeout-panel/timeout-panel.dom.js +8 -8
- package/components/timeout-panel/timeout-panel.spec.js +118 -118
- package/components/upload/_macro.njk +20 -16
- package/components/upload/_macro.spec.js +52 -52
- package/components/upload/_upload.scss +28 -28
- package/components/video/_macro.njk +16 -2
- package/components/video/_macro.spec.js +42 -42
- package/components/video/_video.scss +16 -16
- package/components/video/example-video.njk +2 -2
- package/components/video/video.dom.js +5 -5
- package/components/video/video.js +32 -32
- package/components/video/video.spec.js +103 -97
- package/css/main.css +1 -1
- package/favicons/manifest.json +25 -25
- package/js/abortable-fetch.js +23 -23
- package/js/analytics.js +53 -53
- package/js/cookies-functions.js +135 -135
- package/js/cookies-settings.dom.js +7 -7
- package/js/cookies-settings.js +77 -77
- package/js/cookies-settings.spec.js +106 -106
- package/js/domready.js +8 -8
- package/js/fetch.js +14 -14
- package/js/inpagelink.dom.js +5 -5
- package/js/inpagelink.js +19 -19
- package/js/polyfills.js +0 -1
- package/js/print-button.js +6 -6
- package/js/timeout.js +211 -211
- package/layout/_dsTemplate.njk +22 -20
- package/layout/_template.njk +63 -51
- package/package.json +132 -128
- package/scripts/main.es5.js +1 -1
- package/scripts/main.js +1 -1
- package/scss/base/_forms.scss +10 -10
- package/scss/base/_global.scss +45 -44
- package/scss/base/_typography.scss +20 -20
- package/scss/helpers/_functions.scss +18 -15
- package/scss/helpers/_mixins.scss +59 -53
- package/scss/helpers/_mq.scss +62 -65
- package/scss/objects/_container.scss +20 -20
- package/scss/objects/_page.scss +33 -33
- package/scss/objects/_spacing.scss +10 -10
- package/scss/overrides/hcm.scss +237 -237
- package/scss/overrides/rtl.scss +95 -95
- package/scss/print.scss +47 -47
- package/scss/utilities/_border.scss +7 -7
- package/scss/utilities/_colors.scss +6 -6
- package/scss/utilities/_display.scss +8 -8
- package/scss/utilities/_float.scss +7 -7
- package/scss/utilities/_grid.scss +144 -144
- package/scss/utilities/_highlight.scss +4 -4
- package/scss/utilities/_margin.scss +17 -17
- package/scss/utilities/_pad.scss +15 -15
- package/scss/utilities/_typography.scss +35 -33
- package/scss/utilities/_utilities.scss +8 -8
- package/scss/utilities/_visibility.scss +25 -25
- package/scss/vars/_colors.scss +116 -116
- package/scss/vars/_forms.scss +22 -22
- package/scss/vars/_grid.scss +11 -9
- package/scss/vars/_typography.scss +54 -54
|
@@ -2,1079 +2,1086 @@
|
|
|
2
2
|
function Util() {}
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
|
-
|
|
5
|
+
Class manipulation functions
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
Util.hasClass = function (el, className) {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
if (el.classList) return el.classList.contains(className);
|
|
10
|
+
else return !!el.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'));
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
Util.addClass = function (el, className) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
let classList = className.split(' ');
|
|
15
|
+
if (el.classList) el.classList.add(classList[0]);
|
|
16
|
+
else if (!Util.hasClass(el, classList[0])) el.className += ' ' + classList[0];
|
|
17
|
+
if (classList.length > 1) Util.addClass(el, classList.slice(1).join(' '));
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
Util.removeClass = function (el, className) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
let classList = className.split(' ');
|
|
22
|
+
if (el.classList) el.classList.remove(classList[0]);
|
|
23
|
+
else if (Util.hasClass(el, classList[0])) {
|
|
24
|
+
let reg = new RegExp('(\\s|^)' + classList[0] + '(\\s|$)');
|
|
25
|
+
el.className = el.className.replace(reg, ' ');
|
|
26
|
+
}
|
|
27
|
+
if (classList.length > 1) Util.removeClass(el, classList.slice(1).join(' '));
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
Util.toggleClass = function (el, className, bool) {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
if (bool) Util.addClass(el, className);
|
|
32
|
+
else Util.removeClass(el, className);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
Util.setAttributes = function (el, attrs) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
for (let key in attrs) {
|
|
37
|
+
el.setAttribute(key, attrs[key]);
|
|
38
|
+
}
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
/*
|
|
42
|
-
|
|
42
|
+
DOM manipulation
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
45
|
Util.getChildrenByClassName = function (el, className) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
let childrenByClass = [];
|
|
47
|
+
for (let i = 0; i < el.children.length; i++) {
|
|
48
|
+
if (Util.hasClass(el.children[i], className)) childrenByClass.push(el.children[i]);
|
|
49
|
+
}
|
|
50
|
+
return childrenByClass;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
Util.is = function (elem, selector) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if (selector.nodeType) {
|
|
55
|
+
return elem === selector;
|
|
56
|
+
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
let qa = typeof selector === 'string' ? document.querySelectorAll(selector) : selector,
|
|
59
|
+
length = qa.length;
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
while (length--) {
|
|
62
|
+
if (qa[length] === elem) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
64
65
|
}
|
|
65
|
-
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
return false;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
// Animate height of an element
|
|
71
71
|
Util.setHeight = function (start, to, element, duration, cb) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
72
|
+
let change = to - start,
|
|
73
|
+
currentTime = null;
|
|
74
|
+
|
|
75
|
+
let animateHeight = function (timestamp) {
|
|
76
|
+
if (!currentTime) currentTime = timestamp;
|
|
77
|
+
let progress = timestamp - currentTime;
|
|
78
|
+
let val = parseInt((progress / duration) * change + start);
|
|
79
|
+
element.style.height = val + 'px';
|
|
80
|
+
if (progress < duration) {
|
|
81
|
+
window.requestAnimationFrame(animateHeight);
|
|
82
|
+
} else {
|
|
83
|
+
cb();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
// Set the height of the element before starting animation -> fix bug on Safari
|
|
88
|
+
element.style.height = start + 'px';
|
|
89
|
+
window.requestAnimationFrame(animateHeight);
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
// Smooth Scroll
|
|
93
93
|
Util.scrollTo = function (final, duration, cb, scrollEl) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
94
|
+
let element = scrollEl || window;
|
|
95
|
+
let start = element.scrollTop || document.documentElement.scrollTop,
|
|
96
|
+
currentTime = null;
|
|
97
|
+
|
|
98
|
+
if (!scrollEl) start = window.scrollY || document.documentElement.scrollTop;
|
|
99
|
+
|
|
100
|
+
let animateScroll = function (timestamp) {
|
|
101
|
+
if (!currentTime) currentTime = timestamp;
|
|
102
|
+
let progress = timestamp - currentTime;
|
|
103
|
+
if (progress > duration) progress = duration;
|
|
104
|
+
let val = Math.easeInOutQuad(progress, start, final - start, duration);
|
|
105
|
+
element.scrollTo(0, val);
|
|
106
|
+
if (progress < duration) {
|
|
107
|
+
window.requestAnimationFrame(animateScroll);
|
|
108
|
+
} else {
|
|
109
|
+
cb && cb();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
window.requestAnimationFrame(animateScroll);
|
|
114
114
|
};
|
|
115
115
|
|
|
116
116
|
/*
|
|
117
|
-
|
|
117
|
+
Focus utility classes
|
|
118
118
|
*/
|
|
119
119
|
|
|
120
120
|
// Move focus to an element
|
|
121
121
|
Util.moveFocus = function (element) {
|
|
122
|
-
|
|
123
|
-
element.focus();
|
|
124
|
-
if (document.activeElement !== element) {
|
|
125
|
-
element.setAttribute('tabindex', '-1');
|
|
122
|
+
if (!element) element = document.getElementsByTagName('body')[0];
|
|
126
123
|
element.focus();
|
|
127
|
-
|
|
124
|
+
if (document.activeElement !== element) {
|
|
125
|
+
element.setAttribute('tabindex', '-1');
|
|
126
|
+
element.focus();
|
|
127
|
+
}
|
|
128
128
|
};
|
|
129
129
|
|
|
130
130
|
// Misc
|
|
131
131
|
Util.getIndexInArray = function (array, el) {
|
|
132
|
-
|
|
132
|
+
return Array.prototype.indexOf.call(array, el);
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
Util.cssSupports = function (property, value) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
if ('CSS' in window) {
|
|
137
|
+
return CSS.supports(property, value);
|
|
138
|
+
} else {
|
|
139
|
+
let jsProperty = property.replace(/-([a-z])/g, function (g) {
|
|
140
|
+
return g[1].toUpperCase();
|
|
141
|
+
});
|
|
142
|
+
return jsProperty in document.body.style;
|
|
143
|
+
}
|
|
144
144
|
};
|
|
145
145
|
|
|
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
149
|
Util.extend = function () {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Merge the object into the extended object
|
|
163
|
-
let merge = function (obj) {
|
|
164
|
-
for (let prop in obj) {
|
|
165
|
-
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
166
|
-
// If deep merge and property is an object, merge properties
|
|
167
|
-
if (deep && Object.prototype.toString.call(obj[prop]) === '[object Object]') {
|
|
168
|
-
extended[prop] = extend(true, extended[prop], obj[prop]);
|
|
169
|
-
} else {
|
|
170
|
-
extended[prop] = obj[prop];
|
|
171
|
-
}
|
|
172
|
-
}
|
|
150
|
+
// Variables
|
|
151
|
+
let extended = {};
|
|
152
|
+
let deep = false;
|
|
153
|
+
let i = 0;
|
|
154
|
+
let length = arguments.length;
|
|
155
|
+
|
|
156
|
+
// Check if a deep merge
|
|
157
|
+
if (Object.prototype.toString.call(arguments[0]) === '[object Boolean]') {
|
|
158
|
+
deep = arguments[0];
|
|
159
|
+
i++;
|
|
173
160
|
}
|
|
174
|
-
};
|
|
175
161
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
162
|
+
// Merge the object into the extended object
|
|
163
|
+
let merge = function (obj) {
|
|
164
|
+
for (let prop in obj) {
|
|
165
|
+
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
|
166
|
+
// If deep merge and property is an object, merge properties
|
|
167
|
+
if (deep && Object.prototype.toString.call(obj[prop]) === '[object Object]') {
|
|
168
|
+
extended[prop] = extend(true, extended[prop], obj[prop]);
|
|
169
|
+
} else {
|
|
170
|
+
extended[prop] = obj[prop];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
181
175
|
|
|
182
|
-
|
|
176
|
+
// Loop through each object and conduct a merge
|
|
177
|
+
for (; i < length; i++) {
|
|
178
|
+
let obj = arguments[i];
|
|
179
|
+
merge(obj);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return extended;
|
|
183
183
|
};
|
|
184
184
|
|
|
185
185
|
// Check if Reduced Motion is enabled
|
|
186
186
|
Util.osHasReducedMotion = function () {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
if (!window.matchMedia) return false;
|
|
188
|
+
let matchMediaObj = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
189
|
+
if (matchMediaObj) return matchMediaObj.matches;
|
|
190
|
+
return false; // Return false if not supported
|
|
191
191
|
};
|
|
192
192
|
|
|
193
193
|
/*
|
|
194
|
-
|
|
194
|
+
Polyfills
|
|
195
195
|
*/
|
|
196
196
|
|
|
197
197
|
// Closest() method
|
|
198
198
|
if (!Element.prototype.matches) {
|
|
199
|
-
|
|
199
|
+
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
if (!Element.prototype.closest) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
203
|
+
Element.prototype.closest = function (s) {
|
|
204
|
+
let el = this;
|
|
205
|
+
if (!document.documentElement.contains(el)) return null;
|
|
206
|
+
do {
|
|
207
|
+
if (el.matches(s)) return el;
|
|
208
|
+
el = el.parentElement || el.parentNode;
|
|
209
|
+
} while (el !== null && el.nodeType === 1);
|
|
210
|
+
return null;
|
|
211
|
+
};
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
// Custom Event() constructor
|
|
215
215
|
if (typeof window.CustomEvent !== 'function') {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
216
|
+
function CustomEvent(event, params) {
|
|
217
|
+
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
|
218
|
+
let evt = document.createEvent('CustomEvent');
|
|
219
|
+
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
|
220
|
+
return evt;
|
|
221
|
+
}
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
CustomEvent.prototype = window.Event.prototype;
|
|
224
224
|
|
|
225
|
-
|
|
225
|
+
window.CustomEvent = CustomEvent;
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
/*
|
|
229
|
-
|
|
229
|
+
Animation curves
|
|
230
230
|
*/
|
|
231
231
|
|
|
232
232
|
Math.easeInOutQuad = function (t, b, c, d) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
233
|
+
t /= d / 2;
|
|
234
|
+
if (t < 1) return (c / 2) * t * t + b;
|
|
235
|
+
t--;
|
|
236
|
+
return (-c / 2) * (t * (t - 2) - 1) + b;
|
|
237
237
|
};
|
|
238
238
|
|
|
239
239
|
// FILTERS
|
|
240
240
|
|
|
241
241
|
(function () {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
242
|
+
let Filter = function (opts) {
|
|
243
|
+
this.options = Util.extend(Filter.defaults, opts); // Used to store custom filter/sort functions
|
|
244
|
+
this.element = this.options.element;
|
|
245
|
+
this.elementId = this.element.getAttribute('id');
|
|
246
|
+
this.items = this.element.querySelectorAll('.ons-js-filter__item');
|
|
247
|
+
this.controllers = document.querySelectorAll('[aria-controls="' + this.elementId + '"]'); // Controllers wrappers
|
|
248
|
+
this.fallbackMessage = document.querySelector('[data-fallback-gallery-id="' + this.elementId + '"]');
|
|
249
|
+
this.filterString = []; // Combination of different filter values
|
|
250
|
+
this.sortingString = ''; // Sort value - will include order and type of argument (e.g., number or string)
|
|
251
|
+
|
|
252
|
+
// Store info about sorted/filtered items
|
|
253
|
+
this.filterList = []; // List of boolean for each this.item -> true if still visible , otherwise false
|
|
254
|
+
this.sortingList = []; // List of new ordered this.item -> each element is [item, originalIndex]
|
|
255
|
+
|
|
256
|
+
// Store grid info for animation
|
|
257
|
+
this.itemsGrid = []; // Grid coordinates
|
|
258
|
+
this.itemsInitPosition = []; // Used to store coordinates of this.items before animation
|
|
259
|
+
this.itemsIterPosition = []; // Used to store coordinates of this.items before animation - intermediate state
|
|
260
|
+
this.itemsFinalPosition = []; // Used to store coordinates of this.items after filtering
|
|
261
|
+
|
|
262
|
+
// Animation off
|
|
263
|
+
this.animateOff = this.element.getAttribute('data-filter-animation') == 'off';
|
|
264
|
+
|
|
265
|
+
// Used to update this.itemsGrid on resize
|
|
266
|
+
this.resizingId = false;
|
|
267
|
+
|
|
268
|
+
// Default acceleration style - improve animation
|
|
269
|
+
this.accelerateStyle = 'will-change: transform, opacity; transform: translateZ(0); backface-visibility: hidden;';
|
|
270
|
+
|
|
271
|
+
// Handle multiple changes
|
|
272
|
+
this.animating = false;
|
|
273
|
+
this.reanimate = false;
|
|
274
|
+
|
|
275
|
+
initFilter(this);
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
function initFilter(filter) {
|
|
279
|
+
resetFilterSortArray(filter, true, true); // Init array filter.filterList/filter.sortingList
|
|
280
|
+
createGridInfo(filter); // Store grid coordinates in filter.itemsGrid
|
|
281
|
+
initItemsOrder(filter); // Add data-orders so that we can reset the sorting
|
|
282
|
+
|
|
283
|
+
// Events handling - filter update
|
|
284
|
+
for (let i = 0; i < filter.controllers.length; i++) {
|
|
285
|
+
filter.filterString[i] = ''; // Reset filtering
|
|
286
|
+
|
|
287
|
+
// Get proper filter/sorting string based on selected controllers
|
|
288
|
+
(function (i) {
|
|
289
|
+
filter.controllers[i].addEventListener('change', function (event) {
|
|
290
|
+
if (event.target.tagName.toLowerCase() == 'select') {
|
|
291
|
+
// Select elements
|
|
292
|
+
!event.target.getAttribute('data-filter')
|
|
293
|
+
? setSortingString(filter, event.target.value, event.target.options[event.target.selectedIndex])
|
|
294
|
+
: setFilterString(filter, i, 'select');
|
|
295
|
+
} else if (
|
|
296
|
+
event.target.tagName.toLowerCase() == 'input' &&
|
|
297
|
+
(event.target.getAttribute('type') == 'radio' || event.target.getAttribute('type') == 'checkbox')
|
|
298
|
+
) {
|
|
299
|
+
// Input (radio/checkboxed) elements
|
|
300
|
+
!event.target.getAttribute('data-filter')
|
|
301
|
+
? setSortingString(filter, event.target.getAttribute('data-sort'), event.target)
|
|
302
|
+
: setFilterString(filter, i, 'input');
|
|
303
|
+
} else {
|
|
304
|
+
// Generic inout element
|
|
305
|
+
!filter.controllers[i].getAttribute('data-filter')
|
|
306
|
+
? setSortingString(filter, filter.controllers[i].getAttribute('data-sort'), filter.controllers[i])
|
|
307
|
+
: setFilterString(filter, i, 'custom');
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
updateFilterArray(filter);
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
filter.controllers[i].addEventListener('click', function (event) {
|
|
314
|
+
// Return if target is select/input elements
|
|
315
|
+
let filterEl = event.target.closest('[data-filter]');
|
|
316
|
+
let sortEl = event.target.closest('[data-sort]');
|
|
317
|
+
if (!filterEl && !sortEl) return;
|
|
318
|
+
if (filterEl && (filterEl.tagName.toLowerCase() == 'input' || filterEl.tagName.toLowerCase() == 'select')) return;
|
|
319
|
+
if (sortEl && (sortEl.tagName.toLowerCase() == 'input' || sortEl.tagName.toLowerCase() == 'select')) return;
|
|
320
|
+
if (sortEl && Util.hasClass(sortEl, 'ons-js-filter__custom-control')) return;
|
|
321
|
+
if (filterEl && Util.hasClass(filterEl, 'ons-js-filter__custom-control')) return;
|
|
322
|
+
|
|
323
|
+
// This will be executed only for a list of buttons -> no inputs
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
resetControllersList(filter, i, filterEl, sortEl);
|
|
326
|
+
sortEl ? setSortingString(filter, sortEl.getAttribute('data-sort'), sortEl) : setFilterString(filter, i, 'button');
|
|
327
|
+
updateFilterArray(filter);
|
|
328
|
+
});
|
|
329
|
+
})(i);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Handle resize - update grid coordinates in filter.itemsGrid
|
|
333
|
+
window.addEventListener('resize', function () {
|
|
334
|
+
clearTimeout(filter.resizingId);
|
|
335
|
+
filter.resizingId = setTimeout(function () {
|
|
336
|
+
createGridInfo(filter);
|
|
337
|
+
}, 300);
|
|
311
338
|
});
|
|
312
339
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
// This will be executed only for a list of buttons -> no inputs
|
|
324
|
-
event.preventDefault();
|
|
325
|
-
resetControllersList(filter, i, filterEl, sortEl);
|
|
326
|
-
sortEl ? setSortingString(filter, sortEl.getAttribute('data-sort'), sortEl) : setFilterString(filter, i, 'button');
|
|
327
|
-
updateFilterArray(filter);
|
|
340
|
+
// Check if there are filters/sorting values already set
|
|
341
|
+
checkInitialFiltering(filter);
|
|
342
|
+
|
|
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 () {
|
|
345
|
+
// Reset filters first
|
|
346
|
+
for (let i = 0; i < filter.controllers.length; i++) filter.filterString[i] = '';
|
|
347
|
+
filter.sortingString = '';
|
|
348
|
+
checkInitialFiltering(filter);
|
|
328
349
|
});
|
|
329
|
-
})(i);
|
|
330
350
|
}
|
|
331
351
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
sort
|
|
377
|
-
? setSortingString(filter, filter.controllers[i].value, filter.controllers[i].options[filter.controllers[i].selectedIndex])
|
|
378
|
-
: setFilterString(filter, i, 'select');
|
|
379
|
-
continue;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
// Check if there’s a generic custom input
|
|
383
|
-
let radioInput = filter.controllers[i].querySelector('input[type="radio"]'),
|
|
384
|
-
checkboxInput = filter.controllers[i].querySelector('input[type="checkbox"]');
|
|
385
|
-
if (!radioInput && !checkboxInput) {
|
|
386
|
-
let sort = filter.controllers[i].getAttribute('data-sort');
|
|
387
|
-
let filterString = filter.controllers[i].getAttribute('data-filter');
|
|
388
|
-
if (sort) setSortingString(filter, sort, filter.controllers[i]);
|
|
389
|
-
else if (filterString) setFilterString(filter, i, 'custom');
|
|
390
|
-
}
|
|
391
|
-
}
|
|
352
|
+
function checkInitialFiltering(filter) {
|
|
353
|
+
for (let i = 0; i < filter.controllers.length; i++) {
|
|
354
|
+
// Check if there’s a selected option
|
|
355
|
+
// Buttons list
|
|
356
|
+
let selectedButton = filter.controllers[i].getElementsByClassName('ons-js-filter-selected');
|
|
357
|
+
if (selectedButton.length > 0) {
|
|
358
|
+
let sort = selectedButton[0].getAttribute('data-sort');
|
|
359
|
+
sort
|
|
360
|
+
? setSortingString(filter, selectedButton[0].getAttribute('data-sort'), selectedButton[0])
|
|
361
|
+
: setFilterString(filter, i, 'button');
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// Input list
|
|
366
|
+
let selectedInput = filter.controllers[i].querySelectorAll('input:checked');
|
|
367
|
+
if (selectedInput.length > 0) {
|
|
368
|
+
let sort = selectedInput[0].getAttribute('data-sort');
|
|
369
|
+
sort ? setSortingString(filter, sort, selectedInput[0]) : setFilterString(filter, i, 'input');
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// Select item
|
|
374
|
+
if (filter.controllers[i].tagName.toLowerCase() == 'select') {
|
|
375
|
+
let sort = filter.controllers[i].getAttribute('data-sort');
|
|
376
|
+
sort
|
|
377
|
+
? setSortingString(
|
|
378
|
+
filter,
|
|
379
|
+
filter.controllers[i].value,
|
|
380
|
+
filter.controllers[i].options[filter.controllers[i].selectedIndex],
|
|
381
|
+
)
|
|
382
|
+
: setFilterString(filter, i, 'select');
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// Check if there’s a generic custom input
|
|
387
|
+
let radioInput = filter.controllers[i].querySelector('input[type="radio"]'),
|
|
388
|
+
checkboxInput = filter.controllers[i].querySelector('input[type="checkbox"]');
|
|
389
|
+
if (!radioInput && !checkboxInput) {
|
|
390
|
+
let sort = filter.controllers[i].getAttribute('data-sort');
|
|
391
|
+
let filterString = filter.controllers[i].getAttribute('data-filter');
|
|
392
|
+
if (sort) setSortingString(filter, sort, filter.controllers[i]);
|
|
393
|
+
else if (filterString) setFilterString(filter, i, 'custom');
|
|
394
|
+
}
|
|
395
|
+
}
|
|
392
396
|
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function setSortingString(filter, value, item) {
|
|
397
|
-
// Get sorting string value-> sortName:order:type
|
|
398
|
-
let order = item.getAttribute('data-sort-order') ? 'desc' : 'asc';
|
|
399
|
-
let type = item.getAttribute('data-sort-number') ? 'number' : 'string';
|
|
400
|
-
filter.sortingString = value + ':' + order + ':' + type;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
function setFilterString(filter, index, type) {
|
|
404
|
-
// Get filtering array -> [filter1:filter2, filter3, filter4:filter5]
|
|
405
|
-
if (type == 'input') {
|
|
406
|
-
let checkedInputs = filter.controllers[index].querySelectorAll('input:checked');
|
|
407
|
-
filter.filterString[index] = '';
|
|
408
|
-
for (let i = 0; i < checkedInputs.length; i++) {
|
|
409
|
-
filter.filterString[index] = filter.filterString[index] + checkedInputs[i].getAttribute('data-filter') + ':';
|
|
410
|
-
}
|
|
411
|
-
} else if (type == 'select') {
|
|
412
|
-
if (filter.controllers[index].multiple) {
|
|
413
|
-
// Select with multiple options
|
|
414
|
-
filter.filterString[index] = getMultipleSelectValues(filter.controllers[index]);
|
|
415
|
-
} else {
|
|
416
|
-
// Select with single option
|
|
417
|
-
filter.filterString[index] = filter.controllers[index].value;
|
|
418
|
-
}
|
|
419
|
-
} else if (type == 'button') {
|
|
420
|
-
let selectedButtons = filter.controllers[index].querySelectorAll('.ons-js-filter-selected');
|
|
421
|
-
filter.filterString[index] = '';
|
|
422
|
-
for (let i = 0; i < selectedButtons.length; i++) {
|
|
423
|
-
filter.filterString[index] = filter.filterString[index] + selectedButtons[i].getAttribute('data-filter') + ':';
|
|
424
|
-
}
|
|
425
|
-
} else if (type == 'custom') {
|
|
426
|
-
filter.filterString[index] = filter.controllers[index].getAttribute('data-filter');
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
function resetControllersList(filter, index, target1, target2) {
|
|
431
|
-
// For a <button>s list -> toggle js-filter-selected + custom classes
|
|
432
|
-
let multi = filter.controllers[index].getAttribute('data-filter-checkbox'),
|
|
433
|
-
customClass = filter.controllers[index].getAttribute('data-selected-class');
|
|
434
|
-
|
|
435
|
-
customClass = customClass ? 'ons-js-filter-selected ' + customClass : 'ons-js-filter-selected';
|
|
436
|
-
if (multi == 'true') {
|
|
437
|
-
// Multiple options can be on
|
|
438
|
-
target1
|
|
439
|
-
? Util.toggleClass(target1, customClass, !Util.hasClass(target1, 'ons-js-filter-selected'))
|
|
440
|
-
: Util.toggleClass(target2, customClass, !Util.hasClass(target2, 'ons-js-filter-selected'));
|
|
441
|
-
} else {
|
|
442
|
-
// Only one element at the time
|
|
443
|
-
// Remove the class from all siblings
|
|
444
|
-
let selectedOption = filter.controllers[index].querySelector('.ons-js-filter-selected');
|
|
445
|
-
if (selectedOption) Util.removeClass(selectedOption, customClass);
|
|
446
|
-
target1 ? Util.addClass(target1, customClass) : Util.addClass(target2, customClass);
|
|
397
|
+
updateFilterArray(filter);
|
|
447
398
|
}
|
|
448
|
-
}
|
|
449
399
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
456
|
-
filter.animating = true;
|
|
457
|
-
filter.reanimate = false;
|
|
458
|
-
createGridInfo(filter); // Get new grid coordinates
|
|
459
|
-
sortingGallery(filter); // Update sorting list
|
|
460
|
-
filteringGallery(filter); // Update filter list
|
|
461
|
-
resetFallbackMessage(filter, true); // Toggle fallback message
|
|
462
|
-
if (reducedMotion || filter.animateOff) {
|
|
463
|
-
resetItems(filter);
|
|
464
|
-
} else {
|
|
465
|
-
updateItemsAttributes(filter);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
function sortingGallery(filter) {
|
|
470
|
-
// Use sorting string to reorder gallery
|
|
471
|
-
let sortOptions = filter.sortingString.split(':');
|
|
472
|
-
if (sortOptions[0] == '' || sortOptions[0] == '*') {
|
|
473
|
-
// No sorting needed
|
|
474
|
-
restoreSortOrder(filter);
|
|
475
|
-
} else {
|
|
476
|
-
// Need to sort
|
|
477
|
-
if (filter.options[sortOptions[0]]) {
|
|
478
|
-
// Custom sort function -> user takes care of it
|
|
479
|
-
filter.sortingList = filter.options[sortOptions[0]](filter.sortingList);
|
|
480
|
-
} else {
|
|
481
|
-
filter.sortingList.sort(function (left, right) {
|
|
482
|
-
let leftVal = left[0].getAttribute('data-sort-' + sortOptions[0]),
|
|
483
|
-
rightVal = right[0].getAttribute('data-sort-' + sortOptions[0]);
|
|
484
|
-
if (sortOptions[2] == 'number') {
|
|
485
|
-
leftVal = parseFloat(leftVal);
|
|
486
|
-
rightVal = parseFloat(rightVal);
|
|
487
|
-
}
|
|
488
|
-
if (sortOptions[1] == 'desc') return leftVal <= rightVal ? 1 : -1;
|
|
489
|
-
else return leftVal >= rightVal ? 1 : -1;
|
|
490
|
-
});
|
|
491
|
-
}
|
|
400
|
+
function setSortingString(filter, value, item) {
|
|
401
|
+
// Get sorting string value-> sortName:order:type
|
|
402
|
+
let order = item.getAttribute('data-sort-order') ? 'desc' : 'asc';
|
|
403
|
+
let type = item.getAttribute('data-sort-number') ? 'number' : 'string';
|
|
404
|
+
filter.sortingString = value + ':' + order + ':' + type;
|
|
492
405
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
406
|
+
|
|
407
|
+
function setFilterString(filter, index, type) {
|
|
408
|
+
// Get filtering array -> [filter1:filter2, filter3, filter4:filter5]
|
|
409
|
+
if (type == 'input') {
|
|
410
|
+
let checkedInputs = filter.controllers[index].querySelectorAll('input:checked');
|
|
411
|
+
filter.filterString[index] = '';
|
|
412
|
+
for (let i = 0; i < checkedInputs.length; i++) {
|
|
413
|
+
filter.filterString[index] = filter.filterString[index] + checkedInputs[i].getAttribute('data-filter') + ':';
|
|
414
|
+
}
|
|
415
|
+
} else if (type == 'select') {
|
|
416
|
+
if (filter.controllers[index].multiple) {
|
|
417
|
+
// Select with multiple options
|
|
418
|
+
filter.filterString[index] = getMultipleSelectValues(filter.controllers[index]);
|
|
419
|
+
} else {
|
|
420
|
+
// Select with single option
|
|
421
|
+
filter.filterString[index] = filter.controllers[index].value;
|
|
422
|
+
}
|
|
423
|
+
} else if (type == 'button') {
|
|
424
|
+
let selectedButtons = filter.controllers[index].querySelectorAll('.ons-js-filter-selected');
|
|
425
|
+
filter.filterString[index] = '';
|
|
426
|
+
for (let i = 0; i < selectedButtons.length; i++) {
|
|
427
|
+
filter.filterString[index] = filter.filterString[index] + selectedButtons[i].getAttribute('data-filter') + ':';
|
|
428
|
+
}
|
|
429
|
+
} else if (type == 'custom') {
|
|
430
|
+
filter.filterString[index] = filter.controllers[index].getAttribute('data-filter');
|
|
431
|
+
}
|
|
518
432
|
}
|
|
519
433
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
434
|
+
function resetControllersList(filter, index, target1, target2) {
|
|
435
|
+
// For a <button>s list -> toggle js-filter-selected + custom classes
|
|
436
|
+
let multi = filter.controllers[index].getAttribute('data-filter-checkbox'),
|
|
437
|
+
customClass = filter.controllers[index].getAttribute('data-selected-class');
|
|
438
|
+
|
|
439
|
+
customClass = customClass ? 'ons-js-filter-selected ' + customClass : 'ons-js-filter-selected';
|
|
440
|
+
if (multi == 'true') {
|
|
441
|
+
// Multiple options can be on
|
|
442
|
+
target1
|
|
443
|
+
? Util.toggleClass(target1, customClass, !Util.hasClass(target1, 'ons-js-filter-selected'))
|
|
444
|
+
: Util.toggleClass(target2, customClass, !Util.hasClass(target2, 'ons-js-filter-selected'));
|
|
445
|
+
} else {
|
|
446
|
+
// Only one element at the time
|
|
447
|
+
// Remove the class from all siblings
|
|
448
|
+
let selectedOption = filter.controllers[index].querySelector('.ons-js-filter-selected');
|
|
449
|
+
if (selectedOption) Util.removeClass(selectedOption, customClass);
|
|
450
|
+
target1 ? Util.addClass(target1, customClass) : Util.addClass(target2, customClass);
|
|
531
451
|
}
|
|
532
|
-
}
|
|
533
|
-
filter.filterList[i] = !present ? false : filter.filterList[i];
|
|
534
452
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
Util.removeClass(filter.items[i], 'ons-u-hidden');
|
|
554
|
-
}
|
|
453
|
+
|
|
454
|
+
function updateFilterArray(filter) {
|
|
455
|
+
// Sort/filter strings have been updated -> so you can update the gallery
|
|
456
|
+
if (filter.animating) {
|
|
457
|
+
filter.reanimate = true;
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
filter.animating = true;
|
|
461
|
+
filter.reanimate = false;
|
|
462
|
+
createGridInfo(filter); // Get new grid coordinates
|
|
463
|
+
sortingGallery(filter); // Update sorting list
|
|
464
|
+
filteringGallery(filter); // Update filter list
|
|
465
|
+
resetFallbackMessage(filter, true); // Toggle fallback message
|
|
466
|
+
if (reducedMotion || filter.animateOff) {
|
|
467
|
+
resetItems(filter);
|
|
468
|
+
} else {
|
|
469
|
+
updateItemsAttributes(filter);
|
|
470
|
+
}
|
|
555
471
|
}
|
|
556
472
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
473
|
+
function sortingGallery(filter) {
|
|
474
|
+
// Use sorting string to reorder gallery
|
|
475
|
+
let sortOptions = filter.sortingString.split(':');
|
|
476
|
+
if (sortOptions[0] == '' || sortOptions[0] == '*') {
|
|
477
|
+
// No sorting needed
|
|
478
|
+
restoreSortOrder(filter);
|
|
479
|
+
} else {
|
|
480
|
+
// Need to sort
|
|
481
|
+
if (filter.options[sortOptions[0]]) {
|
|
482
|
+
// Custom sort function -> user takes care of it
|
|
483
|
+
filter.sortingList = filter.options[sortOptions[0]](filter.sortingList);
|
|
484
|
+
} else {
|
|
485
|
+
filter.sortingList.sort(function (left, right) {
|
|
486
|
+
let leftVal = left[0].getAttribute('data-sort-' + sortOptions[0]),
|
|
487
|
+
rightVal = right[0].getAttribute('data-sort-' + sortOptions[0]);
|
|
488
|
+
if (sortOptions[2] == 'number') {
|
|
489
|
+
leftVal = parseFloat(leftVal);
|
|
490
|
+
rightVal = parseFloat(rightVal);
|
|
491
|
+
}
|
|
492
|
+
if (sortOptions[1] == 'desc') return leftVal <= rightVal ? 1 : -1;
|
|
493
|
+
else return leftVal >= rightVal ? 1 : -1;
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
}
|
|
573
497
|
}
|
|
574
498
|
|
|
575
|
-
|
|
576
|
-
|
|
499
|
+
function filteringGallery(filter) {
|
|
500
|
+
// Use filtering string to reorder gallery
|
|
501
|
+
resetFilterSortArray(filter, true, false);
|
|
577
502
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
503
|
+
// We can have multiple filters
|
|
504
|
+
for (let i = 0; i < filter.filterString.length; i++) {
|
|
505
|
+
// Check if multiple filters inside the same controller
|
|
506
|
+
if (filter.filterString[i] != '' && filter.filterString[i] != '*' && filter.filterString[i] != ' ') {
|
|
507
|
+
singleFilterGallery(filter, filter.filterString[i].split(':'));
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
581
511
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
for (let i = 0; i < filter.sortingList.length; i++) {
|
|
585
|
-
let item = filter.items[filter.sortingList[i][1]];
|
|
512
|
+
function singleFilterGallery(filter, subfilter) {
|
|
513
|
+
if (!subfilter || subfilter == '' || subfilter == '*') return;
|
|
586
514
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
515
|
+
// Check if we have custom options
|
|
516
|
+
let customFilterArray = [];
|
|
517
|
+
for (let j = 0; j < subfilter.length; j++) {
|
|
518
|
+
if (filter.options[subfilter[j]]) {
|
|
519
|
+
// Custom function
|
|
520
|
+
customFilterArray[subfilter[j]] = filter.options[subfilter[j]](filter.items);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
593
523
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
524
|
+
for (let i = 0; i < filter.items.length; i++) {
|
|
525
|
+
let filterValues = filter.items[i].getAttribute('data-filter').split(' ');
|
|
526
|
+
let present = false;
|
|
527
|
+
for (let j = 0; j < subfilter.length; j++) {
|
|
528
|
+
if (filter.options[subfilter[j]] && customFilterArray[subfilter[j]][i]) {
|
|
529
|
+
// Custom function
|
|
530
|
+
present = true;
|
|
531
|
+
break;
|
|
532
|
+
} else if (subfilter[j] == '*' || filterValues.indexOf(subfilter[j]) > -1) {
|
|
533
|
+
present = true;
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
filter.filterList[i] = !present ? false : filter.filterList[i];
|
|
538
|
+
}
|
|
597
539
|
}
|
|
598
540
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
'transition: ' +
|
|
607
|
-
transitionValue +
|
|
608
|
-
'; transform: translateX(' +
|
|
609
|
-
parseInt(filter.itemsFinalPosition[i][0] - filter.itemsIterPosition[i][0]) +
|
|
610
|
-
'px) translateY(' +
|
|
611
|
-
parseInt(filter.itemsFinalPosition[i][1] - filter.itemsIterPosition[i][1]) +
|
|
612
|
-
'px) scale(1); opacity: 1;',
|
|
613
|
-
);
|
|
614
|
-
} else if (filter.filterList[i]) {
|
|
615
|
-
// Translate item
|
|
616
|
-
filter.items[i].setAttribute(
|
|
617
|
-
'style',
|
|
618
|
-
filter.accelerateStyle +
|
|
619
|
-
'transition: ' +
|
|
620
|
-
transitionValue +
|
|
621
|
-
'; transform: translateX(' +
|
|
622
|
-
parseInt(filter.itemsFinalPosition[i][0] - filter.itemsIterPosition[i][0]) +
|
|
623
|
-
'px) translateY(' +
|
|
624
|
-
parseInt(filter.itemsFinalPosition[i][1] - filter.itemsIterPosition[i][1]) +
|
|
625
|
-
'px);',
|
|
626
|
-
);
|
|
627
|
-
} else {
|
|
628
|
-
// Scale down item
|
|
629
|
-
filter.items[i].setAttribute(
|
|
541
|
+
function updateItemsAttributes(filter) {
|
|
542
|
+
// Set items before triggering the update animation
|
|
543
|
+
// Get offset of all elements before animation
|
|
544
|
+
storeOffset(filter, filter.itemsInitPosition);
|
|
545
|
+
|
|
546
|
+
// Set height of container
|
|
547
|
+
filter.element.setAttribute(
|
|
630
548
|
'style',
|
|
631
|
-
|
|
632
|
-
|
|
549
|
+
'height: ' + parseFloat(filter.element.offsetHeight) + 'px; width: ' + parseFloat(filter.element.offsetWidth) + 'px;',
|
|
550
|
+
);
|
|
551
|
+
|
|
552
|
+
for (let i = 0; i < filter.items.length; i++) {
|
|
553
|
+
// Remove ons-u-hidden class from items now visible and scale to zero
|
|
554
|
+
if (Util.hasClass(filter.items[i], 'ons-u-hidden') && filter.filterList[i]) {
|
|
555
|
+
filter.items[i].setAttribute('data-scale', 'on');
|
|
556
|
+
filter.items[i].setAttribute('style', filter.accelerateStyle + 'transform: scale(0.5); opacity: 0;');
|
|
557
|
+
Util.removeClass(filter.items[i], 'ons-u-hidden');
|
|
558
|
+
}
|
|
633
559
|
}
|
|
634
|
-
}
|
|
635
|
-
}, 50);
|
|
636
|
-
|
|
637
|
-
// Wait for the end of transition of visible elements
|
|
638
|
-
setTimeout(function () {
|
|
639
|
-
resetItems(filter);
|
|
640
|
-
}, filter.options.duration + 100);
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
function resetItems(filter) {
|
|
644
|
-
// Animation was off or animation is over -> reset attributes
|
|
645
|
-
for (let i = 0; i < filter.items.length; i++) {
|
|
646
|
-
filter.items[i].removeAttribute('style');
|
|
647
|
-
Util.toggleClass(filter.items[i], 'ons-u-hidden', !filter.filterList[i]);
|
|
648
|
-
filter.items[i].removeAttribute('data-scale');
|
|
649
|
-
}
|
|
650
560
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
561
|
+
// Get new elements offset
|
|
562
|
+
storeOffset(filter, filter.itemsIterPosition);
|
|
563
|
+
|
|
564
|
+
// Translate items so that they are in the right initial position
|
|
565
|
+
for (let i = 0; i < filter.items.length; i++) {
|
|
566
|
+
if (filter.items[i].getAttribute('data-scale') != 'on') {
|
|
567
|
+
filter.items[i].setAttribute(
|
|
568
|
+
'style',
|
|
569
|
+
filter.accelerateStyle +
|
|
570
|
+
'transform: translateX(' +
|
|
571
|
+
parseInt(filter.itemsInitPosition[i][0] - filter.itemsIterPosition[i][0]) +
|
|
572
|
+
'px) translateY(' +
|
|
573
|
+
parseInt(filter.itemsInitPosition[i][1] - filter.itemsIterPosition[i][1]) +
|
|
574
|
+
'px);',
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
animateItems(filter);
|
|
654
580
|
}
|
|
655
581
|
|
|
656
|
-
filter
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
582
|
+
function animateItems(filter) {
|
|
583
|
+
let transitionValue =
|
|
584
|
+
'transform ' +
|
|
585
|
+
filter.options.duration +
|
|
586
|
+
'ms cubic-bezier(0.455, 0.03, 0.515, 0.955), opacity ' +
|
|
587
|
+
filter.options.duration +
|
|
588
|
+
'ms';
|
|
589
|
+
|
|
590
|
+
// Get new index of items in the list
|
|
591
|
+
let j = 0;
|
|
592
|
+
for (let i = 0; i < filter.sortingList.length; i++) {
|
|
593
|
+
let item = filter.items[filter.sortingList[i][1]];
|
|
594
|
+
|
|
595
|
+
if (Util.hasClass(item, 'ons-u-hidden') || !filter.filterList[filter.sortingList[i][1]]) {
|
|
596
|
+
// Item is hidden or was previously hidden -> final position equal to first one
|
|
597
|
+
filter.itemsFinalPosition[filter.sortingList[i][1]] = filter.itemsIterPosition[filter.sortingList[i][1]];
|
|
598
|
+
if (item.getAttribute('data-scale') == 'on') j = j + 1;
|
|
599
|
+
} else {
|
|
600
|
+
filter.itemsFinalPosition[filter.sortingList[i][1]] = [filter.itemsGrid[j][0], filter.itemsGrid[j][1]];
|
|
601
|
+
|
|
602
|
+
// Left/top
|
|
603
|
+
j = j + 1;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
setTimeout(function () {
|
|
608
|
+
for (let i = 0; i < filter.items.length; i++) {
|
|
609
|
+
if (filter.filterList[i] && filter.items[i].getAttribute('data-scale') == 'on') {
|
|
610
|
+
// Scale up item
|
|
611
|
+
filter.items[i].setAttribute(
|
|
612
|
+
'style',
|
|
613
|
+
filter.accelerateStyle +
|
|
614
|
+
'transition: ' +
|
|
615
|
+
transitionValue +
|
|
616
|
+
'; transform: translateX(' +
|
|
617
|
+
parseInt(filter.itemsFinalPosition[i][0] - filter.itemsIterPosition[i][0]) +
|
|
618
|
+
'px) translateY(' +
|
|
619
|
+
parseInt(filter.itemsFinalPosition[i][1] - filter.itemsIterPosition[i][1]) +
|
|
620
|
+
'px) scale(1); opacity: 1;',
|
|
621
|
+
);
|
|
622
|
+
} else if (filter.filterList[i]) {
|
|
623
|
+
// Translate item
|
|
624
|
+
filter.items[i].setAttribute(
|
|
625
|
+
'style',
|
|
626
|
+
filter.accelerateStyle +
|
|
627
|
+
'transition: ' +
|
|
628
|
+
transitionValue +
|
|
629
|
+
'; transform: translateX(' +
|
|
630
|
+
parseInt(filter.itemsFinalPosition[i][0] - filter.itemsIterPosition[i][0]) +
|
|
631
|
+
'px) translateY(' +
|
|
632
|
+
parseInt(filter.itemsFinalPosition[i][1] - filter.itemsIterPosition[i][1]) +
|
|
633
|
+
'px);',
|
|
634
|
+
);
|
|
635
|
+
} else {
|
|
636
|
+
// Scale down item
|
|
637
|
+
filter.items[i].setAttribute(
|
|
638
|
+
'style',
|
|
639
|
+
filter.accelerateStyle + 'transition: ' + transitionValue + '; transform: scale(0.5); opacity: 0;',
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}, 50);
|
|
644
|
+
|
|
645
|
+
// Wait for the end of transition of visible elements
|
|
646
|
+
setTimeout(function () {
|
|
647
|
+
resetItems(filter);
|
|
648
|
+
}, filter.options.duration + 100);
|
|
663
649
|
}
|
|
664
650
|
|
|
665
|
-
|
|
651
|
+
function resetItems(filter) {
|
|
652
|
+
// Animation was off or animation is over -> reset attributes
|
|
653
|
+
for (let i = 0; i < filter.items.length; i++) {
|
|
654
|
+
filter.items[i].removeAttribute('style');
|
|
655
|
+
Util.toggleClass(filter.items[i], 'ons-u-hidden', !filter.filterList[i]);
|
|
656
|
+
filter.items[i].removeAttribute('data-scale');
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
for (let i = 0; i < filter.items.length; i++) {
|
|
660
|
+
// Reorder
|
|
661
|
+
filter.element.appendChild(filter.items[filter.sortingList[i][1]]);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
filter.items = [];
|
|
665
|
+
filter.items = filter.element.querySelectorAll('.ons-js-filter__item');
|
|
666
|
+
resetFilterSortArray(filter, false, true);
|
|
667
|
+
filter.element.removeAttribute('style');
|
|
668
|
+
filter.animating = false;
|
|
669
|
+
if (filter.reanimate) {
|
|
670
|
+
updateFilterArray(filter);
|
|
671
|
+
}
|
|
666
672
|
|
|
667
|
-
|
|
668
|
-
// Emit custom event - end of filtering
|
|
669
|
-
filter.element.dispatchEvent(new CustomEvent('filter-selection-updated'));
|
|
670
|
-
}
|
|
673
|
+
resetFallbackMessage(filter, false);
|
|
671
674
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
if (sorting) filter.sortingList[i] = [filter.items[i], i];
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
function createGridInfo(filter) {
|
|
680
|
-
let containerWidth = parseFloat(window.getComputedStyle(filter.element).getPropertyValue('width')),
|
|
681
|
-
itemStyle,
|
|
682
|
-
itemWidth,
|
|
683
|
-
itemHeight,
|
|
684
|
-
marginX,
|
|
685
|
-
marginY,
|
|
686
|
-
colNumber;
|
|
687
|
-
|
|
688
|
-
// Get offset first visible element
|
|
689
|
-
for (let i = 0; i < filter.items.length; i++) {
|
|
690
|
-
if (!Util.hasClass(filter.items[i], 'ons-u-hidden')) {
|
|
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
|
-
filter.itemsGrid[0] = [filter.items[i].offsetLeft, filter.items[i].offsetTop]; // Left, top
|
|
698
|
-
break;
|
|
699
|
-
}
|
|
675
|
+
// Toggle fallback message
|
|
676
|
+
// Emit custom event - end of filtering
|
|
677
|
+
filter.element.dispatchEvent(new CustomEvent('filter-selection-updated'));
|
|
700
678
|
}
|
|
701
679
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
680
|
+
function resetFilterSortArray(filter, filtering, sorting) {
|
|
681
|
+
for (let i = 0; i < filter.items.length; i++) {
|
|
682
|
+
if (filtering) filter.filterList[i] = true;
|
|
683
|
+
if (sorting) filter.sortingList[i] = [filter.items[i], i];
|
|
684
|
+
}
|
|
706
685
|
}
|
|
707
|
-
}
|
|
708
686
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
687
|
+
function createGridInfo(filter) {
|
|
688
|
+
let containerWidth = parseFloat(window.getComputedStyle(filter.element).getPropertyValue('width')),
|
|
689
|
+
itemStyle,
|
|
690
|
+
itemWidth,
|
|
691
|
+
itemHeight,
|
|
692
|
+
marginX,
|
|
693
|
+
marginY,
|
|
694
|
+
colNumber;
|
|
695
|
+
|
|
696
|
+
// Get offset first visible element
|
|
697
|
+
for (let i = 0; i < filter.items.length; i++) {
|
|
698
|
+
if (!Util.hasClass(filter.items[i], 'ons-u-hidden')) {
|
|
699
|
+
itemStyle = window.getComputedStyle(filter.items[i]);
|
|
700
|
+
itemWidth = parseFloat(itemStyle.getPropertyValue('width'));
|
|
701
|
+
itemHeight = parseFloat(itemStyle.getPropertyValue('height'));
|
|
702
|
+
marginX = parseFloat(itemStyle.getPropertyValue('margin-left')) + parseFloat(itemStyle.getPropertyValue('margin-right'));
|
|
703
|
+
marginY = parseFloat(itemStyle.getPropertyValue('margin-bottom')) + parseFloat(itemStyle.getPropertyValue('margin-top'));
|
|
704
|
+
colNumber = parseInt((containerWidth + marginX) / (itemWidth + marginX));
|
|
705
|
+
filter.itemsGrid[0] = [filter.items[i].offsetLeft, filter.items[i].offsetTop]; // Left, top
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
for (let i = 1; i < filter.items.length; i++) {
|
|
711
|
+
let x = i < colNumber ? i : i % colNumber,
|
|
712
|
+
y = i < colNumber ? 0 : Math.floor(i / colNumber);
|
|
713
|
+
filter.itemsGrid[i] = [filter.itemsGrid[0][0] + x * (itemWidth + marginX), filter.itemsGrid[0][1] + y * (itemHeight + marginY)];
|
|
714
|
+
}
|
|
712
715
|
}
|
|
713
|
-
}
|
|
714
716
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
717
|
+
function storeOffset(filter, array) {
|
|
718
|
+
for (let i = 0; i < filter.items.length; i++) {
|
|
719
|
+
array[i] = [filter.items[i].offsetLeft, filter.items[i].offsetTop];
|
|
720
|
+
}
|
|
718
721
|
}
|
|
719
|
-
}
|
|
720
722
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
723
|
+
function initItemsOrder(filter) {
|
|
724
|
+
for (let i = 0; i < filter.items.length; i++) {
|
|
725
|
+
filter.items[i].setAttribute('data-init-sort-order', i);
|
|
726
|
+
}
|
|
724
727
|
}
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
for (let i = 0; i < filter.filterList.length; i++) {
|
|
731
|
-
if (filter.filterList[i]) {
|
|
732
|
-
show = false;
|
|
733
|
-
break;
|
|
734
|
-
}
|
|
728
|
+
|
|
729
|
+
function restoreSortOrder(filter) {
|
|
730
|
+
for (let i = 0; i < filter.items.length; i++) {
|
|
731
|
+
filter.sortingList[parseInt(filter.items[i].getAttribute('data-init-sort-order'))] = [filter.items[i], i];
|
|
732
|
+
}
|
|
735
733
|
}
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
734
|
+
|
|
735
|
+
function resetFallbackMessage(filter, bool) {
|
|
736
|
+
if (!filter.fallbackMessage) return;
|
|
737
|
+
let show = true;
|
|
738
|
+
for (let i = 0; i < filter.filterList.length; i++) {
|
|
739
|
+
if (filter.filterList[i]) {
|
|
740
|
+
show = false;
|
|
741
|
+
break;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
if (bool) {
|
|
745
|
+
// Reset visibility before animation is triggered
|
|
746
|
+
if (!show) Util.addClass(filter.fallbackMessage, 'ons-u-hidden');
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
Util.toggleClass(filter.fallbackMessage, 'ons-u-hidden', !show);
|
|
740
750
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
751
|
+
|
|
752
|
+
function getMultipleSelectValues(multipleSelect) {
|
|
753
|
+
// Get selected options of a <select multiple> element
|
|
754
|
+
let options = multipleSelect.options,
|
|
755
|
+
value = '';
|
|
756
|
+
for (let i = 0; i < options.length; i++) {
|
|
757
|
+
if (options[i].selected) {
|
|
758
|
+
if (value != '') value = value + ':';
|
|
759
|
+
value = value + options[i].value;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
return value;
|
|
753
763
|
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
new Filter({ element: filterGallery[i], duration: duration });
|
|
764
|
+
|
|
765
|
+
Filter.defaults = {
|
|
766
|
+
element: false,
|
|
767
|
+
duration: 400,
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
window.Filter = Filter;
|
|
771
|
+
|
|
772
|
+
// Init Filter object
|
|
773
|
+
let filterGallery = document.getElementsByClassName('ons-js-filter'),
|
|
774
|
+
reducedMotion = Util.osHasReducedMotion();
|
|
775
|
+
if (filterGallery.length > 0) {
|
|
776
|
+
for (let i = 0; i < filterGallery.length; i++) {
|
|
777
|
+
let duration = filterGallery[i].getAttribute('data-filter-duration');
|
|
778
|
+
if (!duration) duration = Filter.defaults.duration;
|
|
779
|
+
new Filter({ element: filterGallery[i], duration: duration });
|
|
780
|
+
}
|
|
772
781
|
}
|
|
773
|
-
}
|
|
774
782
|
})();
|
|
775
783
|
|
|
776
784
|
// ADVANCED FILTERS
|
|
777
785
|
(function () {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
786
|
+
// The Adv Filter object is used to handle:
|
|
787
|
+
// - number of results
|
|
788
|
+
// - form reset
|
|
789
|
+
// - filtering sections label (to show a preview of the option selected by the users)
|
|
790
|
+
|
|
791
|
+
let AdvFilter = function (element) {
|
|
792
|
+
this.element = element;
|
|
793
|
+
this.form = document.getElementsByClassName('ons-js-adv-filter__form');
|
|
794
|
+
this.resultsList = this.element.getElementsByClassName('ons-js-adv-filter__gallery')[0];
|
|
795
|
+
this.resultsCount = this.element.getElementsByClassName('ons-js-adv-filter__results-count');
|
|
796
|
+
this.showCount = document.getElementsByClassName('ons-js-adv-filter__show-results');
|
|
797
|
+
|
|
798
|
+
initAdvFilter(this);
|
|
799
|
+
};
|
|
800
|
+
|
|
801
|
+
function initAdvFilter(filter) {
|
|
802
|
+
if (filter.form.length > 0) {
|
|
803
|
+
// Reset form
|
|
804
|
+
filter.form[0].addEventListener('reset', function () {
|
|
805
|
+
setTimeout(function () {
|
|
806
|
+
resetFilters(filter);
|
|
807
|
+
resetGallery(filter);
|
|
808
|
+
});
|
|
809
|
+
});
|
|
810
|
+
|
|
811
|
+
// Update section labels on form change
|
|
812
|
+
filter.form[0].addEventListener('change', function (event) {
|
|
813
|
+
let section = event.target.closest('.ons-js-adv-filter__item');
|
|
814
|
+
if (section) resetSelection(filter, section);
|
|
815
|
+
else if (Util.is(event.target, '.ons-js-adv-filter__form')) {
|
|
816
|
+
// Reset the entire form lables
|
|
817
|
+
let sections = filter.form[0].getElementsByClassName('ons-js-adv-filter__item');
|
|
818
|
+
for (let i = 0; i < sections.length; i++) resetSelection(filter, sections[i]);
|
|
819
|
+
}
|
|
820
|
+
});
|
|
812
821
|
}
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
822
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
function resetFilters(filter) {
|
|
825
|
-
// Check if there are custom form elemets - reset appearance
|
|
826
|
-
// Custom select
|
|
827
|
-
let customSelect = filter.element.getElementsByClassName('ons-js-select');
|
|
828
|
-
if (customSelect.length > 0) {
|
|
829
|
-
for (let i = 0; i < customSelect.length; i++) customSelect[i].dispatchEvent(new CustomEvent('select-updated'));
|
|
823
|
+
// Reset results count
|
|
824
|
+
if (filter.resultsCount.length > 0) {
|
|
825
|
+
filter.resultsList.addEventListener('filter-selection-updated', function () {
|
|
826
|
+
updateResultsCount(filter);
|
|
827
|
+
});
|
|
828
|
+
}
|
|
830
829
|
}
|
|
831
830
|
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
function resetSelection(filter, section) {
|
|
840
|
-
// Change label value based on input types
|
|
841
|
-
let labelSelection = section.getElementsByClassName('ons-js-adv-filter__selection');
|
|
842
|
-
if (labelSelection.length == 0) return;
|
|
843
|
-
|
|
844
|
-
// Select
|
|
845
|
-
let select = section.getElementsByTagName('select');
|
|
846
|
-
if (select.length > 0) {
|
|
847
|
-
labelSelection[0].textContent = getSelectLabel(section, select[0]);
|
|
848
|
-
return;
|
|
849
|
-
}
|
|
831
|
+
function resetFilters(filter) {
|
|
832
|
+
// Check if there are custom form elemets - reset appearance
|
|
833
|
+
// Custom select
|
|
834
|
+
let customSelect = filter.element.getElementsByClassName('ons-js-select');
|
|
835
|
+
if (customSelect.length > 0) {
|
|
836
|
+
for (let i = 0; i < customSelect.length; i++) customSelect[i].dispatchEvent(new CustomEvent('select-updated'));
|
|
837
|
+
}
|
|
850
838
|
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
839
|
+
// Custom slider
|
|
840
|
+
let customSlider = filter.element.getElementsByClassName('ons-js-slider');
|
|
841
|
+
if (customSlider.length > 0) {
|
|
842
|
+
for (let i = 0; i < customSlider.length; i++) customSlider[i].dispatchEvent(new CustomEvent('slider-updated'));
|
|
843
|
+
}
|
|
856
844
|
}
|
|
857
845
|
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
return;
|
|
863
|
-
}
|
|
846
|
+
function resetSelection(filter, section) {
|
|
847
|
+
// Change label value based on input types
|
|
848
|
+
let labelSelection = section.getElementsByClassName('ons-js-adv-filter__selection');
|
|
849
|
+
if (labelSelection.length == 0) return;
|
|
864
850
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
counter = counter + 1;
|
|
851
|
+
// Select
|
|
852
|
+
let select = section.getElementsByTagName('select');
|
|
853
|
+
if (select.length > 0) {
|
|
854
|
+
labelSelection[0].textContent = getSelectLabel(section, select[0]);
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
// Input number
|
|
859
|
+
let number = section.querySelectorAll('input[type="number"]');
|
|
860
|
+
if (number.length > 0) {
|
|
861
|
+
labelSelection[0].textContent = getNumberLabel(section, number);
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// Input range
|
|
866
|
+
let slider = section.querySelectorAll('input[type="range"]');
|
|
867
|
+
if (slider.length > 0) {
|
|
868
|
+
labelSelection[0].textContent = getSliderLabel(section, slider);
|
|
869
|
+
return;
|
|
885
870
|
}
|
|
886
|
-
if (counter > 1) label = section.getAttribute('data-multi-select-text').replace('{n}', counter);
|
|
887
|
-
}
|
|
888
|
-
return label;
|
|
889
|
-
} else {
|
|
890
|
-
return select.options[select.selectedIndex].text;
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
871
|
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
872
|
+
// Radio/checkboxes
|
|
873
|
+
let radio = section.querySelectorAll('input[type="radio"]'),
|
|
874
|
+
checkbox = section.querySelectorAll('input[type="checkbox"]');
|
|
875
|
+
if (radio.length > 0) {
|
|
876
|
+
labelSelection[0].textContent = getInputListLabel(section, radio);
|
|
877
|
+
return;
|
|
878
|
+
} else if (checkbox.length > 0) {
|
|
879
|
+
labelSelection[0].textContent = getInputListLabel(section, checkbox);
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
898
882
|
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
883
|
+
|
|
884
|
+
function getSelectLabel(section, select) {
|
|
885
|
+
if (select.multiple) {
|
|
886
|
+
let label = '',
|
|
887
|
+
counter = 0;
|
|
888
|
+
for (let i = 0; i < select.options.length; i++) {
|
|
889
|
+
if (select.options[i].selected) {
|
|
890
|
+
label = label + '' + select.options[i].text;
|
|
891
|
+
counter = counter + 1;
|
|
892
|
+
}
|
|
893
|
+
if (counter > 1) label = section.getAttribute('data-multi-select-text').replace('{n}', counter);
|
|
894
|
+
}
|
|
895
|
+
return label;
|
|
896
|
+
} else {
|
|
897
|
+
return select.options[select.selectedIndex].text;
|
|
898
|
+
}
|
|
909
899
|
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
900
|
+
|
|
901
|
+
function getNumberLabel(section, number) {
|
|
902
|
+
let counter = 0;
|
|
903
|
+
for (let i = 0; i < number.length; i++) {
|
|
904
|
+
if (number[i].value != number[i].min) counter = counter + 1;
|
|
905
|
+
}
|
|
906
|
+
if (number.length > 1) {
|
|
907
|
+
// Multiple input number in this section
|
|
908
|
+
if (counter > 0) {
|
|
909
|
+
return section.getAttribute('data-multi-select-text').replace('{n}', counter);
|
|
910
|
+
} else {
|
|
911
|
+
return section.getAttribute('data-default-text');
|
|
912
|
+
}
|
|
913
|
+
} else {
|
|
914
|
+
if (number[0].value == number[0].min) return section.getAttribute('data-default-text');
|
|
915
|
+
else return section.getAttribute('data-number-format').replace('{n}', number[0].value);
|
|
916
|
+
}
|
|
918
917
|
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
if (labelElement.length > 0) label = labelElement[0].textContent;
|
|
929
|
-
counter = counter + 1;
|
|
930
|
-
}
|
|
918
|
+
|
|
919
|
+
function getSliderLabel(section, slider) {
|
|
920
|
+
let label = '',
|
|
921
|
+
labelFormat = section.getAttribute('data-number-format');
|
|
922
|
+
for (let i = 0; i < slider.length; i++) {
|
|
923
|
+
if (i != 0) label = label + ' - ';
|
|
924
|
+
label = label + labelFormat.replace('{n}', slider[i].value);
|
|
925
|
+
}
|
|
926
|
+
return label;
|
|
931
927
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
for (let i = 0; i < resultItems.length; i++) {
|
|
948
|
-
if (isVisible(resultItems[i])) counter = counter + 1;
|
|
928
|
+
|
|
929
|
+
function getInputListLabel(section, inputs) {
|
|
930
|
+
let counter = 0,
|
|
931
|
+
label = '';
|
|
932
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
933
|
+
if (inputs[i].checked) {
|
|
934
|
+
let labelElement = inputs[i].parentNode.getElementsByTagName('label');
|
|
935
|
+
if (labelElement.length > 0) label = labelElement[0].textContent;
|
|
936
|
+
counter = counter + 1;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
if (counter > 1) return section.getAttribute('data-multi-select-text').replace('{n}', counter);
|
|
940
|
+
else if (counter == 0) return section.getAttribute('data-default-text');
|
|
941
|
+
else return label;
|
|
949
942
|
}
|
|
950
943
|
|
|
951
|
-
filter
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
function isVisible(element) {
|
|
956
|
-
return element.offsetWidth || element.offsetHeight || element.getClientRects().length;
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
// Initialize the AdvFilter objects
|
|
960
|
-
let advFilter = document.getElementsByClassName('ons-js-adv-filter');
|
|
961
|
-
if (advFilter.length > 0) {
|
|
962
|
-
for (let i = 0; i < advFilter.length; i++) {
|
|
963
|
-
(function (i) {
|
|
964
|
-
new AdvFilter(advFilter[i]);
|
|
965
|
-
})(i);
|
|
944
|
+
function resetGallery(filter) {
|
|
945
|
+
// Emit change event + reset filtering
|
|
946
|
+
filter.form[0].dispatchEvent(new CustomEvent('change'));
|
|
947
|
+
filter.resultsList.dispatchEvent(new CustomEvent('update-filter-results'));
|
|
966
948
|
}
|
|
967
|
-
}
|
|
968
949
|
|
|
969
|
-
|
|
950
|
+
function updateResultsCount(filter) {
|
|
951
|
+
let resultItems = filter.resultsList.children,
|
|
952
|
+
counter = 0;
|
|
970
953
|
|
|
971
|
-
|
|
972
|
-
|
|
954
|
+
for (let i = 0; i < resultItems.length; i++) {
|
|
955
|
+
if (isVisible(resultItems[i])) counter = counter + 1;
|
|
956
|
+
}
|
|
973
957
|
|
|
974
|
-
|
|
958
|
+
filter.resultsCount[0].textContent = counter; // Update results count
|
|
959
|
+
filter.showCount[0].textContent = counter; // Update show count
|
|
960
|
+
}
|
|
975
961
|
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
962
|
+
function isVisible(element) {
|
|
963
|
+
return element.offsetWidth || element.offsetHeight || element.getClientRects().length;
|
|
964
|
+
}
|
|
979
965
|
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
let
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
let price = parseInt(items[i].getAttribute('data-price'));
|
|
988
|
-
filteredArray[i] = price >= minVal && price <= maxVal;
|
|
989
|
-
}
|
|
990
|
-
return filteredArray;
|
|
991
|
-
},
|
|
992
|
-
indexValue: function (items) {
|
|
993
|
-
// This is the index custom function
|
|
994
|
-
let filteredArray = [],
|
|
995
|
-
value = document.getElementById('index-value').value;
|
|
996
|
-
for (let i = 0; i < items.length; i++) {
|
|
997
|
-
let index = parseInt(items[i].getAttribute('data-sort-index'));
|
|
998
|
-
filteredArray[i] = index >= value;
|
|
966
|
+
// Initialize the AdvFilter objects
|
|
967
|
+
let advFilter = document.getElementsByClassName('ons-js-adv-filter');
|
|
968
|
+
if (advFilter.length > 0) {
|
|
969
|
+
for (let i = 0; i < advFilter.length; i++) {
|
|
970
|
+
(function (i) {
|
|
971
|
+
new AdvFilter(advFilter[i]);
|
|
972
|
+
})(i);
|
|
999
973
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
// Remove the code below if you want to use a custom filtering function (e.g., you need to fetch your results from a database)
|
|
977
|
+
|
|
978
|
+
// The code below is used for filtering of page content (animation of DOM elements, no fetching results from database).
|
|
979
|
+
// It uses the Filter component - you can modify the custom filtering functions based on your needs.
|
|
980
|
+
|
|
981
|
+
let gallery = document.getElementById('adv-filter-gallery');
|
|
982
|
+
|
|
983
|
+
if (gallery) {
|
|
984
|
+
new Filter({
|
|
985
|
+
element: gallery,
|
|
986
|
+
|
|
987
|
+
// This is your gallery element
|
|
988
|
+
priceRange: function (items) {
|
|
989
|
+
// This is the price custom function
|
|
990
|
+
let filteredArray = [],
|
|
991
|
+
minVal = document.getElementById('slider-min-value').value,
|
|
992
|
+
maxVal = document.getElementById('slider-max-value').value;
|
|
993
|
+
for (let i = 0; i < items.length; i++) {
|
|
994
|
+
let price = parseInt(items[i].getAttribute('data-price'));
|
|
995
|
+
filteredArray[i] = price >= minVal && price <= maxVal;
|
|
996
|
+
}
|
|
997
|
+
return filteredArray;
|
|
998
|
+
},
|
|
999
|
+
indexValue: function (items) {
|
|
1000
|
+
// This is the index custom function
|
|
1001
|
+
let filteredArray = [],
|
|
1002
|
+
value = document.getElementById('index-value').value;
|
|
1003
|
+
for (let i = 0; i < items.length; i++) {
|
|
1004
|
+
let index = parseInt(items[i].getAttribute('data-sort-index'));
|
|
1005
|
+
filteredArray[i] = index >= value;
|
|
1006
|
+
}
|
|
1007
|
+
return filteredArray;
|
|
1008
|
+
},
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1004
1011
|
})();
|
|
1005
1012
|
|
|
1006
1013
|
// TOGGLE FILTERS
|
|
1007
1014
|
(function () {
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
// Detect click on update
|
|
1026
|
-
filtersShow.addEventListener('click', function (event) {
|
|
1027
|
-
event.preventDefault();
|
|
1028
|
-
filtersTrigger.click();
|
|
1029
|
-
});
|
|
1030
|
-
|
|
1031
|
-
// Detect click on close
|
|
1032
|
-
filtersClose.addEventListener('click', function (event) {
|
|
1033
|
-
event.preventDefault();
|
|
1034
|
-
filtersTrigger.click();
|
|
1035
|
-
});
|
|
1036
|
-
|
|
1037
|
-
// Listen for key events
|
|
1038
|
-
window.addEventListener('keyup', function (event) {
|
|
1039
|
-
// Listen for ESC key
|
|
1040
|
-
if ((event.keyCode && event.keyCode == 27) || (event.key && event.key.toLowerCase() == 'escape')) {
|
|
1041
|
-
// Close filter panel on mobile if open
|
|
1042
|
-
if (filtersTrigger.getAttribute('aria-expanded') == 'true' && isVisible(filtersTrigger)) {
|
|
1043
|
-
filtersTrigger.click();
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
});
|
|
1015
|
+
let filters = document.getElementsByClassName('ons-js-adv-filter');
|
|
1016
|
+
|
|
1017
|
+
if (filters.length > 0) {
|
|
1018
|
+
let filtersTrigger = filters[0].getElementsByClassName('ons-js-adv-filter__trigger')[0];
|
|
1019
|
+
let filtersClose = filters[0].getElementsByClassName('ons-js-adv-filter__close')[0];
|
|
1020
|
+
let filtersShow = filters[0].getElementsByClassName('ons-js-adv-filter__show')[0];
|
|
1021
|
+
let filtersWrap = filters[0].getElementsByClassName('ons-js-adv-filter__wrap')[0];
|
|
1022
|
+
let filtersPanel = filters[0].getElementsByClassName('ons-js-adv-filter__panel')[0];
|
|
1023
|
+
let body = document.getElementsByTagName('body')[0];
|
|
1024
|
+
let page = document.getElementsByClassName('ons-page')[0];
|
|
1025
|
+
|
|
1026
|
+
// Detect click on filters trigger
|
|
1027
|
+
filtersTrigger.addEventListener('click', function (event) {
|
|
1028
|
+
event.preventDefault();
|
|
1029
|
+
toggleFilters(!Util.hasClass(filtersPanel, 'ons-adv-filter__panel--is-visible'));
|
|
1030
|
+
});
|
|
1047
1031
|
|
|
1048
|
-
|
|
1049
|
-
|
|
1032
|
+
// Detect click on update
|
|
1033
|
+
filtersShow.addEventListener('click', function (event) {
|
|
1034
|
+
event.preventDefault();
|
|
1035
|
+
filtersTrigger.click();
|
|
1036
|
+
});
|
|
1050
1037
|
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1038
|
+
// Detect click on close
|
|
1039
|
+
filtersClose.addEventListener('click', function (event) {
|
|
1040
|
+
event.preventDefault();
|
|
1041
|
+
filtersTrigger.click();
|
|
1042
|
+
});
|
|
1055
1043
|
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1044
|
+
// Listen for key events
|
|
1045
|
+
window.addEventListener('keyup', function (event) {
|
|
1046
|
+
// Listen for ESC key
|
|
1047
|
+
if ((event.keyCode && event.keyCode == 27) || (event.key && event.key.toLowerCase() == 'escape')) {
|
|
1048
|
+
// Close filter panel on mobile if open
|
|
1049
|
+
if (filtersTrigger.getAttribute('aria-expanded') == 'true' && isVisible(filtersTrigger)) {
|
|
1050
|
+
filtersTrigger.click();
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1059
1054
|
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1055
|
+
// Listen for resize
|
|
1056
|
+
let resizingId = false;
|
|
1057
|
+
|
|
1058
|
+
window.addEventListener('resize', function () {
|
|
1059
|
+
clearTimeout(resizingId);
|
|
1060
|
+
resizingId = setTimeout(doneResizing, 500);
|
|
1061
|
+
});
|
|
1062
|
+
|
|
1063
|
+
function doneResizing() {
|
|
1064
|
+
if (!isVisible(filtersTrigger)) toggleFilters(false);
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
function isVisible(element) {
|
|
1068
|
+
return element.offsetWidth || element.offsetHeight || element.getClientRects().length;
|
|
1069
|
+
}
|
|
1063
1070
|
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1071
|
+
// Toggle filters visibility on small devices
|
|
1072
|
+
function toggleFilters(bool) {
|
|
1073
|
+
if (bool === true) {
|
|
1074
|
+
body.appendChild(filtersPanel);
|
|
1075
|
+
} else {
|
|
1076
|
+
filtersWrap.appendChild(filtersPanel);
|
|
1077
|
+
}
|
|
1078
|
+
Util.toggleClass(page, 'ons-u-d-no', bool);
|
|
1079
|
+
Util.toggleClass(filtersPanel, 'ons-adv-filter__panel--is-visible', bool);
|
|
1080
|
+
Util.toggleClass(body, 'ons-no-scroll', bool);
|
|
1081
|
+
filtersTrigger.setAttribute('aria-expanded', bool);
|
|
1082
|
+
filtersTrigger.setAttribute('aria-hidden', bool);
|
|
1083
|
+
page.setAttribute('aria-hidden', bool);
|
|
1084
|
+
Util.toggleClass(filtersTrigger, 'ons-u-d-no', bool);
|
|
1085
|
+
}
|
|
1078
1086
|
}
|
|
1079
|
-
}
|
|
1080
1087
|
})();
|