UNPKG

react-id-swiper

Version:

ReactJs component for iDangerous Swiper

1,559 lines (1,430 loc) 283 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("React"), require("ReactDOM")); else if(typeof define === 'function' && define.amd) define(["React", "ReactDOM"], factory); else if(typeof exports === 'object') exports["ReactIdSwiper"] = factory(require("React"), require("ReactDOM")); else root["ReactIdSwiper"] = factory(root["React"], root["ReactDOM"]); })(window, function(__WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__2__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = __webpack_require__(1); var _react2 = _interopRequireDefault(_react); var _reactDom = __webpack_require__(2); var _reactDom2 = _interopRequireDefault(_reactDom); var _swiper = __webpack_require__(3); var _swiper2 = _interopRequireDefault(_swiper); var _objectAssign = __webpack_require__(4); var _objectAssign2 = _interopRequireDefault(_objectAssign); var _propTypes = __webpack_require__(5); var _propTypes2 = _interopRequireDefault(_propTypes); var _utils = __webpack_require__(10); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var ReactIdSwiper = function (_Component) { _inherits(ReactIdSwiper, _Component); // Proptypes function ReactIdSwiper(props) { _classCallCheck(this, ReactIdSwiper); var _this = _possibleConstructorReturn(this, (ReactIdSwiper.__proto__ || Object.getPrototypeOf(ReactIdSwiper)).call(this, props)); _this.renderContent = _this.renderContent.bind(_this); return _this; } // Default props _createClass(ReactIdSwiper, [{ key: 'componentDidMount', value: function componentDidMount() { this.buildSwiper(); } }, { key: 'componentDidUpdate', value: function componentDidUpdate() { if (typeof this.swiper !== 'undefined') { var _props = this.props, rebuildOnUpdate = _props.rebuildOnUpdate, shouldSwiperUpdate = _props.shouldSwiperUpdate, activeSlideKey = _props.activeSlideKey; if (rebuildOnUpdate) { this.rebuildSwiper(); } else if (shouldSwiperUpdate) { this.updateSwiper(); var numSlides = this.swiper.slides.length; if (numSlides <= this.swiper.activeIndex) { var index = Math.max(numSlides - 1, 0); this.swiper.slideTo(index); } } if (activeSlideKey) { var activeSlideId = null; var id = 0; _react2.default.Children.forEach(this.props.children, function (child) { if (child) { if (child.key === activeSlideKey) { activeSlideId = id; } id += 1; } }); if (activeSlideId !== null) { this.swiper.slideTo(activeSlideId); } } } } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { if (typeof this.swiper !== 'undefined') this.swiper.destroy(true, true); delete this.swiper; } }, { key: 'buildSwiper', value: function buildSwiper() { this.swiper = new _swiper2.default(_reactDom2.default.findDOMNode(this), (0, _objectAssign2.default)({}, this.props)); } }, { key: 'rebuildSwiper', value: function rebuildSwiper() { this.swiper.destroy(true, true); this.buildSwiper(); } }, { key: 'updateSwiper', value: function updateSwiper() { if (typeof this.swiper !== 'undefined') this.swiper.update(); } }, { key: 'renderContent', value: function renderContent(e) { if (!e) return false; var _props2 = this.props, slideClass = _props2.slideClass, noSwiping = _props2.noSwiping; var slideClassNames = [slideClass, e.props.className]; if (noSwiping) slideClassNames.push('swiper-no-swiping'); return _react2.default.cloneElement(e, _extends({}, e.props, { className: slideClassNames.join(' ').trim() })); } }, { key: 'render', value: function render() { var _props3 = this.props, ContainerEl = _props3.ContainerEl, WrapperEl = _props3.WrapperEl, containerClass = _props3.containerClass, wrapperClass = _props3.wrapperClass, children = _props3.children, rtl = _props3.rtl, scrollbar = _props3.scrollbar, renderScrollbar = _props3.renderScrollbar, pagination = _props3.pagination, renderPagination = _props3.renderPagination, navigation = _props3.navigation, renderPrevButton = _props3.renderPrevButton, renderNextButton = _props3.renderNextButton, parallax = _props3.parallax, parallaxEl = _props3.parallaxEl, renderParallax = _props3.renderParallax; return _react2.default.createElement( ContainerEl, { className: containerClass, dir: rtl && 'rtl' }, parallax && parallaxEl && renderParallax(this.props), _react2.default.createElement( WrapperEl, { className: wrapperClass }, _react2.default.Children.map(children, this.renderContent) ), pagination && pagination.el && renderPagination(this.props), scrollbar && scrollbar.el && renderScrollbar(this.props), navigation && navigation.nextEl && renderNextButton(this.props), navigation && navigation.prevEl && renderPrevButton(this.props) ); } }]); return ReactIdSwiper; }(_react.Component); ReactIdSwiper.defaultProps = { containerClass: 'swiper-container', wrapperClass: 'swiper-wrapper', slideClass: 'swiper-slide', ContainerEl: 'div', WrapperEl: 'div', renderScrollbar: function renderScrollbar(_ref) { var scrollbar = _ref.scrollbar; return _react2.default.createElement('div', { className: (0, _utils.cn)(scrollbar.el) }); }, renderPagination: function renderPagination(_ref2) { var pagination = _ref2.pagination; return _react2.default.createElement('div', { className: (0, _utils.cn)(pagination.el) }); }, renderPrevButton: function renderPrevButton(_ref3) { var navigation = _ref3.navigation; return _react2.default.createElement('div', { className: (0, _utils.cn)(navigation.prevEl) }); }, renderNextButton: function renderNextButton(_ref4) { var navigation = _ref4.navigation; return _react2.default.createElement('div', { className: (0, _utils.cn)(navigation.nextEl) }); }, renderParallax: function renderParallax(_ref5) { var parallaxEl = _ref5.parallaxEl; return _react2.default.createElement('div', { className: (0, _utils.cn)(parallaxEl.el), 'data-swiper-parallax': parallaxEl.value }); } }; exports.default = ReactIdSwiper; /***/ }), /* 1 */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE__1__; /***/ }), /* 2 */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE__2__; /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { /** * 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) { true ? module.exports = factory() : undefined; }(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; }, }; var Support = (function Support() { var testDiv = doc.createElement('div'); return { touch: (win.Modernizr && win.Modernizr.touch === true) || (function checkTouch() { return !!(('ontouchstart' in win) || (win.DocumentTouch && doc instanceof win.DocumentTouch)); }()), pointerEvents: !!(win.navigator.pointerEnabled || win.PointerEvent), prefixedPointerEvents: !!win.navigator.msPointerEnabled, transition: (function checkTransition() { var style = testDiv.style; return ('transition' in style || 'webkitTransition' in style || 'MozTransition' in style); }()), transforms3d: (win.Modernizr && win.Modernizr.csstransforms3d === true) || (function checkTransforms3d() { var style = testDiv.style; return ('webkitPerspective' in style || 'MozPerspective' in style || 'OPerspective' in style || 'MsPerspective' in style || 'perspective' in style); }()), flexbox: (function checkFlexbox() { var style = testDiv.style; var styles = ('alignItems webkitAlignItems webkitBoxAlign msFlexAlign mozBoxAlign webkitFlexDirection msFlexDirection mozBoxDirection mozBoxOrient webkitBoxDirection webkitBoxOrient').split(' '); for (var i = 0; i < styles.length; i += 1) { if (styles[i] in style) { return true; } } return false; }()), observer: (function checkObserver() { return ('MutationObserver' in win || 'WebkitMutationObserver' in win); }()), passiveListener: (function checkPassiveListener() { var supportsPassive = false; try { var opts = Object.defineProperty({}, 'passive', { // eslint-disable-next-line get: function get() { supportsPassive = true; }, }); win.addEventListener('testPassiveListener', null, opts); } catch (e) { // No support } return supportsPassive; }()), gestures: (function checkGestures() { return 'ongesturestart' in win; }()), }; }()); var SwiperClass = function SwiperClass(params) { if ( params === void 0 ) params = {}; var self = this; self.params = params; // Events self.eventsListeners = {}; if (self.params && self.params.on) { Object.keys(self.params.on).forEach(function (eventName) { self.on(eventName, self.params.on[eventName]); }); } }; var staticAccessors = { components: { configurable: true } }; SwiperClass.prototype.on = function on (events, handler, priority) { var self = this; if (typeof handler !== 'function') { return self; } var method = priority ? 'unshift' : 'push'; events.split(' ').forEach(function (event) { if (!self.eventsListeners[event]) { self.eventsListeners[event] = []; } self.eventsListeners[event][method](handler); }); return self; }; SwiperClass.prototype.once = function once (events, handler, priority) { var self = this; if (typeof handler !== 'function') { return self; } function onceHandler() { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; handler.apply(self, args); self.off(events, onceHandler); } return self.on(events, onceHandler, priority); }; SwiperClass.prototype.off = function off (events, handler) { var self = this; if (!self.eventsListeners) { return self; } events.split(' ').forEach(function (event) { if (typeof handler === 'undefined') { self.eventsListeners[event] = []; } else { self.eventsListeners[event].forEach(function (eventHandler, index) { if (eventHandler === handler) { self.eventsListeners[event].splice(index, 1); } }); } }); return self; }; SwiperClass.prototype.emit = function emit () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; var self = this; if (!self.eventsListeners) { return self; } var events; var data; var context; if (typeof args[0] === 'string' || Array.isArray(args[0])) { events = args[0]; data = args.slice(1, args.length); context = self; } else { events = args[0].events; data = args[0].data; context = args[0].context || self; } var eventsArray = Array.isArray(events) ? events : events.split(' '); eventsArray.forEach(function (event) { if (self.eventsListeners && self.eventsListeners[event]) { var handlers = []; self.eventsListeners[event].forEach(function (eventHandler) { handlers.push(eventHandler); }); handlers.forEach(function (eventHandler) { eventHandler.apply(context, data); }); } }); return self; }; SwiperClass.prototype.useModulesParams = function useModulesParams (instanceParams) { var instance = this; if (!instance.modules) { return; } Object.keys(instance.modules).forEach(function (moduleName) { var module = instance.modules[moduleName]; // Extend params if (module.params) { Utils.extend(instanceParams, module.params); } }); }; SwiperClass.prototype.useModules = function useModules (modulesParams) { if ( modulesParams === void 0 ) modulesParams = {}; var instance = this; if (!instance.modules) { return; } Object.keys(instance.modules).forEach(function (moduleName) { var module = instance.modules[moduleName]; var moduleParams = modulesParams[moduleName] || {}; // Extend instance methods and props if (module.instance) { Object.keys(module.instance).forEach(function (modulePropName) { var moduleProp = module.instance[modulePropName]; if (typeof moduleProp === 'function') { instance[modulePropName] = moduleProp.bind(instance); } else { instance[modulePropName] = moduleProp; } }); } // Add event listeners if (module.on && instance.on) { Object.keys(module.on).forEach(function (moduleEventName) { instance.on(moduleEventName, module.on[moduleEventName]); }); } // Module create callback if (module.create) { module.create.bind(instance)(moduleParams); } }); }; staticAccessors.components.set = function (components) { var Class = this; if (!Class.use) { return; } Class.use(components); }; SwiperClass.installModule = function installModule (module) { var params = [], len = arguments.length - 1; while ( len-- > 0 ) params[ len ] = arguments[ len + 1 ]; var Class = this; if (!Class.prototype.modules) { Class.prototype.modules = {}; } var name = module.name || (((Object.keys(Class.prototype.modules).length) + "_" + (Utils.now()))); Class.prototype.modules[name] = module; // Prototype if (module.proto) { Object.keys(module.proto).forEach(function (key) { Class.prototype[key] = module.proto[key]; }); } // Class if (module.static) { Object.keys(module.static).forEach(function (key) { Class[key] = module.static[key]; }); } // Callback if (module.install) { module.install.apply(Class, params); } return Class; }; SwiperClass.use = function use (module) { var params = [], len = arguments.length - 1; while ( len-- > 0 ) params[ len ] = arguments[ len + 1 ]; var Class = this; if (Array.isArray(module)) { module.forEach(function (m) { return Class.installModule(m)