From 610e80a19bb2516d7fb169623fa934ea1755c0df Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 1 May 2017 15:21:02 +0200 Subject: update bs4-dev --- library/bootstrap/js/bootstrap.js | 53 ++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 9 deletions(-) (limited to 'library/bootstrap/js/bootstrap.js') diff --git a/library/bootstrap/js/bootstrap.js b/library/bootstrap/js/bootstrap.js index 4a4c966bb..865256739 100644 --- a/library/bootstrap/js/bootstrap.js +++ b/library/bootstrap/js/bootstrap.js @@ -8,16 +8,14 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.') } -+function ($) { +(function ($) { var version = $.fn.jquery.split(' ')[0].split('.') if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] >= 4)) { throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0') } -}(jQuery); - - -+function () { +})(jQuery); +(function () { 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; }; }(); @@ -551,6 +549,7 @@ var Carousel = function ($) { var TRANSITION_DURATION = 600; var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key + var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch var Default = { interval: 5000, @@ -581,6 +580,7 @@ var Carousel = function ($) { KEYDOWN: 'keydown' + EVENT_KEY, MOUSEENTER: 'mouseenter' + EVENT_KEY, MOUSELEAVE: 'mouseleave' + EVENT_KEY, + TOUCHEND: 'touchend' + EVENT_KEY, LOAD_DATA_API: 'load' + EVENT_KEY + DATA_API_KEY, CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY }; @@ -623,6 +623,8 @@ var Carousel = function ($) { this._isPaused = false; this._isSliding = false; + this.touchTimeout = null; + this._config = this._getConfig(config); this._element = $(element)[0]; this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0]; @@ -742,12 +744,30 @@ var Carousel = function ($) { }); } - if (this._config.pause === 'hover' && !('ontouchstart' in document.documentElement)) { + if (this._config.pause === 'hover') { $(this._element).on(Event.MOUSEENTER, function (event) { return _this4.pause(event); }).on(Event.MOUSELEAVE, function (event) { return _this4.cycle(event); }); + if ('ontouchstart' in document.documentElement) { + // if it's a touch-enabled device, mouseenter/leave are fired as + // part of the mouse compatibility events on first tap - the carousel + // would stop cycling until user tapped out of it; + // here, we listen for touchend, explicitly pause the carousel + // (as if it's the second time we tap on it, mouseenter compat event + // is NOT fired) and after a timeout (to allow for mouse compatibility + // events to fire) we explicitly restart cycling + $(this._element).on(Event.TOUCHEND, function () { + _this4.pause(); + if (_this4.touchTimeout) { + clearTimeout(_this4.touchTimeout); + } + _this4.touchTimeout = setTimeout(function (event) { + return _this4.cycle(event); + }, TOUCHEVENT_COMPAT_WAIT + _this4._config.interval); + }); + } } }; @@ -1463,7 +1483,7 @@ var Dropdown = function ($) { // only needed because of broken event delegation on iOS // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html if ('ontouchstart' in document.documentElement && !$(parent).closest(Selector.NAVBAR_NAV).length) { - $('body').children().on('mouseover', '*', $.noop); + $('body').children().on('mouseover', null, $.noop); } this.focus(); @@ -1537,7 +1557,7 @@ var Dropdown = function ($) { // if this is a touch-enabled device we remove the extra // empty mouseover listeners we added for iOS support if ('ontouchstart' in document.documentElement) { - $('body').children().off('mouseover', '*', $.noop); + $('body').children().off('mouseover', null, $.noop); } toggles[i].setAttribute('aria-expanded', 'false'); @@ -3041,6 +3061,14 @@ var Tooltip = function ($) { $(tip).addClass(ClassName.SHOW); + // if this is a touch-enabled device we add extra + // empty mouseover listeners to the body's immediate children; + // only needed because of broken event delegation on iOS + // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html + if ('ontouchstart' in document.documentElement) { + $('body').children().on('mouseover', null, $.noop); + } + var complete = function complete() { var prevHoverState = _this23._hoverState; _this23._hoverState = null; @@ -3089,6 +3117,12 @@ var Tooltip = function ($) { $(tip).removeClass(ClassName.SHOW); + // if this is a touch-enabled device we remove the extra + // empty mouseover listeners we added for iOS support + if ('ontouchstart' in document.documentElement) { + $('body').children().off('mouseover', null, $.noop); + } + this._activeTrigger[Trigger.CLICK] = false; this._activeTrigger[Trigger.FOCUS] = false; this._activeTrigger[Trigger.HOVER] = false; @@ -3593,4 +3627,5 @@ var Popover = function ($) { return Popover; }(jQuery); -}(); + +})() \ No newline at end of file -- cgit v1.2.3