kmaterialize 2.0.0 → 2.3.3-1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +55 -91
  3. package/components/appbar/_navbar.old.scss +223 -0
  4. package/components/appbar/appbar.css +235 -0
  5. package/components/appbar/appbar.mjs +54 -0
  6. package/components/appbar/appbar.test.mjs +9 -0
  7. package/components/atomic/atomic.mjs +19 -0
  8. package/components/atomic/component.mjs +67 -0
  9. package/components/badge/_badges.scss +75 -0
  10. package/components/badge/badge.mjs +11 -0
  11. package/components/breadcrumb/_breadcrumb.scss +27 -0
  12. package/components/button/_buttons.scss +352 -0
  13. package/components/button/button.mjs +11 -0
  14. package/components/button/buttons.stories.ts +150 -0
  15. package/components/button/buttons.ts +282 -0
  16. package/components/button/examples.iso.js +18 -0
  17. package/components/button/fabSpec.js +65 -0
  18. package/components/button/test-button.mjs +16 -0
  19. package/components/card/_cards.scss +229 -0
  20. package/components/card/card.mjs +10 -0
  21. package/components/card/cards.ts +185 -0
  22. package/components/card/cardsSpec.js +269 -0
  23. package/components/carousel/_carousel.scss +93 -0
  24. package/components/carousel/_slider.scss +119 -0
  25. package/components/carousel/carousel.ts +693 -0
  26. package/components/carousel/carouselSpec.js +61 -0
  27. package/components/carousel/slider.ts +431 -0
  28. package/components/carousel/sliderSpec.js +99 -0
  29. package/components/checkbox/_checkboxes.scss +281 -0
  30. package/components/checkbox/checkbox.mdx +24 -0
  31. package/components/checkbox/checkbox.stories.ts +120 -0
  32. package/components/chip/chip.mjs +37 -0
  33. package/components/chip/chip.test.mjs +10 -0
  34. package/components/chip/chips.css +126 -0
  35. package/components/chip/chips.mdx +33 -0
  36. package/components/chip/chips.ts +440 -0
  37. package/components/chip/chipsSpec.js +165 -0
  38. package/components/chip/readme.md +323 -0
  39. package/components/collapsible/_collapsible.scss +82 -0
  40. package/components/collapsible/collapsible.ts +230 -0
  41. package/components/collapsible/collapsibleSpec.js +240 -0
  42. package/components/datepicker/_datepicker.scss +268 -0
  43. package/components/datepicker/datepicker.ts +1450 -0
  44. package/components/datepicker/datepickerSpec.js +162 -0
  45. package/components/dialog/_materialbox.scss +42 -0
  46. package/components/dialog/_modal.scss +79 -0
  47. package/components/dialog/materialbox.ts +446 -0
  48. package/components/dialog/materialboxSpec.js +37 -0
  49. package/components/dialog/modal.ts +111 -0
  50. package/components/dialog/modalSpec.js +83 -0
  51. package/components/dialog/readme.md +5 -0
  52. package/components/divider/readme.md +15 -0
  53. package/components/dropdown/_dropdown.scss +83 -0
  54. package/components/dropdown/dropdown.ts +653 -0
  55. package/components/dropdown/dropdownSpec.js +108 -0
  56. package/components/list/_collection.scss +114 -0
  57. package/components/list/_list.scss +6 -0
  58. package/components/list/list.mjs +58 -0
  59. package/components/list/list.test.mjs +16 -0
  60. package/components/loading/loading.mjs +26 -0
  61. package/components/loading/loading.test.mjs +10 -0
  62. package/components/navigation-bar/_old +582 -0
  63. package/components/navigation-bar/navigation-bar.mdx +20 -0
  64. package/components/navigation-bar/navigation-bar.stories.ts +39 -0
  65. package/components/navigation-drawer/_sidenav.scss +247 -0
  66. package/components/navigation-drawer/sidenav.ts +546 -0
  67. package/components/navigation-drawer/sidenavSpec.js +124 -0
  68. package/components/pagination/_pagination.scss +47 -0
  69. package/components/progress/_preloader.scss +416 -0
  70. package/components/radio-button/_radio-buttons.scss +112 -0
  71. package/components/radio-button/radio-buttons.mdx +28 -0
  72. package/components/radio-button/radio-buttons.stories.ts +51 -0
  73. package/components/search/autocomplete.ts +620 -0
  74. package/components/search/autocompleteSpec.js +321 -0
  75. package/components/slider/_range.scss +157 -0
  76. package/components/slider/range.ts +216 -0
  77. package/components/snackbar/_toast.scss +68 -0
  78. package/components/snackbar/toastSpec.js +132 -0
  79. package/components/snackbar/toasts.ts +312 -0
  80. package/components/switch/_switches.scss +121 -0
  81. package/components/tabs/_tabs.scss +171 -0
  82. package/components/tabs/tabs.mjs +31 -0
  83. package/components/tabs/tabs.ts +358 -0
  84. package/components/tabs/tabsSpec.js +180 -0
  85. package/components/textfield/_file-input.scss +41 -0
  86. package/components/textfield/_input-fields.scss +368 -0
  87. package/components/textfield/_select.scss +104 -0
  88. package/components/textfield/formfields.css +311 -0
  89. package/components/textfield/forms.ts +182 -0
  90. package/components/textfield/formsSpec.js +142 -0
  91. package/components/textfield/select.ts +472 -0
  92. package/components/textfield/selectSpec.js +390 -0
  93. package/components/textfield/textfield.mjs +29 -0
  94. package/components/textfield/textfield.test.mjs +10 -0
  95. package/components/timepicker/_timepicker.scss +362 -0
  96. package/components/timepicker/timepicker.ts +905 -0
  97. package/components/tooltip/_tooltip.scss +40 -0
  98. package/components/tooltip/tooltip.ts +380 -0
  99. package/components/tooltip/tooltipSpec.js +145 -0
  100. package/dist/css/materialize.colors.min.css +6 -0
  101. package/dist/css/materialize.css +7578 -6326
  102. package/dist/css/materialize.min.css +6 -13
  103. package/dist/css/materialize.min.css.map +1 -0
  104. package/dist/js/materialize.cjs.js +8410 -0
  105. package/dist/js/materialize.d.ts +2625 -0
  106. package/dist/js/materialize.js +8415 -12374
  107. package/dist/js/materialize.min.js +6 -6
  108. package/dist/js/materialize.mjs +8382 -0
  109. package/package.json +82 -47
  110. package/sass/_colors.scss +417 -0
  111. package/sass/_global.scss +490 -0
  112. package/sass/_grid.scss +172 -0
  113. package/sass/_table_of_contents.scss +28 -0
  114. package/sass/_tapTarget.scss +102 -0
  115. package/sass/_typography.scss +58 -0
  116. package/sass/_variables.scss +56 -0
  117. package/sass/colors.module.css +74 -0
  118. package/sass/materialize.scss +51 -0
  119. package/sass/mixins.module.scss +168 -0
  120. package/sass/pulse.css +35 -0
  121. package/sass/theme.module.css +140 -0
  122. package/sass/tokens.module.css +272 -0
  123. package/sass/transitions.css +10 -0
  124. package/sass/typography.module.css +150 -0
  125. package/extras/noUiSlider/nouislider.css +0 -406
  126. package/extras/noUiSlider/nouislider.js +0 -2147
  127. package/extras/noUiSlider/nouislider.min.js +0 -1
  128. package/js/anime.min.js +0 -34
  129. package/js/autocomplete.js +0 -448
  130. package/js/buttons.js +0 -354
  131. package/js/cards.js +0 -40
  132. package/js/carousel.js +0 -717
  133. package/js/cash.js +0 -960
  134. package/js/characterCounter.js +0 -136
  135. package/js/chips.js +0 -481
  136. package/js/collapsible.js +0 -275
  137. package/js/component.js +0 -44
  138. package/js/datepicker.js +0 -975
  139. package/js/dropdown.js +0 -635
  140. package/js/forms.js +0 -275
  141. package/js/global.js +0 -444
  142. package/js/materialbox.js +0 -453
  143. package/js/modal.js +0 -382
  144. package/js/parallax.js +0 -138
  145. package/js/pushpin.js +0 -148
  146. package/js/range.js +0 -263
  147. package/js/scrollspy.js +0 -295
  148. package/js/select.js +0 -450
  149. package/js/sidenav.js +0 -580
  150. package/js/slider.js +0 -359
  151. package/js/tabs.js +0 -402
  152. package/js/tapTarget.js +0 -314
  153. package/js/timepicker.js +0 -647
  154. package/js/toasts.js +0 -310
  155. package/js/tooltip.js +0 -303
  156. package/js/waves.js +0 -335
