@ulu/frontend 0.0.3 → 0.0.6
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/CHANGELOG.md +19 -0
- package/README.md +3 -1
- package/js/deprecated/mini-collapsible.js +1 -1
- package/js/events/index.js +4 -1
- package/js/helpers/css-breakpoint.js +5 -7
- package/js/helpers/file-save.js +4 -0
- package/js/helpers/node-data-manager.js +4 -0
- package/js/helpers/pause-youtube-video.js +4 -0
- package/js/helpers/scrollbar-width-property.js +6 -2
- package/js/index.js +0 -2
- package/js/ui/flipcard.js +5 -1
- package/js/ui/grid.js +4 -0
- package/js/ui/modals.js +4 -1
- package/js/ui/overflow-scroller-pager.js +3 -0
- package/js/ui/overflow-scroller.js +4 -1
- package/js/ui/programmatic-modal.js +3 -0
- package/js/ui/resizer.js +3 -0
- package/js/ui/slider.js +7 -4
- package/js/ui/tabs.js +3 -0
- package/js/ui/tooltip.js +3 -0
- package/js/utils/logger.js +3 -0
- package/package.json +20 -11
- package/scss/_breakpoint.scss +3 -4
- package/scss/_button.scss +4 -4
- package/scss/_color.scss +2 -2
- package/scss/_grid.scss +0 -1
- package/scss/_layout.scss +2 -3
- package/scss/_typography.scss +2 -3
- package/scss/_utils.scss +21 -4
- package/scss/base/_normalize.scss +1 -1
- package/scss/helpers/_units.scss +7 -11
- package/scss/stylesheets/full.scss +1 -4
- package/js/polyfills/element-closest.js +0 -17
- package/js/utils/array.js +0 -28
- package/js/utils/dom.js +0 -122
- package/js/utils/object.js +0 -22
- package/js/utils/performance.js +0 -43
- package/js/utils/regex.js +0 -10
- package/js/utils/string.js +0 -107
- package/trash/js-old/deprecated/doc-ready.js +0 -28
- package/trash/js-old/deprecated/jquery-prototypes.js +0 -309
- package/trash/js-old/deprecated/mini-collapsible-popper-positioning.js +0 -126
- package/trash/js-old/deprecated/mini-collapsible.js +0 -607
- package/trash/js-old/deprecated/script-loader.js +0 -60
- package/trash/js-old/events/index.js +0 -42
- package/trash/js-old/helpers/css-breakpoint.js +0 -247
- package/trash/js-old/helpers/file-save.js +0 -48
- package/trash/js-old/helpers/node-data-manager.js +0 -74
- package/trash/js-old/helpers/pause-youtube-video.js +0 -42
- package/trash/js-old/index.js +0 -15
- package/trash/js-old/polyfills/element-closest.js +0 -17
- package/trash/js-old/ui/flipcard.js +0 -202
- package/trash/js-old/ui/grid.js +0 -67
- package/trash/js-old/ui/modals.js +0 -219
- package/trash/js-old/ui/programmatic-modal.js +0 -91
- package/trash/js-old/ui/resizer.js +0 -60
- package/trash/js-old/ui/slider.js +0 -469
- package/trash/js-old/ui/tabs.js +0 -109
- package/trash/js-old/ui/tooltip.js +0 -82
- package/trash/js-old/utils/array.js +0 -28
- package/trash/js-old/utils/dom.js +0 -122
- package/trash/js-old/utils/logger.js +0 -69
- package/trash/js-old/utils/object.js +0 -22
- package/trash/js-old/utils/performance.js +0 -43
- package/trash/js-old/utils/regex.js +0 -10
- package/trash/js-old/utils/string.js +0 -107
- package/trash/js-old/waypoints/README.md +0 -3
- package/trash/js-old/waypoints/anchor-menu.js +0 -76
- package/trash/js-old/waypoints/element-waypoint.js +0 -75
- package/trash/js-old/waypoints/examples/page-link-menu.md +0 -106
- package/trash/js-old/waypoints/state-in-attribute.js +0 -32
- package/trash/js-old-230729/deprecated/doc-ready.js +0 -28
- package/trash/js-old-230729/deprecated/jquery-prototypes.js +0 -309
- package/trash/js-old-230729/deprecated/mini-collapsible-popper-positioning.js +0 -126
- package/trash/js-old-230729/deprecated/mini-collapsible.js +0 -607
- package/trash/js-old-230729/deprecated/script-loader.js +0 -60
- package/trash/js-old-230729/events/index.js +0 -42
- package/trash/js-old-230729/helpers/css-breakpoint.js +0 -247
- package/trash/js-old-230729/helpers/file-save.js +0 -48
- package/trash/js-old-230729/helpers/node-data-manager.js +0 -74
- package/trash/js-old-230729/helpers/pause-youtube-video.js +0 -42
- package/trash/js-old-230729/helpers/scrollbar-width-property.js +0 -10
- package/trash/js-old-230729/index.js +0 -15
- package/trash/js-old-230729/polyfills/element-closest.js +0 -17
- package/trash/js-old-230729/ui/flipcard.js +0 -202
- package/trash/js-old-230729/ui/grid.js +0 -67
- package/trash/js-old-230729/ui/modals.js +0 -219
- package/trash/js-old-230729/ui/overflow-scroller-pager.js +0 -58
- package/trash/js-old-230729/ui/overflow-scroller.js +0 -160
- package/trash/js-old-230729/ui/programmatic-modal.js +0 -91
- package/trash/js-old-230729/ui/resizer.js +0 -60
- package/trash/js-old-230729/ui/slider.js +0 -468
- package/trash/js-old-230729/ui/tabs.js +0 -109
- package/trash/js-old-230729/ui/tooltip.js +0 -82
- package/trash/js-old-230729/utils/array.js +0 -28
- package/trash/js-old-230729/utils/dom.js +0 -122
- package/trash/js-old-230729/utils/logger.js +0 -69
- package/trash/js-old-230729/utils/object.js +0 -22
- package/trash/js-old-230729/utils/performance.js +0 -43
- package/trash/js-old-230729/utils/regex.js +0 -10
- package/trash/js-old-230729/utils/string.js +0 -107
- package/trash/js-old-230729/waypoints/README.md +0 -3
- package/trash/js-old-230729/waypoints/anchor-menu.js +0 -76
- package/trash/js-old-230729/waypoints/element-waypoint.js +0 -75
- package/trash/js-old-230729/waypoints/examples/page-link-menu.md +0 -106
- package/trash/js-old-230729/waypoints/state-in-attribute.js +0 -32
- package/trash/logo-1.svg +0 -13
- package/trash/logo.svg +0 -16
- package/trash/scss-before-cqc-update/README.md +0 -58
- package/trash/scss-before-cqc-update/_breakpoint.scss +0 -190
- package/trash/scss-before-cqc-update/_button.scss +0 -229
- package/trash/scss-before-cqc-update/_calculate.scss +0 -65
- package/trash/scss-before-cqc-update/_color.scss +0 -211
- package/trash/scss-before-cqc-update/_cssvar.scss +0 -116
- package/trash/scss-before-cqc-update/_element.scss +0 -275
- package/trash/scss-before-cqc-update/_index.scss +0 -29
- package/trash/scss-before-cqc-update/_layout.scss +0 -247
- package/trash/scss-before-cqc-update/_path.scss +0 -59
- package/trash/scss-before-cqc-update/_selector.scss +0 -82
- package/trash/scss-before-cqc-update/_typography.scss +0 -322
- package/trash/scss-before-cqc-update/_units.scss +0 -48
- package/trash/scss-before-cqc-update/_utility.scss +0 -13
- package/trash/scss-before-cqc-update/_utils.scss +0 -211
- package/trash/scss-before-cqc-update/base/_color.scss +0 -14
- package/trash/scss-before-cqc-update/base/_elements.scss +0 -189
- package/trash/scss-before-cqc-update/base/_index.scss +0 -63
- package/trash/scss-before-cqc-update/base/_keyframes.scss +0 -74
- package/trash/scss-before-cqc-update/base/_layout.scss +0 -88
- package/trash/scss-before-cqc-update/base/_normalize.scss +0 -316
- package/trash/scss-before-cqc-update/base/_typography.scss +0 -42
- package/trash/scss-before-cqc-update/components/README.md +0 -5
- package/trash/scss-before-cqc-update/components/README.todos +0 -15
- package/trash/scss-before-cqc-update/components/_button.scss +0 -96
- package/trash/scss-before-cqc-update/components/_grid.scss +0 -671
- package/trash/scss-before-cqc-update/components/_index.scss +0 -70
- package/trash/scss-before-cqc-update/components/_links.scss +0 -35
- package/trash/scss-before-cqc-update/components/_list-lines.scss +0 -74
- package/trash/scss-before-cqc-update/components/_list-ordered.scss +0 -17
- package/trash/scss-before-cqc-update/components/_list-unordered.scss +0 -22
- package/trash/scss-before-cqc-update/components/_rule.scss +0 -94
- package/trash/scss-before-cqc-update/helpers/_color.scss +0 -15
- package/trash/scss-before-cqc-update/helpers/_display.scss +0 -73
- package/trash/scss-before-cqc-update/helpers/_index.scss +0 -68
- package/trash/scss-before-cqc-update/helpers/_print.scss +0 -59
- package/trash/scss-before-cqc-update/helpers/_typography.scss +0 -73
- package/trash/scss-before-cqc-update/helpers/_units.scss +0 -79
- package/trash/scss-before-cqc-update/helpers/_utilities.scss +0 -88
- package/trash/scss-before-cqc-update/stylesheets/README.md +0 -3
- package/trash/scss-before-cqc-update/stylesheets/full.scss +0 -17
- package/trash/scss-old/README.md +0 -58
- package/trash/scss-old/_breakpoint.scss +0 -140
- package/trash/scss-old/_button.scss +0 -223
- package/trash/scss-old/_calculate.scss +0 -64
- package/trash/scss-old/_color.scss +0 -200
- package/trash/scss-old/_element.scss +0 -262
- package/trash/scss-old/_grid.scss +0 -558
- package/trash/scss-old/_index.scss +0 -25
- package/trash/scss-old/_layout.scss +0 -170
- package/trash/scss-old/_path.scss +0 -58
- package/trash/scss-old/_selector.scss +0 -81
- package/trash/scss-old/_typography.scss +0 -320
- package/trash/scss-old/_units.scss +0 -47
- package/trash/scss-old/_utility.scss +0 -12
- package/trash/scss-old/_utils.scss +0 -186
- package/trash/scss-old/base/_color.scss +0 -13
- package/trash/scss-old/base/_elements.scss +0 -183
- package/trash/scss-old/base/_index.scss +0 -62
- package/trash/scss-old/base/_keyframes.scss +0 -74
- package/trash/scss-old/base/_layout.scss +0 -81
- package/trash/scss-old/base/_normalize.scss +0 -316
- package/trash/scss-old/base/_typography.scss +0 -42
- package/trash/scss-old/components/README.md +0 -5
- package/trash/scss-old/components/README.todos +0 -15
- package/trash/scss-old/components/_button.scss +0 -74
- package/trash/scss-old/components/_index.scss +0 -63
- package/trash/scss-old/components/_links.scss +0 -34
- package/trash/scss-old/components/_list-lines.scss +0 -73
- package/trash/scss-old/components/_list-ordered.scss +0 -16
- package/trash/scss-old/components/_list-unordered.scss +0 -21
- package/trash/scss-old/components/_rule.scss +0 -84
- package/trash/scss-old/helpers/_color.scss +0 -14
- package/trash/scss-old/helpers/_display.scss +0 -68
- package/trash/scss-old/helpers/_index.scss +0 -67
- package/trash/scss-old/helpers/_print.scss +0 -59
- package/trash/scss-old/helpers/_typography.scss +0 -73
- package/trash/scss-old/helpers/_units.scss +0 -68
- package/trash/scss-old/helpers/_utilities.scss +0 -82
- package/trash/scss-old/packages/README.md +0 -3
- package/trash/scss-old/packages/everything.scss +0 -17
- package/trash/scss-old-2/README.md +0 -58
- package/trash/scss-old-2/_breakpoint.scss +0 -139
- package/trash/scss-old-2/_button.scss +0 -223
- package/trash/scss-old-2/_calculate.scss +0 -64
- package/trash/scss-old-2/_color.scss +0 -202
- package/trash/scss-old-2/_element.scss +0 -263
- package/trash/scss-old-2/_grid.scss +0 -558
- package/trash/scss-old-2/_index.scss +0 -25
- package/trash/scss-old-2/_layout.scss +0 -170
- package/trash/scss-old-2/_path.scss +0 -58
- package/trash/scss-old-2/_selector.scss +0 -81
- package/trash/scss-old-2/_typography.scss +0 -320
- package/trash/scss-old-2/_units.scss +0 -47
- package/trash/scss-old-2/_utility.scss +0 -12
- package/trash/scss-old-2/_utils.scss +0 -186
- package/trash/scss-old-2/base/_color.scss +0 -13
- package/trash/scss-old-2/base/_elements.scss +0 -182
- package/trash/scss-old-2/base/_index.scss +0 -62
- package/trash/scss-old-2/base/_keyframes.scss +0 -73
- package/trash/scss-old-2/base/_layout.scss +0 -83
- package/trash/scss-old-2/base/_normalize.scss +0 -315
- package/trash/scss-old-2/base/_typography.scss +0 -41
- package/trash/scss-old-2/components/README.md +0 -5
- package/trash/scss-old-2/components/README.todos +0 -15
- package/trash/scss-old-2/components/_button.scss +0 -95
- package/trash/scss-old-2/components/_index.scss +0 -63
- package/trash/scss-old-2/components/_links.scss +0 -33
- package/trash/scss-old-2/components/_list-lines.scss +0 -73
- package/trash/scss-old-2/components/_list-ordered.scss +0 -16
- package/trash/scss-old-2/components/_list-unordered.scss +0 -21
- package/trash/scss-old-2/components/_rule.scss +0 -84
- package/trash/scss-old-2/helpers/_color.scss +0 -14
- package/trash/scss-old-2/helpers/_display.scss +0 -67
- package/trash/scss-old-2/helpers/_index.scss +0 -67
- package/trash/scss-old-2/helpers/_print.scss +0 -58
- package/trash/scss-old-2/helpers/_typography.scss +0 -72
- package/trash/scss-old-2/helpers/_units.scss +0 -68
- package/trash/scss-old-2/helpers/_utilities.scss +0 -81
- package/trash/scss-old-2/packages/README.md +0 -3
- package/trash/scss-old-2/packages/everything.scss +0 -17
- package/trash/scss-old-230729/README.md +0 -58
- package/trash/scss-old-230729/_breakpoint.scss +0 -139
- package/trash/scss-old-230729/_button.scss +0 -223
- package/trash/scss-old-230729/_calculate.scss +0 -64
- package/trash/scss-old-230729/_color.scss +0 -202
- package/trash/scss-old-230729/_element.scss +0 -273
- package/trash/scss-old-230729/_grid.scss +0 -694
- package/trash/scss-old-230729/_index.scss +0 -25
- package/trash/scss-old-230729/_layout.scss +0 -193
- package/trash/scss-old-230729/_path.scss +0 -58
- package/trash/scss-old-230729/_selector.scss +0 -81
- package/trash/scss-old-230729/_typography.scss +0 -320
- package/trash/scss-old-230729/_units.scss +0 -47
- package/trash/scss-old-230729/_utility.scss +0 -12
- package/trash/scss-old-230729/_utils.scss +0 -186
- package/trash/scss-old-230729/base/_color.scss +0 -13
- package/trash/scss-old-230729/base/_elements.scss +0 -188
- package/trash/scss-old-230729/base/_index.scss +0 -62
- package/trash/scss-old-230729/base/_keyframes.scss +0 -73
- package/trash/scss-old-230729/base/_layout.scss +0 -83
- package/trash/scss-old-230729/base/_normalize.scss +0 -315
- package/trash/scss-old-230729/base/_typography.scss +0 -41
- package/trash/scss-old-230729/components/README.md +0 -5
- package/trash/scss-old-230729/components/README.todos +0 -15
- package/trash/scss-old-230729/components/_button.scss +0 -95
- package/trash/scss-old-230729/components/_index.scss +0 -63
- package/trash/scss-old-230729/components/_links.scss +0 -34
- package/trash/scss-old-230729/components/_list-lines.scss +0 -73
- package/trash/scss-old-230729/components/_list-ordered.scss +0 -16
- package/trash/scss-old-230729/components/_list-unordered.scss +0 -21
- package/trash/scss-old-230729/components/_rule.scss +0 -93
- package/trash/scss-old-230729/helpers/_color.scss +0 -14
- package/trash/scss-old-230729/helpers/_display.scss +0 -73
- package/trash/scss-old-230729/helpers/_index.scss +0 -67
- package/trash/scss-old-230729/helpers/_print.scss +0 -58
- package/trash/scss-old-230729/helpers/_typography.scss +0 -72
- package/trash/scss-old-230729/helpers/_units.scss +0 -68
- package/trash/scss-old-230729/helpers/_utilities.scss +0 -87
- package/trash/scss-old-230729/packages/README.md +0 -3
- package/trash/scss-old-230729/packages/everything.scss +0 -17
- package/trash/vue/directives/background-image-url.js +0 -12
- package/trash/vue/helpers/add-required-components.js +0 -14
- package/trash/vue/ui/CollapsibleRegion/CollapsibleRegion.vue +0 -277
- package/trash/vue/ui/CollapsibleRegion/Demo.vue +0 -101
- package/trash/vue/ui/Dropdown/Dropdown.vue +0 -184
- package/trash/vue/ui/Modals/components/Modal.vue +0 -49
- package/trash/vue/ui/Modals/components/Modals.vue +0 -103
- package/trash/vue/ui/Modals/plugin.js +0 -215
- package/trash/vue/ui/Modals/readme.note +0 -10
- package/trash/vue/ui/Modals/reference/example-usage.vue +0 -27
- package/trash/vue/ui/Modals/reference/wcag-example/dialog.js +0 -324
- /package/js/{waypoints → deprecated/waypoints}/README.md +0 -0
- /package/js/{waypoints → deprecated/waypoints}/anchor-menu.js +0 -0
- /package/js/{waypoints → deprecated/waypoints}/element-waypoint.js +0 -0
- /package/js/{waypoints → deprecated/waypoints}/examples/page-link-menu.md +0 -0
- /package/js/{waypoints → deprecated/waypoints}/state-in-attribute.js +0 -0
package/js/utils/dom.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns an array of direct descendants
|
|
3
|
-
* @param {Node} element
|
|
4
|
-
* @param {String} selector
|
|
5
|
-
* @return {Array}
|
|
6
|
-
*/
|
|
7
|
-
export function getDirectDescandants(element, selector) {
|
|
8
|
-
return [...element.children].filter(child => child.matches(selector));
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Checks if element is overflown vertically
|
|
13
|
-
* @param {Node} element
|
|
14
|
-
* @return {Boolean}
|
|
15
|
-
*/
|
|
16
|
-
export function isOverflownY(element) {
|
|
17
|
-
return element.scrollHeight > element.clientHeight;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Checks if element is overflown both vertically and horizontally
|
|
22
|
-
* @param {Node} element
|
|
23
|
-
* @return {Boolean}
|
|
24
|
-
*/
|
|
25
|
-
export function isOverflown(element) {
|
|
26
|
-
return element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* For a given element return the first parent that has scrollable overflow
|
|
31
|
-
* - Helpful for debugging position sticky
|
|
32
|
-
* @param {Node} node Node to start search for first scrollable parent
|
|
33
|
-
* @returns {Node}
|
|
34
|
-
* @example
|
|
35
|
-
* const $navcontent = document.querySelector('.nav__content');
|
|
36
|
-
* if ($navcontent) {
|
|
37
|
-
* console.log(getScrollParent($navcontent));
|
|
38
|
-
* }
|
|
39
|
-
*/
|
|
40
|
-
export function getScrollParent(node) {
|
|
41
|
-
if (node == null) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
if (node.scrollHeight > node.clientHeight) {
|
|
45
|
-
return node;
|
|
46
|
-
} else {
|
|
47
|
-
return getScrollParent(node.parentNode);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Returns reliable document height
|
|
53
|
-
* @return {number}
|
|
54
|
-
*/
|
|
55
|
-
export function documentHeight() {
|
|
56
|
-
return Math.max(
|
|
57
|
-
document.body.scrollHeight, document.documentElement.scrollHeight,
|
|
58
|
-
document.body.offsetHeight, document.documentElement.offsetHeight,
|
|
59
|
-
document.body.clientHeight, document.documentElement.clientHeight
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Returns reliable window height
|
|
65
|
-
* @return {number}
|
|
66
|
-
*/
|
|
67
|
-
export function windowHeight() {
|
|
68
|
-
return Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Returns reliable window width
|
|
73
|
-
* @return {number}
|
|
74
|
-
*/
|
|
75
|
-
export function windowWidth() {
|
|
76
|
-
return Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Check browser support for position: sticky
|
|
81
|
-
* - https://stackoverflow.com/questions/60214332/dynamically-detect-if-positionsticky-is-supported-by-the-browser
|
|
82
|
-
* @return {Boolean}
|
|
83
|
-
*/
|
|
84
|
-
export function browserWithPositionSticky() {
|
|
85
|
-
var prop = 'position:';
|
|
86
|
-
var value = 'sticky';
|
|
87
|
-
var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
|
|
88
|
-
|
|
89
|
-
var el = document.createElement('a');
|
|
90
|
-
var mStyle = el.style;
|
|
91
|
-
mStyle.cssText = prop + prefixes.join(value + ';' + prop).slice(0, - prop.length);
|
|
92
|
-
|
|
93
|
-
return mStyle.position.indexOf(value) !== -1;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Returns Node List from HTML markup string
|
|
98
|
-
* @param {String} markup HTML markup to create into an element
|
|
99
|
-
*/
|
|
100
|
-
export function createElementFromHtml(markup) {
|
|
101
|
-
const doc = new DOMParser().parseFromString(markup, 'text/html');
|
|
102
|
-
return doc.body.firstElementChild;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Creates a new element with attributes and children
|
|
107
|
-
* @param {Object} config Configuration object
|
|
108
|
-
* @param {String} config.tag Node type (ie 'div')
|
|
109
|
-
* @param {Object} config.attributes Attributes to add to the new element
|
|
110
|
-
* @param {Array} config.children Array of children to append into the new element
|
|
111
|
-
*/
|
|
112
|
-
export function composeElement(config) { // tag, attributes = {}, children
|
|
113
|
-
const { tag, attributes, children } = config;
|
|
114
|
-
const element = document.createElement(tag);
|
|
115
|
-
if (attributes) {
|
|
116
|
-
Object.entries(attributes).forEach((a, v) => element.setAttribute(a, v));
|
|
117
|
-
}
|
|
118
|
-
if (children) {
|
|
119
|
-
children.forEach(c => element.appendChild(c));
|
|
120
|
-
}
|
|
121
|
-
return element;
|
|
122
|
-
}
|
package/js/utils/object.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Version: 1.0.0
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Checks object has required properties
|
|
5
|
-
* @param {array.string} required Array of properties to check for
|
|
6
|
-
* @return {function} Function for user to use to test for props passed on objects
|
|
7
|
-
* @example
|
|
8
|
-
* const testProps = hasRequiredProps(["name", "date"]);
|
|
9
|
-
* if (testProps(userConfiguration)) {
|
|
10
|
-
* // Stuff
|
|
11
|
-
* }
|
|
12
|
-
*/
|
|
13
|
-
export function hasRequiredProps(required) {
|
|
14
|
-
/**
|
|
15
|
-
* Function used for testing on user end
|
|
16
|
-
* @param {object} testObject Object to test on
|
|
17
|
-
* @return {Boolean}
|
|
18
|
-
*/
|
|
19
|
-
return function(object) {
|
|
20
|
-
return required.every(value => object.hasOwnProperty(value));
|
|
21
|
-
}
|
|
22
|
-
}
|
package/js/utils/performance.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Version: 1.0.0
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns a function, that, as long as it continues to be invoked, will not be triggered
|
|
5
|
-
* @param {Function} callback Function to invoke
|
|
6
|
-
* @param {Number} wait Amount of time after (milliseconds)
|
|
7
|
-
* @param {Boolean} immediate trigger the function on the leading edge, instead of the trailing.
|
|
8
|
-
* @param {Object} valueThis Context for function
|
|
9
|
-
* @author David Walsh
|
|
10
|
-
* - https://davidwalsh.name/javascript-debounce-function
|
|
11
|
-
*/
|
|
12
|
-
export function debounce(callback, wait, immediate, valueThis) {
|
|
13
|
-
var timeout;
|
|
14
|
-
return function executedFunction() {
|
|
15
|
-
var context = valueThis || this;
|
|
16
|
-
var args = arguments;
|
|
17
|
-
var later = function() {
|
|
18
|
-
timeout = null;
|
|
19
|
-
if (!immediate) callback.apply(context, args);
|
|
20
|
-
};
|
|
21
|
-
var callNow = immediate && !timeout;
|
|
22
|
-
clearTimeout(timeout);
|
|
23
|
-
timeout = setTimeout(later, wait);
|
|
24
|
-
if (callNow) callback.apply(context, args);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Debounces function using requestAnimationFrame()
|
|
30
|
-
* @param {Function} callback Function to invoke, cancelled if called faster than RAF
|
|
31
|
-
* @param {Object} context Optional context to bind to callback
|
|
32
|
-
*/
|
|
33
|
-
export function debounceAnimationFrame(callback, context = null) {
|
|
34
|
-
let tid;
|
|
35
|
-
return function debounced() {
|
|
36
|
-
const args = arguments;
|
|
37
|
-
if (tid) window.cancelAnimationFrame(tid);
|
|
38
|
-
tid = window.requestAnimationFrame(() => {
|
|
39
|
-
tid = false;
|
|
40
|
-
callback.apply(context, args);
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
}
|
package/js/utils/regex.js
DELETED
package/js/utils/string.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { patterns } from "./regex.js";
|
|
2
|
-
/**
|
|
3
|
-
* Will return an object with the separation details
|
|
4
|
-
* @param {[type]} string [description]
|
|
5
|
-
* @return {object} keys: value, original, unit
|
|
6
|
-
*/
|
|
7
|
-
export function separateCssUnit(original) {
|
|
8
|
-
const pattern = /(px|vw|vh|%|em|rem)/i;
|
|
9
|
-
return {
|
|
10
|
-
original,
|
|
11
|
-
value: original.replace(pattern, ""),
|
|
12
|
-
unit: original.match(pattern)[0]
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Removes HTML tags from string
|
|
18
|
-
* - Note you can use document.createElement and grab textContent (but this could execute code in browser)
|
|
19
|
-
* - The method below will just use regex without creating Nodes
|
|
20
|
-
* @param {String} html HTML string to find/replace
|
|
21
|
-
*/
|
|
22
|
-
export function stripTags(html) {
|
|
23
|
-
return html.replace(patterns.htmlTag, "");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @param {String} string String to trim
|
|
29
|
-
* @returns
|
|
30
|
-
*/
|
|
31
|
-
export function trimDoubleSpaces(string) {
|
|
32
|
-
return string.replace(patterns.multiSpace, "");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Remove line breaks
|
|
37
|
-
* @param {String} string String to trim
|
|
38
|
-
* @returns {String}
|
|
39
|
-
*/
|
|
40
|
-
export function trimLineBreaks(string) {
|
|
41
|
-
return string.replace(patterns.linebreaks, "");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Designed originally to flatten style definitions
|
|
46
|
-
* @param {String} string String to trim
|
|
47
|
-
* @returns {String}
|
|
48
|
-
*/
|
|
49
|
-
export function trimWhitespace(string) {
|
|
50
|
-
return string.replace(patterns.linebreaks, "")
|
|
51
|
-
.replace(patterns.multiSpace, " ")
|
|
52
|
-
.trim();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Truncates string with ellipsis if over the max, note use framework function
|
|
57
|
-
* if you need to know the effects of the truncate process (returns an object
|
|
58
|
-
* with info instead) this function only modifies the string
|
|
59
|
-
* @param {string} string String to possibly truncate
|
|
60
|
-
* @param {number} max How many characters max?
|
|
61
|
-
* @return {string}
|
|
62
|
-
*/
|
|
63
|
-
export function truncate(string, max, overflowChar = '…') {
|
|
64
|
-
return string.length <= max ? string : string.slice(0, max) + overflowChar;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Replaces non safe characters with "-"
|
|
69
|
-
* - Does not escape characters
|
|
70
|
-
* - Used for id's and classnames or things that can't have anything but normal a-z 0-9
|
|
71
|
-
*/
|
|
72
|
-
export function urlize(string) {
|
|
73
|
-
var newString;
|
|
74
|
-
string = string.replace(/^[^-_a-zA-Z]+/, '').replace(/^-(?:[-0-9]+)/, '-');
|
|
75
|
-
newString = string && string.replace(/[^-_a-zA-Z0-9]+/g, '-');
|
|
76
|
-
return newString;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Converts date to abbreviated month date ie "Mar 7, 2018"
|
|
81
|
-
* @param {String|Date} str Date or date string (passed through date constructor)
|
|
82
|
-
* @return {String} Pretty date string
|
|
83
|
-
*/
|
|
84
|
-
export function prettyDate(str) {
|
|
85
|
-
const date = new Date(str);
|
|
86
|
-
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
87
|
-
return `${ months[date.getMonth()] } ${ date.getDate() }, ${ date.getFullYear() }`;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Generates a random string of defined length based on
|
|
92
|
-
* a string of allowed characters.
|
|
93
|
-
*
|
|
94
|
-
* @param {number} length How many random characters will be in the returned string. Defaults to 10
|
|
95
|
-
* @param {string} allowed Which characters can be used when creating the random string. Defaults to A-Z,a-z,0-9
|
|
96
|
-
* @return {string} A string of random characters
|
|
97
|
-
*/
|
|
98
|
-
export function randomString(
|
|
99
|
-
length = 10,
|
|
100
|
-
allowed = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
|
101
|
-
) {
|
|
102
|
-
let result = '';
|
|
103
|
-
for (let i = 0; i < length; i++) {
|
|
104
|
-
result += allowed.charAt(Math.floor(Math.random() * allowed.length));
|
|
105
|
-
}
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// =============================================================================
|
|
2
|
-
// Doc Ready - Script
|
|
3
|
-
// =============================================================================
|
|
4
|
-
|
|
5
|
-
// Version: 1.0.0
|
|
6
|
-
|
|
7
|
-
// Description: Simple script that will add a property to the window for
|
|
8
|
-
// other scripts to access. Functions will be fired after
|
|
9
|
-
// DomContentLoaded.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(function(d) {
|
|
13
|
-
var callbacks = [],
|
|
14
|
-
fired = false;
|
|
15
|
-
|
|
16
|
-
window.onDocReady = function(callback) {
|
|
17
|
-
if (fired) callback();
|
|
18
|
-
else callbacks.push(callback);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
d.addEventListener("DOMContentLoaded", function() {
|
|
22
|
-
fired = true;
|
|
23
|
-
for (var i = 0; i < callbacks.length; i++) {
|
|
24
|
-
callbacks[i]();
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
}(document));
|
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
// =============================================================================
|
|
2
|
-
// Jquery Prototypes
|
|
3
|
-
// =============================================================================
|
|
4
|
-
|
|
5
|
-
// Version: 2.0.0
|
|
6
|
-
|
|
7
|
-
// Description: All of our simple jQuery prototypes
|
|
8
|
-
|
|
9
|
-
// Change log: 2.0.0 | Converted to ES Module with exports (so we can pick and choose)
|
|
10
|
-
|
|
11
|
-
const $ = jQuery;
|
|
12
|
-
|
|
13
|
-
// FUnction to do conditions in chaining sequences
|
|
14
|
-
export function when(condition, method, argumentsArray) {
|
|
15
|
-
if (!Array.isArray(argumentsArray)) argumentsArray = [argumentsArray];
|
|
16
|
-
if (typeof condition === 'function') condition = condition.apply(this, argumentsArray);
|
|
17
|
-
if (condition) this[method].apply(this, argumentsArray);
|
|
18
|
-
return condition ? this[method].apply(this, argumentsArray) : this;
|
|
19
|
-
}
|
|
20
|
-
export function mergeObjects() {
|
|
21
|
-
var collect = $([]).add(this);
|
|
22
|
-
for (var i = 0; i < arguments.length; i++) collect = collect.add(arguments[i]);
|
|
23
|
-
return collect;
|
|
24
|
-
}
|
|
25
|
-
export function updateSelection() {
|
|
26
|
-
var elements = $(this.selector);
|
|
27
|
-
this.splice(0, this.length);
|
|
28
|
-
this.push.apply(this, elements);
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
export function findFromRoot(selector) {
|
|
32
|
-
return this.filter(selector).add(this.find(selector));
|
|
33
|
-
}
|
|
34
|
-
export function dataExplode(attrName, delimiter) {
|
|
35
|
-
var dataFound = this.data(attrName);
|
|
36
|
-
return dataFound !== undefined && typeof dataFound === 'string' ? dataFound.split('|') : false;
|
|
37
|
-
}
|
|
38
|
-
export function isOverflowingY() {
|
|
39
|
-
var el = this[0];
|
|
40
|
-
return el.offsetHeight < el.scrollHeight;
|
|
41
|
-
}
|
|
42
|
-
export function isOverflowingX() {
|
|
43
|
-
var el = this[0];
|
|
44
|
-
return el.offsetWidth < el.scrollWidth;
|
|
45
|
-
}
|
|
46
|
-
export function escapeSelector(stringPasssed) {
|
|
47
|
-
return stringPasssed.replace(/(:|\.|\[|\]|,)/g, "\\$1");
|
|
48
|
-
}
|
|
49
|
-
export function getControlled(attr) {
|
|
50
|
-
if (!attr) attr = 'aria-controls';
|
|
51
|
-
var id = this.attr(attr);
|
|
52
|
-
return $('#'+id);
|
|
53
|
-
}
|
|
54
|
-
export function getControls(attr) {
|
|
55
|
-
if (!attr) attr = 'aria-controls';
|
|
56
|
-
var id = this.attr('id');
|
|
57
|
-
return $('['+attr+'='+id+']');
|
|
58
|
-
}
|
|
59
|
-
export function queryVar(variable) {
|
|
60
|
-
var query = curQueryVars,
|
|
61
|
-
vars = query.split("&");
|
|
62
|
-
for (var i=0;i<vars.length;i++) {
|
|
63
|
-
var pair = vars[i].split("=");
|
|
64
|
-
if(pair[0] == variable){return pair[1];}
|
|
65
|
-
}
|
|
66
|
-
return(false);
|
|
67
|
-
}
|
|
68
|
-
export function eachMatchingIndexes(method, collection) {
|
|
69
|
-
this.each(function(i) {
|
|
70
|
-
$(this)[method](collection[i]);
|
|
71
|
-
});
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
export function makeFocusable(forScripts, firstDescendant) {
|
|
75
|
-
|
|
76
|
-
var el = this,
|
|
77
|
-
tabindex = forScripts ? -1 : 0;
|
|
78
|
-
// If they said first descendant (that is focusable)
|
|
79
|
-
if (firstDescendant) {
|
|
80
|
-
var newEl = el.find(_g.focus.titleEl+', '+_g.focus.elFocusable).not('[aria-hidden="true"]');
|
|
81
|
-
if (newEl.length) {
|
|
82
|
-
el = newEl;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
el = el.first();
|
|
86
|
-
if (!el.is(_g.focus.elFocusable)) el.attr('tabindex', tabindex); // Make focusable by scripts
|
|
87
|
-
|
|
88
|
-
return el;
|
|
89
|
-
}
|
|
90
|
-
export function attrBooleanToggle(attribute, forceState) {
|
|
91
|
-
this.attr(attribute, function(i, iString) {
|
|
92
|
-
if (forceState === true || forceState === false) return forceState;
|
|
93
|
-
if (iString === 'true') return 'false';
|
|
94
|
-
return 'true';
|
|
95
|
-
});
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
export function checkIdAndSet(stringForId) {
|
|
99
|
-
if ($(this).attr('id')) {
|
|
100
|
-
return (this).attr('id');
|
|
101
|
-
} else {
|
|
102
|
-
var id = stringForId === undefined ? _g.uniqueId() : stringForId; // If they don't pass string use global method.
|
|
103
|
-
$(this).attr('id', id); // Assign id
|
|
104
|
-
return id; // Return Id for user's use
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
export function scrollParent() {
|
|
108
|
-
var overflowRegex = /(auto|scroll)/,
|
|
109
|
-
position = this.css( "position" ),
|
|
110
|
-
excludeStaticParent = position === "absolute",
|
|
111
|
-
scrollParent = this.parents().filter( function() {
|
|
112
|
-
var parent = $( this );
|
|
113
|
-
if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
var overflowState = parent.css(["overflow", "overflowX", "overflowY"]);
|
|
117
|
-
return (overflowRegex).test( overflowState.overflow + overflowState.overflowX + overflowState.overflowY );
|
|
118
|
-
}).eq( 0 );
|
|
119
|
-
|
|
120
|
-
return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
|
|
121
|
-
}
|
|
122
|
-
export function scrollParentY() {
|
|
123
|
-
var overflowRegex = /(auto|scroll)/,
|
|
124
|
-
position = this.css( "position" ),
|
|
125
|
-
excludeStaticParent = position === "absolute",
|
|
126
|
-
scrollParent = this.parents().filter( function() {
|
|
127
|
-
var parent = $( this );
|
|
128
|
-
if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
var overflowState = parent.css(["overflowY"]);
|
|
132
|
-
return (overflowRegex).test(overflowState.overflowY );
|
|
133
|
-
}).eq( 0 );
|
|
134
|
-
|
|
135
|
-
return position === "fixed" || !scrollParent.length ? $htmlBody : scrollParent;
|
|
136
|
-
}
|
|
137
|
-
export function removeClassStartsWith(stringPassed) {
|
|
138
|
-
this.removeClass(function (index, classes) {
|
|
139
|
-
|
|
140
|
-
// This function splits into an array
|
|
141
|
-
// Then filters out the passed string
|
|
142
|
-
// Then returns it joined as space seperated
|
|
143
|
-
// Jquery then removes those classes
|
|
144
|
-
|
|
145
|
-
return classes
|
|
146
|
-
.split(' ')
|
|
147
|
-
.filter(function(value) {
|
|
148
|
-
return value.includes(stringPassed);
|
|
149
|
-
})
|
|
150
|
-
.join(' ');
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
// For Chaining
|
|
154
|
-
return this;
|
|
155
|
-
}
|
|
156
|
-
export function doesExist(callback){
|
|
157
|
-
if (this.length) {
|
|
158
|
-
if (callback) callback.call(this);
|
|
159
|
-
return true;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
export function notExist(callback){
|
|
163
|
-
if (this.length <= 0) {
|
|
164
|
-
if (callback) callback.call(this);
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
export function sortByDepth() {
|
|
169
|
-
// Sorts jquery object by deepest to shallowest item
|
|
170
|
-
var ar = this.map(function() {
|
|
171
|
-
return {length: $(this).parents().length, elt: this};
|
|
172
|
-
}).get(),
|
|
173
|
-
result = [],
|
|
174
|
-
i = ar.length;
|
|
175
|
-
ar.sort(function(a, b) {
|
|
176
|
-
return a.length - b.length;
|
|
177
|
-
});
|
|
178
|
-
while (i--) {
|
|
179
|
-
result.push(ar[i].elt);
|
|
180
|
-
}
|
|
181
|
-
return $(result);
|
|
182
|
-
};
|
|
183
|
-
// throttleScroll
|
|
184
|
-
export function throttleScroll(eventName, optionalHandler) {
|
|
185
|
-
var posLastY = 0,
|
|
186
|
-
posLastX = 0,
|
|
187
|
-
lastFrameComplete = true,
|
|
188
|
-
el = this;
|
|
189
|
-
|
|
190
|
-
// Internal function for touch move and scroll
|
|
191
|
-
function scrollHandler(event) {
|
|
192
|
-
|
|
193
|
-
var posY = el.scrollTop(),
|
|
194
|
-
posX = el.scrollLeft(),
|
|
195
|
-
elHeight = el.innerHeight(); // cOme back
|
|
196
|
-
|
|
197
|
-
if (lastFrameComplete && (posLastY !== posY || posLastX !== posX)) {
|
|
198
|
-
|
|
199
|
-
var scrollData = {
|
|
200
|
-
positionY: posY,
|
|
201
|
-
positionX: posX,
|
|
202
|
-
height: elHeight,
|
|
203
|
-
positionLastY: posLastY,
|
|
204
|
-
positionLastX: posLastX,
|
|
205
|
-
direction: posLastY > posY ? 'up' :'down'
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
posLastY = posY;
|
|
209
|
-
posLastX = posX;
|
|
210
|
-
lastFrameComplete = false;
|
|
211
|
-
|
|
212
|
-
requestAnimationFrame(function(){
|
|
213
|
-
el.trigger(eventName, [scrollData, event]);
|
|
214
|
-
lastFrameComplete = true;
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Attach our throttling handler
|
|
220
|
-
el.on('scroll touchmove', scrollHandler);
|
|
221
|
-
// If they passed a handler attach it
|
|
222
|
-
if (optionalHandler) el.on(eventName, optionalHandler);
|
|
223
|
-
// Chaining
|
|
224
|
-
return scrollHandler;
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
export function copyAttributes() {
|
|
228
|
-
var attrs = {};
|
|
229
|
-
|
|
230
|
-
$.each(this[0].attributes, function(idx, attr) {
|
|
231
|
-
attrs[attr.nodeName] = attr.nodeValue;
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
return attrs;
|
|
235
|
-
};
|
|
236
|
-
export function attributesFrom(elFrom, overwrite) {
|
|
237
|
-
var $this = this;
|
|
238
|
-
$.each(elFrom[0].attributes, function(idx, attr) {
|
|
239
|
-
$this.attr(attr.nodeName, attr.nodeValue);
|
|
240
|
-
});
|
|
241
|
-
return this;
|
|
242
|
-
};
|
|
243
|
-
export function changeElementType(newType) {
|
|
244
|
-
|
|
245
|
-
var attrs = this.copyAttributes(),
|
|
246
|
-
newElement = $("<" + newType + "/>", attrs).append($(this).contents());
|
|
247
|
-
|
|
248
|
-
this.replaceWith(newElement);
|
|
249
|
-
return newElement;
|
|
250
|
-
};
|
|
251
|
-
// This function accepts a string to search for and if found will use the "change" argument passed.
|
|
252
|
-
// Since this is using the string replace() function you can use either a function or a string.
|
|
253
|
-
// Using :contains selector vs anything reg-ex or filter related because it is extremely fast
|
|
254
|
-
// in tests and the search could be deep. Contains will give us both the element with the
|
|
255
|
-
// text and the parents (unfortunate). So once we have them we filter by nodeType 3 which
|
|
256
|
-
// is text nodes. And then check if that node has the string. If it does we run replace with
|
|
257
|
-
// the string and call the users callback for the replacement.
|
|
258
|
-
export function replaceText(find, change, filterSelector) {
|
|
259
|
-
this
|
|
260
|
-
.find(':contains(' + find + ')')
|
|
261
|
-
.filter(filterSelector || null)
|
|
262
|
-
.contents()
|
|
263
|
-
.filter(function() {
|
|
264
|
-
return this.nodeType === 3 && this.nodeValue.includes(find);
|
|
265
|
-
})
|
|
266
|
-
.each(function() {
|
|
267
|
-
var newNode = document.createElement('span');
|
|
268
|
-
newNode.innerHTML = this.nodeValue.replace(find, change);
|
|
269
|
-
this.parentNode.insertBefore(newNode, this);
|
|
270
|
-
this.parentNode.removeChild(this);
|
|
271
|
-
});
|
|
272
|
-
return this;
|
|
273
|
-
};
|
|
274
|
-
// Better jqeury.each(), passes the $(this) that everyone makes into a variable anyways
|
|
275
|
-
// This is based on prototype.each which uses jQuery.each(object, callback) so it
|
|
276
|
-
// should perform as well. Test here: https://codepen.io/Jscherbe/pen/pZMZOo
|
|
277
|
-
export function forEach(callback) {
|
|
278
|
-
var $t;
|
|
279
|
-
for (var i = 0; i < this.length; i++) {
|
|
280
|
-
$t = $(this[i]);
|
|
281
|
-
if (callback.call($t, i, $t) === false) break;
|
|
282
|
-
}
|
|
283
|
-
return this;
|
|
284
|
-
};
|
|
285
|
-
export function isOutside(context) {
|
|
286
|
-
return !context.has(this).length || context.is(this);
|
|
287
|
-
};
|
|
288
|
-
export function apply(fn, args) {
|
|
289
|
-
fn.apply(this, args);
|
|
290
|
-
return this;
|
|
291
|
-
};
|
|
292
|
-
export function hasAttr(name) {
|
|
293
|
-
var attr = this.attr(name);
|
|
294
|
-
return !(typeof attr !== undefined && attr !== false);
|
|
295
|
-
};
|
|
296
|
-
export function debounce(func, wait, immediate, valueThis) {
|
|
297
|
-
var timeout;
|
|
298
|
-
return function() {
|
|
299
|
-
var context = valueThis || this, args = arguments;
|
|
300
|
-
var later = function() {
|
|
301
|
-
timeout = null;
|
|
302
|
-
if (!immediate) func.apply(context, args);
|
|
303
|
-
};
|
|
304
|
-
var callNow = immediate && !timeout;
|
|
305
|
-
clearTimeout(timeout);
|
|
306
|
-
timeout = setTimeout(later, wait);
|
|
307
|
-
if (callNow) func.apply(context, args);
|
|
308
|
-
};
|
|
309
|
-
};
|