UNPKG

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