UNPKG

react-id-swiper

Version:

ReactJs component for iDangerous Swiper

1,464 lines (1,316 loc) 213 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 _objectAssign = __webpack_require__(3); var _objectAssign2 = _interopRequireDefault(_objectAssign); var _propTypes = __webpack_require__(4); var _propTypes2 = _interopRequireDefault(_propTypes); var _custom = __webpack_require__(9); var _custom2 = _interopRequireDefault(_custom); 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; } /* NOTE: Custom version won't support those features below - Virtual - Keyboard - Mouse wheel - Zoom - Lazy load image - A11y - Parallax - History - Hash-navigation - Effect-cube - Effect-flip - Effect-coverflow #Referer link: http://idangero.us/swiper/api/#custom-build */ 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') return; 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 _custom2.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; return _react2.default.createElement( ContainerEl, { className: containerClass, dir: rtl && 'rtl' }, _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) }); } }; 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__) { "use strict"; /* object-assign (c) Sindre Sorhus @license MIT */ /* eslint-disable no-unused-vars */ var getOwnPropertySymbols = Object.getOwnPropertySymbols; var hasOwnProperty = Object.prototype.hasOwnProperty; var propIsEnumerable = Object.prototype.propertyIsEnumerable; function toObject(val) { if (val === null || val === undefined) { throw new TypeError('Object.assign cannot be called with null or undefined'); } return Object(val); } function shouldUseNative() { try { if (!Object.assign) { return false; } // Detect buggy property enumeration order in older V8 versions. // https://bugs.chromium.org/p/v8/issues/detail?id=4118 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers test1[5] = 'de'; if (Object.getOwnPropertyNames(test1)[0] === '5') { return false; } // https://bugs.chromium.org/p/v8/issues/detail?id=3056 var test2 = {}; for (var i = 0; i < 10; i++) { test2['_' + String.fromCharCode(i)] = i; } var order2 = Object.getOwnPropertyNames(test2).map(function (n) { return test2[n]; }); if (order2.join('') !== '0123456789') { return false; } // https://bugs.chromium.org/p/v8/issues/detail?id=3056 var test3 = {}; 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { test3[letter] = letter; }); if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') { return false; } return true; } catch (err) { // We don't expect any of the above to throw, but better to be safe. return false; } } module.exports = shouldUseNative() ? Object.assign : function (target, source) { var from; var to = toObject(target); var symbols; for (var s = 1; s < arguments.length; s++) { from = Object(arguments[s]); for (var key in from) { if (hasOwnProperty.call(from, key)) { to[key] = from[key]; } } if (getOwnPropertySymbols) { symbols = getOwnPropertySymbols(from); for (var i = 0; i < symbols.length; i++) { if (propIsEnumerable.call(from, symbols[i])) { to[symbols[i]] = from[symbols[i]]; } } } } return to; }; /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ if (false) { var throwOnDirectAccess, isValidElement, REACT_ELEMENT_TYPE; } else { // By explicitly using `prop-types` you are opting into new production behavior. // http://fb.me/prop-types-in-prod module.exports = __webpack_require__(5)(); } /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var emptyFunction = __webpack_require__(6); var invariant = __webpack_require__(7); var ReactPropTypesSecret = __webpack_require__(8); module.exports = function() { function shim(props, propName, componentName, location, propFullName, secret) { if (secret === ReactPropTypesSecret) { // It is still safe when called from React. return; } invariant( false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types' ); }; shim.isRequired = shim; function getShim() { return shim; }; // Important! // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. var ReactPropTypes = { array: shim, bool: shim, func: shim, number: shim, object: shim, string: shim, symbol: shim, any: shim, arrayOf: getShim, element: shim, instanceOf: getShim, node: shim, objectOf: getShim, oneOf: getShim, oneOfType: getShim, shape: getShim, exact: getShim }; ReactPropTypes.checkPropTypes = emptyFunction; ReactPropTypes.PropTypes = ReactPropTypes; return ReactPropTypes; }; /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ function makeEmptyFunction(arg) { return function () { return arg; }; } /** * This function accepts and discards inputs; it has no side effects. This is * primarily useful idiomatically for overridable function endpoints which * always need to be callable, since JS lacks a null-call idiom ala Cocoa. */ var emptyFunction = function emptyFunction() {}; emptyFunction.thatReturns = makeEmptyFunction; emptyFunction.thatReturnsFalse = makeEmptyFunction(false); emptyFunction.thatReturnsTrue = makeEmptyFunction(true); emptyFunction.thatReturnsNull = makeEmptyFunction(null); emptyFunction.thatReturnsThis = function () { return this; }; emptyFunction.thatReturnsArgument = function (arg) { return arg; }; module.exports = emptyFunction; /***/ }), /* 7 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ /** * Use invariant() to assert state which your program assumes to be true. * * Provide sprintf-style format (only %s is supported) and arguments * to provide information about what broke and what you were * expecting. * * The invariant message will be stripped in production, but the invariant * will remain to ensure logic does not differ in production. */ var validateFormat = function validateFormat(format) {}; if (false) {} function invariant(condition, format, a, b, c, d, e, f) { validateFormat(format); if (!condition) { var error; if (format === undefined) { error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); } else { var args = [a, b, c, d, e, f]; var argIndex = 0; error = new Error(format.replace(/%s/g, function () { return args[argIndex++]; })); error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } } module.exports = invariant; /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; module.exports = ReactPropTypesSecret; /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__; var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /* NOTE: Custom version won't support those features - Virtual - Keyboard - Mouse wheel - Zoom - Lazy load image - A11y - History - Parallax - Hash-navigation - Effect-cube - Effect-flip - Effect-coverflow */ /** * 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: September 2, 2018 */ (function (global, factory) { ( false ? undefined : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : true ? !(__WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : undefined; })(undefined, function () { 'use strict'; /** * SSR Window 1.0.0 * Better handling for window object in SSR environment * https://github.com/nolimits4web/ssr-window * * Copyright 2018, Vladimir Kharlampidi * * Licensed under MIT * * Released on: February 10, 2018 */ var d; if (typeof document === 'undefined') { d = { 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: '' } }; } else { // eslint-disable-next-line d = document; } var doc = d; var w; if (typeof window === 'undefined') { w = { 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() {} }; } else { // eslint-disable-next-line w = window; } var win = w; /** * Dom7 2.0.5 * 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: April 20, 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].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].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].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]; } 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)) {