1 | function isObject(o) {
|
2 | return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
|
3 | }
|
4 |
|
5 | function extend(target, src) {
|
6 | const noExtend = ['__proto__', 'constructor', 'prototype'];
|
7 | Object.keys(src).filter(key => noExtend.indexOf(key) < 0).forEach(key => {
|
8 | if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject(src[key]) && isObject(target[key]) && Object.keys(src[key]).length > 0) {
|
9 | if (src[key].__swiper__) target[key] = src[key];else extend(target[key], src[key]);
|
10 | } else {
|
11 | target[key] = src[key];
|
12 | }
|
13 | });
|
14 | }
|
15 |
|
16 | function needsNavigation(params) {
|
17 | if (params === void 0) {
|
18 | params = {};
|
19 | }
|
20 |
|
21 | return params.navigation && typeof params.navigation.nextEl === 'undefined' && typeof params.navigation.prevEl === 'undefined';
|
22 | }
|
23 |
|
24 | function needsPagination(params) {
|
25 | if (params === void 0) {
|
26 | params = {};
|
27 | }
|
28 |
|
29 | return params.pagination && typeof params.pagination.el === 'undefined';
|
30 | }
|
31 |
|
32 | function needsScrollbar(params) {
|
33 | if (params === void 0) {
|
34 | params = {};
|
35 | }
|
36 |
|
37 | return params.scrollbar && typeof params.scrollbar.el === 'undefined';
|
38 | }
|
39 |
|
40 | function uniqueClasses(classNames) {
|
41 | if (classNames === void 0) {
|
42 | classNames = '';
|
43 | }
|
44 |
|
45 | const classes = classNames.split(' ').map(c => c.trim()).filter(c => !!c);
|
46 | const unique = [];
|
47 | classes.forEach(c => {
|
48 | if (unique.indexOf(c) < 0) unique.push(c);
|
49 | });
|
50 | return unique.join(' ');
|
51 | }
|
52 |
|
53 | export { isObject, extend, needsNavigation, needsPagination, needsScrollbar, uniqueClasses }; |
\ | No newline at end of file |