assets/javascripts/bootstrap.js in bootstrap-4.0.0.alpha3 vs assets/javascripts/bootstrap.js in bootstrap-4.0.0.alpha3.1

- old
+ new

@@ -1,28 +1,28 @@ /*! - * Bootstrap v4.0.0-alpha.2 (http://getbootstrap.com) - * Copyright 2011-2015 Twitter, Inc. + * Bootstrap v4.0.0-alpha.3 (http://getbootstrap.com) + * Copyright 2011-2016 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) */ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery') } +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] >= 3)) { - throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v3.0.0') + 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 ($) { /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.2): util.js + * Bootstrap (v4.0.0-alpha.3): util.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ 'use strict'; @@ -43,10 +43,12 @@ * ------------------------------------------------------------------------ */ var transition = false; + var MAX_UID = 1000000; + var TransitionEndEvent = { WebkitTransition: 'webkitTransitionEnd', MozTransition: 'transitionend', OTransition: 'oTransitionEnd otransitionend', transition: 'transitionend' @@ -65,12 +67,13 @@ return { bindType: transition.end, delegateType: transition.end, handle: function handle(event) { if ($(event.target).is(this)) { - return event.handleObj.handler.apply(this, arguments); + return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params } + return undefined; } }; } function transitionEndTest() { @@ -127,11 +130,13 @@ TRANSITION_END: 'bsTransitionEnd', getUID: function getUID(prefix) { do { - prefix += ~ ~(Math.random() * 1000000); // "~~" acts like a faster Math.floor() here + /* eslint-disable no-bitwise */ + prefix += ~ ~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here + /* eslint-enable no-bitwise */ } while (document.getElementById(prefix)); return prefix; }, getSelectorFromElement: function getSelectorFromElement(element) { @@ -183,11 +188,11 @@ return Util; })(jQuery); /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.2): alert.js + * Bootstrap (v4.0.0-alpha.3): alert.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ var Alert = (function ($) { @@ -197,11 +202,11 @@ * Constants * ------------------------------------------------------------------------ */ var NAME = 'alert'; - var VERSION = '4.0.0-alpha'; + var VERSION = '4.0.0-alpha.3'; var DATA_KEY = 'bs.alert'; var EVENT_KEY = '.' + DATA_KEY; var DATA_API_KEY = '.data-api'; var JQUERY_NO_CONFLICT = $.fn[NAME]; var TRANSITION_DURATION = 150; @@ -369,11 +374,11 @@ return Alert; })(jQuery); /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.2): button.js + * Bootstrap (v4.0.0-alpha.3): button.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ var Button = (function ($) { @@ -383,11 +388,11 @@ * Constants * ------------------------------------------------------------------------ */ var NAME = 'button'; - var VERSION = '4.0.0-alpha'; + var VERSION = '4.0.0-alpha.3'; var DATA_KEY = 'bs.button'; var EVENT_KEY = '.' + DATA_KEY; var DATA_API_KEY = '.data-api'; var JQUERY_NO_CONFLICT = $.fn[NAME]; @@ -458,10 +463,12 @@ if (triggerChangeEvent) { input.checked = !$(this._element).hasClass(ClassName.ACTIVE); $(this._element).trigger('change'); } + + input.focus(); } } else { this._element.setAttribute('aria-pressed', !$(this._element).hasClass(ClassName.ACTIVE)); } @@ -535,11 +542,11 @@ return Button; })(jQuery); /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.2): carousel.js + * Bootstrap (v4.0.0-alpha.3): carousel.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ var Carousel = (function ($) { @@ -549,16 +556,18 @@ * Constants * ------------------------------------------------------------------------ */ var NAME = 'carousel'; - var VERSION = '4.0.0-alpha'; + var VERSION = '4.0.0-alpha.3'; var DATA_KEY = 'bs.carousel'; var EVENT_KEY = '.' + DATA_KEY; var DATA_API_KEY = '.data-api'; var JQUERY_NO_CONFLICT = $.fn[NAME]; 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 Default = { interval: 5000, keyboard: true, slide: false, @@ -770,14 +779,16 @@ if (/input|textarea/i.test(event.target.tagName)) { return; } switch (event.which) { - case 37: - this.prev();break; - case 39: - this.next();break; + case ARROW_LEFT_KEYCODE: + this.prev(); + break; + case ARROW_RIGHT_KEYCODE: + this.next(); + break; default: return; } } }, { @@ -1007,11 +1018,11 @@ return Carousel; })(jQuery); /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.2): collapse.js + * Bootstrap (v4.0.0-alpha.3): collapse.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ var Collapse = (function ($) { @@ -1021,11 +1032,11 @@ * Constants * ------------------------------------------------------------------------ */ var NAME = 'collapse'; - var VERSION = '4.0.0-alpha'; + var VERSION = '4.0.0-alpha.3'; var DATA_KEY = 'bs.collapse'; var EVENT_KEY = '.' + DATA_KEY; var DATA_API_KEY = '.data-api'; var JQUERY_NO_CONFLICT = $.fn[NAME]; var TRANSITION_DURATION = 600; @@ -1365,11 +1376,11 @@ return Collapse; })(jQuery); /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.2): dropdown.js + * Bootstrap (v4.0.0-alpha.3): dropdown.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ var Dropdown = (function ($) { @@ -1379,15 +1390,19 @@ * Constants * ------------------------------------------------------------------------ */ var NAME = 'dropdown'; - var VERSION = '4.0.0-alpha'; + var VERSION = '4.0.0-alpha.3'; var DATA_KEY = 'bs.dropdown'; var EVENT_KEY = '.' + DATA_KEY; var DATA_API_KEY = '.data-api'; var JQUERY_NO_CONFLICT = $.fn[NAME]; + var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key + var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key + var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key + var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse) var Event = { HIDE: 'hide' + EVENT_KEY, HIDDEN: 'hidden' + EVENT_KEY, SHOW: 'show' + EVENT_KEY, @@ -1518,11 +1533,11 @@ }); } }, { key: '_clearMenus', value: function _clearMenus(event) { - if (event && event.which === 3) { + if (event && event.which === RIGHT_MOUSE_BUTTON_WHICH) { return; } var backdrop = $(Selector.BACKDROP)[0]; if (backdrop) { @@ -1581,13 +1596,13 @@ } var parent = Dropdown._getParentFromElement(this); var isActive = $(parent).hasClass(ClassName.OPEN); - if (!isActive && event.which !== 27 || isActive && event.which === 27) { + if (!isActive && event.which !== ESCAPE_KEYCODE || isActive && event.which === ESCAPE_KEYCODE) { - if (event.which === 27) { + if (event.which === ESCAPE_KEYCODE) { var toggle = $(parent).find(Selector.DATA_TOGGLE)[0]; $(toggle).trigger('focus'); } $(this).trigger('click'); @@ -1604,21 +1619,21 @@ return; } var index = items.indexOf(event.target); - if (event.which === 38 && index > 0) { + if (event.which === ARROW_UP_KEYCODE && index > 0) { // up index--; } - if (event.which === 40 && index < items.length - 1) { + if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { // down index++; } - if (! ~index) { + if (index < 0) { index = 0; } items[index].focus(); } @@ -1652,11 +1667,11 @@ return Dropdown; })(jQuery); /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.2): modal.js + * Bootstrap (v4.0.0-alpha.3): modal.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ var Modal = (function ($) { @@ -1666,17 +1681,18 @@ * Constants * ------------------------------------------------------------------------ */ var NAME = 'modal'; - var VERSION = '4.0.0-alpha'; + var VERSION = '4.0.0-alpha.3'; var DATA_KEY = 'bs.modal'; var EVENT_KEY = '.' + DATA_KEY; var DATA_API_KEY = '.data-api'; var JQUERY_NO_CONFLICT = $.fn[NAME]; var TRANSITION_DURATION = 300; var BACKDROP_TRANSITION_DURATION = 150; + var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key var Default = { backdrop: true, keyboard: true, focus: true, @@ -1868,10 +1884,11 @@ // don't move modals dom position document.body.appendChild(this._element); } this._element.style.display = 'block'; + this._element.removeAttribute('aria-hidden'); this._element.scrollTop = 0; if (transition) { Util.reflow(this._element); } @@ -1904,11 +1921,11 @@ value: function _enforceFocus() { var _this9 = this; $(document).off(Event.FOCUSIN) // guard against infinite focus loop .on(Event.FOCUSIN, function (event) { - if (_this9._element !== event.target && !$(_this9._element).has(event.target).length) { + if (document !== event.target && _this9._element !== event.target && !$(_this9._element).has(event.target).length) { _this9._element.focus(); } }); } }, { @@ -1916,11 +1933,11 @@ value: function _setEscapeEvent() { var _this10 = this; if (this._isShown && this._config.keyboard) { $(this._element).on(Event.KEYDOWN_DISMISS, function (event) { - if (event.which === 27) { + if (event.which === ESCAPE_KEYCODE) { _this10.hide(); } }); } else if (!this._isShown) { $(this._element).off(Event.KEYDOWN_DISMISS); @@ -1939,10 +1956,11 @@ key: '_hideModal', value: function _hideModal() { var _this11 = this; this._element.style.display = 'none'; + this._element.setAttribute('aria-hidden', 'true'); this._showBackdrop(function () { $(document.body).removeClass(ClassName.OPEN); _this11._resetAdjustments(); _this11._resetScrollbar(); $(_this11._element).trigger(Event.HIDDEN); @@ -2044,11 +2062,11 @@ if (!this._isBodyOverflowing && isModalOverflowing) { this._element.style.paddingLeft = this._scrollbarWidth + 'px'; } if (this._isBodyOverflowing && !isModalOverflowing) { - this._element.style.paddingRight = this._scrollbarWidth + 'px~'; + this._element.style.paddingRight = this._scrollbarWidth + 'px'; } } }, { key: '_resetAdjustments', value: function _resetAdjustments() { @@ -2056,17 +2074,11 @@ this._element.style.paddingRight = ''; } }, { key: '_checkScrollbar', value: function _checkScrollbar() { - var fullWindowWidth = window.innerWidth; - if (!fullWindowWidth) { - // workaround for missing window.innerWidth in IE8 - var documentElementRect = document.documentElement.getBoundingClientRect(); - fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left); - } - this._isBodyOverflowing = document.body.clientWidth < fullWindowWidth; + this._isBodyOverflowing = document.body.clientWidth < window.innerWidth; this._scrollbarWidth = this._getScrollbarWidth(); } }, { key: '_setScrollbar', value: function _setScrollbar() { @@ -2182,11 +2194,11 @@ return Modal; })(jQuery); /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.2): scrollspy.js + * Bootstrap (v4.0.0-alpha.3): scrollspy.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ var ScrollSpy = (function ($) { @@ -2196,11 +2208,11 @@ * Constants * ------------------------------------------------------------------------ */ var NAME = 'scrollspy'; - var VERSION = '4.0.0-alpha'; + var VERSION = '4.0.0-alpha.3'; var DATA_KEY = 'bs.scrollspy'; var EVENT_KEY = '.' + DATA_KEY; var DATA_API_KEY = '.data-api'; var JQUERY_NO_CONFLICT = $.fn[NAME]; @@ -2311,10 +2323,11 @@ if (target && (target.offsetWidth || target.offsetHeight)) { // todo (fat): remove sketch reliance on jQuery position/offset return [$(target)[offsetMethod]().top + offsetBase, targetSelector]; } + return null; }).filter(function (item) { return item; }).sort(function (a, b) { return a[0] - b[0]; }).forEach(function (item) { @@ -2417,11 +2430,11 @@ if ($link.hasClass(ClassName.DROPDOWN_ITEM)) { $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE); $link.addClass(ClassName.ACTIVE); } else { - // todo (fat) this is kinda sus… + // todo (fat) this is kinda sus... // recursively add actives to tested nav-links $link.parents(Selector.LI).find(Selector.NAV_LINKS).addClass(ClassName.ACTIVE); } $(this._scrollElement).trigger(Event.ACTIVATE, { @@ -2496,11 +2509,11 @@ return ScrollSpy; })(jQuery); /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.2): tab.js + * Bootstrap (v4.0.0-alpha.3): tab.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ var Tab = (function ($) { @@ -2510,11 +2523,11 @@ * Constants * ------------------------------------------------------------------------ */ var NAME = 'tab'; - var VERSION = '4.0.0-alpha'; + var VERSION = '4.0.0-alpha.3'; var DATA_KEY = 'bs.tab'; var EVENT_KEY = '.' + DATA_KEY; var DATA_API_KEY = '.data-api'; var JQUERY_NO_CONFLICT = $.fn[NAME]; var TRANSITION_DURATION = 150; @@ -2755,11 +2768,11 @@ /* global Tether */ /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.2): tooltip.js + * Bootstrap (v4.0.0-alpha.3): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ var Tooltip = (function ($) { @@ -2777,11 +2790,11 @@ * Constants * ------------------------------------------------------------------------ */ var NAME = 'tooltip'; - var VERSION = '4.0.0-alpha'; + var VERSION = '4.0.0-alpha.3'; var DATA_KEY = 'bs.tooltip'; var EVENT_KEY = '.' + DATA_KEY; var JQUERY_NO_CONFLICT = $.fn[NAME]; var TRANSITION_DURATION = 150; var CLASS_PREFIX = 'bs-tether'; @@ -3366,11 +3379,11 @@ return Tooltip; })(jQuery); /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.2): popover.js + * Bootstrap (v4.0.0-alpha.3): popover.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ var Popover = (function ($) { @@ -3380,10 +3393,10 @@ * Constants * ------------------------------------------------------------------------ */ var NAME = 'popover'; - var VERSION = '4.0.0-alpha'; + var VERSION = '4.0.0-alpha.3'; var DATA_KEY = 'bs.popover'; var EVENT_KEY = '.' + DATA_KEY; var JQUERY_NO_CONFLICT = $.fn[NAME]; var Default = $.extend({}, Tooltip.Default, {