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/FormModule.js
DELETED
|
@@ -1,706 +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
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
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); } }
|
|
19
|
-
|
|
20
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
21
|
-
|
|
22
|
-
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); }
|
|
23
|
-
|
|
24
|
-
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
25
|
-
|
|
26
|
-
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); }
|
|
27
|
-
|
|
28
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
29
|
-
|
|
30
|
-
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); }; }
|
|
31
|
-
|
|
32
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
33
|
-
|
|
34
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
35
|
-
|
|
36
|
-
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; } }
|
|
37
|
-
|
|
38
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
|
-
|
|
40
|
-
var toObject = require('form-to-object');
|
|
41
|
-
|
|
42
|
-
var selectEl = require('select-el');
|
|
43
|
-
/**
|
|
44
|
-
* @classdesc A class for creating an ajax form. <br>
|
|
45
|
-
* Available targets:
|
|
46
|
-
* <ul>
|
|
47
|
-
* <li>success - If success. Argument - {@linkcode Vevet.AJAXEvent.CacheItem}</li>
|
|
48
|
-
* <li>failure - If failure. Argument - {@linkcode Vevet.AJAXEvent.ErrorCallback}</li>
|
|
49
|
-
* </ul>
|
|
50
|
-
* <br><br> <b>import {FormModule} from 'vevet';</b>
|
|
51
|
-
*
|
|
52
|
-
* @vevetModuleCallback { Vevet.FormModule : success : Vevet.AJAXEvent.CacheItem}
|
|
53
|
-
* @vevetModuleCallback { Vevet.FormModule : failure : Vevet.FormModule.ErrorCallback}
|
|
54
|
-
*
|
|
55
|
-
* @class
|
|
56
|
-
* @memberof Vevet
|
|
57
|
-
* @augments Vevet.Module
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var FormModule = /*#__PURE__*/function (_Module) {
|
|
62
|
-
_inherits(FormModule, _Module);
|
|
63
|
-
|
|
64
|
-
var _super = _createSuper(FormModule);
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @memberof Vevet.FormModule
|
|
68
|
-
* @typedef {object} Properties
|
|
69
|
-
* @augments Vevet.Module.Properties
|
|
70
|
-
*
|
|
71
|
-
* @property {object} [selectors] - *** An object with css selectors.
|
|
72
|
-
* @property {string|HTMLFormElement} [selectors.form=.vevet-form] - The form element.
|
|
73
|
-
* @property {string} [selectors.error=.vevet-form__error] - The elements, in which errors will be displayed. For each element it is possible to create a div. It must contain the attribute "for" which is equal to the name of the input.
|
|
74
|
-
* @property {string} [selectors.errors=.vevet-form__errors] - The element, in which all errors will be displayed.
|
|
75
|
-
*
|
|
76
|
-
* @property {boolean} [addErrorClass=true] - True if you need to set error classes to elements.
|
|
77
|
-
* @property {boolean} [addFilledClass=true] - True if you need to set the class "vevet-form__input_filled" when inputs are not empty.
|
|
78
|
-
* @property {Array<string>} [filledExceptions=['', 'none']] - Values that will be thought to be "empty".
|
|
79
|
-
* @property {boolean} [addFocusClass=true] - Add the class "vevet-form__input_focus" to inputs when they are focused.
|
|
80
|
-
* @property {boolean} [clearAfterSuccess=true] - True if you need to reset values after the submit request is successful.
|
|
81
|
-
* @property {boolean} [disabledSubmit=false] - True if you need to disable the submit button until all inputs are filled.
|
|
82
|
-
*
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* @alias Vevet.FormModule
|
|
87
|
-
*
|
|
88
|
-
* @param {Vevet.FormModule.Properties} [data]
|
|
89
|
-
*/
|
|
90
|
-
function FormModule(data) {
|
|
91
|
-
_classCallCheck(this, FormModule);
|
|
92
|
-
|
|
93
|
-
return _super.call(this, data);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
_createClass(FormModule, [{
|
|
97
|
-
key: "prefix",
|
|
98
|
-
get: function get() {
|
|
99
|
-
return "".concat(this._v.prefix, "form");
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* @readonly
|
|
103
|
-
* @type {Vevet.FormModule.Properties}
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
}, {
|
|
107
|
-
key: "defaultProp",
|
|
108
|
-
get: function get() {
|
|
109
|
-
var prefix = this._prefix;
|
|
110
|
-
return (0, _merge.default)(_get(_getPrototypeOf(FormModule.prototype), "defaultProp", this), {
|
|
111
|
-
selectors: {
|
|
112
|
-
form: ".".concat(prefix),
|
|
113
|
-
error: ".".concat(prefix, "__error"),
|
|
114
|
-
errors: ".".concat(prefix, "__errors")
|
|
115
|
-
},
|
|
116
|
-
addErrorClass: true,
|
|
117
|
-
addFilledClass: true,
|
|
118
|
-
filledExceptions: ['', 'none'],
|
|
119
|
-
addFocusClass: true,
|
|
120
|
-
clearAfterSuccess: true,
|
|
121
|
-
disabledSubmit: false
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* @member Vevet.FormModule#prop
|
|
126
|
-
* @memberof Vevet.FormModule
|
|
127
|
-
* @readonly
|
|
128
|
-
* @type {Vevet.FormModule.Properties}
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* @member Vevet.FormModule#_prop
|
|
133
|
-
* @memberof Vevet.FormModule
|
|
134
|
-
* @protected
|
|
135
|
-
* @type {Vevet.FormModule.Properties}
|
|
136
|
-
*/
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* @function Vevet.FormModule#changeProp
|
|
140
|
-
* @memberof Vevet.FormModule
|
|
141
|
-
* @param {Vevet.FormModule.Properties} [prop]
|
|
142
|
-
*/
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* @description If an ajax request is in process.
|
|
146
|
-
* @default false
|
|
147
|
-
* @readonly
|
|
148
|
-
* @type {boolean}
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
}, {
|
|
152
|
-
key: "loading",
|
|
153
|
-
get: function get() {
|
|
154
|
-
return this._loading;
|
|
155
|
-
} // Extra Constructor
|
|
156
|
-
|
|
157
|
-
}, {
|
|
158
|
-
key: "_extra",
|
|
159
|
-
value: function _extra() {
|
|
160
|
-
_get(_getPrototypeOf(FormModule.prototype), "_extra", this).call(this);
|
|
161
|
-
/**
|
|
162
|
-
* @description If loading at the moment.
|
|
163
|
-
* @protected
|
|
164
|
-
* @member {boolean}
|
|
165
|
-
*/
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
this._loading = false;
|
|
169
|
-
this._inputClass = "".concat(this._prefix, "__input");
|
|
170
|
-
this._filledClass = "".concat(this._inputClass, "_filled"); // get elements
|
|
171
|
-
|
|
172
|
-
this._getElements();
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* @description Get elements
|
|
176
|
-
* @protected
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
|
-
}, {
|
|
180
|
-
key: "_getElements",
|
|
181
|
-
value: function _getElements() {
|
|
182
|
-
var _this = this;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* @description The form element.
|
|
186
|
-
* @protected
|
|
187
|
-
* @member {HTMLFormElement}
|
|
188
|
-
*/
|
|
189
|
-
this._outer = selectEl.one(this._prop.selectors.form);
|
|
190
|
-
var outer = this._outer;
|
|
191
|
-
/**
|
|
192
|
-
* @description Form inputs.
|
|
193
|
-
* @protected
|
|
194
|
-
* @member {NodeList}
|
|
195
|
-
*/
|
|
196
|
-
|
|
197
|
-
this._el = outer.querySelectorAll('input:not([type="submit"]):not([type="button"]), select, textarea, keygen'); // set filled class
|
|
198
|
-
|
|
199
|
-
this._el.forEach(function (el) {
|
|
200
|
-
_this._classFilled(el);
|
|
201
|
-
});
|
|
202
|
-
/**
|
|
203
|
-
* @description Error elements.
|
|
204
|
-
* @protected
|
|
205
|
-
* @member {NodeList}
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
this._errors = outer.querySelectorAll(this._prop.selectors.error);
|
|
210
|
-
/**
|
|
211
|
-
* @description Errors outer.
|
|
212
|
-
* @protected
|
|
213
|
-
* @member {HTMLElement}
|
|
214
|
-
*/
|
|
215
|
-
|
|
216
|
-
this._errorsOuter = outer.querySelector(this._prop.selectors.errors);
|
|
217
|
-
/**
|
|
218
|
-
* @description Submit button.
|
|
219
|
-
* @protected
|
|
220
|
-
* @member {HTMLButtonElement|HTMLInputElement}
|
|
221
|
-
*/
|
|
222
|
-
|
|
223
|
-
this._submit = outer.querySelector("input[type='submit'], button[type='submit']"); // if submit is now disabled
|
|
224
|
-
|
|
225
|
-
this._submitDisabled();
|
|
226
|
-
} // Events
|
|
227
|
-
|
|
228
|
-
}, {
|
|
229
|
-
key: "_setEvents",
|
|
230
|
-
value: function _setEvents() {
|
|
231
|
-
var _this2 = this;
|
|
232
|
-
|
|
233
|
-
// events on elements
|
|
234
|
-
this._el.forEach(function (el) {
|
|
235
|
-
_this2.listener(el, 'focus', _this2._inputFocus.bind(_this2, el));
|
|
236
|
-
|
|
237
|
-
_this2.listener(el, 'blur', _this2._inputBlur.bind(_this2, el));
|
|
238
|
-
|
|
239
|
-
_this2.listener(el, 'keyup', _this2._inputKeyup.bind(_this2, el));
|
|
240
|
-
}); // submit event
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
this.listener(this._outer, 'submit', this.submit.bind(this));
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* @description Set classes if an input is not empty.
|
|
247
|
-
* @param {HTMLElement} el
|
|
248
|
-
* @protected
|
|
249
|
-
*/
|
|
250
|
-
|
|
251
|
-
}, {
|
|
252
|
-
key: "_classFilled",
|
|
253
|
-
value: function _classFilled(el) {
|
|
254
|
-
var parent = el.parentElement,
|
|
255
|
-
filledClass = this._filledClass;
|
|
256
|
-
|
|
257
|
-
if (parent.classList.contains(this._inputClass)) {
|
|
258
|
-
if (this._filled(el)) {
|
|
259
|
-
parent.classList.add(filledClass);
|
|
260
|
-
} else {
|
|
261
|
-
parent.classList.remove(filledClass);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* @description Check if an input is not empty.
|
|
267
|
-
* @param {HTMLElement} el
|
|
268
|
-
* @protected
|
|
269
|
-
*/
|
|
270
|
-
|
|
271
|
-
}, {
|
|
272
|
-
key: "_filled",
|
|
273
|
-
value: function _filled(el) {
|
|
274
|
-
var value = el.value,
|
|
275
|
-
prop = this._prop;
|
|
276
|
-
|
|
277
|
-
if (prop.filledExceptions.includes(value)) {
|
|
278
|
-
return false;
|
|
279
|
-
} else {
|
|
280
|
-
if (prop.addFilledClass) {
|
|
281
|
-
return true;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return false;
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* @description Check if all inputs are not empty.
|
|
289
|
-
* @protected
|
|
290
|
-
*/
|
|
291
|
-
|
|
292
|
-
}, {
|
|
293
|
-
key: "_filledAll",
|
|
294
|
-
value: function _filledAll() {
|
|
295
|
-
var _this3 = this;
|
|
296
|
-
|
|
297
|
-
var count = 0;
|
|
298
|
-
|
|
299
|
-
this._el.forEach(function (el) {
|
|
300
|
-
if (_this3._filled(el)) {
|
|
301
|
-
count++;
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
if (count == this._el.length) {
|
|
306
|
-
return true;
|
|
307
|
-
} else {
|
|
308
|
-
return false;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* @description Disable submit if inputs are empty.
|
|
313
|
-
* @protected
|
|
314
|
-
*/
|
|
315
|
-
|
|
316
|
-
}, {
|
|
317
|
-
key: "_submitDisabled",
|
|
318
|
-
value: function _submitDisabled() {
|
|
319
|
-
var attr = "disabled";
|
|
320
|
-
|
|
321
|
-
if (this._prop.disabledSubmit) {
|
|
322
|
-
if (this._submit) {
|
|
323
|
-
if (!this._filledAll()) {
|
|
324
|
-
this._submit.setAttribute(attr, attr);
|
|
325
|
-
} else {
|
|
326
|
-
this._submit.removeAttribute(attr);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* @description Element focus.
|
|
333
|
-
* @param {HTMLElement} el
|
|
334
|
-
* @protected
|
|
335
|
-
*/
|
|
336
|
-
|
|
337
|
-
}, {
|
|
338
|
-
key: "_inputFocus",
|
|
339
|
-
value: function _inputFocus(el) {
|
|
340
|
-
var parent = el.parentElement;
|
|
341
|
-
|
|
342
|
-
if (!this._prop.addFocusClass) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
if (parent.classList.contains(this._inputClass)) {
|
|
347
|
-
parent.classList.add("".concat(this._inputClass, "_focus"));
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* @description Element blur.
|
|
352
|
-
* @param {HTMLElement} el
|
|
353
|
-
* @protected
|
|
354
|
-
*/
|
|
355
|
-
|
|
356
|
-
}, {
|
|
357
|
-
key: "_inputBlur",
|
|
358
|
-
value: function _inputBlur(el) {
|
|
359
|
-
var parent = el.parentElement;
|
|
360
|
-
|
|
361
|
-
if (parent.classList.contains(this._inputClass)) {
|
|
362
|
-
parent.classList.remove("".concat(this._inputClass, "_focus"));
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
this._classFilled(el);
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* @description Element keyup.
|
|
369
|
-
* @protected
|
|
370
|
-
*/
|
|
371
|
-
|
|
372
|
-
}, {
|
|
373
|
-
key: "_inputKeyup",
|
|
374
|
-
value: function _inputKeyup() {
|
|
375
|
-
// check if submit is still disabled
|
|
376
|
-
this._submitDisabled();
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* @description Submit form.
|
|
380
|
-
* @param {object} [e=false] - Event data.
|
|
381
|
-
* @returns {boolean} Return true if success.
|
|
382
|
-
*/
|
|
383
|
-
|
|
384
|
-
}, {
|
|
385
|
-
key: "submit",
|
|
386
|
-
value: function submit() {
|
|
387
|
-
var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
388
|
-
|
|
389
|
-
// prevent default action
|
|
390
|
-
if (e) {
|
|
391
|
-
e.preventDefault();
|
|
392
|
-
} // check if possible
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
if (this._loading) {
|
|
396
|
-
return false;
|
|
397
|
-
} // object
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
var obj = {},
|
|
401
|
-
outer = this._outer; // get action
|
|
402
|
-
|
|
403
|
-
obj.action = outer.action; // get method
|
|
404
|
-
|
|
405
|
-
obj.method = outer.method; // get data
|
|
406
|
-
|
|
407
|
-
obj.data = toObject(outer); // disable submit
|
|
408
|
-
|
|
409
|
-
if (this._submit) {
|
|
410
|
-
this._submit.disabled = true;
|
|
411
|
-
} // change vars
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
this._loading = true; // ajax request
|
|
415
|
-
|
|
416
|
-
this._submitRequest(obj); // return
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
return true;
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* @description Ajax Request.
|
|
423
|
-
* @param {object} obj
|
|
424
|
-
* @protected
|
|
425
|
-
*/
|
|
426
|
-
|
|
427
|
-
}, {
|
|
428
|
-
key: "_submitRequest",
|
|
429
|
-
value: function _submitRequest(obj) {
|
|
430
|
-
var _this4 = this;
|
|
431
|
-
|
|
432
|
-
this._v.ajax.load({
|
|
433
|
-
url: obj.action,
|
|
434
|
-
method: obj.method,
|
|
435
|
-
data: obj.data,
|
|
436
|
-
success: function success(data) {
|
|
437
|
-
_this4._submitResponse(data);
|
|
438
|
-
},
|
|
439
|
-
abort: function abort() {
|
|
440
|
-
_this4._submitRequest(obj);
|
|
441
|
-
},
|
|
442
|
-
error: function error() {
|
|
443
|
-
_this4._submitError();
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* @description Request error.
|
|
449
|
-
* @protected
|
|
450
|
-
*/
|
|
451
|
-
|
|
452
|
-
}, {
|
|
453
|
-
key: "_submitError",
|
|
454
|
-
value: function _submitError() {
|
|
455
|
-
throw new Error('Form Error');
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* @description Request response.
|
|
459
|
-
* @param {object} data
|
|
460
|
-
* @protected
|
|
461
|
-
*/
|
|
462
|
-
|
|
463
|
-
}, {
|
|
464
|
-
key: "_submitResponse",
|
|
465
|
-
value: function _submitResponse(data) {
|
|
466
|
-
this._validResponse(data); // enable submit
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
if (this._submit) {
|
|
470
|
-
this._submit.disabled = false;
|
|
471
|
-
} // change vars
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
this._loading = false;
|
|
475
|
-
} // Validators
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* @description Check if the form is valid.
|
|
479
|
-
* @param {object} data
|
|
480
|
-
* @protected
|
|
481
|
-
*/
|
|
482
|
-
|
|
483
|
-
}, {
|
|
484
|
-
key: "_validResponse",
|
|
485
|
-
value: function _validResponse(data) {
|
|
486
|
-
// get response
|
|
487
|
-
var response = data.xhr.response,
|
|
488
|
-
json;
|
|
489
|
-
|
|
490
|
-
try {
|
|
491
|
-
json = JSON.parse(response);
|
|
492
|
-
} catch (e) {
|
|
493
|
-
json = response;
|
|
494
|
-
} // define what action
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
if (json.success) {
|
|
498
|
-
this._validSuccess(data);
|
|
499
|
-
} else {
|
|
500
|
-
this._validErrors(data, json);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* @description Success validation.
|
|
505
|
-
* @param {object} data
|
|
506
|
-
* @protected
|
|
507
|
-
*/
|
|
508
|
-
|
|
509
|
-
}, {
|
|
510
|
-
key: "_validSuccess",
|
|
511
|
-
value: function _validSuccess(data) {
|
|
512
|
-
// hide errors
|
|
513
|
-
this._errorClasses();
|
|
514
|
-
|
|
515
|
-
this._errorEl(); // clear inputs
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
if (this._prop.clearAfterSuccess) {
|
|
519
|
-
this.clear();
|
|
520
|
-
} // callback
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
this.lbt("success", data);
|
|
524
|
-
}
|
|
525
|
-
/**
|
|
526
|
-
* @memberof Vevet.FormModule
|
|
527
|
-
* @typedef {object} ErrorCallback
|
|
528
|
-
* @property {Vevet.AJAXEvent.CacheItem} data - Response data.
|
|
529
|
-
* @property {Array<Vevet.FormModule.Error>} errors - Array of errors.
|
|
530
|
-
*/
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* @description Validate errors.
|
|
534
|
-
* @param {object} data
|
|
535
|
-
* @param {object} json
|
|
536
|
-
* @protected
|
|
537
|
-
*/
|
|
538
|
-
|
|
539
|
-
}, {
|
|
540
|
-
key: "_validErrors",
|
|
541
|
-
value: function _validErrors(data, json) {
|
|
542
|
-
var _this5 = this;
|
|
543
|
-
|
|
544
|
-
var errors = [],
|
|
545
|
-
allErrors = []; // errors
|
|
546
|
-
|
|
547
|
-
if (json.errors) {
|
|
548
|
-
// classes & error elements
|
|
549
|
-
Object.keys(json.errors).forEach(function (key) {
|
|
550
|
-
var value = json.errors[key]; // search overlappings in inputs
|
|
551
|
-
|
|
552
|
-
_this5._el.forEach(function (el) {
|
|
553
|
-
if (el.name == key) {
|
|
554
|
-
errors.push({
|
|
555
|
-
key: key,
|
|
556
|
-
value: value
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
});
|
|
560
|
-
|
|
561
|
-
allErrors.push({
|
|
562
|
-
key: key,
|
|
563
|
-
value: value
|
|
564
|
-
});
|
|
565
|
-
}); // show errors
|
|
566
|
-
|
|
567
|
-
this._errorClasses(errors, allErrors);
|
|
568
|
-
|
|
569
|
-
this._errorEl(errors, allErrors);
|
|
570
|
-
} // callback
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
this.lbt("failure", {
|
|
574
|
-
data: data,
|
|
575
|
-
errors: errors
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
/**
|
|
579
|
-
* @memberof Vevet.FormModule
|
|
580
|
-
* @typedef {object} Error
|
|
581
|
-
* @property {string} key - Input name.
|
|
582
|
-
* @property {string} value - Error message.
|
|
583
|
-
*/
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* @description Set errors in the form.
|
|
587
|
-
* @protected
|
|
588
|
-
* @param {Array<Vevet.FormModule.Error>} [array] - Array of errors for existing inputs.
|
|
589
|
-
* @param {Array<Vevet.FormModule.Error>} [allErrors] - Array of all errors.
|
|
590
|
-
*/
|
|
591
|
-
// eslint-disable-next-line no-unused-vars
|
|
592
|
-
|
|
593
|
-
}, {
|
|
594
|
-
key: "_errorClasses",
|
|
595
|
-
value: function _errorClasses() {
|
|
596
|
-
var _this6 = this;
|
|
597
|
-
|
|
598
|
-
var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
599
|
-
var allErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
600
|
-
|
|
601
|
-
if (!this._prop.addErrorClass) {
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
this._el.forEach(function (el) {
|
|
606
|
-
var error = false,
|
|
607
|
-
name = el.name,
|
|
608
|
-
parent = el.parentElement;
|
|
609
|
-
array.forEach(function (item) {
|
|
610
|
-
if (name == item.key) {
|
|
611
|
-
error = true;
|
|
612
|
-
}
|
|
613
|
-
}); // add classes
|
|
614
|
-
|
|
615
|
-
var inputClass = _this6._inputClass;
|
|
616
|
-
|
|
617
|
-
if (error) {
|
|
618
|
-
el.classList.add("error");
|
|
619
|
-
|
|
620
|
-
if (parent.classList.contains(inputClass)) {
|
|
621
|
-
parent.classList.add("".concat(inputClass, "_error"));
|
|
622
|
-
}
|
|
623
|
-
} else {
|
|
624
|
-
el.classList.remove("error");
|
|
625
|
-
|
|
626
|
-
if (parent.classList.contains(inputClass)) {
|
|
627
|
-
parent.classList.remove("".concat(inputClass, "_error"));
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
/**
|
|
633
|
-
* @description Show errors.
|
|
634
|
-
* @param {Array<object>} array
|
|
635
|
-
* @param {Array<object>} allErrors
|
|
636
|
-
* @protected
|
|
637
|
-
*/
|
|
638
|
-
|
|
639
|
-
}, {
|
|
640
|
-
key: "_errorEl",
|
|
641
|
-
value: function _errorEl() {
|
|
642
|
-
var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
643
|
-
var allErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
644
|
-
|
|
645
|
-
// elements
|
|
646
|
-
this._errors.forEach(function (el) {
|
|
647
|
-
var error = false,
|
|
648
|
-
name = el.getAttribute("for");
|
|
649
|
-
array.forEach(function (item) {
|
|
650
|
-
if (name == item.key) {
|
|
651
|
-
error = true;
|
|
652
|
-
el.innerHTML = item.value;
|
|
653
|
-
}
|
|
654
|
-
}); // add classes
|
|
655
|
-
|
|
656
|
-
if (error) {
|
|
657
|
-
el.classList.add("show");
|
|
658
|
-
} else {
|
|
659
|
-
el.classList.remove("show");
|
|
660
|
-
el.innerHTML = '';
|
|
661
|
-
}
|
|
662
|
-
}); // outer
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
if (this._errorsOuter) {
|
|
666
|
-
if (allErrors.length > 0) {
|
|
667
|
-
var html = '';
|
|
668
|
-
allErrors.forEach(function (item) {
|
|
669
|
-
html += "<li>".concat(item.value, "</li>");
|
|
670
|
-
});
|
|
671
|
-
this._errorsOuter.innerHTML = "\n <ul>\n ".concat(html, "\n </ul>\n ");
|
|
672
|
-
|
|
673
|
-
this._errorsOuter.classList.add("show");
|
|
674
|
-
} else {
|
|
675
|
-
this._errorsOuter.classList.remove("show");
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* @description Clear all inputs except for hidden.
|
|
681
|
-
*/
|
|
682
|
-
|
|
683
|
-
}, {
|
|
684
|
-
key: "clear",
|
|
685
|
-
value: function clear() {
|
|
686
|
-
var _this7 = this;
|
|
687
|
-
|
|
688
|
-
this._el.forEach(function (el) {
|
|
689
|
-
if (el.type != 'hidden') {
|
|
690
|
-
el.value = ''; // reset classes
|
|
691
|
-
|
|
692
|
-
var parent = el.parentElement;
|
|
693
|
-
|
|
694
|
-
if (parent.classList.contains(_this7._inputClass)) {
|
|
695
|
-
parent.classList.remove("".concat(_this7._inputClass, "_filled"));
|
|
696
|
-
parent.classList.remove("".concat(_this7._inputClass, "_focus"));
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
}]);
|
|
702
|
-
|
|
703
|
-
return FormModule;
|
|
704
|
-
}(_Module2.default);
|
|
705
|
-
|
|
706
|
-
exports.default = FormModule;
|