@materializecss/materialize 1.2.2 → 2.0.1-alpha

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 (90) hide show
  1. package/Gruntfile.js +68 -313
  2. package/README.md +26 -14
  3. package/dist/css/materialize.css +1009 -1822
  4. package/dist/css/materialize.min.css +2 -8
  5. package/dist/js/materialize.js +8414 -12299
  6. package/dist/js/materialize.min.js +8968 -2
  7. package/dist/js/materialize.min.js.map +1 -0
  8. package/package.json +13 -9
  9. package/sass/components/_badges.scss +12 -2
  10. package/sass/components/_buttons.scss +16 -11
  11. package/sass/components/_cards.scss +14 -9
  12. package/sass/components/_carousel.scss +5 -2
  13. package/sass/components/_chips.scss +3 -3
  14. package/sass/components/_collapsible.scss +22 -8
  15. package/sass/components/_collection.scss +14 -6
  16. package/sass/components/_datepicker.scss +30 -11
  17. package/sass/components/_dropdown.scss +6 -4
  18. package/sass/components/_global.scss +132 -111
  19. package/sass/components/_grid.scss +119 -98
  20. package/sass/components/_modal.scss +3 -3
  21. package/sass/components/_navbar.scss +31 -17
  22. package/sass/components/_normalize.scss +26 -124
  23. package/sass/components/_sidenav.scss +21 -20
  24. package/sass/components/_slider.scss +27 -7
  25. package/sass/components/_table_of_contents.scss +12 -12
  26. package/sass/components/_tabs.scss +47 -16
  27. package/sass/components/_tapTarget.scss +6 -6
  28. package/sass/components/_theme_variables.scss +98 -0
  29. package/sass/components/_timepicker.scss +54 -46
  30. package/sass/components/_toast.scss +3 -3
  31. package/sass/components/_tooltip.scss +4 -5
  32. package/sass/components/_typography.scss +1 -1
  33. package/sass/components/_variables.scss +185 -120
  34. package/sass/components/forms/_checkboxes.scss +9 -9
  35. package/sass/components/forms/_file-input.scss +9 -7
  36. package/sass/components/forms/_input-fields.scss +173 -234
  37. package/sass/components/forms/_radio-buttons.scss +1 -1
  38. package/sass/components/forms/_range.scss +11 -11
  39. package/sass/components/forms/_select.scss +29 -19
  40. package/sass/components/forms/_switches.scss +22 -18
  41. package/sass/materialize.scss +1 -1
  42. package/src/autocomplete.ts +459 -0
  43. package/src/bounding.ts +6 -0
  44. package/{js/buttons.js → src/buttons.ts} +103 -162
  45. package/src/cards.ts +54 -0
  46. package/{js/carousel.js → src/carousel.ts} +137 -262
  47. package/src/characterCounter.ts +88 -0
  48. package/src/chips.ts +350 -0
  49. package/src/collapsible.ts +184 -0
  50. package/{js/component.js → src/component.ts} +6 -19
  51. package/{js/datepicker.js → src/datepicker.ts} +213 -299
  52. package/{js/dropdown.js → src/dropdown.ts} +140 -254
  53. package/src/edges.ts +6 -0
  54. package/src/forms.ts +120 -0
  55. package/src/global.ts +385 -0
  56. package/src/materialbox.ts +348 -0
  57. package/src/modal.ts +256 -0
  58. package/{js/parallax.js → src/parallax.ts} +47 -60
  59. package/{js/pushpin.js → src/pushpin.ts} +19 -47
  60. package/{js/range.js → src/range.ts} +58 -139
  61. package/{js/scrollspy.js → src/scrollspy.ts} +81 -153
  62. package/src/select.ts +448 -0
  63. package/{js/sidenav.js → src/sidenav.ts} +96 -202
  64. package/src/slider.ts +415 -0
  65. package/src/tabs.ts +293 -0
  66. package/src/tapTarget.ts +240 -0
  67. package/{js/timepicker.js → src/timepicker.ts} +268 -272
  68. package/{js/toasts.js → src/toasts.ts} +75 -134
  69. package/{js/tooltip.js → src/tooltip.ts} +59 -96
  70. package/src/waves.ts +70 -0
  71. package/extras/noUiSlider/nouislider.css +0 -404
  72. package/extras/noUiSlider/nouislider.js +0 -2147
  73. package/extras/noUiSlider/nouislider.min.js +0 -1
  74. package/js/anime.min.js +0 -34
  75. package/js/autocomplete.js +0 -479
  76. package/js/cards.js +0 -40
  77. package/js/cash.js +0 -960
  78. package/js/characterCounter.js +0 -136
  79. package/js/chips.js +0 -486
  80. package/js/collapsible.js +0 -275
  81. package/js/forms.js +0 -285
  82. package/js/global.js +0 -428
  83. package/js/materialbox.js +0 -453
  84. package/js/modal.js +0 -382
  85. package/js/select.js +0 -391
  86. package/js/slider.js +0 -497
  87. package/js/tabs.js +0 -402
  88. package/js/tapTarget.js +0 -315
  89. package/js/waves.js +0 -615
  90. package/sass/components/_waves.scss +0 -187
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
- });