vevet 1.4.27 → 2.0.1-dev.3
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/LICENSE +1 -1
- package/README.md +7 -71
- package/build/cdn/index.js +12 -0
- package/build/cdn/index.js.LICENSE.txt +14 -0
- package/build/cjs/app/Application.js +297 -0
- package/build/cjs/app/events/PageLoad.js +74 -0
- package/build/cjs/app/events/Viewport.js +303 -0
- package/build/cjs/base/Callbacks.js +232 -0
- package/build/cjs/base/Component.js +56 -0
- package/build/cjs/base/Module.js +262 -0
- package/build/cjs/base/MutableProp.js +165 -0
- package/build/cjs/base/Plugin.js +56 -0
- package/build/cjs/components/animation-frame/AnimationFrame.js +183 -0
- package/build/cjs/components/canvas/Ctx2D.js +200 -0
- package/build/cjs/components/canvas/Ctx2DPrerender.js +72 -0
- package/build/cjs/components/cursor/CustomCursor.js +344 -0
- package/build/cjs/components/dragger/Dragger.js +229 -0
- package/build/cjs/components/dragger/DraggerDirection.js +77 -0
- package/build/cjs/components/dragger/DraggerMove.js +84 -0
- package/build/cjs/components/loading/Preloader.js +229 -0
- package/build/cjs/components/loading/ProgressPreloader.js +377 -0
- package/build/cjs/components/page/Page.js +353 -0
- package/build/cjs/components/scroll/custom-scroll/CustomScroll.js +517 -0
- package/build/cjs/components/scroll/plugins/SmoothScrollDragPlugin.js +178 -0
- package/build/cjs/components/scroll/plugins/SmoothScrollKeyboardPlugin.js +138 -0
- package/build/cjs/components/scroll/scrollable/ScrollEventsBase.js +133 -0
- package/build/cjs/components/scroll/scrollable/ScrollView.js +315 -0
- package/build/cjs/components/scroll/scrollbar/Bar.js +315 -0
- package/build/cjs/components/scroll/scrollbar/ScrollBar.js +206 -0
- package/build/cjs/components/scroll/smooth-scroll/SmoothScroll.js +625 -0
- package/build/cjs/components/scroll/types.js +2 -0
- package/build/cjs/components/split-text/SplitText.js +233 -0
- package/build/cjs/components/text/SplitText.js +329 -0
- package/build/cjs/components/timeline/StaticTimeline.js +137 -0
- package/build/cjs/components/timeline/Timeline.js +190 -0
- package/build/cjs/index.js +87 -0
- package/build/cjs/utils/common/index.js +12 -0
- package/build/cjs/utils/common/mergeWithoutArrays.js +19 -0
- package/build/cjs/utils/common/randID.js +11 -0
- package/build/cjs/utils/common/timeoutCallback.js +17 -0
- package/build/cjs/utils/errors.js +8 -0
- package/build/cjs/utils/listeners/index.js +10 -0
- package/build/cjs/utils/listeners/intersectionObserverSupported.js +11 -0
- package/build/cjs/utils/listeners/onScroll.js +47 -0
- package/build/cjs/utils/math/boundVal.js +16 -0
- package/build/cjs/utils/math/index.js +12 -0
- package/build/cjs/utils/math/lerp.js +15 -0
- package/build/cjs/utils/math/scopeProgress.js +25 -0
- package/build/cjs/utils/types/general.js +2 -0
- package/build/cjs/utils/types/utility.js +2 -0
- package/build/es/app/Application.js +210 -0
- package/build/es/app/events/PageLoad.js +47 -0
- package/build/es/app/events/Viewport.js +232 -0
- package/build/es/base/Callbacks.js +205 -0
- package/build/es/base/Component.js +32 -0
- package/build/es/base/Module.js +225 -0
- package/build/es/base/MutableProp.js +152 -0
- package/build/es/base/Plugin.js +31 -0
- package/build/es/components/animation-frame/AnimationFrame.js +145 -0
- package/build/es/components/canvas/Ctx2D.js +133 -0
- package/build/es/components/canvas/Ctx2DPrerender.js +37 -0
- package/build/es/components/cursor/CustomCursor.js +274 -0
- package/build/es/components/dragger/Dragger.js +175 -0
- package/build/es/components/dragger/DraggerDirection.js +42 -0
- package/build/es/components/dragger/DraggerMove.js +56 -0
- package/build/es/components/loading/Preloader.js +164 -0
- package/build/es/components/loading/ProgressPreloader.js +304 -0
- package/build/es/components/page/Page.js +283 -0
- package/build/es/components/scroll/custom-scroll/CustomScroll.js +486 -0
- package/build/es/components/scroll/plugins/SmoothScrollDragPlugin.js +140 -0
- package/build/es/components/scroll/plugins/SmoothScrollKeyboardPlugin.js +109 -0
- package/build/es/components/scroll/scrollable/ScrollEventsBase.js +79 -0
- package/build/es/components/scroll/scrollable/ScrollView.js +264 -0
- package/build/es/components/scroll/scrollbar/Bar.js +262 -0
- package/build/es/components/scroll/scrollbar/ScrollBar.js +152 -0
- package/build/es/components/scroll/smooth-scroll/SmoothScroll.js +519 -0
- package/build/es/components/scroll/types.js +1 -0
- package/build/es/components/split-text/SplitText.js +199 -0
- package/build/es/components/text/SplitText.js +270 -0
- package/build/es/components/timeline/StaticTimeline.js +92 -0
- package/build/es/components/timeline/Timeline.js +141 -0
- package/build/es/index.js +37 -0
- package/build/es/utils/common/index.js +4 -0
- package/build/es/utils/common/mergeWithoutArrays.js +13 -0
- package/build/es/utils/common/randID.js +7 -0
- package/build/es/utils/common/timeoutCallback.js +14 -0
- package/build/es/utils/errors.js +5 -0
- package/build/es/utils/listeners/index.js +3 -0
- package/build/es/utils/listeners/intersectionObserverSupported.js +8 -0
- package/build/es/utils/listeners/onScroll.js +44 -0
- package/build/es/utils/math/boundVal.js +12 -0
- package/build/es/utils/math/index.js +4 -0
- package/build/es/utils/math/lerp.js +11 -0
- package/build/es/utils/math/scopeProgress.js +22 -0
- package/build/es/utils/types/general.js +1 -0
- package/build/es/utils/types/utility.js +1 -0
- package/build/types/app/Application.d.ts +161 -0
- package/build/types/app/Application.d.ts.map +1 -0
- package/build/types/app/events/PageLoad.d.ts +28 -0
- package/build/types/app/events/PageLoad.d.ts.map +1 -0
- package/build/types/app/events/Viewport.d.ts +137 -0
- package/build/types/app/events/Viewport.d.ts.map +1 -0
- package/build/types/base/Callbacks.d.ts +174 -0
- package/build/types/base/Callbacks.d.ts.map +1 -0
- package/build/types/base/Component.d.ts +48 -0
- package/build/types/base/Component.d.ts.map +1 -0
- package/build/types/base/Module.d.ts +179 -0
- package/build/types/base/Module.d.ts.map +1 -0
- package/build/types/base/MutableProp.d.ts +142 -0
- package/build/types/base/MutableProp.d.ts.map +1 -0
- package/build/types/base/Plugin.d.ts +35 -0
- package/build/types/base/Plugin.d.ts.map +1 -0
- package/build/types/components/animation-frame/AnimationFrame.d.ts +96 -0
- package/build/types/components/animation-frame/AnimationFrame.d.ts.map +1 -0
- package/build/types/components/canvas/Ctx2D.d.ts +111 -0
- package/build/types/components/canvas/Ctx2D.d.ts.map +1 -0
- package/build/types/components/canvas/Ctx2DPrerender.d.ts +41 -0
- package/build/types/components/canvas/Ctx2DPrerender.d.ts.map +1 -0
- package/build/types/components/cursor/CustomCursor.d.ts +181 -0
- package/build/types/components/cursor/CustomCursor.d.ts.map +1 -0
- package/build/types/components/dragger/Dragger.d.ts +120 -0
- package/build/types/components/dragger/Dragger.d.ts.map +1 -0
- package/build/types/components/dragger/DraggerDirection.d.ts +39 -0
- package/build/types/components/dragger/DraggerDirection.d.ts.map +1 -0
- package/build/types/components/dragger/DraggerMove.d.ts +49 -0
- package/build/types/components/dragger/DraggerMove.d.ts.map +1 -0
- package/build/types/components/loading/Preloader.d.ts +107 -0
- package/build/types/components/loading/Preloader.d.ts.map +1 -0
- package/build/types/components/loading/ProgressPreloader.d.ts +166 -0
- package/build/types/components/loading/ProgressPreloader.d.ts.map +1 -0
- package/build/types/components/page/Page.d.ts +126 -0
- package/build/types/components/page/Page.d.ts.map +1 -0
- package/build/types/components/scroll/custom-scroll/CustomScroll.d.ts +322 -0
- package/build/types/components/scroll/custom-scroll/CustomScroll.d.ts.map +1 -0
- package/build/types/components/scroll/plugins/SmoothScrollDragPlugin.d.ts +97 -0
- package/build/types/components/scroll/plugins/SmoothScrollDragPlugin.d.ts.map +1 -0
- package/build/types/components/scroll/plugins/SmoothScrollKeyboardPlugin.d.ts +34 -0
- package/build/types/components/scroll/plugins/SmoothScrollKeyboardPlugin.d.ts.map +1 -0
- package/build/types/components/scroll/scrollable/ScrollEventsBase.d.ts +60 -0
- package/build/types/components/scroll/scrollable/ScrollEventsBase.d.ts.map +1 -0
- package/build/types/components/scroll/scrollable/ScrollView.d.ts +140 -0
- package/build/types/components/scroll/scrollable/ScrollView.d.ts.map +1 -0
- package/build/types/components/scroll/scrollbar/Bar.d.ts +84 -0
- package/build/types/components/scroll/scrollbar/Bar.d.ts.map +1 -0
- package/build/types/components/scroll/scrollbar/ScrollBar.d.ts +109 -0
- package/build/types/components/scroll/scrollbar/ScrollBar.d.ts.map +1 -0
- package/build/types/components/scroll/smooth-scroll/SmoothScroll.d.ts +307 -0
- package/build/types/components/scroll/smooth-scroll/SmoothScroll.d.ts.map +1 -0
- package/build/types/components/scroll/types.d.ts +11 -0
- package/build/types/components/scroll/types.d.ts.map +1 -0
- package/build/types/components/split-text/SplitText.d.ts +118 -0
- package/build/types/components/split-text/SplitText.d.ts.map +1 -0
- package/build/types/components/text/SplitText.d.ts +118 -0
- package/build/types/components/text/SplitText.d.ts.map +1 -0
- package/build/types/components/timeline/StaticTimeline.d.ts +92 -0
- package/build/types/components/timeline/StaticTimeline.d.ts.map +1 -0
- package/build/types/components/timeline/Timeline.d.ts +101 -0
- package/build/types/components/timeline/Timeline.d.ts.map +1 -0
- package/build/types/index.d.ts +38 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/utils/common/index.d.ts +5 -0
- package/build/types/utils/common/index.d.ts.map +1 -0
- package/build/types/utils/common/mergeWithoutArrays.d.ts +6 -0
- package/build/types/utils/common/mergeWithoutArrays.d.ts.map +1 -0
- package/build/types/utils/common/randID.d.ts +5 -0
- package/build/types/utils/common/randID.d.ts.map +1 -0
- package/build/types/utils/common/timeoutCallback.d.ts +6 -0
- package/build/types/utils/common/timeoutCallback.d.ts.map +1 -0
- package/build/types/utils/errors.d.ts +3 -0
- package/build/types/utils/errors.d.ts.map +1 -0
- package/build/types/utils/listeners/index.d.ts +4 -0
- package/build/types/utils/listeners/index.d.ts.map +1 -0
- package/build/types/utils/listeners/intersectionObserverSupported.d.ts +2 -0
- package/build/types/utils/listeners/intersectionObserverSupported.d.ts.map +1 -0
- package/build/types/utils/listeners/onScroll.d.ts +10 -0
- package/build/types/utils/listeners/onScroll.d.ts.map +1 -0
- package/build/types/utils/math/boundVal.d.ts +5 -0
- package/build/types/utils/math/boundVal.d.ts.map +1 -0
- package/build/types/utils/math/index.d.ts +5 -0
- package/build/types/utils/math/index.d.ts.map +1 -0
- package/build/types/utils/math/lerp.d.ts +5 -0
- package/build/types/utils/math/lerp.d.ts.map +1 -0
- package/build/types/utils/math/scopeProgress.d.ts +20 -0
- package/build/types/utils/math/scopeProgress.d.ts.map +1 -0
- package/build/types/utils/types/general.d.ts +7 -0
- package/build/types/utils/types/general.d.ts.map +1 -0
- package/build/types/utils/types/utility.d.ts +14 -0
- package/build/types/utils/types/utility.d.ts.map +1 -0
- package/package.json +88 -82
- package/src/cdn/index.js +3 -0
- package/src/sass/base.scss +3 -0
- package/src/sass/components/cursor/_custom-cursor.scss +63 -0
- package/src/sass/components/index.scss +6 -0
- package/src/sass/components/loading/_preloader.scss +15 -0
- package/src/sass/components/scroll/_scrollbar.scss +73 -0
- package/src/sass/components/scroll/_smooth-scroll.scss +17 -0
- package/src/sass/index.scss +3 -0
- package/src/sass/mixins/_scroll.scss +7 -0
- package/{dist/scss → src/sass}/mixins/_transition.scss +8 -4
- package/src/sass/mixins/_viewport.scss +69 -0
- package/src/sass/mixins/index.scss +3 -0
- package/src/ts/app/Application.ts +350 -0
- package/src/ts/app/events/PageLoad.ts +79 -0
- package/src/ts/app/events/Viewport.ts +365 -0
- package/src/ts/base/Callbacks.ts +380 -0
- package/src/ts/base/Component.ts +83 -0
- package/src/ts/base/Module.ts +385 -0
- package/src/ts/base/MutableProp.ts +242 -0
- package/src/ts/base/Plugin.ts +76 -0
- package/src/ts/components/animation-frame/AnimationFrame.ts +264 -0
- package/src/ts/components/canvas/Ctx2D.ts +260 -0
- package/src/ts/components/canvas/Ctx2DPrerender.ts +96 -0
- package/src/ts/components/cursor/CustomCursor.ts +462 -0
- package/src/ts/components/dragger/Dragger.ts +313 -0
- package/src/ts/components/dragger/DraggerDirection.ts +106 -0
- package/src/ts/components/dragger/DraggerMove.ts +114 -0
- package/src/ts/components/loading/Preloader.ts +279 -0
- package/src/ts/components/loading/ProgressPreloader.ts +484 -0
- package/src/ts/components/page/Page.ts +421 -0
- package/src/ts/components/scroll/plugins/SmoothScrollDragPlugin.ts +251 -0
- package/src/ts/components/scroll/plugins/SmoothScrollKeyboardPlugin.ts +166 -0
- package/src/ts/components/scroll/scrollable/ScrollEventsBase.ts +151 -0
- package/src/ts/components/scroll/scrollable/ScrollView.ts +435 -0
- package/src/ts/components/scroll/scrollbar/Bar.ts +364 -0
- package/src/ts/components/scroll/scrollbar/ScrollBar.ts +292 -0
- package/src/ts/components/scroll/smooth-scroll/SmoothScroll.ts +861 -0
- package/src/ts/components/scroll/types.ts +10 -0
- package/src/ts/components/text/SplitText.ts +418 -0
- package/src/ts/components/timeline/StaticTimeline.ts +197 -0
- package/src/ts/components/timeline/Timeline.ts +256 -0
- package/src/ts/index.ts +94 -0
- package/src/ts/utils/common/index.ts +9 -0
- package/src/ts/utils/common/mergeWithoutArrays.ts +20 -0
- package/src/ts/utils/common/randID.ts +9 -0
- package/src/ts/utils/common/timeoutCallback.ts +16 -0
- package/src/ts/utils/errors.ts +6 -0
- package/src/ts/utils/listeners/index.ts +7 -0
- package/src/ts/utils/listeners/intersectionObserverSupported.ts +10 -0
- package/src/ts/utils/listeners/onScroll.ts +56 -0
- package/src/ts/utils/math/boundVal.ts +15 -0
- package/src/ts/utils/math/index.ts +9 -0
- package/src/ts/utils/math/lerp.ts +16 -0
- package/src/ts/utils/math/scopeProgress.ts +23 -0
- package/src/ts/utils/types/general.ts +7 -0
- package/src/ts/utils/types/utility.ts +34 -0
- package/dist/js/AJAXEvent.js +0 -355
- package/dist/js/Application.js +0 -345
- package/dist/js/ColumnsModule.js +0 -392
- package/dist/js/CursorModule.js +0 -390
- package/dist/js/DraggerModule.js +0 -792
- package/dist/js/Event.js +0 -538
- package/dist/js/FilterModule.js +0 -943
- package/dist/js/FormModule.js +0 -706
- package/dist/js/FrameModule.js +0 -229
- package/dist/js/IntervalModule.js +0 -270
- package/dist/js/KeydownModule.js +0 -293
- package/dist/js/LoadEvent.js +0 -106
- package/dist/js/MenuBaseModule.js +0 -292
- package/dist/js/MenuModule.js +0 -265
- package/dist/js/MenuTimelineModule.js +0 -321
- package/dist/js/Module.js +0 -478
- package/dist/js/PageAjaxModule.js +0 -1010
- package/dist/js/PageLoadMediaPlugin.js +0 -285
- package/dist/js/PageModule.js +0 -440
- package/dist/js/PaginationModule.js +0 -961
- package/dist/js/PaginationScrollPlugin.js +0 -209
- package/dist/js/Plugin.js +0 -114
- package/dist/js/PopupModule.js +0 -942
- package/dist/js/PreloaderModule.js +0 -724
- package/dist/js/ResponsiveProp.js +0 -301
- package/dist/js/ScrollAnchorModule.js +0 -554
- package/dist/js/ScrollAnimateModule.js +0 -419
- package/dist/js/ScrollBarPlugin.js +0 -594
- package/dist/js/ScrollDragPlugin.js +0 -396
- package/dist/js/ScrollModule.js +0 -1071
- package/dist/js/ScrollViewModule.js +0 -388
- package/dist/js/SelectModule.js +0 -860
- package/dist/js/SliderCanvasModule.js +0 -733
- package/dist/js/SliderControlsPlugin.js +0 -247
- package/dist/js/SliderCounterPlugin.js +0 -278
- package/dist/js/SliderDotsPlugin.js +0 -270
- package/dist/js/SliderDragSwipePlugin.js +0 -245
- package/dist/js/SliderIntervalPlugin.js +0 -192
- package/dist/js/SliderKeydownPlugin.js +0 -185
- package/dist/js/SliderModule.js +0 -1062
- package/dist/js/SliderWheelPlugin.js +0 -194
- package/dist/js/TextAnimateModule.js +0 -663
- package/dist/js/TextSplitModule.js +0 -785
- package/dist/js/TimelineBaseModule.js +0 -405
- package/dist/js/TimelineModule.js +0 -494
- package/dist/js/URLEvent.js +0 -239
- package/dist/js/ViewportEvent.js +0 -465
- package/dist/js/WheelEventModule.js +0 -295
- package/dist/js/domChildOf.js +0 -46
- package/dist/js/domChildren.js +0 -47
- package/dist/js/domInsertAfter.js +0 -32
- package/dist/js/domRemoveChildren.js +0 -26
- package/dist/js/easing.js +0 -363
- package/dist/js/eventListenerAdd.js +0 -87
- package/dist/js/eventListenerGet.js +0 -49
- package/dist/js/eventListenerRemove.js +0 -36
- package/dist/js/generateId.js +0 -29
- package/dist/js/getBrowserName.js +0 -60
- package/dist/js/getOsName.js +0 -39
- package/dist/js/getVevetProperties.js +0 -22
- package/dist/js/index.js +0 -519
- package/dist/js/mathScopeProgress.js +0 -32
- package/dist/js/mathSpreadScopeProgress.js +0 -35
- package/dist/js/merge.js +0 -33
- package/dist/js/normalizeWheel.js +0 -97
- package/dist/js/text_animate_module_addons/_composite_elementary.js +0 -196
- package/dist/js/text_animate_module_addons/_elementary.js +0 -88
- package/dist/js/timeoutCallback.js +0 -26
- package/dist/js/vevet.js +0 -10
- package/dist/scss/_prefix.scss +0 -1
- package/dist/scss/classes/_clear.scss +0 -5
- package/dist/scss/classes/_col-row.scss +0 -48
- package/dist/scss/classes/_display.scss +0 -65
- package/dist/scss/classes/_document-reset.scss +0 -28
- package/dist/scss/classes/_document.scss +0 -7
- package/dist/scss/classes/_overflow.scss +0 -39
- package/dist/scss/classes/_position.scss +0 -55
- package/dist/scss/classes/_text.scss +0 -24
- package/dist/scss/classes/_transition.scss +0 -22
- package/dist/scss/classes/_wrap.scss +0 -31
- package/dist/scss/classes/index.scss +0 -14
- package/dist/scss/index.scss +0 -3
- package/dist/scss/mixins/_clear.scss +0 -6
- package/dist/scss/mixins/_display.scss +0 -6
- package/dist/scss/mixins/_form.scss +0 -14
- package/dist/scss/mixins/_position.scss +0 -42
- package/dist/scss/mixins/_reset.scss +0 -17
- package/dist/scss/mixins/_responsive.scss +0 -88
- package/dist/scss/mixins/index.scss +0 -7
- package/dist/scss/modules/columns/_settings.scss +0 -1
- package/dist/scss/modules/columns/index.scss +0 -19
- package/dist/scss/modules/cursor/_settings.scss +0 -7
- package/dist/scss/modules/cursor/index.scss +0 -15
- package/dist/scss/modules/form/_settings.scss +0 -15
- package/dist/scss/modules/form/index.scss +0 -57
- package/dist/scss/modules/index.scss +0 -11
- package/dist/scss/modules/menu/_button.scss +0 -58
- package/dist/scss/modules/menu/_menu.scss +0 -25
- package/dist/scss/modules/menu/_settings.scss +0 -23
- package/dist/scss/modules/menu/index.scss +0 -3
- package/dist/scss/modules/pagination/_settings.scss +0 -6
- package/dist/scss/modules/pagination/index.scss +0 -24
- package/dist/scss/modules/popup/_settings.scss +0 -26
- package/dist/scss/modules/popup/index.scss +0 -294
- package/dist/scss/modules/preloader/_settings.scss +0 -3
- package/dist/scss/modules/preloader/index.scss +0 -19
- package/dist/scss/modules/scroll/_settings.scss +0 -22
- package/dist/scss/modules/scroll/index.scss +0 -94
- package/dist/scss/modules/select/_settings.scss +0 -28
- package/dist/scss/modules/select/index.scss +0 -142
- package/dist/scss/modules/slider/_settings.scss +0 -35
- package/dist/scss/modules/slider/index.scss +0 -153
- package/dist/scss/modules/text/_settings.scss +0 -1
- package/dist/scss/modules/text/index.scss +0 -19
- package/dist/types/types.d.ts +0 -18763
package/dist/js/FilterModule.js
DELETED
|
@@ -1,943 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _Module2 = _interopRequireDefault(require("./Module"));
|
|
11
|
-
|
|
12
|
-
var _merge = _interopRequireDefault(require("./merge"));
|
|
13
|
-
|
|
14
|
-
var _generateId = _interopRequireDefault(require("./generateId"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
19
|
-
|
|
20
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
21
|
-
|
|
22
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
23
|
-
|
|
24
|
-
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
|
25
|
-
|
|
26
|
-
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
27
|
-
|
|
28
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
29
|
-
|
|
30
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
|
-
|
|
32
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
33
|
-
|
|
34
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
35
|
-
|
|
36
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
37
|
-
|
|
38
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
-
|
|
40
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
41
|
-
|
|
42
|
-
var selectEl = require('select-el');
|
|
43
|
-
/**
|
|
44
|
-
* @classdesc This class is to create filters. It works together with {@linkcode Vevet.PaginationModule} <br>
|
|
45
|
-
* Available targets:
|
|
46
|
-
* <ul>
|
|
47
|
-
* <li>popstate - argument {@linkcode Vevet.FilterModule.PopstateCallback }</li>
|
|
48
|
-
* <li>save</li>
|
|
49
|
-
* </ul>
|
|
50
|
-
* <br><br> <b>import {FilterModule} from 'vevet';</b>
|
|
51
|
-
*
|
|
52
|
-
* @vevetModuleCallback { Vevet.FilterModule : popstate : Vevet.FilterModule.PopstateCallback }
|
|
53
|
-
* @vevetModuleCallback { Vevet.FilterModule : save : }
|
|
54
|
-
*
|
|
55
|
-
* @class
|
|
56
|
-
* @memberof Vevet
|
|
57
|
-
* @augments Vevet.Module
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var FilterModule = /*#__PURE__*/function (_Module) {
|
|
62
|
-
_inherits(FilterModule, _Module);
|
|
63
|
-
|
|
64
|
-
var _super = _createSuper(FilterModule);
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @memberof Vevet.FilterModule
|
|
68
|
-
* @typedef {object} Properties
|
|
69
|
-
* @augments Vevet.Module.Properties
|
|
70
|
-
*
|
|
71
|
-
* @property {object} [selectors] - ***
|
|
72
|
-
* @property {string|HTMLElement|NodeList|Array<HTMLElement>} [selectors.group=.vevet-filter__group] - Group of filters.
|
|
73
|
-
* Each group must/may have the following data attributes:
|
|
74
|
-
* <ul>
|
|
75
|
-
* <li>data-vevet-filter-group - the name (id) of the group</li>
|
|
76
|
-
* <li>data-vevet-filter-multiple - an optional attribute which defines that several filters
|
|
77
|
-
* may be active within one group. By default, none of the groups are multiple.</li>
|
|
78
|
-
* </ul>
|
|
79
|
-
* @property {string|HTMLElement|NodeList|Array<HTMLElement>} [selectors.filter=.vevet-filter__filter] - Filter elements.
|
|
80
|
-
* Each element must have the following data attributes:
|
|
81
|
-
* <ul>
|
|
82
|
-
* <li>data-vevet-filter-group - to what group the filter belongs</li>
|
|
83
|
-
* <li>data-vevet-filter-id - the filter's ID</li>
|
|
84
|
-
* </ul>
|
|
85
|
-
*
|
|
86
|
-
* @property {boolean} [saveOnChange=true] - Defines if you need to save values when filters are changed.
|
|
87
|
-
*
|
|
88
|
-
* @property {string} [multipleSeparator=_]
|
|
89
|
-
* @property {number} [timeout=0] - Timeout before loading.
|
|
90
|
-
*
|
|
91
|
-
* @property {object} [popstate]
|
|
92
|
-
* @property {boolean} [popstate.event=true] - Catch popstate event.
|
|
93
|
-
* @property {boolean} [popstate.reload=false] - Reload on popstate.
|
|
94
|
-
* @property {number} [popstate.timeout=300]
|
|
95
|
-
*
|
|
96
|
-
* @property {Vevet.PaginationModule} pagination - Pagination Module.
|
|
97
|
-
*
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @alias Vevet.FilterModule
|
|
102
|
-
*
|
|
103
|
-
* @param {Vevet.FilterModule.Properties} data
|
|
104
|
-
*/
|
|
105
|
-
function FilterModule(data) {
|
|
106
|
-
_classCallCheck(this, FilterModule);
|
|
107
|
-
|
|
108
|
-
return _super.call(this, data);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
_createClass(FilterModule, [{
|
|
112
|
-
key: "prefix",
|
|
113
|
-
get: function get() {
|
|
114
|
-
return "".concat(this._v.prefix, "filter");
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* @readonly
|
|
118
|
-
* @type {Vevet.FilterModule.Properties}
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
}, {
|
|
122
|
-
key: "defaultProp",
|
|
123
|
-
get: function get() {
|
|
124
|
-
var prefix = this._prefix;
|
|
125
|
-
return (0, _merge.default)(_get(_getPrototypeOf(FilterModule.prototype), "defaultProp", this), {
|
|
126
|
-
selectors: {
|
|
127
|
-
group: ".".concat(prefix, "__group"),
|
|
128
|
-
filter: ".".concat(prefix, "__filter")
|
|
129
|
-
},
|
|
130
|
-
saveOnChange: true,
|
|
131
|
-
multipleSeparator: '_',
|
|
132
|
-
timeout: 0,
|
|
133
|
-
popstate: {
|
|
134
|
-
event: true,
|
|
135
|
-
reload: false,
|
|
136
|
-
timeout: 300
|
|
137
|
-
},
|
|
138
|
-
pagination: {}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* @member Vevet.FilterModule#prop
|
|
143
|
-
* @memberof Vevet.FilterModule
|
|
144
|
-
* @readonly
|
|
145
|
-
* @type {Vevet.FilterModule.Properties}
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @member Vevet.FilterModule#_prop
|
|
150
|
-
* @memberof Vevet.FilterModule
|
|
151
|
-
* @protected
|
|
152
|
-
* @type {Vevet.FilterModule.Properties}
|
|
153
|
-
*/
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @memberof Vevet.FilterModule
|
|
157
|
-
* @typedef {object} ChangeProperties
|
|
158
|
-
* @augments Vevet.FilterModule.Properties
|
|
159
|
-
*
|
|
160
|
-
* @property {Vevet.PaginationModule} [pagination]
|
|
161
|
-
*
|
|
162
|
-
*/
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* @function Vevet.FilterModule#changeProp
|
|
166
|
-
* @memberof Vevet.FilterModule
|
|
167
|
-
* @param {Vevet.FilterModule.ChangeProperties} [prop]
|
|
168
|
-
*/
|
|
169
|
-
// Extra constructor
|
|
170
|
-
|
|
171
|
-
}, {
|
|
172
|
-
key: "_extra",
|
|
173
|
-
value: function _extra() {
|
|
174
|
-
_get(_getPrototypeOf(FilterModule.prototype), "_extra", this).call(this);
|
|
175
|
-
|
|
176
|
-
var prefix = this._prefix;
|
|
177
|
-
/**
|
|
178
|
-
* @description Available data attributes.
|
|
179
|
-
* @member {object}
|
|
180
|
-
* @protected
|
|
181
|
-
*/
|
|
182
|
-
|
|
183
|
-
this._data = {
|
|
184
|
-
group: "data-".concat(prefix, "-group"),
|
|
185
|
-
multiple: "data-".concat(prefix, "-multiple"),
|
|
186
|
-
id: "data-".concat(prefix, "-id")
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* @description Filter groups.
|
|
190
|
-
* @member {Array<Vevet.FilterModule.Group>}
|
|
191
|
-
* @protected
|
|
192
|
-
*/
|
|
193
|
-
|
|
194
|
-
this._groups = [];
|
|
195
|
-
/**
|
|
196
|
-
* @description Filters.
|
|
197
|
-
* @type {Array<Vevet.FilterModule.Filter>}
|
|
198
|
-
* @protected
|
|
199
|
-
*/
|
|
200
|
-
|
|
201
|
-
this._filters = [];
|
|
202
|
-
/**
|
|
203
|
-
* @description Events that were set on filters
|
|
204
|
-
* @protected
|
|
205
|
-
* @member {Vevet.BindListener}
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
this._filtersEvents = [];
|
|
209
|
-
/**
|
|
210
|
-
* @description Current json - current filters
|
|
211
|
-
* @member {string}
|
|
212
|
-
* @protected
|
|
213
|
-
*/
|
|
214
|
-
|
|
215
|
-
this._json = '{}';
|
|
216
|
-
/**
|
|
217
|
-
* @member {false|number}
|
|
218
|
-
* @protected
|
|
219
|
-
*/
|
|
220
|
-
|
|
221
|
-
this._popstateTimeout = false; // get elements
|
|
222
|
-
|
|
223
|
-
this._elementsGet();
|
|
224
|
-
|
|
225
|
-
this.setFilters(true);
|
|
226
|
-
this._json = this._getFiltersQuery();
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* @description Get filters.
|
|
230
|
-
* @type {Array<Vevet.FilterModule.Filter>}
|
|
231
|
-
* @readonly
|
|
232
|
-
*/
|
|
233
|
-
|
|
234
|
-
}, {
|
|
235
|
-
key: "filters",
|
|
236
|
-
get: function get() {
|
|
237
|
-
return this._filters;
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* @description Get filter groups.
|
|
241
|
-
* @type {Array<Vevet.FilterModule.Group>}
|
|
242
|
-
* @readonly
|
|
243
|
-
*/
|
|
244
|
-
|
|
245
|
-
}, {
|
|
246
|
-
key: "groups",
|
|
247
|
-
get: function get() {
|
|
248
|
-
return this._groups;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* @description Get elements and form arrays of groups and filters.
|
|
252
|
-
* @protected
|
|
253
|
-
*/
|
|
254
|
-
|
|
255
|
-
}, {
|
|
256
|
-
key: "_elementsGet",
|
|
257
|
-
value: function _elementsGet() {
|
|
258
|
-
// get groups
|
|
259
|
-
this._getGroups(); // get filters
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
this._getFilters();
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* @description Get groups.
|
|
266
|
-
* @protected
|
|
267
|
-
*/
|
|
268
|
-
|
|
269
|
-
}, {
|
|
270
|
-
key: "_getGroups",
|
|
271
|
-
value: function _getGroups() {
|
|
272
|
-
var _this = this;
|
|
273
|
-
|
|
274
|
-
// clear groups
|
|
275
|
-
this._groups = []; // get dom groups
|
|
276
|
-
|
|
277
|
-
var items = selectEl.all(this._prop.selectors.group);
|
|
278
|
-
items.forEach(function (el) {
|
|
279
|
-
// get the group's id
|
|
280
|
-
var group = _this._getGroupId(el);
|
|
281
|
-
|
|
282
|
-
if (group) {
|
|
283
|
-
// check if it is multiple
|
|
284
|
-
var multiple = _this._getGroupMultiple(el); // create an object and push it to the stack
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
_this._groups.push({
|
|
288
|
-
el: el,
|
|
289
|
-
id: group,
|
|
290
|
-
multiple: multiple
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* @description Get filters.
|
|
297
|
-
* @protected
|
|
298
|
-
*/
|
|
299
|
-
|
|
300
|
-
}, {
|
|
301
|
-
key: "_getFilters",
|
|
302
|
-
value: function _getFilters() {
|
|
303
|
-
var _this2 = this;
|
|
304
|
-
|
|
305
|
-
// clear filters
|
|
306
|
-
this._clearFilters(); // get dom groups
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
var items = selectEl.all(this._prop.selectors.filter),
|
|
310
|
-
i = 0;
|
|
311
|
-
items.forEach(function (el) {
|
|
312
|
-
// get the filter's properties
|
|
313
|
-
var group = _this2._getGroupByElement(el),
|
|
314
|
-
id = _this2._getFilterID(el);
|
|
315
|
-
|
|
316
|
-
if (group !== false & id !== false) {
|
|
317
|
-
// create an object and push it to the stack
|
|
318
|
-
var obj = {
|
|
319
|
-
el: el,
|
|
320
|
-
group: group,
|
|
321
|
-
active: el.classList.contains("".concat(_this2._prefix, "__filter_active")),
|
|
322
|
-
disabled: false,
|
|
323
|
-
unique_id: (0, _generateId.default)(i),
|
|
324
|
-
id: id
|
|
325
|
-
};
|
|
326
|
-
|
|
327
|
-
_this2._filters.push(obj); // set events
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
var event = _this2.listener(el, "click", _this2.filterClick.bind(_this2, el));
|
|
331
|
-
|
|
332
|
-
_this2._filtersEvents.push(event);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
i++;
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* @description Remove events from filters.
|
|
340
|
-
* @protected
|
|
341
|
-
*/
|
|
342
|
-
|
|
343
|
-
}, {
|
|
344
|
-
key: "_clearFilters",
|
|
345
|
-
value: function _clearFilters() {
|
|
346
|
-
var _this3 = this;
|
|
347
|
-
|
|
348
|
-
this._filtersEvents.forEach(function (event) {
|
|
349
|
-
_this3.removeEventListener(event);
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
this._filters = [];
|
|
353
|
-
this._filtersEvents = [];
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* @memberof Vevet.FilterModule
|
|
357
|
-
* @typedef {object} Group
|
|
358
|
-
*
|
|
359
|
-
* @property {HTMLElement} el
|
|
360
|
-
* @property {string} id
|
|
361
|
-
* @property {boolean} multiple
|
|
362
|
-
*
|
|
363
|
-
*/
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* @memberof Vevet.FilterModule
|
|
367
|
-
* @typedef {object} Filter
|
|
368
|
-
*
|
|
369
|
-
* @property {HTMLElement} el
|
|
370
|
-
* @property {Vevet.FilterModule.Group} group
|
|
371
|
-
* @property {boolean} active
|
|
372
|
-
* @property {boolean} disabled
|
|
373
|
-
* @property {string} id
|
|
374
|
-
* @property {string} unique_id
|
|
375
|
-
*
|
|
376
|
-
*/
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* @description Get group id.
|
|
380
|
-
* @param {HTMLElement} el
|
|
381
|
-
* @returns {string|false} Returns the group's id or false.
|
|
382
|
-
* @protected
|
|
383
|
-
*/
|
|
384
|
-
|
|
385
|
-
}, {
|
|
386
|
-
key: "_getGroupId",
|
|
387
|
-
value: function _getGroupId(el) {
|
|
388
|
-
var attr = el.getAttribute(this._data.group);
|
|
389
|
-
|
|
390
|
-
if (attr) {
|
|
391
|
-
return attr;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
return false;
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* @description Check if the group is multiple.
|
|
398
|
-
* @param {HTMLElement} el
|
|
399
|
-
* @returns {boolean} Returns true or false.
|
|
400
|
-
* @protected
|
|
401
|
-
*/
|
|
402
|
-
|
|
403
|
-
}, {
|
|
404
|
-
key: "_getGroupMultiple",
|
|
405
|
-
value: function _getGroupMultiple(el) {
|
|
406
|
-
var attr = el.getAttribute(this._data.multiple);
|
|
407
|
-
|
|
408
|
-
if (attr) {
|
|
409
|
-
return true;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
return false;
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* @description Get group of an element.
|
|
416
|
-
* @param {HTMLElement} el
|
|
417
|
-
* @returns {Vevet.FilterModule.Group|false} Returns the group or false.
|
|
418
|
-
* @protected
|
|
419
|
-
*/
|
|
420
|
-
|
|
421
|
-
}, {
|
|
422
|
-
key: "_getGroupByElement",
|
|
423
|
-
value: function _getGroupByElement(el) {
|
|
424
|
-
var attr = el.getAttribute(this._data.group);
|
|
425
|
-
|
|
426
|
-
if (attr) {
|
|
427
|
-
var group = false;
|
|
428
|
-
|
|
429
|
-
this._groups.forEach(function (obj) {
|
|
430
|
-
if (obj.id == attr) {
|
|
431
|
-
group = obj;
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
|
|
435
|
-
return group;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
return false;
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* @description Get filter by element.
|
|
442
|
-
* @param {HTMLElement} el
|
|
443
|
-
* @returns {Vevet.FilterModule.Filter|false} Returns the group or false.
|
|
444
|
-
* @protected
|
|
445
|
-
*/
|
|
446
|
-
|
|
447
|
-
}, {
|
|
448
|
-
key: "_getFilterByElement",
|
|
449
|
-
value: function _getFilterByElement(el) {
|
|
450
|
-
var filter = false;
|
|
451
|
-
|
|
452
|
-
this._filters.forEach(function (obj) {
|
|
453
|
-
if (obj.el == el) {
|
|
454
|
-
filter = obj;
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
return filter;
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* @description Get filter by the id of the group.
|
|
462
|
-
* @param {string} id
|
|
463
|
-
* @returns {Array<Vevet.FilterModule.Filter>} Returns filters.
|
|
464
|
-
* @protected
|
|
465
|
-
*/
|
|
466
|
-
|
|
467
|
-
}, {
|
|
468
|
-
key: "_getFiltersByGroupID",
|
|
469
|
-
value: function _getFiltersByGroupID(id) {
|
|
470
|
-
var filters = [];
|
|
471
|
-
|
|
472
|
-
this._filters.forEach(function (obj) {
|
|
473
|
-
if (obj.group.id == id) {
|
|
474
|
-
filters.push(obj);
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
|
|
478
|
-
return filters;
|
|
479
|
-
}
|
|
480
|
-
/**
|
|
481
|
-
* @description Get filters' id.
|
|
482
|
-
* @param {HTMLElement} el
|
|
483
|
-
* @returns {string|false} Returns the value or false.
|
|
484
|
-
* @protected
|
|
485
|
-
*/
|
|
486
|
-
|
|
487
|
-
}, {
|
|
488
|
-
key: "_getFilterID",
|
|
489
|
-
value: function _getFilterID(el) {
|
|
490
|
-
var attr = el.getAttribute(this._data.id);
|
|
491
|
-
|
|
492
|
-
if (attr) {
|
|
493
|
-
return attr;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
return false;
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* @description Save values and push them to the URL.
|
|
500
|
-
* @returns {boolean} Returns true if there are any changes.
|
|
501
|
-
*/
|
|
502
|
-
|
|
503
|
-
}, {
|
|
504
|
-
key: "save",
|
|
505
|
-
value: function save() {
|
|
506
|
-
var query = this._getFiltersQuery();
|
|
507
|
-
|
|
508
|
-
if (query !== this._json) {
|
|
509
|
-
var canUpdate = this._update(query);
|
|
510
|
-
|
|
511
|
-
if (canUpdate) {
|
|
512
|
-
this._json = query;
|
|
513
|
-
this.lbt("save");
|
|
514
|
-
} else {
|
|
515
|
-
return false;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
return true;
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* @description Click on filter. It can be also imitated.
|
|
523
|
-
* @param {HTMLElement} el
|
|
524
|
-
* @param {object} [e]
|
|
525
|
-
* @returns {boolean} Returns true or false.
|
|
526
|
-
*/
|
|
527
|
-
|
|
528
|
-
}, {
|
|
529
|
-
key: "filterClick",
|
|
530
|
-
value: function filterClick(el) {
|
|
531
|
-
var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
532
|
-
|
|
533
|
-
// prevent default action
|
|
534
|
-
if (e) {
|
|
535
|
-
e.preventDefault();
|
|
536
|
-
} // get filter
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
var filter = this._getFilterByElement(el);
|
|
540
|
-
|
|
541
|
-
if (!filter) {
|
|
542
|
-
return false;
|
|
543
|
-
} // check if event possible
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
if (!this._checkFilterClick(filter)) {
|
|
547
|
-
return false;
|
|
548
|
-
} // change values of the filters
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
this._changeFiltersProp(filter); // change classes of the filters
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
this._changeFiltersClasses(filter); // update values if saving is enabled
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
if (this._prop.saveOnChange) {
|
|
558
|
-
return this.save();
|
|
559
|
-
} // return success
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
return true;
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* @description Check if the change of the filter is available.
|
|
566
|
-
* @param {Vevet.FilterModule.Filter} filter
|
|
567
|
-
* @protected
|
|
568
|
-
* @returns {boolean} Ture or false.
|
|
569
|
-
*/
|
|
570
|
-
|
|
571
|
-
}, {
|
|
572
|
-
key: "_checkFilterClick",
|
|
573
|
-
value: function _checkFilterClick(filter) {
|
|
574
|
-
var prop = this._prop; // check if pagination is loading
|
|
575
|
-
|
|
576
|
-
if (prop.pagination.loading) {
|
|
577
|
-
return false;
|
|
578
|
-
} // if the filter is disabled
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
if (filter.disabled) {
|
|
582
|
-
return false;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
return true;
|
|
586
|
-
}
|
|
587
|
-
/**
|
|
588
|
-
* @description Change properties of the filters within one group - active values.
|
|
589
|
-
* @param {Vevet.FilterModule.Filter} filter - Current filter.
|
|
590
|
-
* @protected
|
|
591
|
-
*/
|
|
592
|
-
|
|
593
|
-
}, {
|
|
594
|
-
key: "_changeFiltersProp",
|
|
595
|
-
value: function _changeFiltersProp(filter) {
|
|
596
|
-
// get current group
|
|
597
|
-
var group = filter.group; // get all filters
|
|
598
|
-
|
|
599
|
-
var allFilters = this._getFiltersByGroupID(group.id); // change active/non-active of the current filter and other filters
|
|
600
|
-
// within one group
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
for (var i = 0; i < allFilters.length; i++) {
|
|
604
|
-
var obj = allFilters[i]; // make the current filter active/non-active if the group is multiple
|
|
605
|
-
|
|
606
|
-
if (group.multiple) {
|
|
607
|
-
if (obj.unique_id == filter.unique_id) {
|
|
608
|
-
obj.active = !filter.active;
|
|
609
|
-
}
|
|
610
|
-
} // make the current filter active and others non-active
|
|
611
|
-
// if the group is not multiple
|
|
612
|
-
else {
|
|
613
|
-
if (obj.unique_id == filter.unique_id) {
|
|
614
|
-
obj.active = true;
|
|
615
|
-
} else {
|
|
616
|
-
obj.active = false;
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
/**
|
|
622
|
-
* @description Set classes to the filters: active & disabled.
|
|
623
|
-
* @protected
|
|
624
|
-
*/
|
|
625
|
-
|
|
626
|
-
}, {
|
|
627
|
-
key: "_changeFiltersClasses",
|
|
628
|
-
value: function _changeFiltersClasses() {
|
|
629
|
-
var prefix = this._prefix;
|
|
630
|
-
|
|
631
|
-
this._filters.forEach(function (filter) {
|
|
632
|
-
// active class
|
|
633
|
-
var activeClass = "".concat(prefix, "__filter_active");
|
|
634
|
-
|
|
635
|
-
if (filter.active) {
|
|
636
|
-
filter.el.classList.add(activeClass);
|
|
637
|
-
} else {
|
|
638
|
-
filter.el.classList.remove(activeClass);
|
|
639
|
-
} // disabled class & attribute (for selectors, buttons, etc)
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
var disabledClass = "".concat(prefix, "__filter_disabled");
|
|
643
|
-
|
|
644
|
-
if (filter.disabled) {
|
|
645
|
-
filter.el.classList.add(disabledClass);
|
|
646
|
-
filter.el.disabled = true;
|
|
647
|
-
} else {
|
|
648
|
-
filter.el.classList.remove(disabledClass);
|
|
649
|
-
filter.el.disabled = false;
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
/**
|
|
654
|
-
* @description Set filter properties and classes according to the url. This happens
|
|
655
|
-
* while initializing the class.
|
|
656
|
-
* @param {boolean} considerClasses - Set true if you need to take into consideration active classes
|
|
657
|
-
* of the filters. It is used on initialization.
|
|
658
|
-
*/
|
|
659
|
-
|
|
660
|
-
}, {
|
|
661
|
-
key: "setFilters",
|
|
662
|
-
value: function setFilters() {
|
|
663
|
-
var _this4 = this;
|
|
664
|
-
|
|
665
|
-
var considerClasses = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
666
|
-
var classActive = "".concat(this._prefix, "__filter_active"); // go thru all groups and search groups that exist in the URL
|
|
667
|
-
|
|
668
|
-
this._groups.forEach(function (group) {
|
|
669
|
-
var param = _this4._v.url.getParam({
|
|
670
|
-
key: group.id
|
|
671
|
-
});
|
|
672
|
-
|
|
673
|
-
if (param) {
|
|
674
|
-
var paramValues = param.split(_this4._prop.multipleSeparator); // get filters in the group
|
|
675
|
-
|
|
676
|
-
var filters = _this4._getFiltersByGroupID(group.id);
|
|
677
|
-
|
|
678
|
-
filters.forEach(function (filter) {
|
|
679
|
-
if (paramValues.includes(filter.id)) {
|
|
680
|
-
filter.active = true;
|
|
681
|
-
} else {
|
|
682
|
-
filter.active = false;
|
|
683
|
-
|
|
684
|
-
if (considerClasses) {
|
|
685
|
-
if (filter.el.classList.contains(classActive)) {
|
|
686
|
-
filter.active = true;
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
} else {
|
|
692
|
-
// get filters in the group
|
|
693
|
-
var _filters = _this4._getFiltersByGroupID(group.id);
|
|
694
|
-
|
|
695
|
-
_filters.forEach(function (filter) {
|
|
696
|
-
filter.active = false;
|
|
697
|
-
|
|
698
|
-
if (considerClasses) {
|
|
699
|
-
if (filter.el.classList.contains(classActive)) {
|
|
700
|
-
filter.active = true;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
}); // set classes
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
this._changeFiltersClasses();
|
|
709
|
-
}
|
|
710
|
-
/**
|
|
711
|
-
* @description Get a url query according to the active filters.
|
|
712
|
-
* @protected
|
|
713
|
-
* @returns {string} Returns a JSON string.
|
|
714
|
-
*/
|
|
715
|
-
|
|
716
|
-
}, {
|
|
717
|
-
key: "_getFiltersQuery",
|
|
718
|
-
value: function _getFiltersQuery() {
|
|
719
|
-
var groupsFilters = {};
|
|
720
|
-
|
|
721
|
-
this._filters.forEach(function (filter) {
|
|
722
|
-
// check if the filter is active
|
|
723
|
-
// and only then add it to its group
|
|
724
|
-
if (filter.active) {
|
|
725
|
-
// create group if doesn't exist
|
|
726
|
-
var groupID = filter.group.id;
|
|
727
|
-
|
|
728
|
-
if (typeof groupsFilters[groupID] == "undefined") {
|
|
729
|
-
groupsFilters[groupID] = [];
|
|
730
|
-
} // add filter to the group
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
groupsFilters[groupID].push(filter.id);
|
|
734
|
-
}
|
|
735
|
-
}); // make a json of it
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
var json = JSON.stringify(groupsFilters);
|
|
739
|
-
return json;
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* @description Get active url params.
|
|
743
|
-
* @param {string} json
|
|
744
|
-
* @returns {Array<Array<string>>} Returns values.
|
|
745
|
-
* @protected
|
|
746
|
-
*/
|
|
747
|
-
|
|
748
|
-
}, {
|
|
749
|
-
key: "_getURLParams",
|
|
750
|
-
value: function _getURLParams(json) {
|
|
751
|
-
var prop = this._prop; // create an array: key => value
|
|
752
|
-
|
|
753
|
-
var obj = JSON.parse(json),
|
|
754
|
-
params = [];
|
|
755
|
-
|
|
756
|
-
for (var key in obj) {
|
|
757
|
-
var values = obj[key].join(prop.multipleSeparator);
|
|
758
|
-
params.push([key, values]);
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
return params;
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* @description Update the URL & content according to active filters.
|
|
765
|
-
* @param {string} json
|
|
766
|
-
* @returns {boolean} Returns true the filters have changed.
|
|
767
|
-
* @protected
|
|
768
|
-
*/
|
|
769
|
-
|
|
770
|
-
}, {
|
|
771
|
-
key: "_update",
|
|
772
|
-
value: function _update(json) {
|
|
773
|
-
var prop = this._prop; // check if the url changed
|
|
774
|
-
|
|
775
|
-
if (this._json == json) {
|
|
776
|
-
return false;
|
|
777
|
-
} // create an arryy: key => value
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
var params = this._getURLParams(json),
|
|
781
|
-
paramsPrev = this._getURLParams(this._json); // get pagination
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
var pagination = prop.pagination; // reset pagination
|
|
785
|
-
|
|
786
|
-
var url = this._v.url.setParam({
|
|
787
|
-
key: pagination.prop.param,
|
|
788
|
-
value: '',
|
|
789
|
-
push: false
|
|
790
|
-
}); // reset previous params
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
for (var i = 0; i < paramsPrev.length; i++) {
|
|
794
|
-
var push = false;
|
|
795
|
-
|
|
796
|
-
if (i == paramsPrev.length - 1) {
|
|
797
|
-
push = params.length === 0 ? true : false;
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
url = this._v.url.setParam({
|
|
801
|
-
url: url,
|
|
802
|
-
key: paramsPrev[i][0],
|
|
803
|
-
value: '',
|
|
804
|
-
push: push
|
|
805
|
-
});
|
|
806
|
-
} // push it to the url
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
for (var _i = 0; _i < params.length; _i++) {
|
|
810
|
-
var _push = false;
|
|
811
|
-
|
|
812
|
-
if (_i == params.length - 1) {
|
|
813
|
-
_push = true;
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
url = this._v.url.setParam({
|
|
817
|
-
url: url,
|
|
818
|
-
key: params[_i][0],
|
|
819
|
-
value: params[_i][1] == 'null' ? '' : params[_i][1],
|
|
820
|
-
push: _push
|
|
821
|
-
});
|
|
822
|
-
} // update content
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
pagination.url = url;
|
|
826
|
-
pagination.reload(false); // success
|
|
827
|
-
|
|
828
|
-
return true;
|
|
829
|
-
} // Set events
|
|
830
|
-
|
|
831
|
-
}, {
|
|
832
|
-
key: "_setEvents",
|
|
833
|
-
value: function _setEvents() {
|
|
834
|
-
// popstate event
|
|
835
|
-
this.listener(window, "popstate", this._popstate.bind(this));
|
|
836
|
-
}
|
|
837
|
-
/**
|
|
838
|
-
* @description Popstate events.
|
|
839
|
-
* @protected
|
|
840
|
-
*/
|
|
841
|
-
|
|
842
|
-
}, {
|
|
843
|
-
key: "_popstate",
|
|
844
|
-
value: function _popstate() {
|
|
845
|
-
var popstate = this._prop.popstate;
|
|
846
|
-
|
|
847
|
-
if (!popstate.event) {
|
|
848
|
-
if (popstate.reload) {
|
|
849
|
-
window.location.reload();
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
return false;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
this._popstateLoad();
|
|
856
|
-
}
|
|
857
|
-
/**
|
|
858
|
-
* @description Catch popstate and load new data.
|
|
859
|
-
* @protected
|
|
860
|
-
*/
|
|
861
|
-
|
|
862
|
-
}, {
|
|
863
|
-
key: "_popstateLoad",
|
|
864
|
-
value: function _popstateLoad() {
|
|
865
|
-
var prop = this._prop,
|
|
866
|
-
timeout = prop.popstate.timeout,
|
|
867
|
-
pagination = prop.pagination; // clear timeout
|
|
868
|
-
|
|
869
|
-
if (this._popstateTimeout) {
|
|
870
|
-
clearTimeout(this._popstateTimeout);
|
|
871
|
-
this._popstateTimeout = false;
|
|
872
|
-
} // check if available and then load
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
if (!pagination.loading) {
|
|
876
|
-
this._popstateTimeout = setTimeout(this._popstateForceLoad.bind(this), timeout);
|
|
877
|
-
} // timeouts and callbacks if not available
|
|
878
|
-
else {
|
|
879
|
-
this._popstateTimeout = setTimeout(this._popstateBusyLoad.bind(this), timeout);
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* @description Popstate event when pagination is loading.
|
|
884
|
-
* @protected
|
|
885
|
-
*/
|
|
886
|
-
|
|
887
|
-
}, {
|
|
888
|
-
key: "_popstateBusyLoad",
|
|
889
|
-
value: function _popstateBusyLoad() {
|
|
890
|
-
var _this5 = this;
|
|
891
|
-
|
|
892
|
-
this._prop.pagination.on("load", function () {
|
|
893
|
-
_this5._popstateLoad();
|
|
894
|
-
}, {
|
|
895
|
-
once: true
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* @memberof Vevet.FilterModule
|
|
900
|
-
* @typedef {object} PopstateCallback
|
|
901
|
-
*
|
|
902
|
-
* @property {string} href
|
|
903
|
-
*
|
|
904
|
-
*/
|
|
905
|
-
|
|
906
|
-
/**
|
|
907
|
-
* @description Popstate force load.
|
|
908
|
-
* @protected
|
|
909
|
-
*/
|
|
910
|
-
|
|
911
|
-
}, {
|
|
912
|
-
key: "_popstateForceLoad",
|
|
913
|
-
value: function _popstateForceLoad() {
|
|
914
|
-
this.lbt('popstate', {
|
|
915
|
-
href: window.location.href
|
|
916
|
-
}); // set filters
|
|
917
|
-
|
|
918
|
-
this.setFilters(); // get pagination
|
|
919
|
-
|
|
920
|
-
var pagination = this._prop.pagination; // update pagination url
|
|
921
|
-
|
|
922
|
-
pagination.url = window.location.href; // update pagination active
|
|
923
|
-
|
|
924
|
-
var active = this._v.url.getParam({
|
|
925
|
-
key: pagination.prop.param
|
|
926
|
-
});
|
|
927
|
-
|
|
928
|
-
if (active != null) {
|
|
929
|
-
active = parseInt(active);
|
|
930
|
-
} else {
|
|
931
|
-
active = 1;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
pagination._active = active; // reload pagination
|
|
935
|
-
|
|
936
|
-
pagination.reload(false, false);
|
|
937
|
-
}
|
|
938
|
-
}]);
|
|
939
|
-
|
|
940
|
-
return FilterModule;
|
|
941
|
-
}(_Module2.default);
|
|
942
|
-
|
|
943
|
-
exports.default = FilterModule;
|