Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap-rubygem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/bootstrap/carousel.js')
-rw-r--r--assets/javascripts/bootstrap/carousel.js520
1 files changed, 250 insertions, 270 deletions
diff --git a/assets/javascripts/bootstrap/carousel.js b/assets/javascripts/bootstrap/carousel.js
index 8bacf79..cfe5ce3 100644
--- a/assets/javascripts/bootstrap/carousel.js
+++ b/assets/javascripts/bootstrap/carousel.js
@@ -1,17 +1,17 @@
-'use strict';
+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 _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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.4): carousel.js
+ * Bootstrap (v4.0.0-alpha.5): carousel.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
-var Carousel = (function ($) {
+var Carousel = function ($) {
/**
* ------------------------------------------------------------------------
@@ -20,7 +20,7 @@ var Carousel = (function ($) {
*/
var NAME = 'carousel';
- var VERSION = '4.0.0-alpha.4';
+ var VERSION = '4.0.0-alpha.5';
var DATA_KEY = 'bs.carousel';
var EVENT_KEY = '.' + DATA_KEY;
var DATA_API_KEY = '.data-api';
@@ -85,7 +85,7 @@ var Carousel = (function ($) {
* ------------------------------------------------------------------------
*/
- var Carousel = (function () {
+ var Carousel = function () {
function Carousel(element, config) {
_classCallCheck(this, Carousel);
@@ -103,344 +103,318 @@ var Carousel = (function ($) {
this._addEventListeners();
}
- /**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
- */
-
// getters
- _createClass(Carousel, [{
- key: 'next',
+ // public
- // public
+ Carousel.prototype.next = function next() {
+ if (!this._isSliding) {
+ this._slide(Direction.NEXT);
+ }
+ };
- value: function next() {
- if (!this._isSliding) {
- this._slide(Direction.NEXT);
- }
+ Carousel.prototype.nextWhenVisible = function nextWhenVisible() {
+ // Don't call next when the page isn't visible
+ if (!document.hidden) {
+ this.next();
}
- }, {
- key: 'nextWhenVisible',
- value: function nextWhenVisible() {
- // Don't call next when the page isn't visible
- if (!document.hidden) {
- this.next();
- }
+ };
+
+ Carousel.prototype.prev = function prev() {
+ if (!this._isSliding) {
+ this._slide(Direction.PREVIOUS);
}
- }, {
- key: 'prev',
- value: function prev() {
- if (!this._isSliding) {
- this._slide(Direction.PREVIOUS);
- }
+ };
+
+ Carousel.prototype.pause = function pause(event) {
+ if (!event) {
+ this._isPaused = true;
}
- }, {
- key: 'pause',
- value: function pause(event) {
- if (!event) {
- this._isPaused = true;
- }
- if ($(this._element).find(Selector.NEXT_PREV)[0] && Util.supportsTransitionEnd()) {
- Util.triggerTransitionEnd(this._element);
- this.cycle(true);
- }
+ if ($(this._element).find(Selector.NEXT_PREV)[0] && Util.supportsTransitionEnd()) {
+ Util.triggerTransitionEnd(this._element);
+ this.cycle(true);
+ }
+ clearInterval(this._interval);
+ this._interval = null;
+ };
+
+ Carousel.prototype.cycle = function cycle(event) {
+ if (!event) {
+ this._isPaused = false;
+ }
+
+ if (this._interval) {
clearInterval(this._interval);
this._interval = null;
}
- }, {
- key: 'cycle',
- value: function cycle(event) {
- if (!event) {
- this._isPaused = false;
- }
- if (this._interval) {
- clearInterval(this._interval);
- this._interval = null;
- }
+ if (this._config.interval && !this._isPaused) {
+ this._interval = setInterval($.proxy(document.visibilityState ? this.nextWhenVisible : this.next, this), this._config.interval);
+ }
+ };
- if (this._config.interval && !this._isPaused) {
- this._interval = setInterval($.proxy(document.visibilityState ? this.nextWhenVisible : this.next, this), this._config.interval);
- }
+ Carousel.prototype.to = function to(index) {
+ var _this = this;
+
+ this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
+
+ var activeIndex = this._getItemIndex(this._activeElement);
+
+ if (index > this._items.length - 1 || index < 0) {
+ return;
}
- }, {
- key: 'to',
- value: function to(index) {
- var _this = this;
- this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
+ if (this._isSliding) {
+ $(this._element).one(Event.SLID, function () {
+ return _this.to(index);
+ });
+ return;
+ }
- var activeIndex = this._getItemIndex(this._activeElement);
+ if (activeIndex === index) {
+ this.pause();
+ this.cycle();
+ return;
+ }
- if (index > this._items.length - 1 || index < 0) {
- return;
- }
+ var direction = index > activeIndex ? Direction.NEXT : Direction.PREVIOUS;
- if (this._isSliding) {
- $(this._element).one(Event.SLID, function () {
- return _this.to(index);
- });
- return;
- }
+ this._slide(direction, this._items[index]);
+ };
- if (activeIndex === index) {
- this.pause();
- this.cycle();
- return;
- }
+ Carousel.prototype.dispose = function dispose() {
+ $(this._element).off(EVENT_KEY);
+ $.removeData(this._element, DATA_KEY);
- var direction = index > activeIndex ? Direction.NEXT : Direction.PREVIOUS;
+ this._items = null;
+ this._config = null;
+ this._element = null;
+ this._interval = null;
+ this._isPaused = null;
+ this._isSliding = null;
+ this._activeElement = null;
+ this._indicatorsElement = null;
+ };
- this._slide(direction, this._items[index]);
- }
- }, {
- key: 'dispose',
- value: function dispose() {
- $(this._element).off(EVENT_KEY);
- $.removeData(this._element, DATA_KEY);
-
- this._items = null;
- this._config = null;
- this._element = null;
- this._interval = null;
- this._isPaused = null;
- this._isSliding = null;
- this._activeElement = null;
- this._indicatorsElement = null;
- }
+ // private
- // private
+ Carousel.prototype._getConfig = function _getConfig(config) {
+ config = $.extend({}, Default, config);
+ Util.typeCheckConfig(NAME, config, DefaultType);
+ return config;
+ };
- }, {
- key: '_getConfig',
- value: function _getConfig(config) {
- config = $.extend({}, Default, config);
- Util.typeCheckConfig(NAME, config, DefaultType);
- return config;
+ Carousel.prototype._addEventListeners = function _addEventListeners() {
+ if (this._config.keyboard) {
+ $(this._element).on(Event.KEYDOWN, $.proxy(this._keydown, this));
}
- }, {
- key: '_addEventListeners',
- value: function _addEventListeners() {
- if (this._config.keyboard) {
- $(this._element).on(Event.KEYDOWN, $.proxy(this._keydown, this));
- }
- if (this._config.pause === 'hover' && !('ontouchstart' in document.documentElement)) {
- $(this._element).on(Event.MOUSEENTER, $.proxy(this.pause, this)).on(Event.MOUSELEAVE, $.proxy(this.cycle, this));
- }
+ if (this._config.pause === 'hover' && !('ontouchstart' in document.documentElement)) {
+ $(this._element).on(Event.MOUSEENTER, $.proxy(this.pause, this)).on(Event.MOUSELEAVE, $.proxy(this.cycle, this));
}
- }, {
- key: '_keydown',
- value: function _keydown(event) {
- event.preventDefault();
+ };
- if (/input|textarea/i.test(event.target.tagName)) {
- return;
- }
+ Carousel.prototype._keydown = function _keydown(event) {
+ event.preventDefault();
- switch (event.which) {
- case ARROW_LEFT_KEYCODE:
- this.prev();
- break;
- case ARROW_RIGHT_KEYCODE:
- this.next();
- break;
- default:
- return;
- }
+ if (/input|textarea/i.test(event.target.tagName)) {
+ return;
}
- }, {
- key: '_getItemIndex',
- value: function _getItemIndex(element) {
- this._items = $.makeArray($(element).parent().find(Selector.ITEM));
- return this._items.indexOf(element);
+
+ switch (event.which) {
+ case ARROW_LEFT_KEYCODE:
+ this.prev();
+ break;
+ case ARROW_RIGHT_KEYCODE:
+ this.next();
+ break;
+ default:
+ return;
+ }
+ };
+
+ Carousel.prototype._getItemIndex = function _getItemIndex(element) {
+ this._items = $.makeArray($(element).parent().find(Selector.ITEM));
+ return this._items.indexOf(element);
+ };
+
+ Carousel.prototype._getItemByDirection = function _getItemByDirection(direction, activeElement) {
+ var isNextDirection = direction === Direction.NEXT;
+ var isPrevDirection = direction === Direction.PREVIOUS;
+ var activeIndex = this._getItemIndex(activeElement);
+ var lastItemIndex = this._items.length - 1;
+ var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
+
+ if (isGoingToWrap && !this._config.wrap) {
+ return activeElement;
}
- }, {
- key: '_getItemByDirection',
- value: function _getItemByDirection(direction, activeElement) {
- var isNextDirection = direction === Direction.NEXT;
- var isPrevDirection = direction === Direction.PREVIOUS;
- var activeIndex = this._getItemIndex(activeElement);
- var lastItemIndex = this._items.length - 1;
- var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
-
- if (isGoingToWrap && !this._config.wrap) {
- return activeElement;
- }
- var delta = direction === Direction.PREVIOUS ? -1 : 1;
- var itemIndex = (activeIndex + delta) % this._items.length;
+ var delta = direction === Direction.PREVIOUS ? -1 : 1;
+ var itemIndex = (activeIndex + delta) % this._items.length;
- return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
- }
- }, {
- key: '_triggerSlideEvent',
- value: function _triggerSlideEvent(relatedTarget, directionalClassname) {
- var slideEvent = $.Event(Event.SLIDE, {
- relatedTarget: relatedTarget,
- direction: directionalClassname
- });
+ return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
+ };
- $(this._element).trigger(slideEvent);
+ Carousel.prototype._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, directionalClassname) {
+ var slideEvent = $.Event(Event.SLIDE, {
+ relatedTarget: relatedTarget,
+ direction: directionalClassname
+ });
- return slideEvent;
- }
- }, {
- key: '_setActiveIndicatorElement',
- value: function _setActiveIndicatorElement(element) {
- if (this._indicatorsElement) {
- $(this._indicatorsElement).find(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
+ $(this._element).trigger(slideEvent);
- var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
+ return slideEvent;
+ };
- if (nextIndicator) {
- $(nextIndicator).addClass(ClassName.ACTIVE);
- }
+ Carousel.prototype._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
+ if (this._indicatorsElement) {
+ $(this._indicatorsElement).find(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
+
+ var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
+
+ if (nextIndicator) {
+ $(nextIndicator).addClass(ClassName.ACTIVE);
}
}
- }, {
- key: '_slide',
- value: function _slide(direction, element) {
- var _this2 = this;
+ };
- var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
- var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
+ Carousel.prototype._slide = function _slide(direction, element) {
+ var _this2 = this;
- var isCycling = Boolean(this._interval);
+ var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
+ var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
- var directionalClassName = direction === Direction.NEXT ? ClassName.LEFT : ClassName.RIGHT;
+ var isCycling = Boolean(this._interval);
- if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
- this._isSliding = false;
- return;
- }
+ var directionalClassName = direction === Direction.NEXT ? ClassName.LEFT : ClassName.RIGHT;
- var slideEvent = this._triggerSlideEvent(nextElement, directionalClassName);
- if (slideEvent.isDefaultPrevented()) {
- return;
- }
+ if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) {
+ this._isSliding = false;
+ return;
+ }
- if (!activeElement || !nextElement) {
- // some weirdness is happening, so we bail
- return;
- }
+ var slideEvent = this._triggerSlideEvent(nextElement, directionalClassName);
+ if (slideEvent.isDefaultPrevented()) {
+ return;
+ }
- this._isSliding = true;
+ if (!activeElement || !nextElement) {
+ // some weirdness is happening, so we bail
+ return;
+ }
- if (isCycling) {
- this.pause();
- }
+ this._isSliding = true;
- this._setActiveIndicatorElement(nextElement);
+ if (isCycling) {
+ this.pause();
+ }
- var slidEvent = $.Event(Event.SLID, {
- relatedTarget: nextElement,
- direction: directionalClassName
- });
+ this._setActiveIndicatorElement(nextElement);
- if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) {
+ var slidEvent = $.Event(Event.SLID, {
+ relatedTarget: nextElement,
+ direction: directionalClassName
+ });
- $(nextElement).addClass(direction);
+ if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) {
- Util.reflow(nextElement);
+ $(nextElement).addClass(direction);
- $(activeElement).addClass(directionalClassName);
- $(nextElement).addClass(directionalClassName);
+ Util.reflow(nextElement);
- $(activeElement).one(Util.TRANSITION_END, function () {
- $(nextElement).removeClass(directionalClassName).removeClass(direction);
+ $(activeElement).addClass(directionalClassName);
+ $(nextElement).addClass(directionalClassName);
- $(nextElement).addClass(ClassName.ACTIVE);
+ $(activeElement).one(Util.TRANSITION_END, function () {
+ $(nextElement).removeClass(directionalClassName).removeClass(direction);
- $(activeElement).removeClass(ClassName.ACTIVE).removeClass(direction).removeClass(directionalClassName);
+ $(nextElement).addClass(ClassName.ACTIVE);
- _this2._isSliding = false;
+ $(activeElement).removeClass(ClassName.ACTIVE).removeClass(direction).removeClass(directionalClassName);
- setTimeout(function () {
- return $(_this2._element).trigger(slidEvent);
- }, 0);
- }).emulateTransitionEnd(TRANSITION_DURATION);
- } else {
- $(activeElement).removeClass(ClassName.ACTIVE);
- $(nextElement).addClass(ClassName.ACTIVE);
+ _this2._isSliding = false;
- this._isSliding = false;
- $(this._element).trigger(slidEvent);
- }
+ setTimeout(function () {
+ return $(_this2._element).trigger(slidEvent);
+ }, 0);
+ }).emulateTransitionEnd(TRANSITION_DURATION);
+ } else {
+ $(activeElement).removeClass(ClassName.ACTIVE);
+ $(nextElement).addClass(ClassName.ACTIVE);
- if (isCycling) {
- this.cycle();
- }
+ this._isSliding = false;
+ $(this._element).trigger(slidEvent);
}
- // static
+ if (isCycling) {
+ this.cycle();
+ }
+ };
- }], [{
- key: '_jQueryInterface',
- value: function _jQueryInterface(config) {
- return this.each(function () {
- var data = $(this).data(DATA_KEY);
- var _config = $.extend({}, Default, $(this).data());
+ // static
- if (typeof config === 'object') {
- $.extend(_config, config);
- }
+ Carousel._jQueryInterface = function _jQueryInterface(config) {
+ return this.each(function () {
+ var data = $(this).data(DATA_KEY);
+ var _config = $.extend({}, Default, $(this).data());
- var action = typeof config === 'string' ? config : _config.slide;
+ if ((typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object') {
+ $.extend(_config, config);
+ }
- if (!data) {
- data = new Carousel(this, _config);
- $(this).data(DATA_KEY, data);
- }
+ var action = typeof config === 'string' ? config : _config.slide;
- if (typeof config === 'number') {
- data.to(config);
- } else if (typeof action === 'string') {
- if (data[action] === undefined) {
- throw new Error('No method named "' + action + '"');
- }
- data[action]();
- } else if (_config.interval) {
- data.pause();
- data.cycle();
- }
- });
- }
- }, {
- key: '_dataApiClickHandler',
- value: function _dataApiClickHandler(event) {
- var selector = Util.getSelectorFromElement(this);
+ if (!data) {
+ data = new Carousel(this, _config);
+ $(this).data(DATA_KEY, data);
+ }
- if (!selector) {
- return;
+ if (typeof config === 'number') {
+ data.to(config);
+ } else if (typeof action === 'string') {
+ if (data[action] === undefined) {
+ throw new Error('No method named "' + action + '"');
+ }
+ data[action]();
+ } else if (_config.interval) {
+ data.pause();
+ data.cycle();
}
+ });
+ };
- var target = $(selector)[0];
+ Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
+ var selector = Util.getSelectorFromElement(this);
- if (!target || !$(target).hasClass(ClassName.CAROUSEL)) {
- return;
- }
+ if (!selector) {
+ return;
+ }
- var config = $.extend({}, $(target).data(), $(this).data());
- var slideIndex = this.getAttribute('data-slide-to');
+ var target = $(selector)[0];
- if (slideIndex) {
- config.interval = false;
- }
+ if (!target || !$(target).hasClass(ClassName.CAROUSEL)) {
+ return;
+ }
- Carousel._jQueryInterface.call($(target), config);
+ var config = $.extend({}, $(target).data(), $(this).data());
+ var slideIndex = this.getAttribute('data-slide-to');
- if (slideIndex) {
- $(target).data(DATA_KEY).to(slideIndex);
- }
+ if (slideIndex) {
+ config.interval = false;
+ }
- event.preventDefault();
+ Carousel._jQueryInterface.call($(target), config);
+
+ if (slideIndex) {
+ $(target).data(DATA_KEY).to(slideIndex);
}
- }, {
+
+ event.preventDefault();
+ };
+
+ _createClass(Carousel, null, [{
key: 'VERSION',
get: function get() {
return VERSION;
@@ -453,7 +427,13 @@ var Carousel = (function ($) {
}]);
return Carousel;
- })();
+ }();
+
+ /**
+ * ------------------------------------------------------------------------
+ * Data Api implementation
+ * ------------------------------------------------------------------------
+ */
$(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler);
@@ -478,4 +458,4 @@ var Carousel = (function ($) {
};
return Carousel;
-})(jQuery);
+}(jQuery);