package/js/cash.js DELETED
@@ -1,960 +0,0 @@
1
- /*! cash-dom 1.3.5, https://github.com/kenwheeler/cash @license MIT */
2
- (function (factory) {
3
- window.cash = factory();
4
- })(function () {
5
- var doc = document, win = window, ArrayProto = Array.prototype, slice = ArrayProto.slice, filter = ArrayProto.filter, push = ArrayProto.push;
6
-
7
- var noop = function () {}, isFunction = function (item) {
8
- // @see https://crbug.com/568448
9
- return typeof item === typeof noop && item.call;
10
- }, isString = function (item) {
11
- return typeof item === typeof "";
12
- };
13
-
14
- var idMatch = /^#[\w-]*$/, classMatch = /^\.[\w-]*$/, htmlMatch = /<.+>/, singlet = /^\w+$/;
15
-
16
- function find(selector, context) {
17
- context = context || doc;
18
- var elems = (classMatch.test(selector) ? context.getElementsByClassName(selector.slice(1)) : singlet.test(selector) ? context.getElementsByTagName(selector) : context.querySelectorAll(selector));
19
- return elems;
20
- }
21
-
22
- var frag;
23
- function parseHTML(str) {
24
- if (!frag) {
25
- frag = doc.implementation.createHTMLDocument(null);
26
- var base = frag.createElement("base");
27
- base.href = doc.location.href;
28
- frag.head.appendChild(base);
29
- }
30
-
31
- frag.body.innerHTML = str;
32
-
33
- return frag.body.childNodes;
34
- }
35
-
36
- function onReady(fn) {
37
- if (doc.readyState !== "loading") {
38
- fn();
39
- } else {
40
- doc.addEventListener("DOMContentLoaded", fn);
41
- }
42
- }
43
-
44
- function Init(selector, context) {
45
- if (!selector) {
46
- return this;
47
- }
48
-
49
- // If already a cash collection, don't do any further processing
50
- if (selector.cash && selector !== win) {
51
- return selector;
52
- }
53
-
54
- var elems = selector, i = 0, length;
55
-
56
- if (isString(selector)) {
57
- elems = (idMatch.test(selector) ?
58
- // If an ID use the faster getElementById check
59
- doc.getElementById(selector.slice(1)) : htmlMatch.test(selector) ?
60
- // If HTML, parse it into real elements
61
- parseHTML(selector) :
62
- // else use `find`
63
- find(selector, context));
64
-
65
- // If function, use as shortcut for DOM ready
66
- } else if (isFunction(selector)) {
67
- onReady(selector);return this;
68
- }
69
-
70
- if (!elems) {
71
- return this;
72
- }
73
-
74
- // If a single DOM element is passed in or received via ID, return the single element
75
- if (elems.nodeType || elems === win) {
76
- this[0] = elems;
77
- this.length = 1;
78
- } else {
79
- // Treat like an array and loop through each item.
80
- length = this.length = elems.length;
81
- for (; i < length; i++) {
82
- this[i] = elems[i];
83
- }
84
- }
85
-
86
- return this;
87
- }
88
-
89
- function cash(selector, context) {
90
- return new Init(selector, context);
91
- }
92
-
93
- var fn = cash.fn = cash.prototype = Init.prototype = { // jshint ignore:line
94
- cash: true,
95
- length: 0,
96
- push: push,
97
- splice: ArrayProto.splice,
98
- map: ArrayProto.map,
99
- init: Init
100
- };
101
-
102
- Object.defineProperty(fn, "constructor", { value: cash });
103
-
104
- cash.parseHTML = parseHTML;
105
- cash.noop = noop;
106
- cash.isFunction = isFunction;
107
- cash.isString = isString;
108
-
109
- cash.extend = fn.extend = function (target) {
110
- target = target || {};
111
-
112
- var args = slice.call(arguments), length = args.length, i = 1;
113
-
114
- if (args.length === 1) {
115
- target = this;
116
- i = 0;
117
- }
118
-
119
- for (; i < length; i++) {
120
- if (!args[i]) {
121
- continue;
122
- }
123
- for (var key in args[i]) {
124
- if (args[i].hasOwnProperty(key)) {
125
- target[key] = args[i][key];
126
- }
127
- }
128
- }
129
-
130
- return target;
131
- };
132
-
133
- function each(collection, callback) {
134
- var l = collection.length, i = 0;
135
-
136
- for (; i < l; i++) {
137
- if (callback.call(collection[i], collection[i], i, collection) === false) {
138
- break;
139
- }
140
- }
141
- }
142
-
143
- function matches(el, selector) {
144
- var m = el && (el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector || el.oMatchesSelector);
145
- return !!m && m.call(el, selector);
146
- }
147
-
148
- function getCompareFunction(selector) {
149
- return (
150
- /* Use browser's `matches` function if string */
151
- isString(selector) ? matches :
152
- /* Match a cash element */
153
- selector.cash ? function (el) {
154
- return selector.is(el);
155
- } :
156
- /* Direct comparison */
157
- function (el, selector) {
158
- return el === selector;
159
- });
160
- }
161
-
162
- function unique(collection) {
163
- return cash(slice.call(collection).filter(function (item, index, self) {
164
- return self.indexOf(item) === index;
165
- }));
166
- }
167
-
168
- cash.extend({
169
- merge: function (first, second) {
170
- var len = +second.length, i = first.length, j = 0;
171
-
172
- for (; j < len; i++, j++) {
173
- first[i] = second[j];
174
- }
175
-
176
- first.length = i;
177
- return first;
178
- },
179
-
180
- each: each,
181
- matches: matches,
182
- unique: unique,
183
- isArray: Array.isArray,
184
- isNumeric: function (n) {
185
- return !isNaN(parseFloat(n)) && isFinite(n);
186
- }
187
-
188
- });
189
-
190
- var uid = cash.uid = "_cash" + Date.now();
191
-
192
- function getDataCache(node) {
193
- return (node[uid] = node[uid] || {});
194
- }
195
-
196
- function setData(node, key, value) {
197
- return (getDataCache(node)[key] = value);
198
- }
199
-
200
- function getData(node, key) {
201
- var c = getDataCache(node);
202
- if (c[key] === undefined) {
203
- c[key] = node.dataset ? node.dataset[key] : cash(node).attr("data-" + key);
204
- }
205
- return c[key];
206
- }
207
-
208
- function removeData(node, key) {
209
- var c = getDataCache(node);
210
- if (c) {
211
- delete c[key];
212
- } else if (node.dataset) {
213
- delete node.dataset[key];
214
- } else {
215
- cash(node).removeAttr("data-" + name);
216
- }
217
- }
218
-
219
- fn.extend({
220
- data: function (name, value) {
221
- if (isString(name)) {
222
- return (value === undefined ? getData(this[0], name) : this.each(function (v) {
223
- return setData(v, name, value);
224
- }));
225
- }
226
-
227
- for (var key in name) {
228
- this.data(key, name[key]);
229
- }
230
-
231
- return this;
232
- },
233
-
234
- removeData: function (key) {
235
- return this.each(function (v) {
236
- return removeData(v, key);
237
- });
238
- }
239
-
240
- });
241
-
242
- var notWhiteMatch = /\S+/g;
243
-
244
- function getClasses(c) {
245
- return isString(c) && c.match(notWhiteMatch);
246
- }
247
-
248
- function hasClass(v, c) {
249
- return (v.classList ? v.classList.contains(c) : new RegExp("(^| )" + c + "( |$)", "gi").test(v.className));
250
- }
251
-
252
- function addClass(v, c, spacedName) {
253
- if (v.classList) {
254
- v.classList.add(c);
255
- } else if (spacedName.indexOf(" " + c + " ")) {
256
- v.className += " " + c;
257
- }
258
- }
259
-
260
- function removeClass(v, c) {
261
- if (v.classList) {
262
- v.classList.remove(c);
263
- } else {
264
- v.className = v.className.replace(c, "");
265
- }
266
- }
267
-
268
- fn.extend({
269
- addClass: function (c) {
270
- var classes = getClasses(c);
271
-
272
- return (classes ? this.each(function (v) {
273
- var spacedName = " " + v.className + " ";
274
- each(classes, function (c) {
275
- addClass(v, c, spacedName);
276
- });
277
- }) : this);
278
- },
279
-
280
- attr: function (name, value) {
281
- if (!name) {
282
- return undefined;
283
- }
284
-
285
- if (isString(name)) {
286
- if (value === undefined) {
287
- return this[0] ? this[0].getAttribute ? this[0].getAttribute(name) : this[0][name] : undefined;
288
- }
289
-
290
- return this.each(function (v) {
291
- if (v.setAttribute) {
292
- v.setAttribute(name, value);
293
- } else {
294
- v[name] = value;
295
- }
296
- });
297
- }
298
-
299
- for (var key in name) {
300
- this.attr(key, name[key]);
301
- }
302
-
303
- return this;
304
- },
305
-
306
- hasClass: function (c) {
307
- var check = false, classes = getClasses(c);
308
- if (classes && classes.length) {
309
- this.each(function (v) {
310
- check = hasClass(v, classes[0]);
311
- return !check;
312
- });
313
- }
314
- return check;
315
- },
316
-
317
- prop: function (name, value) {
318
- if (isString(name)) {
319
- return (value === undefined ? this[0][name] : this.each(function (v) {
320
- v[name] = value;
321
- }));
322
- }
323
-
324
- for (var key in name) {
325
- this.prop(key, name[key]);
326
- }
327
-
328
- return this;
329
- },
330
-
331
- removeAttr: function (name) {
332
- return this.each(function (v) {
333
- if (v.removeAttribute) {
334
- v.removeAttribute(name);
335
- } else {
336
- delete v[name];
337
- }
338
- });
339
- },
340
-
341
- removeClass: function (c) {
342
- if (!arguments.length) {
343
- return this.attr("class", "");
344
- }
345
- var classes = getClasses(c);
346
- return (classes ? this.each(function (v) {
347
- each(classes, function (c) {
348
- removeClass(v, c);
349
- });
350
- }) : this);
351
- },
352
-
353
- removeProp: function (name) {
354
- return this.each(function (v) {
355
- delete v[name];
356
- });
357
- },
358
-
359
- toggleClass: function (c, state) {
360
- if (state !== undefined) {
361
- return this[state ? "addClass" : "removeClass"](c);
362
- }
363
- var classes = getClasses(c);
364
- return (classes ? this.each(function (v) {
365
- var spacedName = " " + v.className + " ";
366
- each(classes, function (c) {
367
- if (hasClass(v, c)) {
368
- removeClass(v, c);
369
- } else {
370
- addClass(v, c, spacedName);
371
- }
372
- });
373
- }) : this);
374
- } });
375
-
376
- fn.extend({
377
- add: function (selector, context) {
378
- return unique(cash.merge(this, cash(selector, context)));
379
- },
380
-
381
- each: function (callback) {
382
- each(this, callback);
383
- return this;
384
- },
385
-
386
- eq: function (index) {
387
- return cash(this.get(index));
388
- },
389
-
390
- filter: function (selector) {
391
- if (!selector) {
392
- return this;
393
- }
394
-
395
- var comparator = (isFunction(selector) ? selector : getCompareFunction(selector));
396
-
397
- return cash(filter.call(this, function (e) {
398
- return comparator(e, selector);
399
- }));
400
- },
401
-
402
- first: function () {
403
- return this.eq(0);
404
- },
405
-
406
- get: function (index) {
407
- if (index === undefined) {
408
- return slice.call(this);
409
- }
410
- return (index < 0 ? this[index + this.length] : this[index]);
411
- },
412
-
413
- index: function (elem) {
414
- var child = elem ? cash(elem)[0] : this[0], collection = elem ? this : cash(child).parent().children();
415
- return slice.call(collection).indexOf(child);
416
- },
417
-
418
- last: function () {
419
- return this.eq(-1);
420
- }
421
-
422
- });
423
-
424
- var camelCase = (function () {
425
- var camelRegex = /(?:^\w|[A-Z]|\b\w)/g, whiteSpace = /[\s-_]+/g;
426
- return function (str) {
427
- return str.replace(camelRegex, function (letter, index) {
428
- return letter[index === 0 ? "toLowerCase" : "toUpperCase"]();
429
- }).replace(whiteSpace, "");
430
- };
431
- }());
432
-
433
- var getPrefixedProp = (function () {
434
- var cache = {}, doc = document, div = doc.createElement("div"), style = div.style;
435
-
436
- return function (prop) {
437
- prop = camelCase(prop);
438
- if (cache[prop]) {
439
- return cache[prop];
440
- }
441
-
442
- var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1), prefixes = ["webkit", "moz", "ms", "o"], props = (prop + " " + (prefixes).join(ucProp + " ") + ucProp).split(" ");
443
-
444
- each(props, function (p) {
445
- if (p in style) {
446
- cache[p] = prop = cache[prop] = p;
447
- return false;
448
- }
449
- });
450
-
451
- return cache[prop];
452
- };
453
- }());
454
-
455
- cash.prefixedProp = getPrefixedProp;
456
- cash.camelCase = camelCase;
457
-
458
- fn.extend({
459
- css: function (prop, value) {
460
- if (isString(prop)) {
461
- prop = getPrefixedProp(prop);
462
- return (arguments.length > 1 ? this.each(function (v) {
463
- return v.style[prop] = value;
464
- }) : win.getComputedStyle(this[0])[prop]);
465
- }
466
-
467
- for (var key in prop) {
468
- this.css(key, prop[key]);
469
- }
470
-
471
- return this;
472
- }
473
-
474
- });
475
-
476
- function compute(el, prop) {
477
- return parseInt(win.getComputedStyle(el[0], null)[prop], 10) || 0;
478
- }
479
-
480
- each(["Width", "Height"], function (v) {
481
- var lower = v.toLowerCase();
482
-
483
- fn[lower] = function () {
484
- return this[0].getBoundingClientRect()[lower];
485
- };
486
-
487
- fn["inner" + v] = function () {
488
- return this[0]["client" + v];
489
- };
490
-
491
- fn["outer" + v] = function (margins) {
492
- return this[0]["offset" + v] + (margins ? compute(this, "margin" + (v === "Width" ? "Left" : "Top")) + compute(this, "margin" + (v === "Width" ? "Right" : "Bottom")) : 0);
493
- };
494
- });
495
-
496
- function registerEvent(node, eventName, callback) {
497
- var eventCache = getData(node, "_cashEvents") || setData(node, "_cashEvents", {});
498
- eventCache[eventName] = eventCache[eventName] || [];
499
- eventCache[eventName].push(callback);
500
- node.addEventListener(eventName, callback);
501
- }
502
-
503
- function removeEvent(node, eventName, callback) {
504
- var events = getData(node, "_cashEvents"), eventCache = (events && events[eventName]), index;
505
-
506
- if (!eventCache) {
507
- return;
508
- }
509
-
510
- if (callback) {
511
- node.removeEventListener(eventName, callback);
512
- index = eventCache.indexOf(callback);
513
- if (index >= 0) {
514
- eventCache.splice(index, 1);
515
- }
516
- } else {
517
- each(eventCache, function (event) {
518
- node.removeEventListener(eventName, event);
519
- });
520
- eventCache = [];
521
- }
522
- }
523
-
524
- fn.extend({
525
- off: function (eventName, callback) {
526
- return this.each(function (v) {
527
- return removeEvent(v, eventName, callback);
528
- });
529
- },
530
-
531
- on: function (eventName, delegate, callback, runOnce) {
532
- // jshint ignore:line
533
- var originalCallback;
534
- if (!isString(eventName)) {
535
- for (var key in eventName) {
536
- this.on(key, delegate, eventName[key]);
537
- }
538
- return this;
539
- }
540
-
541
- if (isFunction(delegate)) {
542
- callback = delegate;
543
- delegate = null;
544
- }
545
-
546
- if (eventName === "ready") {
547
- onReady(callback);
548
- return this;
549
- }
550
-
551
- if (delegate) {
552
- originalCallback = callback;
553
- callback = function (e) {
554
- var t = e.target;
555
- while (!matches(t, delegate)) {
556
- if (t === this || t === null) {
557
- return (t = false);
558
- }
559
-
560
- t = t.parentNode;
561
- }
562
-
563
- if (t) {
564
- originalCallback.call(t, e);
565
- }
566
- };
567
- }
568
-
569
- return this.each(function (v) {
570
- var finalCallback = callback;
571
- if (runOnce) {
572
- finalCallback = function () {
573
- callback.apply(this, arguments);
574
- removeEvent(v, eventName, finalCallback);
575
- };
576
- }
577
- registerEvent(v, eventName, finalCallback);
578
- });
579
- },
580
-
581
- one: function (eventName, delegate, callback) {
582
- return this.on(eventName, delegate, callback, true);
583
- },
584
-
585
- ready: onReady,
586
-
587
- /**
588
- * Modified
589
- * Triggers browser event
590
- * @param String eventName
591
- * @param Object data - Add properties to event object
592
- */
593
- trigger: function (eventName, data) {
594
- if (document.createEvent) {
595
- let evt = document.createEvent('HTMLEvents');
596
- evt.initEvent(eventName, true, false);
597
- evt = this.extend(evt, data);
598
- return this.each(function (v) {
599
- return v.dispatchEvent(evt);
600
- });
601
- }
602
- }
603
-
604
- });
605
-
606
- function encode(name, value) {
607
- return "&" + encodeURIComponent(name) + "=" + encodeURIComponent(value).replace(/%20/g, "+");
608
- }
609
-
610
- function getSelectMultiple_(el) {
611
- var values = [];
612
- each(el.options, function (o) {
613
- if (o.selected) {
614
- values.push(o.value);
615
- }
616
- });
617
- return values.length ? values : null;
618
- }
619
-
620
- function getSelectSingle_(el) {
621
- var selectedIndex = el.selectedIndex;
622
- return selectedIndex >= 0 ? el.options[selectedIndex].value : null;
623
- }
624
-
625
- function getValue(el) {
626
- var type = el.type;
627
- if (!type) {
628
- return null;
629
- }
630
- switch (type.toLowerCase()) {
631
- case "select-one":
632
- return getSelectSingle_(el);
633
- case "select-multiple":
634
- return getSelectMultiple_(el);
635
- case "radio":
636
- return (el.checked) ? el.value : null;
637
- case "checkbox":
638
- return (el.checked) ? el.value : null;
639
- default:
640
- return el.value ? el.value : null;
641
- }
642
- }
643
-
644
- fn.extend({
645
- serialize: function () {
646
- var query = "";
647
-
648
- each(this[0].elements || this, function (el) {
649
- if (el.disabled || el.tagName === "FIELDSET") {
650
- return;
651
- }
652
- var name = el.name;
653
- switch (el.type.toLowerCase()) {
654
- case "file":
655
- case "reset":
656
- case "submit":
657
- case "button":
658
- break;
659
- case "select-multiple":
660
- var values = getValue(el);
661
- if (values !== null) {
662
- each(values, function (value) {
663
- query += encode(name, value);
664
- });
665
- }
666
- break;
667
- default:
668
- var value = getValue(el);
669
- if (value !== null) {
670
- query += encode(name, value);
671
- }
672
- }
673
- });
674
-
675
- return query.substr(1);
676
- },
677
-
678
- val: function (value) {
679
- if (value === undefined) {
680
- return getValue(this[0]);
681
- }
682
-
683
- return this.each(function (v) {
684
- return v.value = value;
685
- });
686
- }
687
-
688
- });
689
-
690
- function insertElement(el, child, prepend) {
691
- if (prepend) {
692
- var first = el.childNodes[0];
693
- el.insertBefore(child, first);
694
- } else {
695
- el.appendChild(child);
696
- }
697
- }
698
-
699
- function insertContent(parent, child, prepend) {
700
- var str = isString(child);
701
-
702
- if (!str && child.length) {
703
- each(child, function (v) {
704
- return insertContent(parent, v, prepend);
705
- });
706
- return;
707
- }
708
-
709
- each(parent, str ? function (v) {
710
- return v.insertAdjacentHTML(prepend ? "afterbegin" : "beforeend", child);
711
- } : function (v, i) {
712
- return insertElement(v, (i === 0 ? child : child.cloneNode(true)), prepend);
713
- });
714
- }
715
-
716
- fn.extend({
717
- after: function (selector) {
718
- cash(selector).insertAfter(this);
719
- return this;
720
- },
721
-
722
- append: function (content) {
723
- insertContent(this, content);
724
- return this;
725
- },
726
-
727
- appendTo: function (parent) {
728
- insertContent(cash(parent), this);
729
- return this;
730
- },
731
-
732
- before: function (selector) {
733
- cash(selector).insertBefore(this);
734
- return this;
735
- },
736
-
737
- clone: function () {
738
- return cash(this.map(function (v) {
739
- return v.cloneNode(true);
740
- }));
741
- },
742
-
743
- empty: function () {
744
- this.html("");
745
- return this;
746
- },
747
-
748
- html: function (content) {
749
- if (content === undefined) {
750
- return this[0].innerHTML;
751
- }
752
- var source = (content.nodeType ? content[0].outerHTML : content);
753
- return this.each(function (v) {
754
- return v.innerHTML = source;
755
- });
756
- },
757
-
758
- insertAfter: function (selector) {
759
- var _this = this;
760
-
761
-
762
- cash(selector).each(function (el, i) {
763
- var parent = el.parentNode, sibling = el.nextSibling;
764
- _this.each(function (v) {
765
- parent.insertBefore((i === 0 ? v : v.cloneNode(true)), sibling);
766
- });
767
- });
768
-
769
- return this;
770
- },
771
-
772
- insertBefore: function (selector) {
773
- var _this2 = this;
774
- cash(selector).each(function (el, i) {
775
- var parent = el.parentNode;
776
- _this2.each(function (v) {
777
- parent.insertBefore((i === 0 ? v : v.cloneNode(true)), el);
778
- });
779
- });
780
- return this;
781
- },
782
-
783
- prepend: function (content) {
784
- insertContent(this, content, true);
785
- return this;
786
- },
787
-
788
- prependTo: function (parent) {
789
- insertContent(cash(parent), this, true);
790
- return this;
791
- },
792
-
793
- remove: function () {
794
- return this.each(function (v) {
795
- if (!!v.parentNode) {
796
- return v.parentNode.removeChild(v);
797
- }
798
- });
799
- },
800
-
801
- text: function (content) {
802
- if (content === undefined) {
803
- return this[0].textContent;
804
- }
805
- return this.each(function (v) {
806
- return v.textContent = content;
807
- });
808
- }
809
-
810
- });
811
-
812
- var docEl = doc.documentElement;
813
-
814
- fn.extend({
815
- position: function () {
816
- var el = this[0];
817
- return {
818
- left: el.offsetLeft,
819
- top: el.offsetTop
820
- };
821
- },
822
-
823
- offset: function () {
824
- var rect = this[0].getBoundingClientRect();
825
- return {
826
- top: rect.top + win.pageYOffset - docEl.clientTop,
827
- left: rect.left + win.pageXOffset - docEl.clientLeft
828
- };
829
- },
830
-
831
- offsetParent: function () {
832
- return cash(this[0].offsetParent);
833
- }
834
-
835
- });
836
-
837
- fn.extend({
838
- children: function (selector) {
839
- var elems = [];
840
- this.each(function (el) {
841
- push.apply(elems, el.children);
842
- });
843
- elems = unique(elems);
844
-
845
- return (!selector ? elems : elems.filter(function (v) {
846
- return matches(v, selector);
847
- }));
848
- },
849
-
850
- closest: function (selector) {
851
- if (!selector || this.length < 1) {
852
- return cash();
853
- }
854
- if (this.is(selector)) {
855
- return this.filter(selector);
856
- }
857
- return this.parent().closest(selector);
858
- },
859
-
860
- is: function (selector) {
861
- if (!selector) {
862
- return false;
863
- }
864
-
865
- var match = false, comparator = getCompareFunction(selector);
866
-
867
- this.each(function (el) {
868
- match = comparator(el, selector);
869
- return !match;
870
- });
871
-
872
- return match;
873
- },
874
-
875
- find: function (selector) {
876
- if (!selector || selector.nodeType) {
877
- return cash(selector && this.has(selector).length ? selector : null);
878
- }
879
-
880
- var elems = [];
881
- this.each(function (el) {
882
- push.apply(elems, find(selector, el));
883
- });
884
-
885
- return unique(elems);
886
- },
887
-
888
- has: function (selector) {
889
- var comparator = (isString(selector) ? function (el) {
890
- return find(selector, el).length !== 0;
891
- } : function (el) {
892
- return el.contains(selector);
893
- });
894
-
895
- return this.filter(comparator);
896
- },
897
-
898
- next: function () {
899
- return cash(this[0].nextElementSibling);
900
- },
901
-
902
- not: function (selector) {
903
- if (!selector) {
904
- return this;
905
- }
906
-
907
- var comparator = getCompareFunction(selector);
908
-
909
- return this.filter(function (el) {
910
- return !comparator(el, selector);
911
- });
912
- },
913
-
914
- parent: function () {
915
- var result = [];
916
-
917
- this.each(function (item) {
918
- if (item && item.parentNode) {
919
- result.push(item.parentNode);
920
- }
921
- });
922
-
923
- return unique(result);
924
- },
925
-
926
- parents: function (selector) {
927
- var last, result = [];
928
-
929
- this.each(function (item) {
930
- last = item;
931
-
932
- while (last && last.parentNode && last !== doc.body.parentNode) {
933
- last = last.parentNode;
934
-
935
- if (!selector || (selector && matches(last, selector))) {
936
- result.push(last);
937
- }
938
- }
939
- });
940
-
941
- return unique(result);
942
- },
943
-
944
- prev: function () {
945
- return cash(this[0].previousElementSibling);
946
- },
947
-
948
- siblings: function (selector) {
949
- var collection = this.parent().children(selector), el = this[0];
950
-
951
- return collection.filter(function (i) {
952
- return i !== el;
953
- });
954
- }
955
-
956
- });
957
-
958
-
959
- return cash;
960
- });