From eb2e1a606e2c3324e7c511ba07c5ba0195801b00 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Mon, 11 Sep 2017 15:23:33 +0100 Subject: rake update[v4-dev] --- assets/javascripts/bootstrap-sprockets.js | 12 +- assets/javascripts/bootstrap.js | 2494 ++++++++++---------- assets/javascripts/bootstrap.min.js | 10 +- assets/javascripts/bootstrap/alert.js | 168 +- assets/javascripts/bootstrap/button.js | 122 +- assets/javascripts/bootstrap/carousel.js | 597 ++--- assets/javascripts/bootstrap/collapse.js | 358 +-- assets/javascripts/bootstrap/dropdown.js | 457 ++-- assets/javascripts/bootstrap/modal.js | 696 +++--- assets/javascripts/bootstrap/popover.js | 130 +- assets/javascripts/bootstrap/scrollspy.js | 313 +-- assets/javascripts/bootstrap/tab.js | 257 +- assets/javascripts/bootstrap/tooltip.js | 798 ++++--- assets/javascripts/bootstrap/util.js | 17 +- assets/stylesheets/bootstrap/_breadcrumb.scss | 5 +- assets/stylesheets/bootstrap/_forms.scss | 1 + assets/stylesheets/bootstrap/mixins/_buttons.scss | 2 +- .../stylesheets/bootstrap/utilities/_borders.scss | 4 +- 18 files changed, 3356 insertions(+), 3085 deletions(-) (limited to 'assets') diff --git a/assets/javascripts/bootstrap-sprockets.js b/assets/javascripts/bootstrap-sprockets.js index bb12c99..92f1afc 100644 --- a/assets/javascripts/bootstrap-sprockets.js +++ b/assets/javascripts/bootstrap-sprockets.js @@ -1,11 +1,11 @@ +//= require ./bootstrap/button //= require ./bootstrap/util +//= require ./bootstrap/dropdown //= require ./bootstrap/alert -//= require ./bootstrap/button -//= require ./bootstrap/carousel //= require ./bootstrap/collapse -//= require ./bootstrap/dropdown -//= require ./bootstrap/modal +//= require ./bootstrap/tab +//= require ./bootstrap/scrollspy //= require ./bootstrap/tooltip //= require ./bootstrap/popover -//= require ./bootstrap/scrollspy -//= require ./bootstrap/tab +//= require ./bootstrap/modal +//= require ./bootstrap/carousel diff --git a/assets/javascripts/bootstrap.js b/assets/javascripts/bootstrap.js index c2fbb79..c0579e2 100644 --- a/assets/javascripts/bootstrap.js +++ b/assets/javascripts/bootstrap.js @@ -1,30 +1,14 @@ /*! - * Bootstrap v4.0.0-beta (https://getbootstrap.com) - * Copyright 2011-2017 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. jQuery must be included before Bootstrap\'s JavaScript.') -} - -(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 () { -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; }; + * Bootstrap v4.0.0-beta (https://getbootstrap.com) + * Copyright 2011-2017 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + +var bootstrap = (function (exports,$,Popper) { +'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 _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; } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } +$ = $ && $.hasOwnProperty('default') ? $['default'] : $; +Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper; /** * -------------------------------------------------------------------------- @@ -33,7 +17,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons * -------------------------------------------------------------------------- */ -var Util = function ($) { +var Util = function () { /** * ------------------------------------------------------------------------ @@ -50,9 +34,10 @@ var Util = function ($) { MozTransition: 'transitionend', OTransition: 'oTransitionEnd otransitionend', transition: 'transitionend' + }; - // shoutout AngusCroll (https://goo.gl/pxwQGp) - };function toType(obj) { + // shoutout AngusCroll (https://goo.gl/pxwQGp) + function toType(obj) { return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); } @@ -68,7 +53,7 @@ var Util = function ($) { if ($(event.target).is(this)) { return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params } - return undefined; + return undefined; // eslint-disable-line no-undefined } }; } @@ -81,7 +66,7 @@ var Util = function ($) { var el = document.createElement('bootstrap'); for (var name in TransitionEndEvent) { - if (el.style[name] !== undefined) { + if (typeof el.style[name] !== 'undefined') { return { end: TransitionEndEvent[name] }; @@ -143,7 +128,7 @@ var Util = function ($) { } try { - var $selector = $(selector); + var $selector = $(document).find(selector); return $selector.length > 0 ? selector : null; } catch (error) { return null; @@ -160,7 +145,7 @@ var Util = function ($) { }, typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) { for (var property in configTypes) { - if (configTypes.hasOwnProperty(property)) { + if (Object.prototype.hasOwnProperty.call(configTypes, property)) { var expectedTypes = configTypes[property]; var value = config[property]; var valueType = value && isElement(value) ? 'element' : toType(value); @@ -178,6 +163,63 @@ var Util = function ($) { return Util; }(jQuery); +var babelHelpers = {}; +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 classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; + +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 inherits = function (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 possibleConstructorReturn = function (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; +}; + +babelHelpers; + /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta): alert.js @@ -185,7 +227,7 @@ var Util = function ($) { * -------------------------------------------------------------------------- */ -var Alert = function ($) { +var Alert = function () { /** * ------------------------------------------------------------------------ @@ -215,17 +257,17 @@ var Alert = function ($) { ALERT: 'alert', FADE: 'fade', SHOW: 'show' + }; - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - }; var Alert = function () { function Alert(element) { - _classCallCheck(this, Alert); + classCallCheck(this, Alert); this._element = element; } @@ -277,7 +319,7 @@ var Alert = function ($) { }; Alert.prototype._removeElement = function _removeElement(element) { - var _this2 = this; + var _this = this; $(element).removeClass(ClassName.SHOW); @@ -287,7 +329,7 @@ var Alert = function ($) { } $(element).one(Util.TRANSITION_END, function (event) { - return _this2._destroyElement(element, event); + return _this._destroyElement(element, event); }).emulateTransitionEnd(TRANSITION_DURATION); }; @@ -323,13 +365,12 @@ var Alert = function ($) { }; }; - _createClass(Alert, null, [{ + createClass(Alert, null, [{ key: 'VERSION', get: function get() { return VERSION; } }]); - return Alert; }(); @@ -364,7 +405,7 @@ var Alert = function ($) { * -------------------------------------------------------------------------- */ -var Button = function ($) { +var Button = function () { /** * ------------------------------------------------------------------------ @@ -396,17 +437,17 @@ var Button = function ($) { var Event = { CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY, FOCUS_BLUR_DATA_API: 'focus' + EVENT_KEY + DATA_API_KEY + ' ' + ('blur' + EVENT_KEY + DATA_API_KEY) + }; - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - }; var Button = function () { function Button(element) { - _classCallCheck(this, Button); + classCallCheck(this, Button); this._element = element; } @@ -480,13 +521,12 @@ var Button = function ($) { }); }; - _createClass(Button, null, [{ + createClass(Button, null, [{ key: 'VERSION', get: function get() { return VERSION; } }]); - return Button; }(); @@ -534,7 +574,7 @@ var Button = function ($) { * -------------------------------------------------------------------------- */ -var Carousel = function ($) { +var Carousel = function () { /** * ------------------------------------------------------------------------ @@ -606,17 +646,17 @@ var Carousel = function ($) { INDICATORS: '.carousel-indicators', DATA_SLIDE: '[data-slide], [data-slide-to]', DATA_RIDE: '[data-ride="carousel"]' + }; - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - }; var Carousel = function () { function Carousel(element, config) { - _classCallCheck(this, Carousel); + classCallCheck(this, Carousel); this._items = null; this._interval = null; @@ -688,7 +728,7 @@ var Carousel = function ($) { }; Carousel.prototype.to = function to(index) { - var _this3 = this; + var _this = this; this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0]; @@ -700,7 +740,7 @@ var Carousel = function ($) { if (this._isSliding) { $(this._element).one(Event.SLID, function () { - return _this3.to(index); + return _this.to(index); }); return; } @@ -739,19 +779,19 @@ var Carousel = function ($) { }; Carousel.prototype._addEventListeners = function _addEventListeners() { - var _this4 = this; + var _this2 = this; if (this._config.keyboard) { $(this._element).on(Event.KEYDOWN, function (event) { - return _this4._keydown(event); + return _this2._keydown(event); }); } if (this._config.pause === 'hover') { $(this._element).on(Event.MOUSEENTER, function (event) { - return _this4.pause(event); + return _this2.pause(event); }).on(Event.MOUSELEAVE, function (event) { - return _this4.cycle(event); + return _this2.cycle(event); }); if ('ontouchstart' in document.documentElement) { // if it's a touch-enabled device, mouseenter/leave are fired as @@ -762,13 +802,13 @@ var Carousel = function ($) { // 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); + _this2.pause(); + if (_this2.touchTimeout) { + clearTimeout(_this2.touchTimeout); } - _this4.touchTimeout = setTimeout(function (event) { - return _this4.cycle(event); - }, TOUCHEVENT_COMPAT_WAIT + _this4._config.interval); + _this2.touchTimeout = setTimeout(function (event) { + return _this2.cycle(event); + }, TOUCHEVENT_COMPAT_WAIT + _this2._config.interval); }); } } @@ -843,7 +883,7 @@ var Carousel = function ($) { }; Carousel.prototype._slide = function _slide(direction, element) { - var _this5 = this; + var _this3 = this; var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0]; var activeElementIndex = this._getItemIndex(activeElement); @@ -909,10 +949,10 @@ var Carousel = function ($) { $(activeElement).removeClass(ClassName.ACTIVE + ' ' + orderClassName + ' ' + directionalClassName); - _this5._isSliding = false; + _this3._isSliding = false; setTimeout(function () { - return $(_this5._element).trigger(slidEvent); + return $(_this3._element).trigger(slidEvent); }, 0); }).emulateTransitionEnd(TRANSITION_DURATION); } else { @@ -949,7 +989,7 @@ var Carousel = function ($) { if (typeof config === 'number') { data.to(config); } else if (typeof action === 'string') { - if (data[action] === undefined) { + if (typeof data[action] === 'undefined') { throw new Error('No method named "' + action + '"'); } data[action](); @@ -989,7 +1029,7 @@ var Carousel = function ($) { event.preventDefault(); }; - _createClass(Carousel, null, [{ + createClass(Carousel, null, [{ key: 'VERSION', get: function get() { return VERSION; @@ -1000,7 +1040,6 @@ var Carousel = function ($) { return Default; } }]); - return Carousel; }(); @@ -1042,7 +1081,7 @@ var Carousel = function ($) { * -------------------------------------------------------------------------- */ -var Collapse = function ($) { +var Collapse = function () { /** * ------------------------------------------------------------------------ @@ -1091,17 +1130,17 @@ var Collapse = function ($) { var Selector = { ACTIVES: '.show, .collapsing', DATA_TOGGLE: '[data-toggle="collapse"]' + }; - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - }; var Collapse = function () { function Collapse(element, config) { - _classCallCheck(this, Collapse); + classCallCheck(this, Collapse); this._isTransitioning = false; this._element = element; @@ -1140,7 +1179,7 @@ var Collapse = function ($) { }; Collapse.prototype.show = function show() { - var _this6 = this; + var _this = this; if (this._isTransitioning || $(this._element).hasClass(ClassName.SHOW)) { return; @@ -1189,13 +1228,13 @@ var Collapse = function ($) { this.setTransitioning(true); var complete = function complete() { - $(_this6._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.SHOW); + $(_this._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.SHOW); - _this6._element.style[dimension] = ''; + _this._element.style[dimension] = ''; - _this6.setTransitioning(false); + _this.setTransitioning(false); - $(_this6._element).trigger(Event.SHOWN); + $(_this._element).trigger(Event.SHOWN); }; if (!Util.supportsTransitionEnd()) { @@ -1212,7 +1251,7 @@ var Collapse = function ($) { }; Collapse.prototype.hide = function hide() { - var _this7 = this; + var _this2 = this; if (this._isTransitioning || !$(this._element).hasClass(ClassName.SHOW)) { return; @@ -1248,8 +1287,8 @@ var Collapse = function ($) { this.setTransitioning(true); var complete = function complete() { - _this7.setTransitioning(false); - $(_this7._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN); + _this2.setTransitioning(false); + $(_this2._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN); }; this._element.style[dimension] = ''; @@ -1291,13 +1330,13 @@ var Collapse = function ($) { }; Collapse.prototype._getParent = function _getParent() { - var _this8 = this; + var _this3 = this; var parent = $(this._config.parent)[0]; var selector = '[data-toggle="collapse"][data-parent="' + this._config.parent + '"]'; $(parent).find(selector).each(function (i, element) { - _this8._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); + _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); }); return parent; @@ -1336,7 +1375,7 @@ var Collapse = function ($) { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error('No method named "' + config + '"'); } data[config](); @@ -1344,7 +1383,7 @@ var Collapse = function ($) { }); }; - _createClass(Collapse, null, [{ + createClass(Collapse, null, [{ key: 'VERSION', get: function get() { return VERSION; @@ -1355,7 +1394,6 @@ var Collapse = function ($) { return Default; } }]); - return Collapse; }(); @@ -1366,7 +1404,8 @@ var Collapse = function ($) { */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { - if (!/input|textarea/i.test(event.target.tagName)) { + // preventDefault only for elements (which change the URL) not inside the collapsible element + if (event.target.tagName === 'A' && !$.contains(this, event.target)) { event.preventDefault(); } @@ -1396,8 +1435,6 @@ var Collapse = function ($) { return Collapse; }(jQuery); -/* global Popper */ - /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta): dropdown.js @@ -1405,7 +1442,7 @@ var Collapse = function ($) { * -------------------------------------------------------------------------- */ -var Dropdown = function ($) { +var Dropdown = function () { /** * Check for Popper dependency @@ -1470,26 +1507,24 @@ var Dropdown = function ($) { }; var Default = { - placement: AttachmentMap.BOTTOM, offset: 0, flip: true }; var DefaultType = { - placement: 'string', offset: '(number|string)', flip: 'boolean' + }; - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - }; var Dropdown = function () { function Dropdown(element, config) { - _classCallCheck(this, Dropdown); + classCallCheck(this, Dropdown); this._element = element; this._popper = null; @@ -1574,21 +1609,16 @@ var Dropdown = function ($) { // private Dropdown.prototype._addEventListeners = function _addEventListeners() { - var _this9 = this; + var _this = this; $(this._element).on(Event.CLICK, function (event) { event.preventDefault(); event.stopPropagation(); - _this9.toggle(); + _this.toggle(); }); }; Dropdown.prototype._getConfig = function _getConfig(config) { - var elementData = $(this._element).data(); - if (elementData.placement !== undefined) { - elementData.placement = AttachmentMap[elementData.placement.toUpperCase()]; - } - config = $.extend({}, this.constructor.Default, $(this._element).data(), config); Util.typeCheckConfig(NAME, config, this.constructor.DefaultType); @@ -1606,10 +1636,10 @@ var Dropdown = function ($) { Dropdown.prototype._getPlacement = function _getPlacement() { var $parentDropdown = $(this._element).parent(); - var placement = this._config.placement; + var placement = AttachmentMap.BOTTOM; // Handle dropup - if ($parentDropdown.hasClass(ClassName.DROPUP) || this._config.placement === AttachmentMap.TOP) { + if ($parentDropdown.hasClass(ClassName.DROPUP)) { placement = AttachmentMap.TOP; if ($(this._menu).hasClass(ClassName.MENURIGHT)) { placement = AttachmentMap.TOPEND; @@ -1635,9 +1665,10 @@ var Dropdown = function ($) { enabled: this._config.flip } } + }; - // Disable Popper.js for Dropdown in Navbar - };if (this._inNavbar) { + // Disable Popper.js for Dropdown in Navbar + if (this._inNavbar) { popperConfig.modifiers.applyStyle = { enabled: !this._inNavbar }; @@ -1658,7 +1689,7 @@ var Dropdown = function ($) { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error('No method named "' + config + '"'); } data[config](); @@ -1773,7 +1804,7 @@ var Dropdown = function ($) { items[index].focus(); }; - _createClass(Dropdown, null, [{ + createClass(Dropdown, null, [{ key: 'VERSION', get: function get() { return VERSION; @@ -1789,7 +1820,6 @@ var Dropdown = function ($) { return DefaultType; } }]); - return Dropdown; }(); @@ -1821,7 +1851,7 @@ var Dropdown = function ($) { }; return Dropdown; -}(jQuery); +}(jQuery, Popper); /** * -------------------------------------------------------------------------- @@ -1830,7 +1860,7 @@ var Dropdown = function ($) { * -------------------------------------------------------------------------- */ -var Modal = function ($) { +var Modal = function () { /** * ------------------------------------------------------------------------ @@ -1889,18 +1919,19 @@ var Modal = function ($) { DATA_TOGGLE: '[data-toggle="modal"]', DATA_DISMISS: '[data-dismiss="modal"]', FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top', + STICKY_CONTENT: '.sticky-top', NAVBAR_TOGGLER: '.navbar-toggler' + }; - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - }; var Modal = function () { function Modal(element, config) { - _classCallCheck(this, Modal); + classCallCheck(this, Modal); this._config = this._getConfig(config); this._element = element; @@ -1922,7 +1953,7 @@ var Modal = function ($) { }; Modal.prototype.show = function show(relatedTarget) { - var _this10 = this; + var _this = this; if (this._isTransitioning) { return; @@ -1947,30 +1978,32 @@ var Modal = function ($) { this._checkScrollbar(); this._setScrollbar(); + this._adjustDialog(); + $(document.body).addClass(ClassName.OPEN); this._setEscapeEvent(); this._setResizeEvent(); $(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, function (event) { - return _this10.hide(event); + return _this.hide(event); }); $(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () { - $(_this10._element).one(Event.MOUSEUP_DISMISS, function (event) { - if ($(event.target).is(_this10._element)) { - _this10._ignoreBackdropClick = true; + $(_this._element).one(Event.MOUSEUP_DISMISS, function (event) { + if ($(event.target).is(_this._element)) { + _this._ignoreBackdropClick = true; } }); }); this._showBackdrop(function () { - return _this10._showElement(relatedTarget); + return _this._showElement(relatedTarget); }); }; Modal.prototype.hide = function hide(event) { - var _this11 = this; + var _this2 = this; if (event) { event.preventDefault(); @@ -2009,7 +2042,7 @@ var Modal = function ($) { if (transition) { $(this._element).one(Util.TRANSITION_END, function (event) { - return _this11._hideModal(event); + return _this2._hideModal(event); }).emulateTransitionEnd(TRANSITION_DURATION); } else { this._hideModal(); @@ -2044,7 +2077,7 @@ var Modal = function ($) { }; Modal.prototype._showElement = function _showElement(relatedTarget) { - var _this12 = this; + var _this3 = this; var transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE); @@ -2072,11 +2105,11 @@ var Modal = function ($) { }); var transitionComplete = function transitionComplete() { - if (_this12._config.focus) { - _this12._element.focus(); + if (_this3._config.focus) { + _this3._element.focus(); } - _this12._isTransitioning = false; - $(_this12._element).trigger(shownEvent); + _this3._isTransitioning = false; + $(_this3._element).trigger(shownEvent); }; if (transition) { @@ -2087,24 +2120,24 @@ var Modal = function ($) { }; Modal.prototype._enforceFocus = function _enforceFocus() { - var _this13 = this; + var _this4 = this; $(document).off(Event.FOCUSIN) // guard against infinite focus loop .on(Event.FOCUSIN, function (event) { - if (document !== event.target && _this13._element !== event.target && !$(_this13._element).has(event.target).length) { - _this13._element.focus(); + if (document !== event.target && _this4._element !== event.target && !$(_this4._element).has(event.target).length) { + _this4._element.focus(); } }); }; Modal.prototype._setEscapeEvent = function _setEscapeEvent() { - var _this14 = this; + var _this5 = this; if (this._isShown && this._config.keyboard) { $(this._element).on(Event.KEYDOWN_DISMISS, function (event) { if (event.which === ESCAPE_KEYCODE) { event.preventDefault(); - _this14.hide(); + _this5.hide(); } }); } else if (!this._isShown) { @@ -2113,11 +2146,11 @@ var Modal = function ($) { }; Modal.prototype._setResizeEvent = function _setResizeEvent() { - var _this15 = this; + var _this6 = this; if (this._isShown) { $(window).on(Event.RESIZE, function (event) { - return _this15.handleUpdate(event); + return _this6.handleUpdate(event); }); } else { $(window).off(Event.RESIZE); @@ -2125,16 +2158,16 @@ var Modal = function ($) { }; Modal.prototype._hideModal = function _hideModal() { - var _this16 = this; + var _this7 = this; this._element.style.display = 'none'; this._element.setAttribute('aria-hidden', true); this._isTransitioning = false; this._showBackdrop(function () { $(document.body).removeClass(ClassName.OPEN); - _this16._resetAdjustments(); - _this16._resetScrollbar(); - $(_this16._element).trigger(Event.HIDDEN); + _this7._resetAdjustments(); + _this7._resetScrollbar(); + $(_this7._element).trigger(Event.HIDDEN); }); }; @@ -2146,7 +2179,7 @@ var Modal = function ($) { }; Modal.prototype._showBackdrop = function _showBackdrop(callback) { - var _this17 = this; + var _this8 = this; var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : ''; @@ -2163,17 +2196,17 @@ var Modal = function ($) { $(this._backdrop).appendTo(document.body); $(this._element).on(Event.CLICK_DISMISS, function (event) { - if (_this17._ignoreBackdropClick) { - _this17._ignoreBackdropClick = false; + if (_this8._ignoreBackdropClick) { + _this8._ignoreBackdropClick = false; return; } if (event.target !== event.currentTarget) { return; } - if (_this17._config.backdrop === 'static') { - _this17._element.focus(); + if (_this8._config.backdrop === 'static') { + _this8._element.focus(); } else { - _this17.hide(); + _this8.hide(); } }); @@ -2197,7 +2230,7 @@ var Modal = function ($) { $(this._backdrop).removeClass(ClassName.SHOW); var callbackRemove = function callbackRemove() { - _this17._removeBackdrop(); + _this8._removeBackdrop(); if (callback) { callback(); } @@ -2236,12 +2269,13 @@ var Modal = function ($) { }; Modal.prototype._checkScrollbar = function _checkScrollbar() { - this._isBodyOverflowing = document.body.clientWidth < window.innerWidth; + var rect = document.body.getBoundingClientRect(); + this._isBodyOverflowing = rect.left + rect.right < window.innerWidth; this._scrollbarWidth = this._getScrollbarWidth(); }; Modal.prototype._setScrollbar = function _setScrollbar() { - var _this18 = this; + var _this9 = this; if (this._isBodyOverflowing) { // Note: DOMNode.style.paddingRight returns the actual value or '' if not set @@ -2251,14 +2285,21 @@ var Modal = function ($) { $(Selector.FIXED_CONTENT).each(function (index, element) { var actualPadding = $(element)[0].style.paddingRight; var calculatedPadding = $(element).css('padding-right'); - $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this18._scrollbarWidth + 'px'); + $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this9._scrollbarWidth + 'px'); + }); + + // Adjust sticky content margin + $(Selector.STICKY_CONTENT).each(function (index, element) { + var actualMargin = $(element)[0].style.marginRight; + var calculatedMargin = $(element).css('margin-right'); + $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this9._scrollbarWidth + 'px'); }); // Adjust navbar-toggler margin $(Selector.NAVBAR_TOGGLER).each(function (index, element) { var actualMargin = $(element)[0].style.marginRight; var calculatedMargin = $(element).css('margin-right'); - $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) + _this18._scrollbarWidth + 'px'); + $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) + _this9._scrollbarWidth + 'px'); }); // Adjust body padding @@ -2277,8 +2318,8 @@ var Modal = function ($) { } }); - // Restore navbar-toggler margin - $(Selector.NAVBAR_TOGGLER).each(function (index, element) { + // Restore sticky content and navbar-toggler margin + $(Selector.STICKY_CONTENT + ', ' + Selector.NAVBAR_TOGGLER).each(function (index, element) { var margin = $(element).data('margin-right'); if (typeof margin !== 'undefined') { $(element).css('margin-right', margin).removeData('margin-right'); @@ -2315,7 +2356,7 @@ var Modal = function ($) { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error('No method named "' + config + '"'); } data[config](relatedTarget); @@ -2325,7 +2366,7 @@ var Modal = function ($) { }); }; - _createClass(Modal, null, [{ + createClass(Modal, null, [{ key: 'VERSION', get: function get() { return VERSION; @@ -2336,7 +2377,6 @@ var Modal = function ($) { return Default; } }]); - return Modal; }(); @@ -2347,7 +2387,7 @@ var Modal = function ($) { */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { - var _this19 = this; + var _this10 = this; var target = void 0; var selector = Util.getSelectorFromElement(this); @@ -2369,8 +2409,8 @@ var Modal = function ($) { } $target.one(Event.HIDDEN, function () { - if ($(_this19).is(':visible')) { - _this19.focus(); + if ($(_this10).is(':visible')) { + _this10.focus(); } }); }); @@ -2396,12 +2436,20 @@ var Modal = function ($) { /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-beta): scrollspy.js + * Bootstrap (v4.0.0-beta): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ -var ScrollSpy = function ($) { +var Tooltip = function () { + + /** + * Check for Popper dependency + * Popper - https://popper.js.org + */ + if (typeof Popper === 'undefined') { + throw new Error('Bootstrap tooltips require Popper.js (https://popper.js.org)'); + } /** * ------------------------------------------------------------------------ @@ -2409,520 +2457,599 @@ var ScrollSpy = function ($) { * ------------------------------------------------------------------------ */ - var NAME = 'scrollspy'; + var NAME = 'tooltip'; var VERSION = '4.0.0-beta'; - var DATA_KEY = 'bs.scrollspy'; + var DATA_KEY = 'bs.tooltip'; var EVENT_KEY = '.' + DATA_KEY; - var DATA_API_KEY = '.data-api'; var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 150; + var CLASS_PREFIX = 'bs-tooltip'; + var BSCLS_PREFIX_REGEX = new RegExp('(^|\\s)' + CLASS_PREFIX + '\\S+', 'g'); + + var DefaultType = { + animation: 'boolean', + template: 'string', + title: '(string|element|function)', + trigger: 'string', + delay: '(number|object)', + html: 'boolean', + selector: '(string|boolean)', + placement: '(string|function)', + offset: '(number|string)', + container: '(string|element|boolean)', + fallbackPlacement: '(string|array)' + }; + + var AttachmentMap = { + AUTO: 'auto', + TOP: 'top', + RIGHT: 'right', + BOTTOM: 'bottom', + LEFT: 'left' + }; var Default = { - offset: 10, - method: 'auto', - target: '' + animation: true, + template: '', + trigger: 'hover focus', + title: '', + delay: 0, + html: false, + selector: false, + placement: 'top', + offset: 0, + container: false, + fallbackPlacement: 'flip' }; - var DefaultType = { - offset: 'number', - method: 'string', - target: '(string|element)' + var HoverState = { + SHOW: 'show', + OUT: 'out' }; var Event = { - ACTIVATE: 'activate' + EVENT_KEY, - SCROLL: 'scroll' + EVENT_KEY, - LOAD_DATA_API: 'load' + EVENT_KEY + DATA_API_KEY + HIDE: 'hide' + EVENT_KEY, + HIDDEN: 'hidden' + EVENT_KEY, + SHOW: 'show' + EVENT_KEY, + SHOWN: 'shown' + EVENT_KEY, + INSERTED: 'inserted' + EVENT_KEY, + CLICK: 'click' + EVENT_KEY, + FOCUSIN: 'focusin' + EVENT_KEY, + FOCUSOUT: 'focusout' + EVENT_KEY, + MOUSEENTER: 'mouseenter' + EVENT_KEY, + MOUSELEAVE: 'mouseleave' + EVENT_KEY }; var ClassName = { - DROPDOWN_ITEM: 'dropdown-item', - DROPDOWN_MENU: 'dropdown-menu', - ACTIVE: 'active' + FADE: 'fade', + SHOW: 'show' }; var Selector = { - DATA_SPY: '[data-spy="scroll"]', - ACTIVE: '.active', - NAV_LIST_GROUP: '.nav, .list-group', - NAV_LINKS: '.nav-link', - LIST_ITEMS: '.list-group-item', - DROPDOWN: '.dropdown', - DROPDOWN_ITEMS: '.dropdown-item', - DROPDOWN_TOGGLE: '.dropdown-toggle' + TOOLTIP: '.tooltip', + TOOLTIP_INNER: '.tooltip-inner', + ARROW: '.arrow' }; - var OffsetMethod = { - OFFSET: 'offset', - POSITION: 'position' + var Trigger = { + HOVER: 'hover', + FOCUS: 'focus', + CLICK: 'click', + MANUAL: 'manual' + }; - /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ - */ + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - }; - var ScrollSpy = function () { - function ScrollSpy(element, config) { - var _this20 = this; + var Tooltip = function () { + function Tooltip(element, config) { + classCallCheck(this, Tooltip); - _classCallCheck(this, ScrollSpy); - this._element = element; - this._scrollElement = element.tagName === 'BODY' ? window : element; - this._config = this._getConfig(config); - this._selector = this._config.target + ' ' + Selector.NAV_LINKS + ',' + (this._config.target + ' ' + Selector.LIST_ITEMS + ',') + (this._config.target + ' ' + Selector.DROPDOWN_ITEMS); - this._offsets = []; - this._targets = []; - this._activeTarget = null; - this._scrollHeight = 0; + // private + this._isEnabled = true; + this._timeout = 0; + this._hoverState = ''; + this._activeTrigger = {}; + this._popper = null; - $(this._scrollElement).on(Event.SCROLL, function (event) { - return _this20._process(event); - }); + // protected + this.element = element; + this.config = this._getConfig(config); + this.tip = null; - this.refresh(); - this._process(); + this._setListeners(); } // getters // public - ScrollSpy.prototype.refresh = function refresh() { - var _this21 = this; - - var autoMethod = this._scrollElement !== this._scrollElement.window ? OffsetMethod.POSITION : OffsetMethod.OFFSET; + Tooltip.prototype.enable = function enable() { + this._isEnabled = true; + }; - var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; + Tooltip.prototype.disable = function disable() { + this._isEnabled = false; + }; - var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0; + Tooltip.prototype.toggleEnabled = function toggleEnabled() { + this._isEnabled = !this._isEnabled; + }; - this._offsets = []; - this._targets = []; + Tooltip.prototype.toggle = function toggle(event) { + if (!this._isEnabled) { + return; + } - this._scrollHeight = this._getScrollHeight(); + if (event) { + var dataKey = this.constructor.DATA_KEY; + var context = $(event.currentTarget).data(dataKey); - var targets = $.makeArray($(this._selector)); + if (!context) { + context = new this.constructor(event.currentTarget, this._getDelegateConfig()); + $(event.currentTarget).data(dataKey, context); + } - targets.map(function (element) { - var target = void 0; - var targetSelector = Util.getSelectorFromElement(element); + context._activeTrigger.click = !context._activeTrigger.click; - if (targetSelector) { - target = $(targetSelector)[0]; + if (context._isWithActiveTrigger()) { + context._enter(null, context); + } else { + context._leave(null, context); } + } else { - if (target) { - var targetBCR = target.getBoundingClientRect(); - if (targetBCR.width || targetBCR.height) { - // todo (fat): remove sketch reliance on jQuery position/offset - return [$(target)[offsetMethod]().top + offsetBase, targetSelector]; - } + if ($(this.getTipElement()).hasClass(ClassName.SHOW)) { + this._leave(null, this); + return; } - return null; - }).filter(function (item) { - return item; - }).sort(function (a, b) { - return a[0] - b[0]; - }).forEach(function (item) { - _this21._offsets.push(item[0]); - _this21._targets.push(item[1]); - }); - }; - ScrollSpy.prototype.dispose = function dispose() { - $.removeData(this._element, DATA_KEY); - $(this._scrollElement).off(EVENT_KEY); - - this._element = null; - this._scrollElement = null; - this._config = null; - this._selector = null; - this._offsets = null; - this._targets = null; - this._activeTarget = null; - this._scrollHeight = null; + this._enter(null, this); + } }; - // private + Tooltip.prototype.dispose = function dispose() { + clearTimeout(this._timeout); - ScrollSpy.prototype._getConfig = function _getConfig(config) { - config = $.extend({}, Default, config); + $.removeData(this.element, this.constructor.DATA_KEY); - if (typeof config.target !== 'string') { - var id = $(config.target).attr('id'); - if (!id) { - id = Util.getUID(NAME); - $(config.target).attr('id', id); - } - config.target = '#' + id; + $(this.element).off(this.constructor.EVENT_KEY); + $(this.element).closest('.modal').off('hide.bs.modal'); + + if (this.tip) { + $(this.tip).remove(); } - Util.typeCheckConfig(NAME, config, DefaultType); + this._isEnabled = null; + this._timeout = null; + this._hoverState = null; + this._activeTrigger = null; + if (this._popper !== null) { + this._popper.destroy(); + } - return config; + this._popper = null; + this.element = null; + this.config = null; + this.tip = null; }; - ScrollSpy.prototype._getScrollTop = function _getScrollTop() { - return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop; - }; + Tooltip.prototype.show = function show() { + var _this = this; - ScrollSpy.prototype._getScrollHeight = function _getScrollHeight() { - return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); - }; + if ($(this.element).css('display') === 'none') { + throw new Error('Please use show on visible elements'); + } - ScrollSpy.prototype._getOffsetHeight = function _getOffsetHeight() { - return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height; - }; + var showEvent = $.Event(this.constructor.Event.SHOW); + if (this.isWithContent() && this._isEnabled) { + $(this.element).trigger(showEvent); - ScrollSpy.prototype._process = function _process() { - var scrollTop = this._getScrollTop() + this._config.offset; - var scrollHeight = this._getScrollHeight(); - var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight(); + var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element); - if (this._scrollHeight !== scrollHeight) { - this.refresh(); - } + if (showEvent.isDefaultPrevented() || !isInTheDom) { + return; + } - if (scrollTop >= maxScroll) { - var target = this._targets[this._targets.length - 1]; + var tip = this.getTipElement(); + var tipId = Util.getUID(this.constructor.NAME); - if (this._activeTarget !== target) { - this._activate(target); + tip.setAttribute('id', tipId); + this.element.setAttribute('aria-describedby', tipId); + + this.setContent(); + + if (this.config.animation) { + $(tip).addClass(ClassName.FADE); } - return; - } - if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { - this._activeTarget = null; - this._clear(); - return; - } + var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement; - for (var i = this._offsets.length; i--;) { - var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (this._offsets[i + 1] === undefined || scrollTop < this._offsets[i + 1]); + var attachment = this._getAttachment(placement); + this.addAttachmentClass(attachment); - if (isActiveTarget) { - this._activate(this._targets[i]); + var container = this.config.container === false ? document.body : $(this.config.container); + + $(tip).data(this.constructor.DATA_KEY, this); + + if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) { + $(tip).appendTo(container); } - } - }; - ScrollSpy.prototype._activate = function _activate(target) { - this._activeTarget = target; + $(this.element).trigger(this.constructor.Event.INSERTED); - this._clear(); + this._popper = new Popper(this.element, tip, { + placement: attachment, + modifiers: { + offset: { + offset: this.config.offset + }, + flip: { + behavior: this.config.fallbackPlacement + }, + arrow: { + element: Selector.ARROW + } + }, + onCreate: function onCreate(data) { + if (data.originalPlacement !== data.placement) { + _this._handlePopperPlacementChange(data); + } + }, + onUpdate: function onUpdate(data) { + _this._handlePopperPlacementChange(data); + } + }); - var queries = this._selector.split(','); - queries = queries.map(function (selector) { - return selector + '[data-target="' + target + '"],' + (selector + '[href="' + target + '"]'); - }); + $(tip).addClass(ClassName.SHOW); - var $link = $(queries.join(',')); + // 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); + } - if ($link.hasClass(ClassName.DROPDOWN_ITEM)) { - $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE); - $link.addClass(ClassName.ACTIVE); - } else { - // Set triggered link as active - $link.addClass(ClassName.ACTIVE); - // Set triggered links parents as active - // With both