-
Notifications
You must be signed in to change notification settings - Fork 9
/
swiper.js
7742 lines (7113 loc) · 273 KB
/
swiper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* Swiper 4.3.5
* Most modern mobile touch slider and framework with hardware accelerated transitions
* http://www.idangero.us/swiper/
*
* Copyright 2014-2018 Vladimir Kharlampidi
*
* Released under the MIT License
*
* Released on: July 31, 2018
*/
// (function (global, factory) {
// typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
// typeof define === 'function' && define.amd ? define(factory) :
// (global.Swiper = factory());
// }(this, (function () { 'use strict';
/**
* SSR Window 1.0.1
* Better handling for window object in SSR environment
* https://github.com/nolimits4web/ssr-window
*
* Copyright 2018, Vladimir Kharlampidi
*
* Licensed under MIT
*
* Released on: July 18, 2018
*/
var doc = (typeof document === 'undefined') ? {
body: {},
addEventListener: function addEventListener() {},
removeEventListener: function removeEventListener() {},
activeElement: {
blur: function blur() {},
nodeName: '',
},
querySelector: function querySelector() {
return null;
},
querySelectorAll: function querySelectorAll() {
return [];
},
getElementById: function getElementById() {
return null;
},
createEvent: function createEvent() {
return {
initEvent: function initEvent() {},
};
},
createElement: function createElement() {
return {
children: [],
childNodes: [],
style: {},
setAttribute: function setAttribute() {},
getElementsByTagName: function getElementsByTagName() {
return [];
},
};
},
location: { hash: '' },
} : document; // eslint-disable-line
var win = (typeof window === 'undefined') ? {
document: doc,
navigator: {
userAgent: '',
},
location: {},
history: {},
CustomEvent: function CustomEvent() {
return this;
},
addEventListener: function addEventListener() {},
removeEventListener: function removeEventListener() {},
getComputedStyle: function getComputedStyle() {
return {
getPropertyValue: function getPropertyValue() {
return '';
},
};
},
Image: function Image() {},
Date: function Date() {},
screen: {},
setTimeout: function setTimeout() {},
clearTimeout: function clearTimeout() {},
} : window; // eslint-disable-line
/**
* Dom7 2.0.7
* Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
* http://framework7.io/docs/dom.html
*
* Copyright 2018, Vladimir Kharlampidi
* The iDangero.us
* http://www.idangero.us/
*
* Licensed under MIT
*
* Released on: June 14, 2018
*/
var Dom7 = function Dom7(arr) {
var self = this;
// Create array-like object
for (var i = 0; i < arr.length; i += 1) {
self[i] = arr[i];
}
self.length = arr.length;
// Return collection with methods
return this;
};
function $(selector, context) {
var arr = [];
var i = 0;
if (selector && !context) {
if (selector instanceof Dom7) {
return selector;
}
}
if (selector) {
// String
if (typeof selector === 'string') {
var els;
var tempParent;
var html = selector.trim();
if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
var toCreate = 'div';
if (html.indexOf('<li') === 0) { toCreate = 'ul'; }
if (html.indexOf('<tr') === 0) { toCreate = 'tbody'; }
if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) { toCreate = 'tr'; }
if (html.indexOf('<tbody') === 0) { toCreate = 'table'; }
if (html.indexOf('<option') === 0) { toCreate = 'select'; }
tempParent = doc.createElement(toCreate);
tempParent.innerHTML = html;
for (i = 0; i < tempParent.childNodes.length; i += 1) {
arr.push(tempParent.childNodes[i]);
}
} else {
if (!context && selector[0] === '#' && !selector.match(/[ .<>:~]/)) {
// Pure ID selector
els = [doc.getElementById(selector.trim().split('#')[1])];
} else {
// Other selectors
els = (context || doc).querySelectorAll(selector.trim());
}
for (i = 0; i < els.length; i += 1) {
if (els[i]) { arr.push(els[i]); }
}
}
} else if (selector.nodeType || selector === win || selector === doc) {
// Node/element
arr.push(selector);
} else if (selector.length > 0 && selector[0].nodeType) {
// Array of elements or instance of Dom
for (i = 0; i < selector.length; i += 1) {
arr.push(selector[i]);
}
}
}
return new Dom7(arr);
}
$.fn = Dom7.prototype;
$.Class = Dom7;
$.Dom7 = Dom7;
function unique(arr) {
var uniqueArray = [];
for (var i = 0; i < arr.length; i += 1) {
if (uniqueArray.indexOf(arr[i]) === -1) { uniqueArray.push(arr[i]); }
}
return uniqueArray;
}
// Classes and attributes
function addClass(className) {
var this$1 = this;
if (typeof className === 'undefined') {
return this;
}
var classes = className.split(' ');
for (var i = 0; i < classes.length; i += 1) {
for (var j = 0; j < this.length; j += 1) {
if (typeof this$1[j] !== 'undefined' && typeof this$1[j].classList !== 'undefined') { this$1[j].classList.add(classes[i]); }
}
}
return this;
}
function removeClass(className) {
var this$1 = this;
var classes = className.split(' ');
for (var i = 0; i < classes.length; i += 1) {
for (var j = 0; j < this.length; j += 1) {
if (typeof this$1[j] !== 'undefined' && typeof this$1[j].classList !== 'undefined') { this$1[j].classList.remove(classes[i]); }
}
}
return this;
}
function hasClass(className) {
if (!this[0]) { return false; }
return this[0].classList.contains(className);
}
function toggleClass(className) {
var this$1 = this;
var classes = className.split(' ');
for (var i = 0; i < classes.length; i += 1) {
for (var j = 0; j < this.length; j += 1) {
if (typeof this$1[j] !== 'undefined' && typeof this$1[j].classList !== 'undefined') { this$1[j].classList.toggle(classes[i]); }
}
}
return this;
}
function attr(attrs, value) {
var arguments$1 = arguments;
var this$1 = this;
if (arguments.length === 1 && typeof attrs === 'string') {
// Get attr
if (this[0]) { return this[0].getAttribute(attrs); }
return undefined;
}
// Set attrs
for (var i = 0; i < this.length; i += 1) {
if (arguments$1.length === 2) {
// String
this$1[i].setAttribute(attrs, value);
} else {
// Object
// eslint-disable-next-line
for (var attrName in attrs) {
this$1[i][attrName] = attrs[attrName];
this$1[i].setAttribute(attrName, attrs[attrName]);
}
}
}
return this;
}
// eslint-disable-next-line
function removeAttr(attr) {
var this$1 = this;
for (var i = 0; i < this.length; i += 1) {
this$1[i].removeAttribute(attr);
}
return this;
}
function data(key, value) {
var this$1 = this;
var el;
if (typeof value === 'undefined') {
el = this[0];
// Get value
if (el) {
if (el.dom7ElementDataStorage && (key in el.dom7ElementDataStorage)) {
return el.dom7ElementDataStorage[key];
}
var dataKey = el.getAttribute(("data-" + key));
if (dataKey) {
return dataKey;
}
return undefined;
}
return undefined;
}
// Set value
for (var i = 0; i < this.length; i += 1) {
el = this$1[i];
if (!el.dom7ElementDataStorage) { el.dom7ElementDataStorage = {}; }
el.dom7ElementDataStorage[key] = value;
}
return this;
}
// Transforms
// eslint-disable-next-line
function transform(transform) {
var this$1 = this;
for (var i = 0; i < this.length; i += 1) {
var elStyle = this$1[i].style;
elStyle.webkitTransform = transform;
elStyle.transform = transform;
}
return this;
}
function transition(duration) {
var this$1 = this;
if (typeof duration !== 'string') {
duration = duration + "ms"; // eslint-disable-line
}
for (var i = 0; i < this.length; i += 1) {
var elStyle = this$1[i].style;
elStyle.webkitTransitionDuration = duration;
elStyle.transitionDuration = duration;
}
return this;
}
// Events
function on() {
var this$1 = this;
var assign;
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var eventType = args[0];
var targetSelector = args[1];
var listener = args[2];
var capture = args[3];
if (typeof args[1] === 'function') {
(assign = args, eventType = assign[0], listener = assign[1], capture = assign[2]);
targetSelector = undefined;
}
if (!capture) { capture = false; }
function handleLiveEvent(e) {
var target = e.target;
if (!target) { return; }
var eventData = e.target.dom7EventData || [];
if (eventData.indexOf(e) < 0) {
eventData.unshift(e);
}
if ($(target).is(targetSelector)) { listener.apply(target, eventData); }
else {
var parents = $(target).parents(); // eslint-disable-line
for (var k = 0; k < parents.length; k += 1) {
if ($(parents[k]).is(targetSelector)) { listener.apply(parents[k], eventData); }
}
}
}
function handleEvent(e) {
var eventData = e && e.target ? e.target.dom7EventData || [] : [];
if (eventData.indexOf(e) < 0) {
eventData.unshift(e);
}
listener.apply(this, eventData);
}
var events = eventType.split(' ');
var j;
for (var i = 0; i < this.length; i += 1) {
var el = this$1[i];
if (!targetSelector) {
for (j = 0; j < events.length; j += 1) {
var event = events[j];
if (!el.dom7Listeners) { el.dom7Listeners = {}; }
if (!el.dom7Listeners[event]) { el.dom7Listeners[event] = []; }
el.dom7Listeners[event].push({
listener: listener,
proxyListener: handleEvent,
});
el.addEventListener(event, handleEvent, capture);
}
} else {
// Live events
for (j = 0; j < events.length; j += 1) {
var event$1 = events[j];
if (!el.dom7LiveListeners) { el.dom7LiveListeners = {}; }
if (!el.dom7LiveListeners[event$1]) { el.dom7LiveListeners[event$1] = []; }
el.dom7LiveListeners[event$1].push({
listener: listener,
proxyListener: handleLiveEvent,
});
el.addEventListener(event$1, handleLiveEvent, capture);
}
}
}
return this;
}
function off() {
var this$1 = this;
var assign;
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var eventType = args[0];
var targetSelector = args[1];
var listener = args[2];
var capture = args[3];
if (typeof args[1] === 'function') {
(assign = args, eventType = assign[0], listener = assign[1], capture = assign[2]);
targetSelector = undefined;
}
if (!capture) { capture = false; }
var events = eventType.split(' ');
for (var i = 0; i < events.length; i += 1) {
var event = events[i];
for (var j = 0; j < this.length; j += 1) {
var el = this$1[j];
var handlers = (void 0);
if (!targetSelector && el.dom7Listeners) {
handlers = el.dom7Listeners[event];
} else if (targetSelector && el.dom7LiveListeners) {
handlers = el.dom7LiveListeners[event];
}
if (handlers && handlers.length) {
for (var k = handlers.length - 1; k >= 0; k -= 1) {
var handler = handlers[k];
if (listener && handler.listener === listener) {
el.removeEventListener(event, handler.proxyListener, capture);
handlers.splice(k, 1);
} else if (!listener) {
el.removeEventListener(event, handler.proxyListener, capture);
handlers.splice(k, 1);
}
}
}
}
}
return this;
}
function trigger() {
var this$1 = this;
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var events = args[0].split(' ');
var eventData = args[1];
for (var i = 0; i < events.length; i += 1) {
var event = events[i];
for (var j = 0; j < this.length; j += 1) {
var el = this$1[j];
var evt = (void 0);
try {
evt = new win.CustomEvent(event, {
detail: eventData,
bubbles: true,
cancelable: true,
});
} catch (e) {
evt = doc.createEvent('Event');
evt.initEvent(event, true, true);
evt.detail = eventData;
}
// eslint-disable-next-line
el.dom7EventData = args.filter(function (data, dataIndex) { return dataIndex > 0; });
el.dispatchEvent(evt);
el.dom7EventData = [];
delete el.dom7EventData;
}
}
return this;
}
function transitionEnd(callback) {
var events = ['webkitTransitionEnd', 'transitionend'];
var dom = this;
var i;
function fireCallBack(e) {
/* jshint validthis:true */
if (e.target !== this) { return; }
callback.call(this, e);
for (i = 0; i < events.length; i += 1) {
dom.off(events[i], fireCallBack);
}
}
if (callback) {
for (i = 0; i < events.length; i += 1) {
dom.on(events[i], fireCallBack);
}
}
return this;
}
function outerWidth(includeMargins) {
if (this.length > 0) {
if (includeMargins) {
// eslint-disable-next-line
var styles = this.styles();
return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left'));
}
return this[0].offsetWidth;
}
return null;
}
function outerHeight(includeMargins) {
if (this.length > 0) {
if (includeMargins) {
// eslint-disable-next-line
var styles = this.styles();
return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom'));
}
return this[0].offsetHeight;
}
return null;
}
function offset() {
if (this.length > 0) {
var el = this[0];
var box = el.getBoundingClientRect();
var body = doc.body;
var clientTop = el.clientTop || body.clientTop || 0;
var clientLeft = el.clientLeft || body.clientLeft || 0;
var scrollTop = el === win ? win.scrollY : el.scrollTop;
var scrollLeft = el === win ? win.scrollX : el.scrollLeft;
return {
top: (box.top + scrollTop) - clientTop,
left: (box.left + scrollLeft) - clientLeft,
};
}
return null;
}
function styles() {
if (this[0]) { return win.getComputedStyle(this[0], null); }
return {};
}
function css(props, value) {
var this$1 = this;
var i;
if (arguments.length === 1) {
if (typeof props === 'string') {
if (this[0]) { return win.getComputedStyle(this[0], null).getPropertyValue(props); }
} else {
for (i = 0; i < this.length; i += 1) {
// eslint-disable-next-line
for (var prop in props) {
this$1[i].style[prop] = props[prop];
}
}
return this;
}
}
if (arguments.length === 2 && typeof props === 'string') {
for (i = 0; i < this.length; i += 1) {
this$1[i].style[props] = value;
}
return this;
}
return this;
}
// Iterate over the collection passing elements to `callback`
function each(callback) {
var this$1 = this;
// Don't bother continuing without a callback
if (!callback) { return this; }
// Iterate over the current collection
for (var i = 0; i < this.length; i += 1) {
// If the callback returns false
if (callback.call(this$1[i], i, this$1[i]) === false) {
// End the loop early
return this$1;
}
}
// Return `this` to allow chained DOM operations
return this;
}
// eslint-disable-next-line
function html(html) {
var this$1 = this;
if (typeof html === 'undefined') {
return this[0] ? this[0].innerHTML : undefined;
}
for (var i = 0; i < this.length; i += 1) {
this$1[i].innerHTML = html;
}
return this;
}
// eslint-disable-next-line
function text(text) {
var this$1 = this;
if (typeof text === 'undefined') {
if (this[0]) {
return this[0].textContent.trim();
}
return null;
}
for (var i = 0; i < this.length; i += 1) {
this$1[i].textContent = text;
}
return this;
}
function is(selector) {
var el = this[0];
var compareWith;
var i;
if (!el || typeof selector === 'undefined') { return false; }
if (typeof selector === 'string') {
if (el.matches) { return el.matches(selector); }
else if (el.webkitMatchesSelector) { return el.webkitMatchesSelector(selector); }
else if (el.msMatchesSelector) { return el.msMatchesSelector(selector); }
compareWith = $(selector);
for (i = 0; i < compareWith.length; i += 1) {
if (compareWith[i] === el) { return true; }
}
return false;
} else if (selector === doc) { return el === doc; }
else if (selector === win) { return el === win; }
if (selector.nodeType || selector instanceof Dom7) {
compareWith = selector.nodeType ? [selector] : selector;
for (i = 0; i < compareWith.length; i += 1) {
if (compareWith[i] === el) { return true; }
}
return false;
}
return false;
}
function index() {
var child = this[0];
var i;
if (child) {
i = 0;
// eslint-disable-next-line
while ((child = child.previousSibling) !== null) {
if (child.nodeType === 1) { i += 1; }
}
return i;
}
return undefined;
}
// eslint-disable-next-line
function eq(index) {
if (typeof index === 'undefined') { return this; }
var length = this.length;
var returnIndex;
if (index > length - 1) {
return new Dom7([]);
}
if (index < 0) {
returnIndex = length + index;
if (returnIndex < 0) { return new Dom7([]); }
return new Dom7([this[returnIndex]]);
}
return new Dom7([this[index]]);
}
function append() {
var this$1 = this;
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var newChild;
for (var k = 0; k < args.length; k += 1) {
newChild = args[k];
for (var i = 0; i < this.length; i += 1) {
if (typeof newChild === 'string') {
var tempDiv = doc.createElement('div');
tempDiv.innerHTML = newChild;
while (tempDiv.firstChild) {
this$1[i].appendChild(tempDiv.firstChild);
}
} else if (newChild instanceof Dom7) {
for (var j = 0; j < newChild.length; j += 1) {
this$1[i].appendChild(newChild[j]);
}
} else {
this$1[i].appendChild(newChild);
}
}
}
return this;
}
function prepend(newChild) {
var this$1 = this;
var i;
var j;
for (i = 0; i < this.length; i += 1) {
if (typeof newChild === 'string') {
var tempDiv = doc.createElement('div');
tempDiv.innerHTML = newChild;
for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) {
this$1[i].insertBefore(tempDiv.childNodes[j], this$1[i].childNodes[0]);
}
} else if (newChild instanceof Dom7) {
for (j = 0; j < newChild.length; j += 1) {
this$1[i].insertBefore(newChild[j], this$1[i].childNodes[0]);
}
} else {
this$1[i].insertBefore(newChild, this$1[i].childNodes[0]);
}
}
return this;
}
function next(selector) {
if (this.length > 0) {
if (selector) {
if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) {
return new Dom7([this[0].nextElementSibling]);
}
return new Dom7([]);
}
if (this[0].nextElementSibling) { return new Dom7([this[0].nextElementSibling]); }
return new Dom7([]);
}
return new Dom7([]);
}
function nextAll(selector) {
var nextEls = [];
var el = this[0];
if (!el) { return new Dom7([]); }
while (el.nextElementSibling) {
var next = el.nextElementSibling; // eslint-disable-line
if (selector) {
if ($(next).is(selector)) { nextEls.push(next); }
} else { nextEls.push(next); }
el = next;
}
return new Dom7(nextEls);
}
function prev(selector) {
if (this.length > 0) {
var el = this[0];
if (selector) {
if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) {
return new Dom7([el.previousElementSibling]);
}
return new Dom7([]);
}
if (el.previousElementSibling) { return new Dom7([el.previousElementSibling]); }
return new Dom7([]);
}
return new Dom7([]);
}
function prevAll(selector) {
var prevEls = [];
var el = this[0];
if (!el) { return new Dom7([]); }
while (el.previousElementSibling) {
var prev = el.previousElementSibling; // eslint-disable-line
if (selector) {
if ($(prev).is(selector)) { prevEls.push(prev); }
} else { prevEls.push(prev); }
el = prev;
}
return new Dom7(prevEls);
}
function parent(selector) {
var this$1 = this;
var parents = []; // eslint-disable-line
for (var i = 0; i < this.length; i += 1) {
if (this$1[i].parentNode !== null) {
if (selector) {
if ($(this$1[i].parentNode).is(selector)) { parents.push(this$1[i].parentNode); }
} else {
parents.push(this$1[i].parentNode);
}
}
}
return $(unique(parents));
}
function parents(selector) {
var this$1 = this;
var parents = []; // eslint-disable-line
for (var i = 0; i < this.length; i += 1) {
var parent = this$1[i].parentNode; // eslint-disable-line
while (parent) {
if (selector) {
if ($(parent).is(selector)) { parents.push(parent); }
} else {
parents.push(parent);
}
parent = parent.parentNode;
}
}
return $(unique(parents));
}
function closest(selector) {
var closest = this; // eslint-disable-line
if (typeof selector === 'undefined') {
return new Dom7([]);
}
if (!closest.is(selector)) {
closest = closest.parents(selector).eq(0);
}
return closest;
}
function find(selector) {
var this$1 = this;
var foundElements = [];
for (var i = 0; i < this.length; i += 1) {
var found = this$1[i].querySelectorAll(selector);
for (var j = 0; j < found.length; j += 1) {
foundElements.push(found[j]);
}
}
return new Dom7(foundElements);
}
function children(selector) {
var this$1 = this;
var children = []; // eslint-disable-line
for (var i = 0; i < this.length; i += 1) {
var childNodes = this$1[i].childNodes;
for (var j = 0; j < childNodes.length; j += 1) {
if (!selector) {
if (childNodes[j].nodeType === 1) { children.push(childNodes[j]); }
} else if (childNodes[j].nodeType === 1 && $(childNodes[j]).is(selector)) {
children.push(childNodes[j]);
}
}
}
return new Dom7(unique(children));
}
function remove() {
var this$1 = this;
for (var i = 0; i < this.length; i += 1) {
if (this$1[i].parentNode) { this$1[i].parentNode.removeChild(this$1[i]); }
}
return this;
}
function add() {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var dom = this;
var i;
var j;
for (i = 0; i < args.length; i += 1) {
var toAdd = $(args[i]);
for (j = 0; j < toAdd.length; j += 1) {
dom[dom.length] = toAdd[j];
dom.length += 1;
}
}
return dom;
}
var Methods = {
addClass: addClass,
removeClass: removeClass,
hasClass: hasClass,
toggleClass: toggleClass,
attr: attr,
removeAttr: removeAttr,
data: data,
transform: transform,
transition: transition,
on: on,
off: off,
trigger: trigger,
transitionEnd: transitionEnd,
outerWidth: outerWidth,
outerHeight: outerHeight,
offset: offset,
css: css,
each: each,
html: html,
text: text,
is: is,
index: index,
eq: eq,
append: append,
prepend: prepend,
next: next,
nextAll: nextAll,
prev: prev,
prevAll: prevAll,
parent: parent,
parents: parents,
closest: closest,
find: find,
children: children,
remove: remove,
add: add,
styles: styles,
};
Object.keys(Methods).forEach(function (methodName) {
$.fn[methodName] = Methods[methodName];
});
var Utils = {
deleteProps: function deleteProps(obj) {
var object = obj;
Object.keys(object).forEach(function (key) {
try {
object[key] = null;
} catch (e) {
// no getter for object
}
try {
delete object[key];
} catch (e) {
// something got wrong
}
});
},
nextTick: function nextTick(callback, delay) {
if ( delay === void 0 ) delay = 0;
return setTimeout(callback, delay);
},
now: function now() {
return Date.now();
},
getTranslate: function getTranslate(el, axis) {
if ( axis === void 0 ) axis = 'x';
var matrix;
var curTransform;
var transformMatrix;
var curStyle = win.getComputedStyle(el, null);
if (win.WebKitCSSMatrix) {
curTransform = curStyle.transform || curStyle.webkitTransform;
if (curTransform.split(',').length > 6) {
curTransform = curTransform.split(', ').map(function (a) { return a.replace(',', '.'); }).join(', ');
}
// Some old versions of Webkit choke when 'none' is passed; pass
// empty string instead in this case
transformMatrix = new win.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
} else {
transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
matrix = transformMatrix.toString().split(',');
}
if (axis === 'x') {
// Latest Chrome and webkits Fix
if (win.WebKitCSSMatrix) { curTransform = transformMatrix.m41; }
// Crazy IE10 Matrix
else if (matrix.length === 16) { curTransform = parseFloat(matrix[12]); }
// Normal Browsers
else { curTransform = parseFloat(matrix[4]); }
}
if (axis === 'y') {
// Latest Chrome and webkits Fix
if (win.WebKitCSSMatrix) { curTransform = transformMatrix.m42; }
// Crazy IE10 Matrix
else if (matrix.length === 16) { curTransform = parseFloat(matrix[13]); }
// Normal Browsers
else { curTransform = parseFloat(matrix[5]); }
}
return curTransform || 0;
},
parseUrlQuery: function parseUrlQuery(url) {
var query = {};
var urlToParse = url || win.location.href;
var i;
var params;
var param;
var length;
if (typeof urlToParse === 'string' && urlToParse.length) {
urlToParse = urlToParse.indexOf('?') > -1 ? urlToParse.replace(/\S*\?/, '') : '';
params = urlToParse.split('&').filter(function (paramsPart) { return paramsPart !== ''; });
length = params.length;
for (i = 0; i < length; i += 1) {
param = params[i].replace(/#\S+/g, '').split('=');
query[decodeURIComponent(param[0])] = typeof param[1] === 'undefined' ? undefined : decodeURIComponent(param[1]) || '';
}
}
return query;
},
isObject: function isObject(o) {
return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object;
},
extend: function extend() {
var args = [], len$1 = arguments.length;
while ( len$1-- ) args[ len$1 ] = arguments[ len$1 ];
var to = Object(args[0]);
for (var i = 1; i < args.length; i += 1) {
var nextSource = args[i];
if (nextSource !== undefined && nextSource !== null) {
var keysArray = Object.keys(Object(nextSource));
for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
var nextKey = keysArray[nextIndex];
var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
if (desc !== undefined && desc.enumerable) {
if (Utils.isObject(to[nextKey]) && Utils.isObject(nextSource[nextKey])) {
Utils.extend(to[nextKey], nextSource[nextKey]);
} else if (!Utils.isObject(to[nextKey]) && Utils.isObject(nextSource[nextKey])) {
to[nextKey] = {};
Utils.extend(to[nextKey], nextSource[nextKey]);
} else {
to[nextKey] = nextSource[nextKey];
}
}
}
}
}
return to;
},