bulma-extensions
Version:
Set of extensions for Bulma.io CSS Framework
1,403 lines (1,198 loc) • 82.8 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["bulmaCarousel"] = factory();
else
root["bulmaCarousel"] = factory();
})(typeof self !== 'undefined' ? self : this, function() {
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, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // 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 = 5);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export addClasses */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return removeClasses; });
/* unused harmony export show */
/* unused harmony export hide */
/* unused harmony export offset */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return width; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return height; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return outerHeight; });
/* unused harmony export outerWidth */
/* unused harmony export position */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return css; });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__type__ = __webpack_require__(2);
var addClasses = function addClasses(element, classes) {
classes = Array.isArray(classes) ? classes : classes.split(' ');
classes.forEach(function (cls) {
element.classList.add(cls);
});
};
var removeClasses = function removeClasses(element, classes) {
classes = Array.isArray(classes) ? classes : classes.split(' ');
classes.forEach(function (cls) {
element.classList.remove(cls);
});
};
var show = function show(elements) {
elements = Array.isArray(elements) ? elements : [elements];
elements.forEach(function (element) {
element.style.display = '';
});
};
var hide = function hide(elements) {
elements = Array.isArray(elements) ? elements : [elements];
elements.forEach(function (element) {
element.style.display = 'none';
});
};
var offset = function offset(element) {
var rect = element.getBoundingClientRect();
return {
top: rect.top + document.body.scrollTop,
left: rect.left + document.body.scrollLeft
};
};
// returns an element's width
var width = function width(element) {
return element.getBoundingClientRect().width || element.offsetWidth;
};
// returns an element's height
var height = function height(element) {
return element.getBoundingClientRect().height || element.offsetHeight;
};
var outerHeight = function outerHeight(element) {
var withMargin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var height = element.offsetHeight;
if (withMargin) {
var style = window.getComputedStyle(element);
height += parseInt(style.marginTop) + parseInt(style.marginBottom);
}
return height;
};
var outerWidth = function outerWidth(element) {
var withMargin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var width = element.offsetWidth;
if (withMargin) {
var style = window.getComputedStyle(element);
width += parseInt(style.marginLeft) + parseInt(style.marginRight);
}
return width;
};
var position = function position(element) {
return {
left: element.offsetLeft,
top: element.offsetTop
};
};
var css = function css(element, obj) {
if (!obj) {
return window.getComputedStyle(element);
}
if (Object(__WEBPACK_IMPORTED_MODULE_0__type__["b" /* isObject */])(obj)) {
var style = '';
Object.keys(obj).forEach(function (key) {
style += key + ': ' + obj[key] + ';';
});
element.style.cssText += style;
}
};
/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = detectSupportsPassive;
function detectSupportsPassive() {
var supportsPassive = false;
try {
var opts = Object.defineProperty({}, 'passive', {
get: function get() {
supportsPassive = true;
}
});
window.addEventListener('testPassive', null, opts);
window.removeEventListener('testPassive', null, opts);
} catch (e) {}
return supportsPassive;
}
/***/ }),
/* 2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return isFunction; });
/* unused harmony export isNumber */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return isString; });
/* unused harmony export isDate */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isObject; });
/* unused harmony export isEmptyObject */
/* unused harmony export isNode */
/* unused harmony export isVideo */
/* unused harmony export isHTML5 */
/* unused harmony export isIFrame */
/* unused harmony export isYoutube */
/* unused harmony export isVimeo */
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; };
var isFunction = function isFunction(unknown) {
return typeof unknown === 'function';
};
var isNumber = function isNumber(unknown) {
return typeof unknown === "number";
};
var isString = function isString(unknown) {
return typeof unknown === 'string' || !!unknown && (typeof unknown === 'undefined' ? 'undefined' : _typeof(unknown)) === 'object' && Object.prototype.toString.call(unknown) === '[object String]';
};
var isDate = function isDate(unknown) {
return (Object.prototype.toString.call(unknown) === '[object Date]' || unknown instanceof Date) && !isNaN(unknown.valueOf());
};
var isObject = function isObject(unknown) {
return (typeof unknown === 'function' || (typeof unknown === 'undefined' ? 'undefined' : _typeof(unknown)) === 'object' && !!unknown) && !Array.isArray(unknown);
};
var isEmptyObject = function isEmptyObject(unknown) {
for (var name in unknown) {
if (unknown.hasOwnProperty(name)) {
return false;
}
}
return true;
};
var isNode = function isNode(unknown) {
return !!(unknown && unknown.nodeType === HTMLElement | SVGElement);
};
var isVideo = function isVideo(unknown) {
return isYoutube(unknown) || isVimeo(unknown) || isHTML5(unknown);
};
var isHTML5 = function isHTML5(unknown) {
return isNode(unknown) && unknown.tagName === 'VIDEO';
};
var isIFrame = function isIFrame(unknown) {
return isNode(unknown) && unknown.tagName === 'IFRAME';
};
var isYoutube = function isYoutube(unknown) {
return isIFrame(unknown) && !!unknown.src.match(/\/\/.*?youtube(-nocookie)?\.[a-z]+\/(watch\?v=[^&\s]+|embed)|youtu\.be\/.*/);
};
var isVimeo = function isVimeo(unknown) {
return isIFrame(unknown) && !!unknown.src.match(/vimeo\.com\/video\/.*/);
};
/***/ }),
/* 3 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
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; }; }();
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var EventEmitter = function () {
function EventEmitter() {
var events = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
_classCallCheck(this, EventEmitter);
this.events = new Map(events);
}
_createClass(EventEmitter, [{
key: "on",
value: function on(name, cb) {
var _this = this;
this.events.set(name, [].concat(_toConsumableArray(this.events.has(name) ? this.events.get(name) : []), [cb]));
return function () {
return _this.events.set(name, _this.events.get(name).filter(function (fn) {
return fn !== cb;
}));
};
}
}, {
key: "emit",
value: function emit(name) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return this.events.has(name) && this.events.get(name).map(function (fn) {
return fn.apply(undefined, args);
});
}
}]);
return EventEmitter;
}();
/* harmony default export */ __webpack_exports__["a"] = (EventEmitter);
/***/ }),
/* 4 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Coordinate = function () {
function Coordinate() {
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
_classCallCheck(this, Coordinate);
this._x = x;
this._y = y;
}
_createClass(Coordinate, [{
key: 'add',
value: function add(coord) {
return new Coordinate(this._x + coord._x, this._y + coord._y);
}
}, {
key: 'sub',
value: function sub(coord) {
return new Coordinate(this._x - coord._x, this._y - coord._y);
}
}, {
key: 'distance',
value: function distance(coord) {
var deltaX = this._x - coord._x;
var deltaY = this._y - coord._y;
return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
}
}, {
key: 'max',
value: function max(coord) {
var x = Math.max(this._x, coord._x);
var y = Math.max(this._y, coord._y);
return new Coordinate(x, y);
}
}, {
key: 'equals',
value: function equals(coord) {
if (this == coord) {
return true;
}
if (!coord || coord == null) {
return false;
}
return this._x == coord._x && this._y == coord._y;
}
}, {
key: 'inside',
value: function inside(northwest, southeast) {
if (this._x >= northwest._x && this._x <= southeast._x && this._y >= northwest._y && this._y <= southeast._y) {
return true;
}
return false;
}
}, {
key: 'constrain',
value: function constrain(min, max) {
if (min._x > max._x || min._y > max._y) {
return this;
}
var x = this._x,
y = this._y;
if (min._x !== null) {
x = Math.max(x, min._x);
}
if (max._x !== null) {
x = Math.min(x, max._x);
}
if (min._y !== null) {
y = Math.max(y, min._y);
}
if (max._y !== null) {
y = Math.min(y, max._y);
}
return new Coordinate(x, y);
}
}, {
key: 'reposition',
value: function reposition(element) {
element.style['top'] = this._y + 'px';
element.style['left'] = this._x + 'px';
}
}, {
key: 'toString',
value: function toString() {
return '(' + this._x + ',' + this._y + ')';
}
}, {
key: 'x',
get: function get() {
return this._x;
},
set: function set() {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
this._x = value;
return this;
}
}, {
key: 'y',
get: function get() {
return this._y;
},
set: function set() {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
this._y = value;
return this;
}
}]);
return Coordinate;
}();
/* harmony default export */ __webpack_exports__["a"] = (Coordinate);
/***/ }),
/* 5 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils_index__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils_css__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils_type__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_eventEmitter__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__components_autoplay__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__components_breakpoint__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__components_infinite__ = __webpack_require__(10);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__components_loop__ = __webpack_require__(11);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__components_navigation__ = __webpack_require__(13);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__components_pagination__ = __webpack_require__(15);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__components_swipe__ = __webpack_require__(18);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__components_transitioner__ = __webpack_require__(19);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__defaultOptions__ = __webpack_require__(22);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__templates__ = __webpack_require__(23);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__templates_item__ = __webpack_require__(24);
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; }; }();
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return 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 bulmaCarousel = function (_EventEmitter) {
_inherits(bulmaCarousel, _EventEmitter);
function bulmaCarousel(selector) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
_classCallCheck(this, bulmaCarousel);
var _this = _possibleConstructorReturn(this, (bulmaCarousel.__proto__ || Object.getPrototypeOf(bulmaCarousel)).call(this));
_this.element = Object(__WEBPACK_IMPORTED_MODULE_2__utils_type__["c" /* isString */])(selector) ? document.querySelector(selector) : selector;
// An invalid selector or non-DOM node has been provided.
if (!_this.element) {
throw new Error('An invalid selector or non-DOM node has been provided.');
}
_this._clickEvents = ['click', 'touch'];
// Use Element dataset values to override options
var elementConfig = _this.element.dataset ? Object.keys(_this.element.dataset).filter(function (key) {
return Object.keys(__WEBPACK_IMPORTED_MODULE_12__defaultOptions__["a" /* default */]).includes(key);
}).reduce(function (obj, key) {
return _extends({}, obj, _defineProperty({}, key, _this.element.dataset[key]));
}, {}) : {};
// Set default options - dataset attributes are master
_this.options = _extends({}, __WEBPACK_IMPORTED_MODULE_12__defaultOptions__["a" /* default */], options, elementConfig);
_this._id = Object(__WEBPACK_IMPORTED_MODULE_0__utils_index__["a" /* uuid */])('slider');
_this.onShow = _this.onShow.bind(_this);
// Initiate plugin
_this._init();
return _this;
}
/**
* Initiate all DOM element containing datePicker class
* @method
* @return {Array} Array of all datePicker instances
*/
_createClass(bulmaCarousel, [{
key: '_init',
/****************************************************
* *
* PRIVATE FUNCTIONS *
* *
****************************************************/
/**
* Initiate plugin instance
* @method _init
* @return {Slider} Current plugin instance
*/
value: function _init() {
this._items = Array.from(this.element.children);
// Load plugins
this._breakpoint = new __WEBPACK_IMPORTED_MODULE_5__components_breakpoint__["a" /* default */](this);
this._autoplay = new __WEBPACK_IMPORTED_MODULE_4__components_autoplay__["a" /* default */](this);
this._navigation = new __WEBPACK_IMPORTED_MODULE_8__components_navigation__["a" /* default */](this);
this._pagination = new __WEBPACK_IMPORTED_MODULE_9__components_pagination__["a" /* default */](this);
this._infinite = new __WEBPACK_IMPORTED_MODULE_6__components_infinite__["a" /* default */](this);
this._loop = new __WEBPACK_IMPORTED_MODULE_7__components_loop__["a" /* default */](this);
this._swipe = new __WEBPACK_IMPORTED_MODULE_10__components_swipe__["a" /* default */](this);
this._build();
if (Object(__WEBPACK_IMPORTED_MODULE_2__utils_type__["a" /* isFunction */])(this.options.onReady)) {
this.options.onReady(this);
}
return this;
}
/**
* Build Slider HTML component and append it to the DOM
* @method _build
*/
}, {
key: '_build',
value: function _build() {
var _this2 = this;
// Generate HTML Fragment of template
this.node = document.createRange().createContextualFragment(Object(__WEBPACK_IMPORTED_MODULE_13__templates__["a" /* default */])(this.id));
// Save pointers to template parts
this._ui = {
wrapper: this.node.firstChild,
container: this.node.querySelector('.slider-container')
// Add slider to DOM
};this.element.appendChild(this.node);
this._ui.wrapper.classList.add('is-loading');
this._ui.container.style.opacity = 0;
this._transitioner = new __WEBPACK_IMPORTED_MODULE_11__components_transitioner__["a" /* default */](this);
// Wrap all items by slide element
this._slides = this._items.map(function (item, index) {
return _this2._createSlide(item, index);
});
this.reset();
this._bindEvents();
this._ui.container.style.opacity = 1;
this._ui.wrapper.classList.remove('is-loading');
}
/**
* Bind all events
* @method _bindEvents
* @return {void}
*/
}, {
key: '_bindEvents',
value: function _bindEvents() {
this.on('show', this.onShow);
}
}, {
key: '_unbindEvents',
value: function _unbindEvents() {
this.off('show', this.onShow);
}
}, {
key: '_createSlide',
value: function _createSlide(item, index) {
var slide = document.createRange().createContextualFragment(Object(__WEBPACK_IMPORTED_MODULE_14__templates_item__["a" /* default */])()).firstChild;
slide.dataset.sliderIndex = index;
slide.appendChild(item);
return slide;
}
/**
* Calculate slider dimensions
*/
}, {
key: '_setDimensions',
value: function _setDimensions() {
var _this3 = this;
if (!this.options.vertical) {
if (this.options.centerMode) {
this._ui.wrapper.style.padding = '0px ' + this.options.centerPadding;
}
} else {
this._ui.wrapper.style.height = Object(__WEBPACK_IMPORTED_MODULE_1__utils_css__["c" /* outerHeight */])(this._slides[0]) * this.slidesToShow;
if (this.options.centerMode) {
this._ui.wrapper.style.padding = this.options.centerPadding + ' 0px';
}
}
this._wrapperWidth = Object(__WEBPACK_IMPORTED_MODULE_1__utils_css__["e" /* width */])(this._ui.wrapper);
this._wrapperHeight = Object(__WEBPACK_IMPORTED_MODULE_1__utils_css__["c" /* outerHeight */])(this._ui.wrapper);
if (!this.options.vertical) {
this._slideWidth = Math.ceil(this._wrapperWidth / this.slidesToShow);
this._containerWidth = Math.ceil(this._slideWidth * this._slides.length);
this._ui.container.style.width = this._containerWidth + 'px';
} else {
this._slideWidth = Math.ceil(this._wrapperWidth);
this._containerHeight = Math.ceil(Object(__WEBPACK_IMPORTED_MODULE_1__utils_css__["c" /* outerHeight */])(this._slides[0]) * this._slides.length);
this._ui.container.style.height = this._containerHeight + 'px';
}
this._slides.forEach(function (slide) {
slide.style.width = _this3._slideWidth + 'px';
});
}
}, {
key: '_setHeight',
value: function _setHeight() {
if (this.options.effect !== 'translate') {
this._ui.container.style.height = Object(__WEBPACK_IMPORTED_MODULE_1__utils_css__["c" /* outerHeight */])(this._slides[this.state.index]) + 'px';
}
}
// Update slides classes
}, {
key: '_setClasses',
value: function _setClasses() {
var _this4 = this;
this._slides.forEach(function (slide) {
Object(__WEBPACK_IMPORTED_MODULE_1__utils_css__["d" /* removeClasses */])(slide, 'is-active is-current is-slide-previous is-slide-next');
if (Math.abs((_this4.state.index - 1) % _this4.state.length) === parseInt(slide.dataset.sliderIndex, 10)) {
slide.classList.add('is-slide-previous');
}
if (Math.abs(_this4.state.index % _this4.state.length) === parseInt(slide.dataset.sliderIndex, 10)) {
slide.classList.add('is-current');
}
if (Math.abs((_this4.state.index + 1) % _this4.state.length) === parseInt(slide.dataset.sliderIndex, 10)) {
slide.classList.add('is-slide-next');
}
});
}
/****************************************************
* *
* GETTERS and SETTERS *
* *
****************************************************/
/**
* Get id of current datePicker
*/
}, {
key: 'onShow',
/****************************************************
* *
* EVENTS FUNCTIONS *
* *
****************************************************/
value: function onShow(e) {
this._navigation.refresh();
this._pagination.refresh();
this._setClasses();
}
/****************************************************
* *
* PUBLIC FUNCTIONS *
* *
****************************************************/
}, {
key: 'next',
value: function next() {
if (!this.options.loop && !this.options.infinite && this.state.index + this.slidesToScroll > this.state.length - this.slidesToShow && !this.options.centerMode) {
this.state.next = this.state.index;
} else {
this.state.next = this.state.index + this.slidesToScroll;
}
this.show();
}
}, {
key: 'previous',
value: function previous() {
if (!this.options.loop && !this.options.infinite && this.state.index === 0) {
this.state.next = this.state.index;
} else {
this.state.next = this.state.index - this.slidesToScroll;
}
this.show();
}
}, {
key: 'start',
value: function start() {
this._autoplay.start();
}
}, {
key: 'pause',
value: function pause() {
this._autoplay.pause();
}
}, {
key: 'stop',
value: function stop() {
this._autoplay.stop();
}
}, {
key: 'show',
value: function show(index) {
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
// If all slides are already visible then return
if (!this.state.length || this.state.length <= this.slidesToShow) {
return;
}
if (typeof index === 'Number') {
this.state.next = index;
}
if (this.options.loop) {
this._loop.apply();
}
if (this.options.infinite) {
this._infinite.apply();
}
// If new slide is already the current one then return
if (this.state.index === this.state.next) {
return;
}
this.emit('before:show', this.state);
this._transitioner.apply(force, this._setHeight.bind(this));
this.emit('after:show', this.state);
this.emit('show', this);
}
}, {
key: 'reset',
value: function reset() {
var _this5 = this;
this.state = {
length: this._items.length,
index: Math.abs(this.options.initialSlide),
next: Math.abs(this.options.initialSlide),
prev: undefined
};
// Fix options
if (this.options.loop && this.options.infinite) {
this.options.loop = false;
}
if (this.options.slidesToScroll > this.options.slidesToShow) {
this.options.slidesToScroll = this.slidesToShow;
}
this._breakpoint.init();
if (this.state.index >= this.state.length && this.state.index !== 0) {
this.state.index = this.state.index - this.slidesToScroll;
}
if (this.state.length <= this.slidesToShow) {
this.state.index = 0;
}
this._ui.wrapper.appendChild(this._navigation.init().render());
this._ui.wrapper.appendChild(this._pagination.init().render());
if (this.options.navigationSwipe) {
this._swipe.bindEvents();
} else {
this._swipe._bindEvents();
}
this._breakpoint.apply();
// Move all created slides into slider
this._slides.forEach(function (slide) {
return _this5._ui.container.appendChild(slide);
});
this._transitioner.init().apply(true, this._setHeight.bind(this));
if (this.options.autoplay) {
this._autoplay.init().start();
}
}
/**
* Destroy Slider
* @method destroy
*/
}, {
key: 'destroy',
value: function destroy() {
var _this6 = this;
this._unbindEvents();
this._items.forEach(function (item) {
_this6.element.appendChild(item);
});
this.node.remove();
}
}, {
key: 'id',
get: function get() {
return this._id;
}
}, {
key: 'index',
set: function set(index) {
this._index = index;
},
get: function get() {
return this._index;
}
}, {
key: 'length',
set: function set(length) {
this._length = length;
},
get: function get() {
return this._length;
}
}, {
key: 'slides',
get: function get() {
return this._slides;
},
set: function set(slides) {
this._slides = slides;
}
}, {
key: 'slidesToScroll',
get: function get() {
return this.options.effect === 'translate' ? this._breakpoint.getSlidesToScroll() : 1;
}
}, {
key: 'slidesToShow',
get: function get() {
return this.options.effect === 'translate' ? this._breakpoint.getSlidesToShow() : 1;
}
}, {
key: 'direction',
get: function get() {
return this.element.dir.toLowerCase() === 'rtl' || this.element.style.direction === 'rtl' ? 'rtl' : 'ltr';
}
}, {
key: 'wrapper',
get: function get() {
return this._ui.wrapper;
}
}, {
key: 'wrapperWidth',
get: function get() {
return this._wrapperWidth || 0;
}
}, {
key: 'container',
get: function get() {
return this._ui.container;
}
}, {
key: 'containerWidth',
get: function get() {
return this._containerWidth || 0;
}
}, {
key: 'slideWidth',
get: function get() {
return this._slideWidth || 0;
}
}, {
key: 'transitioner',
get: function get() {
return this._transitioner;
}
}], [{
key: 'attach',
value: function attach() {
var _this7 = this;
var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '.slider';
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var instances = new Array();
var elements = Object(__WEBPACK_IMPORTED_MODULE_2__utils_type__["c" /* isString */])(selector) ? document.querySelectorAll(selector) : Array.isArray(selector) ? selector : [selector];
[].forEach.call(elements, function (element) {
if (typeof element[_this7.constructor.name] === 'undefined') {
var instance = new bulmaCarousel(element, options);
element[_this7.constructor.name] = instance;
instances.push(instance);
} else {
instances.push(element[_this7.constructor.name]);
}
});
return instances;
}
}]);
return bulmaCarousel;
}(__WEBPACK_IMPORTED_MODULE_3__utils_eventEmitter__["a" /* default */]);
/* harmony default export */ __webpack_exports__["default"] = (bulmaCarousel);
/***/ }),
/* 6 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return uuid; });
/* unused harmony export isRtl */
/* unused harmony export defer */
/* unused harmony export getNodeIndex */
/* unused harmony export camelize */
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var uuid = function uuid() {
var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
return prefix + ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
});
};
var isRtl = function isRtl() {
return document.documentElement.getAttribute('dir') === 'rtl';
};
var defer = function defer() {
this.promise = new Promise(function (resolve, reject) {
this.resolve = resolve;
this.reject = reject;
}.bind(this));
this.then = this.promise.then.bind(this.promise);
this.catch = this.promise.catch.bind(this.promise);
};
var getNodeIndex = function getNodeIndex(node) {
return [].concat(_toConsumableArray(node.parentNode.children)).indexOf(node);
};
var camelize = function camelize(str) {
return str.replace(/-(\w)/g, toUpper);
};
/***/ }),
/* 7 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils_eventEmitter__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils_device__ = __webpack_require__(8);
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; }; }();
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 onVisibilityChange = Symbol('onVisibilityChange');
var onMouseEnter = Symbol('onMouseEnter');
var onMouseLeave = Symbol('onMouseLeave');
var defaultOptions = {
autoplay: false,
autoplaySpeed: 3000
};
var Autoplay = function (_EventEmitter) {
_inherits(Autoplay, _EventEmitter);
function Autoplay(slider) {
_classCallCheck(this, Autoplay);
var _this = _possibleConstructorReturn(this, (Autoplay.__proto__ || Object.getPrototypeOf(Autoplay)).call(this));
_this.slider = slider;
_this.onVisibilityChange = _this.onVisibilityChange.bind(_this);
_this.onMouseEnter = _this.onMouseEnter.bind(_this);
_this.onMouseLeave = _this.onMouseLeave.bind(_this);
return _this;
}
_createClass(Autoplay, [{
key: 'init',
value: function init() {
this._bindEvents();
return this;
}
}, {
key: '_bindEvents',
value: function _bindEvents() {
document.addEventListener('visibilitychange', this.onVisibilityChange);
if (this.slider.options.pauseOnHover) {
this.slider.container.addEventListener(__WEBPACK_IMPORTED_MODULE_1__utils_device__["a" /* pointerEnter */], this.onMouseEnter);
this.slider.container.addEventListener(__WEBPACK_IMPORTED_MODULE_1__utils_device__["b" /* pointerLeave */], this.onMouseLeave);
}
}
}, {
key: '_unbindEvents',
value: function _unbindEvents() {
document.removeEventListener('visibilitychange', this.onVisibilityChange);
this.slider.container.removeEventListener(__WEBPACK_IMPORTED_MODULE_1__utils_device__["a" /* pointerEnter */], this.onMouseEnter);
this.slider.container.removeEventListener(__WEBPACK_IMPORTED_MODULE_1__utils_device__["b" /* pointerLeave */], this.onMouseLeave);
}
}, {
key: 'start',
value: function start() {
var _this2 = this;
this.stop();
if (this.slider.options.autoplay) {
this.emit('start', this);
this._interval = setInterval(function () {
if (!(_this2._hovering && _this2.slider.options.pauseOnHover)) {
if (!_this2.slider.options.centerMode && _this2.slider.state.next >= _this2.slider.state.length - _this2.slider.slidesToShow && !_this2.slider.options.loop && !_this2.slider.options.infinite) {
_this2.stop();
} else {
_this2.slider.next();
}
}
}, this.slider.options.autoplaySpeed);
}
}
}, {
key: 'stop',
value: function stop() {
this._interval = clearInterval(this._interval);
this.emit('stop', this);
}
}, {
key: 'pause',
value: function pause() {
var _this3 = this;
var speed = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
if (this.paused) {
return;
}
if (this.timer) {
this.stop();
}
this.paused = true;
if (speed === 0) {
this.paused = false;
this.start();
} else {
this.slider.on('transition:end', function () {
if (!_this3) {
return;
}
_this3.paused = false;
if (!_this3.run) {
_this3.stop();
} else {
_this3.start();
}
});
}
}
}, {
key: 'onVisibilityChange',
value: function onVisibilityChange(e) {
if (document.hidden) {
this.stop();
} else {
this.start();
}
}
}, {
key: 'onMouseEnter',
value: function onMouseEnter(e) {
this._hovering = true;
if (this.slider.options.pauseOnHover) {
this.pause();
}
}
}, {
key: 'onMouseLeave',
value: function onMouseLeave(e) {
this._hovering = false;
if (this.slider.options.pauseOnHover) {
this.pause();
}
}
}]);
return Autoplay;
}(__WEBPACK_IMPORTED_MODULE_0__utils_eventEmitter__["a" /* default */]);
/* harmony default export */ __webpack_exports__["a"] = (Autoplay);
/***/ }),
/* 8 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export isIE */
/* unused harmony export isIETouch */
/* unused harmony export isAndroid */
/* unused harmony export isiPad */
/* unused harmony export isiPod */
/* unused harmony export isiPhone */
/* unused harmony export isSafari */
/* unused harmony export isUiWebView */
/* unused harmony export supportsTouchEvents */
/* unused harmony export supportsPointerEvents */
/* unused harmony export supportsTouch */
/* unused harmony export pointerDown */
/* unused harmony export pointerMove */
/* unused harmony export pointerUp */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return pointerEnter; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return pointerLeave; });
var isIE = window.navigator.pointerEnabled || window.navigator.msPointerEnabled;
var isIETouch = window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints > 1 || window.navigator.pointerEnabled && window.navigator.maxTouchPoints > 1;
var isAndroid = navigator.userAgent.match(/(Android);?[\s\/]+([\d.]+)?/);
var isiPad = navigator.userAgent.match(/(iPad).*OS\s([\d_]+)/);
var isiPod = navigator.userAgent.match(/(iPod)(.*OS\s([\d_]+))?/);
var isiPhone = !navigator.userAgent.match(/(iPad).*OS\s([\d_]+)/) && navigator.userAgent.match(/(iPhone\sOS)\s([\d_]+)/);
var isSafari = navigator.userAgent.toLowerCase().indexOf('safari') >= 0 && navigator.userAgent.toLowerCase().indexOf('chrome') < 0 && navigator.userAgent.toLowerCase().indexOf('android') < 0;
var isUiWebView = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent);
var supportsTouchEvents = !!('ontouchstart' in window);
var supportsPointerEvents = !!('PointerEvent' in window);
var supportsTouch = supportsTouchEvents || window.DocumentTouch && document instanceof DocumentTouch || navigator.maxTouchPoints; // IE >=11
var pointerDown = !supportsTouch ? 'mousedown' : 'mousedown ' + (supportsTouchEvents ? 'touchstart' : 'pointerdown');
var pointerMove = !supportsTouch ? 'mousemove' : 'mousemove ' + (supportsTouchEvents ? 'touchmove' : 'pointermove');
var pointerUp = !supportsTouch ? 'mouseup' : 'mouseup ' + (supportsTouchEvents ? 'touchend' : 'pointerup');
var pointerEnter = supportsTouch && supportsPointerEvents ? 'pointerenter' : 'mouseenter';
var pointerLeave = supportsTouch && supportsPointerEvents ? 'pointerleave' : 'mouseleave';
/***/ }),
/* 9 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var onResize = Symbol('onResize');
var Breakpoints = function () {
function Breakpoints(slider) {
_classCallCheck(this, Breakpoints);
this.slider = slider;
this.options = slider.options;
this[onResize] = this[onResize].bind(this);
this._bindEvents();
}
_createClass(Breakpoints, [{
key: 'init',
value: function init() {
this._defaultBreakpoint = {
slidesToShow: this.options.slidesToShow,
slidesToScroll: this.options.slidesToScroll
};
this.options.breakpoints.sort(function (a, b) {
return parseInt(a.changePoint, 10) > parseInt(b.changePoint, 10);
});
this._currentBreakpoint = this._getActiveBreakpoint();
return this;
}
}, {
key: 'destroy',
value: function destroy() {
this._unbindEvents();
}
}, {
key: '_bindEvents',
value: function _bindEvents() {
window.addEventListener('resize', this[onResize]);
window.addEventListener('orientationchange', this[onResize]);
}
}, {
key: '_unbindEvents',
value: function _unbindEvents() {
window.removeEventListener('resize', this[onResize]);
window.removeEventListener('orientationchange', this[onResize]);
}
}, {
key: '_getActiveBreakpoint',
value: function _getActiveBreakpoint() {
//Get breakpoint for window width
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = this.options.breakpoints[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var point = _step.value;
if (point.changePoint >= window.innerWidth) {
return point;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return this._defaultBreakpoint;
}
}, {
key: 'getSlidesToShow',
value: function getSlidesToShow() {
return this._currentBreakpoint ? this._currentBreakpoint.slidesToShow : this._defaultBreakpoint.slidesToShow;
}
}, {
key: 'getSlidesToScroll',
value: function getSlidesToScroll() {
return this._currentBreakpoint ? this._currentBreakpoint.slidesToScroll : this._defaultBreakpoint.slidesToScroll;
}
}, {
key: 'apply',
value: function apply() {
if (this.slider.state.index >= this.slider.state.length && this.slider.state.index !== 0) {
this.slider.state.index = this.slider.state.index - this._currentBreakpoint.slidesToScroll;
}
if (this.slider.state.length <= this._currentBreakpoint.slidesToShow) {
this.slider.state.index = 0;
}
if (this.options.loop) {
this.slider._loop.init().apply();
}
if (this.options.infinite) {
this.slider._infinite.init().apply();
}
this.slider._setDimensions();
this.slider._transitioner.init().apply(true, this.slider._setHeight.bind(this.slider));
this.slider._setClasses();
this.slider._navigation.refresh();
this.slider._pagination.refresh();
}
}, {
key: onResize,
value: function value(e) {
var newBreakPoint = this._getActiveBreakpoint();
if (newBreakPoint.slidesToShow !== this._currentBreakpoint.slidesToShow) {
this._currentBreakpoint = newBreakPoint;
this.apply();
}
}
}]);
return Breakpoints;
}();
/* harmony default export */ __webpack_exports__["a"] = (Breakpoints);
/***/ }),
/* 10 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
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; }; }();
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Infinite = function () {
function Infinite(slider) {
_classCallCheck(this, Infinite);
this.slider = slider;
}
_createClass(Infinite, [{
key: 'init',
value: function init() {
if (this.slider.options.infinite && this.slider.options.effect === 'translate') {
if (this.slider.options.centerMode) {
this._infiniteCount = Math.ceil(this.slider.slidesToShow + this.slider.slidesToShow / 2);
} else {
this._infiniteCount = this.slider.slidesToShow;
}
var frontClones = [];
var slideIndex = 0;
for (var i = this.slider.state.length; i > this.slider.state.length - 1 - this._infiniteCount; i -= 1) {
slideIndex = i - 1;
frontClones.unshift(this._cloneSlide(this.slider.slides[slideIndex], slideIndex - this.slider.state.length));
}
var backClones = [];
for (var _i = 0; _i < this._infiniteCount + this.slider.state.length; _i += 1) {
backClones.push(this._cloneSlide(this.slider.slides[_i % this.slider.state.length], _i + this.slider.state.length));
}
this.slider.slides = [].concat(frontClones, _toConsumableArray(this.slider.slides), backClones);
}
return this;
}
}, {
key: 'apply',
value: function apply() {}
}, {
key: 'onTransitionEnd',
value: function onTransitionEnd(e) {
if (this.slider.options.infinite) {
if (this.slider.state.next >= this.slider.state.length) {
this.slider.state.index = this.slider.state.next = this.slider.state.next - this.slider.state.length;
this.slider.transitioner.apply(true);
} else if (this.slider.state.next < 0) {
this.slider.state.index = this.slider.state.next = this.slider.state.length + this.slider.state.next;
this.slider.transitioner.apply(true);
}
}
}
}, {
key: '_cloneS