assets/javascripts/bootstrap.js in bootstrap-4.0.0.alpha6 vs assets/javascripts/bootstrap.js in bootstrap-4.0.0.beta
- old
+ new
@@ -1,25 +1,23 @@
/*!
- * Bootstrap v4.0.0-alpha.6 (https://getbootstrap.com)
+ * 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 ($) {
+(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);
+})(jQuery);
-
-+function () {
-
+(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; }; }();
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; }
@@ -28,11 +26,11 @@
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.6): util.js
+ * Bootstrap (v4.0.0-beta): util.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
var Util = function ($) {
@@ -50,14 +48,13 @@
var TransitionEndEvent = {
WebkitTransition: 'webkitTransitionEnd',
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();
}
function isElement(obj) {
return (obj[0] || obj).nodeType;
@@ -139,17 +136,20 @@
} while (document.getElementById(prefix));
return prefix;
},
getSelectorFromElement: function getSelectorFromElement(element) {
var selector = element.getAttribute('data-target');
-
- if (!selector) {
+ if (!selector || selector === '#') {
selector = element.getAttribute('href') || '';
- selector = /^#[a-z]/i.test(selector) ? selector : null;
}
- return selector;
+ try {
+ var $selector = $(selector);
+ return $selector.length > 0 ? selector : null;
+ } catch (error) {
+ return null;
+ }
},
reflow: function reflow(element) {
return element.offsetHeight;
},
triggerTransitionEnd: function triggerTransitionEnd(element) {
@@ -178,11 +178,11 @@
return Util;
}(jQuery);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.6): alert.js
+ * Bootstrap (v4.0.0-beta): alert.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
var Alert = function ($) {
@@ -192,11 +192,11 @@
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'alert';
- var VERSION = '4.0.0-alpha.6';
+ var VERSION = '4.0.0-beta';
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;
@@ -213,18 +213,18 @@
var ClassName = {
ALERT: 'alert',
FADE: 'fade',
SHOW: 'show'
- };
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
+ };
var Alert = function () {
function Alert(element) {
_classCallCheck(this, Alert);
this._element = element;
@@ -357,11 +357,11 @@
return Alert;
}(jQuery);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.6): button.js
+ * Bootstrap (v4.0.0-beta): button.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
var Button = function ($) {
@@ -371,11 +371,11 @@
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'button';
- var VERSION = '4.0.0-alpha.6';
+ var VERSION = '4.0.0-beta';
var DATA_KEY = 'bs.button';
var EVENT_KEY = '.' + DATA_KEY;
var DATA_API_KEY = '.data-api';
var JQUERY_NO_CONFLICT = $.fn[NAME];
@@ -394,18 +394,18 @@
};
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);
this._element = element;
@@ -415,10 +415,11 @@
// public
Button.prototype.toggle = function toggle() {
var triggerChangeEvent = true;
+ var addAriaPressed = true;
var rootElement = $(this._element).closest(Selector.DATA_TOGGLE)[0];
if (rootElement) {
var input = $(this._element).find(Selector.INPUT)[0];
@@ -434,19 +435,25 @@
}
}
}
if (triggerChangeEvent) {
+ if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains('disabled') || rootElement.classList.contains('disabled')) {
+ return;
+ }
input.checked = !$(this._element).hasClass(ClassName.ACTIVE);
$(input).trigger('change');
}
input.focus();
+ addAriaPressed = false;
}
}
- this._element.setAttribute('aria-pressed', !$(this._element).hasClass(ClassName.ACTIVE));
+ if (addAriaPressed) {
+ this._element.setAttribute('aria-pressed', !$(this._element).hasClass(ClassName.ACTIVE));
+ }
if (triggerChangeEvent) {
$(this._element).toggleClass(ClassName.ACTIVE);
}
};
@@ -520,11 +527,11 @@
return Button;
}(jQuery);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.6): carousel.js
+ * Bootstrap (v4.0.0-beta): carousel.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
var Carousel = function ($) {
@@ -534,18 +541,19 @@
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'carousel';
- var VERSION = '4.0.0-alpha.6';
+ var VERSION = '4.0.0-beta';
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 TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
var Default = {
interval: 5000,
keyboard: true,
slide: false,
@@ -572,10 +580,11 @@
SLIDE: 'slide' + EVENT_KEY,
SLID: 'slid' + EVENT_KEY,
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
};
var ClassName = {
@@ -595,18 +604,18 @@
ITEM: '.carousel-item',
NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
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);
this._items = null;
@@ -614,10 +623,12 @@
this._activeElement = null;
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];
this._addEventListeners();
@@ -626,28 +637,26 @@
// getters
// public
Carousel.prototype.next = function next() {
- if (this._isSliding) {
- throw new Error('Carousel is sliding');
+ if (!this._isSliding) {
+ this._slide(Direction.NEXT);
}
- this._slide(Direction.NEXT);
};
Carousel.prototype.nextWhenVisible = 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) {
- throw new Error('Carousel is sliding');
+ if (!this._isSliding) {
+ this._slide(Direction.PREV);
}
- this._slide(Direction.PREVIOUS);
};
Carousel.prototype.pause = function pause(event) {
if (!event) {
this._isPaused = true;
@@ -699,11 +708,11 @@
this.pause();
this.cycle();
return;
}
- var direction = index > activeIndex ? Direction.NEXT : Direction.PREVIOUS;
+ var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
this._slide(direction, this._items[index]);
};
Carousel.prototype.dispose = function dispose() {
@@ -735,16 +744,34 @@
$(this._element).on(Event.KEYDOWN, function (event) {
return _this4._keydown(event);
});
}
- 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);
+ });
+ }
}
};
Carousel.prototype._keydown = function _keydown(event) {
if (/input|textarea/i.test(event.target.tagName)) {
@@ -770,29 +797,33 @@
return this._items.indexOf(element);
};
Carousel.prototype._getItemByDirection = function _getItemByDirection(direction, activeElement) {
var isNextDirection = direction === Direction.NEXT;
- var isPrevDirection = direction === Direction.PREVIOUS;
+ var isPrevDirection = direction === Direction.PREV;
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 delta = direction === Direction.PREV ? -1 : 1;
var itemIndex = (activeIndex + delta) % this._items.length;
return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
};
Carousel.prototype._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
+ var targetIndex = this._getItemIndex(relatedTarget);
+ var fromIndex = this._getItemIndex($(this._element).find(Selector.ACTIVE_ITEM)[0]);
var slideEvent = $.Event(Event.SLIDE, {
relatedTarget: relatedTarget,
- direction: eventDirectionName
+ direction: eventDirectionName,
+ from: fromIndex,
+ to: targetIndex
});
$(this._element).trigger(slideEvent);
return slideEvent;
@@ -812,12 +843,13 @@
Carousel.prototype._slide = function _slide(direction, element) {
var _this5 = this;
var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
+ var activeElementIndex = this._getItemIndex(activeElement);
var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
-
+ var nextElementIndex = this._getItemIndex(nextElement);
var isCycling = Boolean(this._interval);
var directionalClassName = void 0;
var orderClassName = void 0;
var eventDirectionName = void 0;
@@ -855,11 +887,13 @@
this._setActiveIndicatorElement(nextElement);
var slidEvent = $.Event(Event.SLID, {
relatedTarget: nextElement,
- direction: eventDirectionName
+ direction: eventDirectionName,
+ from: activeElementIndex,
+ to: nextElementIndex
});
if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) {
$(nextElement).addClass(orderClassName);
@@ -1000,11 +1034,11 @@
return Carousel;
}(jQuery);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.6): collapse.js
+ * Bootstrap (v4.0.0-beta): collapse.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
var Collapse = function ($) {
@@ -1014,11 +1048,11 @@
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'collapse';
- var VERSION = '4.0.0-alpha.6';
+ var VERSION = '4.0.0-beta';
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;
@@ -1052,28 +1086,36 @@
WIDTH: 'width',
HEIGHT: 'height'
};
var Selector = {
- ACTIVES: '.card > .show, .card > .collapsing',
+ ACTIVES: '.show, .collapsing',
DATA_TOGGLE: '[data-toggle="collapse"]'
- };
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
+ };
var Collapse = function () {
function Collapse(element, config) {
_classCallCheck(this, Collapse);
this._isTransitioning = false;
this._element = element;
this._config = this._getConfig(config);
this._triggerArray = $.makeArray($('[data-toggle="collapse"][href="#' + element.id + '"],' + ('[data-toggle="collapse"][data-target="#' + element.id + '"]')));
+ var tabToggles = $(Selector.DATA_TOGGLE);
+ for (var i = 0; i < tabToggles.length; i++) {
+ var elem = tabToggles[i];
+ var selector = Util.getSelectorFromElement(elem);
+ if (selector !== null && $(selector).filter(element).length > 0) {
+ this._triggerArray.push(elem);
+ }
+ }
this._parent = this._config.parent ? this._getParent() : null;
if (!this._config.parent) {
this._addAriaAndCollapsedClass(this._element, this._triggerArray);
@@ -1097,23 +1139,19 @@
};
Collapse.prototype.show = function show() {
var _this6 = this;
- if (this._isTransitioning) {
- throw new Error('Collapse is transitioning');
- }
-
- if ($(this._element).hasClass(ClassName.SHOW)) {
+ if (this._isTransitioning || $(this._element).hasClass(ClassName.SHOW)) {
return;
}
var actives = void 0;
var activesData = void 0;
if (this._parent) {
- actives = $.makeArray($(this._parent).find(Selector.ACTIVES));
+ actives = $.makeArray($(this._parent).children().children(Selector.ACTIVES));
if (!actives.length) {
actives = null;
}
}
@@ -1140,11 +1178,10 @@
var dimension = this._getDimension();
$(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING);
this._element.style[dimension] = 0;
- this._element.setAttribute('aria-expanded', true);
if (this._triggerArray.length) {
$(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true);
}
@@ -1174,37 +1211,39 @@
};
Collapse.prototype.hide = function hide() {
var _this7 = this;
- if (this._isTransitioning) {
- throw new Error('Collapse is transitioning');
- }
-
- if (!$(this._element).hasClass(ClassName.SHOW)) {
+ if (this._isTransitioning || !$(this._element).hasClass(ClassName.SHOW)) {
return;
}
var startEvent = $.Event(Event.HIDE);
$(this._element).trigger(startEvent);
if (startEvent.isDefaultPrevented()) {
return;
}
var dimension = this._getDimension();
- var offsetDimension = dimension === Dimension.WIDTH ? 'offsetWidth' : 'offsetHeight';
- this._element.style[dimension] = this._element[offsetDimension] + 'px';
+ this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + 'px';
Util.reflow(this._element);
$(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.SHOW);
- this._element.setAttribute('aria-expanded', false);
-
if (this._triggerArray.length) {
- $(this._triggerArray).addClass(ClassName.COLLAPSED).attr('aria-expanded', false);
+ for (var i = 0; i < this._triggerArray.length; i++) {
+ var trigger = this._triggerArray[i];
+ var selector = Util.getSelectorFromElement(trigger);
+ if (selector !== null) {
+ var $elem = $(selector);
+ if (!$elem.hasClass(ClassName.SHOW)) {
+ $(trigger).addClass(ClassName.COLLAPSED).attr('aria-expanded', false);
+ }
+ }
+ }
}
this.setTransitioning(true);
var complete = function complete() {
@@ -1264,11 +1303,10 @@
};
Collapse.prototype._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
if (element) {
var isOpen = $(element).hasClass(ClassName.SHOW);
- element.setAttribute('aria-expanded', isOpen);
if (triggerArray.length) {
$(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
}
}
@@ -1325,17 +1363,22 @@
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
- event.preventDefault();
+ if (!/input|textarea/i.test(event.target.tagName)) {
+ event.preventDefault();
+ }
- var target = Collapse._getTargetFromElement(this);
- var data = $(target).data(DATA_KEY);
- var config = data ? 'toggle' : $(this).data();
-
- Collapse._jQueryInterface.call($(target), config);
+ var $trigger = $(this);
+ var selector = Util.getSelectorFromElement(this);
+ $(selector).each(function () {
+ var $target = $(this);
+ var data = $target.data(DATA_KEY);
+ var config = data ? 'toggle' : $trigger.data();
+ Collapse._jQueryInterface.call($target, config);
+ });
});
/**
* ------------------------------------------------------------------------
* jQuery
@@ -1350,191 +1393,321 @@
};
return Collapse;
}(jQuery);
+/* global Popper */
+
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.6): dropdown.js
+ * Bootstrap (v4.0.0-beta): dropdown.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
var Dropdown = function ($) {
/**
+ * Check for Popper dependency
+ * Popper - https://popper.js.org
+ */
+ if (typeof Popper === 'undefined') {
+ throw new Error('Bootstrap dropdown require Popper.js (https://popper.js.org)');
+ }
+
+ /**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'dropdown';
- var VERSION = '4.0.0-alpha.6';
+ var VERSION = '4.0.0-beta';
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 SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
+ var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab 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 REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + '|' + ARROW_DOWN_KEYCODE + '|' + ESCAPE_KEYCODE);
var Event = {
HIDE: 'hide' + EVENT_KEY,
HIDDEN: 'hidden' + EVENT_KEY,
SHOW: 'show' + EVENT_KEY,
SHOWN: 'shown' + EVENT_KEY,
CLICK: 'click' + EVENT_KEY,
CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY,
- FOCUSIN_DATA_API: 'focusin' + EVENT_KEY + DATA_API_KEY,
- KEYDOWN_DATA_API: 'keydown' + EVENT_KEY + DATA_API_KEY
+ KEYDOWN_DATA_API: 'keydown' + EVENT_KEY + DATA_API_KEY,
+ KEYUP_DATA_API: 'keyup' + EVENT_KEY + DATA_API_KEY
};
var ClassName = {
- BACKDROP: 'dropdown-backdrop',
DISABLED: 'disabled',
- SHOW: 'show'
+ SHOW: 'show',
+ DROPUP: 'dropup',
+ MENURIGHT: 'dropdown-menu-right',
+ MENULEFT: 'dropdown-menu-left'
};
var Selector = {
- BACKDROP: '.dropdown-backdrop',
DATA_TOGGLE: '[data-toggle="dropdown"]',
FORM_CHILD: '.dropdown form',
- ROLE_MENU: '[role="menu"]',
- ROLE_LISTBOX: '[role="listbox"]',
+ MENU: '.dropdown-menu',
NAVBAR_NAV: '.navbar-nav',
- VISIBLE_ITEMS: '[role="menu"] li:not(.disabled) a, ' + '[role="listbox"] li:not(.disabled) a'
+ VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled)'
};
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
+ var AttachmentMap = {
+ TOP: 'top-start',
+ TOPEND: 'top-end',
+ BOTTOM: 'bottom-start',
+ BOTTOMEND: 'bottom-end'
+ };
+ var Default = {
+ placement: AttachmentMap.BOTTOM,
+ offset: 0,
+ flip: true
+ };
+
+ var DefaultType = {
+ placement: 'string',
+ offset: '(number|string)',
+ flip: 'boolean'
+
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
+
+ };
var Dropdown = function () {
- function Dropdown(element) {
+ function Dropdown(element, config) {
_classCallCheck(this, Dropdown);
this._element = element;
+ this._popper = null;
+ this._config = this._getConfig(config);
+ this._menu = this._getMenuElement();
+ this._inNavbar = this._detectNavbar();
this._addEventListeners();
}
// getters
// public
Dropdown.prototype.toggle = function toggle() {
- if (this.disabled || $(this).hasClass(ClassName.DISABLED)) {
- return false;
+ if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED)) {
+ return;
}
- var parent = Dropdown._getParentFromElement(this);
- var isActive = $(parent).hasClass(ClassName.SHOW);
+ var parent = Dropdown._getParentFromElement(this._element);
+ var isActive = $(this._menu).hasClass(ClassName.SHOW);
Dropdown._clearMenus();
if (isActive) {
- return false;
+ return;
}
- if ('ontouchstart' in document.documentElement && !$(parent).closest(Selector.NAVBAR_NAV).length) {
-
- // if mobile we use a backdrop because click events don't delegate
- var dropdown = document.createElement('div');
- dropdown.className = ClassName.BACKDROP;
- $(dropdown).insertBefore(this);
- $(dropdown).on('click', Dropdown._clearMenus);
- }
-
var relatedTarget = {
- relatedTarget: this
+ relatedTarget: this._element
};
var showEvent = $.Event(Event.SHOW, relatedTarget);
$(parent).trigger(showEvent);
if (showEvent.isDefaultPrevented()) {
- return false;
+ return;
}
- this.focus();
- this.setAttribute('aria-expanded', true);
+ var element = this._element;
+ // for dropup with alignment we use the parent as popper container
+ if ($(parent).hasClass(ClassName.DROPUP)) {
+ if ($(this._menu).hasClass(ClassName.MENULEFT) || $(this._menu).hasClass(ClassName.MENURIGHT)) {
+ element = parent;
+ }
+ }
+ this._popper = new Popper(element, this._menu, this._getPopperConfig());
- $(parent).toggleClass(ClassName.SHOW);
- $(parent).trigger($.Event(Event.SHOWN, relatedTarget));
+ // 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 && !$(parent).closest(Selector.NAVBAR_NAV).length) {
+ $('body').children().on('mouseover', null, $.noop);
+ }
- return false;
+ this._element.focus();
+ this._element.setAttribute('aria-expanded', true);
+
+ $(this._menu).toggleClass(ClassName.SHOW);
+ $(parent).toggleClass(ClassName.SHOW).trigger($.Event(Event.SHOWN, relatedTarget));
};
Dropdown.prototype.dispose = function dispose() {
$.removeData(this._element, DATA_KEY);
$(this._element).off(EVENT_KEY);
this._element = null;
+ this._menu = null;
+ if (this._popper !== null) {
+ this._popper.destroy();
+ }
+ this._popper = null;
};
+ Dropdown.prototype.update = function update() {
+ this._inNavbar = this._detectNavbar();
+ if (this._popper !== null) {
+ this._popper.scheduleUpdate();
+ }
+ };
+
// private
Dropdown.prototype._addEventListeners = function _addEventListeners() {
- $(this._element).on(Event.CLICK, this.toggle);
+ var _this9 = this;
+
+ $(this._element).on(Event.CLICK, function (event) {
+ event.preventDefault();
+ event.stopPropagation();
+ _this9.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);
+
+ return config;
+ };
+
+ Dropdown.prototype._getMenuElement = function _getMenuElement() {
+ if (!this._menu) {
+ var parent = Dropdown._getParentFromElement(this._element);
+ this._menu = $(parent).find(Selector.MENU)[0];
+ }
+ return this._menu;
+ };
+
+ Dropdown.prototype._getPlacement = function _getPlacement() {
+ var $parentDropdown = $(this._element).parent();
+ var placement = this._config.placement;
+
+ // Handle dropup
+ if ($parentDropdown.hasClass(ClassName.DROPUP) || this._config.placement === AttachmentMap.TOP) {
+ placement = AttachmentMap.TOP;
+ if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
+ placement = AttachmentMap.TOPEND;
+ }
+ } else if ($(this._menu).hasClass(ClassName.MENURIGHT)) {
+ placement = AttachmentMap.BOTTOMEND;
+ }
+ return placement;
+ };
+
+ Dropdown.prototype._detectNavbar = function _detectNavbar() {
+ return $(this._element).closest('.navbar').length > 0;
+ };
+
+ Dropdown.prototype._getPopperConfig = function _getPopperConfig() {
+ var popperConfig = {
+ placement: this._getPlacement(),
+ modifiers: {
+ offset: {
+ offset: this._config.offset
+ },
+ flip: {
+ enabled: this._config.flip
+ }
+ }
+
+ // Disable Popper.js for Dropdown in Navbar
+ };if (this._inNavbar) {
+ popperConfig.modifiers.applyStyle = {
+ enabled: !this._inNavbar
+ };
+ }
+ return popperConfig;
+ };
+
// static
Dropdown._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY);
+ var _config = (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' ? config : null;
if (!data) {
- data = new Dropdown(this);
+ data = new Dropdown(this, _config);
$(this).data(DATA_KEY, data);
}
if (typeof config === 'string') {
if (data[config] === undefined) {
throw new Error('No method named "' + config + '"');
}
- data[config].call(this);
+ data[config]();
}
});
};
Dropdown._clearMenus = function _clearMenus(event) {
- if (event && event.which === RIGHT_MOUSE_BUTTON_WHICH) {
+ if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
return;
}
- var backdrop = $(Selector.BACKDROP)[0];
- if (backdrop) {
- backdrop.parentNode.removeChild(backdrop);
- }
-
var toggles = $.makeArray($(Selector.DATA_TOGGLE));
-
for (var i = 0; i < toggles.length; i++) {
var parent = Dropdown._getParentFromElement(toggles[i]);
+ var context = $(toggles[i]).data(DATA_KEY);
var relatedTarget = {
relatedTarget: toggles[i]
};
+ if (!context) {
+ continue;
+ }
+
+ var dropdownMenu = context._menu;
if (!$(parent).hasClass(ClassName.SHOW)) {
continue;
}
- if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'focusin') && $.contains(parent, event.target)) {
+ if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
continue;
}
var hideEvent = $.Event(Event.HIDE, relatedTarget);
$(parent).trigger(hideEvent);
if (hideEvent.isDefaultPrevented()) {
continue;
}
+ // 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);
+ }
+
toggles[i].setAttribute('aria-expanded', 'false');
+ $(dropdownMenu).removeClass(ClassName.SHOW);
$(parent).removeClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget));
}
};
Dropdown._getParentFromElement = function _getParentFromElement(element) {
@@ -1547,11 +1720,11 @@
return parent || element.parentNode;
};
Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
- if (!/(38|40|27|32)/.test(event.which) || /input|textarea/i.test(event.target.tagName)) {
+ if (!REGEXP_KEYDOWN.test(event.which) || /button/i.test(event.target.tagName) && event.which === SPACE_KEYCODE || /input|textarea/i.test(event.target.tagName)) {
return;
}
event.preventDefault();
event.stopPropagation();
@@ -1561,11 +1734,11 @@
}
var parent = Dropdown._getParentFromElement(this);
var isActive = $(parent).hasClass(ClassName.SHOW);
- if (!isActive && event.which !== ESCAPE_KEYCODE || isActive && event.which === ESCAPE_KEYCODE) {
+ if (!isActive && (event.which !== ESCAPE_KEYCODE || event.which !== SPACE_KEYCODE) || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
if (event.which === ESCAPE_KEYCODE) {
var toggle = $(parent).find(Selector.DATA_TOGGLE)[0];
$(toggle).trigger('focus');
}
@@ -1602,10 +1775,20 @@
_createClass(Dropdown, null, [{
key: 'VERSION',
get: function get() {
return VERSION;
}
+ }, {
+ key: 'Default',
+ get: function get() {
+ return Default;
+ }
+ }, {
+ key: 'DefaultType',
+ get: function get() {
+ return DefaultType;
+ }
}]);
return Dropdown;
}();
@@ -1613,11 +1796,15 @@
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
- $(document).on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.ROLE_MENU, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.ROLE_LISTBOX, Dropdown._dataApiKeydownHandler).on(Event.CLICK_DATA_API + ' ' + Event.FOCUSIN_DATA_API, Dropdown._clearMenus).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, Dropdown.prototype.toggle).on(Event.CLICK_DATA_API, Selector.FORM_CHILD, function (e) {
+ $(document).on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown._dataApiKeydownHandler).on(Event.CLICK_DATA_API + ' ' + Event.KEYUP_DATA_API, Dropdown._clearMenus).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
+ event.preventDefault();
+ event.stopPropagation();
+ Dropdown._jQueryInterface.call($(this), 'toggle');
+ }).on(Event.CLICK_DATA_API, Selector.FORM_CHILD, function (e) {
e.stopPropagation();
});
/**
* ------------------------------------------------------------------------
@@ -1635,11 +1822,11 @@
return Dropdown;
}(jQuery);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.6): modal.js
+ * Bootstrap (v4.0.0-beta): modal.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
var Modal = function ($) {
@@ -1649,11 +1836,11 @@
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'modal';
- var VERSION = '4.0.0-alpha.6';
+ var VERSION = '4.0.0-beta';
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;
@@ -1698,19 +1885,20 @@
var Selector = {
DIALOG: '.modal-dialog',
DATA_TOGGLE: '[data-toggle="modal"]',
DATA_DISMISS: '[data-dismiss="modal"]',
- FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'
- };
+ FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
+ NAVBAR_TOGGLER: '.navbar-toggler'
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
+ };
var Modal = function () {
function Modal(element, config) {
_classCallCheck(this, Modal);
this._config = this._getConfig(config);
@@ -1718,11 +1906,10 @@
this._dialog = $(element).find(Selector.DIALOG)[0];
this._backdrop = null;
this._isShown = false;
this._isBodyOverflowing = false;
this._ignoreBackdropClick = false;
- this._isTransitioning = false;
this._originalBodyPadding = 0;
this._scrollbarWidth = 0;
}
// getters
@@ -1732,19 +1919,20 @@
Modal.prototype.toggle = function toggle(relatedTarget) {
return this._isShown ? this.hide() : this.show(relatedTarget);
};
Modal.prototype.show = function show(relatedTarget) {
- var _this9 = this;
+ var _this10 = this;
if (this._isTransitioning) {
- throw new Error('Modal is transitioning');
+ return;
}
if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) {
this._isTransitioning = true;
}
+
var showEvent = $.Event(Event.SHOW, {
relatedTarget: relatedTarget
});
$(this._element).trigger(showEvent);
@@ -1762,43 +1950,45 @@
this._setEscapeEvent();
this._setResizeEvent();
$(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, function (event) {
- return _this9.hide(event);
+ return _this10.hide(event);
});
$(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () {
- $(_this9._element).one(Event.MOUSEUP_DISMISS, function (event) {
- if ($(event.target).is(_this9._element)) {
- _this9._ignoreBackdropClick = true;
+ $(_this10._element).one(Event.MOUSEUP_DISMISS, function (event) {
+ if ($(event.target).is(_this10._element)) {
+ _this10._ignoreBackdropClick = true;
}
});
});
this._showBackdrop(function () {
- return _this9._showElement(relatedTarget);
+ return _this10._showElement(relatedTarget);
});
};
Modal.prototype.hide = function hide(event) {
- var _this10 = this;
+ var _this11 = this;
if (event) {
event.preventDefault();
}
- if (this._isTransitioning) {
- throw new Error('Modal is transitioning');
+ if (this._isTransitioning || !this._isShown) {
+ return;
}
var transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE);
+
if (transition) {
this._isTransitioning = true;
}
var hideEvent = $.Event(Event.HIDE);
+
$(this._element).trigger(hideEvent);
if (!this._isShown || hideEvent.isDefaultPrevented()) {
return;
}
@@ -1814,12 +2004,13 @@
$(this._element).off(Event.CLICK_DISMISS);
$(this._dialog).off(Event.MOUSEDOWN_DISMISS);
if (transition) {
+
$(this._element).one(Util.TRANSITION_END, function (event) {
- return _this10._hideModal(event);
+ return _this11._hideModal(event);
}).emulateTransitionEnd(TRANSITION_DURATION);
} else {
this._hideModal();
}
};
@@ -1834,24 +2025,27 @@
this._dialog = null;
this._backdrop = null;
this._isShown = null;
this._isBodyOverflowing = null;
this._ignoreBackdropClick = null;
- this._originalBodyPadding = null;
this._scrollbarWidth = null;
};
+ Modal.prototype.handleUpdate = function handleUpdate() {
+ this._adjustDialog();
+ };
+
// private
Modal.prototype._getConfig = function _getConfig(config) {
config = $.extend({}, Default, config);
Util.typeCheckConfig(NAME, config, DefaultType);
return config;
};
Modal.prototype._showElement = function _showElement(relatedTarget) {
- var _this11 = this;
+ var _this12 = this;
var transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE);
if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
// don't move modals dom position
@@ -1875,72 +2069,73 @@
var shownEvent = $.Event(Event.SHOWN, {
relatedTarget: relatedTarget
});
var transitionComplete = function transitionComplete() {
- if (_this11._config.focus) {
- _this11._element.focus();
+ if (_this12._config.focus) {
+ _this12._element.focus();
}
- _this11._isTransitioning = false;
- $(_this11._element).trigger(shownEvent);
+ _this12._isTransitioning = false;
+ $(_this12._element).trigger(shownEvent);
};
if (transition) {
$(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(TRANSITION_DURATION);
} else {
transitionComplete();
}
};
Modal.prototype._enforceFocus = function _enforceFocus() {
- var _this12 = this;
+ var _this13 = this;
$(document).off(Event.FOCUSIN) // guard against infinite focus loop
.on(Event.FOCUSIN, function (event) {
- if (document !== event.target && _this12._element !== event.target && !$(_this12._element).has(event.target).length) {
- _this12._element.focus();
+ if (document !== event.target && _this13._element !== event.target && !$(_this13._element).has(event.target).length) {
+ _this13._element.focus();
}
});
};
Modal.prototype._setEscapeEvent = function _setEscapeEvent() {
- var _this13 = this;
+ var _this14 = this;
if (this._isShown && this._config.keyboard) {
$(this._element).on(Event.KEYDOWN_DISMISS, function (event) {
if (event.which === ESCAPE_KEYCODE) {
- _this13.hide();
+ event.preventDefault();
+ _this14.hide();
}
});
} else if (!this._isShown) {
$(this._element).off(Event.KEYDOWN_DISMISS);
}
};
Modal.prototype._setResizeEvent = function _setResizeEvent() {
- var _this14 = this;
+ var _this15 = this;
if (this._isShown) {
$(window).on(Event.RESIZE, function (event) {
- return _this14._handleUpdate(event);
+ return _this15.handleUpdate(event);
});
} else {
$(window).off(Event.RESIZE);
}
};
Modal.prototype._hideModal = function _hideModal() {
- var _this15 = this;
+ var _this16 = this;
this._element.style.display = 'none';
- this._element.setAttribute('aria-hidden', 'true');
+ this._element.setAttribute('aria-hidden', true);
this._isTransitioning = false;
this._showBackdrop(function () {
$(document.body).removeClass(ClassName.OPEN);
- _this15._resetAdjustments();
- _this15._resetScrollbar();
- $(_this15._element).trigger(Event.HIDDEN);
+ _this16._resetAdjustments();
+ _this16._resetScrollbar();
+ $(_this16._element).trigger(Event.HIDDEN);
});
};
Modal.prototype._removeBackdrop = function _removeBackdrop() {
if (this._backdrop) {
@@ -1948,11 +2143,11 @@
this._backdrop = null;
}
};
Modal.prototype._showBackdrop = function _showBackdrop(callback) {
- var _this16 = this;
+ var _this17 = this;
var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : '';
if (this._isShown && this._config.backdrop) {
var doAnimate = Util.supportsTransitionEnd() && animate;
@@ -1965,21 +2160,21 @@
}
$(this._backdrop).appendTo(document.body);
$(this._element).on(Event.CLICK_DISMISS, function (event) {
- if (_this16._ignoreBackdropClick) {
- _this16._ignoreBackdropClick = false;
+ if (_this17._ignoreBackdropClick) {
+ _this17._ignoreBackdropClick = false;
return;
}
if (event.target !== event.currentTarget) {
return;
}
- if (_this16._config.backdrop === 'static') {
- _this16._element.focus();
+ if (_this17._config.backdrop === 'static') {
+ _this17._element.focus();
} else {
- _this16.hide();
+ _this17.hide();
}
});
if (doAnimate) {
Util.reflow(this._backdrop);
@@ -1999,11 +2194,11 @@
$(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION);
} else if (!this._isShown && this._backdrop) {
$(this._backdrop).removeClass(ClassName.SHOW);
var callbackRemove = function callbackRemove() {
- _this16._removeBackdrop();
+ _this17._removeBackdrop();
if (callback) {
callback();
}
};
@@ -2020,14 +2215,10 @@
// ----------------------------------------------------------------------
// the following methods are used to handle overflowing modals
// todo (fat): these should probably be refactored out of modal.js
// ----------------------------------------------------------------------
- Modal.prototype._handleUpdate = function _handleUpdate() {
- this._adjustDialog();
- };
-
Modal.prototype._adjustDialog = function _adjustDialog() {
var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
if (!this._isBodyOverflowing && isModalOverflowing) {
this._element.style.paddingLeft = this._scrollbarWidth + 'px';
@@ -2047,29 +2238,67 @@
this._isBodyOverflowing = document.body.clientWidth < window.innerWidth;
this._scrollbarWidth = this._getScrollbarWidth();
};
Modal.prototype._setScrollbar = function _setScrollbar() {
- var bodyPadding = parseInt($(Selector.FIXED_CONTENT).css('padding-right') || 0, 10);
+ var _this18 = this;
- this._originalBodyPadding = document.body.style.paddingRight || '';
-
if (this._isBodyOverflowing) {
- document.body.style.paddingRight = bodyPadding + this._scrollbarWidth + 'px';
+ // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
+ // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
+
+ // Adjust fixed content padding
+ $(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');
+ });
+
+ // 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');
+ });
+
+ // Adjust body padding
+ var actualPadding = document.body.style.paddingRight;
+ var calculatedPadding = $('body').css('padding-right');
+ $('body').data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + 'px');
}
};
Modal.prototype._resetScrollbar = function _resetScrollbar() {
- document.body.style.paddingRight = this._originalBodyPadding;
+ // Restore fixed content padding
+ $(Selector.FIXED_CONTENT).each(function (index, element) {
+ var padding = $(element).data('padding-right');
+ if (typeof padding !== 'undefined') {
+ $(element).css('padding-right', padding).removeData('padding-right');
+ }
+ });
+
+ // Restore navbar-toggler margin
+ $(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');
+ }
+ });
+
+ // Restore body padding
+ var padding = $('body').data('padding-right');
+ if (typeof padding !== 'undefined') {
+ $('body').css('padding-right', padding).removeData('padding-right');
+ }
};
Modal.prototype._getScrollbarWidth = function _getScrollbarWidth() {
// thx d.walsh
var scrollDiv = document.createElement('div');
scrollDiv.className = ClassName.SCROLLBAR_MEASURER;
document.body.appendChild(scrollDiv);
- var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
+ var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
return scrollbarWidth;
};
// static
@@ -2115,11 +2344,11 @@
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
- var _this17 = this;
+ var _this19 = this;
var target = void 0;
var selector = Util.getSelectorFromElement(this);
if (selector) {
@@ -2137,12 +2366,12 @@
// only register focus restorer if modal will actually get shown
return;
}
$target.one(Event.HIDDEN, function () {
- if ($(_this17).is(':visible')) {
- _this17.focus();
+ if ($(_this19).is(':visible')) {
+ _this19.focus();
}
});
});
Modal._jQueryInterface.call($(target), config, this);
@@ -2164,11 +2393,11 @@
return Modal;
}(jQuery);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.6): scrollspy.js
+ * Bootstrap (v4.0.0-beta): scrollspy.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
var ScrollSpy = function ($) {
@@ -2178,11 +2407,11 @@
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'scrollspy';
- var VERSION = '4.0.0-alpha.6';
+ var VERSION = '4.0.0-beta';
var DATA_KEY = 'bs.scrollspy';
var EVENT_KEY = '.' + DATA_KEY;
var DATA_API_KEY = '.data-api';
var JQUERY_NO_CONFLICT = $.fn[NAME];
@@ -2205,55 +2434,52 @@
};
var ClassName = {
DROPDOWN_ITEM: 'dropdown-item',
DROPDOWN_MENU: 'dropdown-menu',
- NAV_LINK: 'nav-link',
- NAV: 'nav',
ACTIVE: 'active'
};
var Selector = {
DATA_SPY: '[data-spy="scroll"]',
ACTIVE: '.active',
- LIST_ITEM: '.list-item',
- LI: 'li',
- LI_DROPDOWN: 'li.dropdown',
+ 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'
};
var OffsetMethod = {
OFFSET: 'offset',
POSITION: 'position'
- };
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
+ };
var ScrollSpy = function () {
function ScrollSpy(element, config) {
- var _this18 = this;
+ var _this20 = this;
_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.DROPDOWN_ITEMS);
+ 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;
$(this._scrollElement).on(Event.SCROLL, function (event) {
- return _this18._process(event);
+ return _this20._process(event);
});
this.refresh();
this._process();
}
@@ -2261,11 +2487,11 @@
// getters
// public
ScrollSpy.prototype.refresh = function refresh() {
- var _this19 = this;
+ var _this21 = this;
var autoMethod = this._scrollElement !== this._scrollElement.window ? OffsetMethod.POSITION : OffsetMethod.OFFSET;
var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
@@ -2284,22 +2510,25 @@
if (targetSelector) {
target = $(targetSelector)[0];
}
- if (target && (target.offsetWidth || target.offsetHeight)) {
- // todo (fat): remove sketch reliance on jQuery position/offset
- return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
+ 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];
+ }
}
return null;
}).filter(function (item) {
return item;
}).sort(function (a, b) {
return a[0] - b[0];
}).forEach(function (item) {
- _this19._offsets.push(item[0]);
- _this19._targets.push(item[1]);
+ _this21._offsets.push(item[0]);
+ _this21._targets.push(item[1]);
});
};
ScrollSpy.prototype.dispose = function dispose() {
$.removeData(this._element, DATA_KEY);
@@ -2341,11 +2570,11 @@
ScrollSpy.prototype._getScrollHeight = function _getScrollHeight() {
return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
};
ScrollSpy.prototype._getOffsetHeight = function _getOffsetHeight() {
- return this._scrollElement === window ? window.innerHeight : this._scrollElement.offsetHeight;
+ return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
};
ScrollSpy.prototype._process = function _process() {
var scrollTop = this._getScrollTop() + this._config.offset;
var scrollHeight = this._getScrollHeight();
@@ -2393,13 +2622,15 @@
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...
- // recursively add actives to tested nav-links
- $link.parents(Selector.LI).find('> ' + Selector.NAV_LINKS).addClass(ClassName.ACTIVE);
+ // Set triggered link as active
+ $link.addClass(ClassName.ACTIVE);
+ // Set triggered links parents as active
+ // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
+ $link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_LINKS + ', ' + Selector.LIST_ITEMS).addClass(ClassName.ACTIVE);
}
$(this._scrollElement).trigger(Event.ACTIVATE, {
relatedTarget: target
});
@@ -2476,11 +2707,11 @@
return ScrollSpy;
}(jQuery);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.6): tab.js
+ * Bootstrap (v4.0.0-beta): tab.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
var Tab = function ($) {
@@ -2490,11 +2721,11 @@
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'tab';
- var VERSION = '4.0.0-alpha.6';
+ var VERSION = '4.0.0-beta';
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;
@@ -2514,28 +2745,24 @@
FADE: 'fade',
SHOW: 'show'
};
var Selector = {
- A: 'a',
- LI: 'li',
DROPDOWN: '.dropdown',
- LIST: 'ul:not(.dropdown-menu), ol:not(.dropdown-menu), nav:not(.dropdown-menu)',
- FADE_CHILD: '> .nav-item .fade, > .fade',
+ NAV_LIST_GROUP: '.nav, .list-group',
ACTIVE: '.active',
- ACTIVE_CHILD: '> .nav-item > .active, > .active',
- DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"]',
+ DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
DROPDOWN_TOGGLE: '.dropdown-toggle',
DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
- };
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
+ };
var Tab = function () {
function Tab(element) {
_classCallCheck(this, Tab);
this._element = element;
@@ -2544,19 +2771,19 @@
// getters
// public
Tab.prototype.show = function show() {
- var _this20 = this;
+ var _this22 = this;
if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName.ACTIVE) || $(this._element).hasClass(ClassName.DISABLED)) {
return;
}
var target = void 0;
var previous = void 0;
- var listElement = $(this._element).closest(Selector.LIST)[0];
+ var listElement = $(this._element).closest(Selector.NAV_LIST_GROUP)[0];
var selector = Util.getSelectorFromElement(this._element);
if (listElement) {
previous = $.makeArray($(listElement).find(Selector.ACTIVE));
previous = previous[previous.length - 1];
@@ -2586,43 +2813,43 @@
this._activate(this._element, listElement);
var complete = function complete() {
var hiddenEvent = $.Event(Event.HIDDEN, {
- relatedTarget: _this20._element
+ relatedTarget: _this22._element
});
var shownEvent = $.Event(Event.SHOWN, {
relatedTarget: previous
});
$(previous).trigger(hiddenEvent);
- $(_this20._element).trigger(shownEvent);
+ $(_this22._element).trigger(shownEvent);
};
if (target) {
this._activate(target, target.parentNode, complete);
} else {
complete();
}
};
Tab.prototype.dispose = function dispose() {
- $.removeClass(this._element, DATA_KEY);
+ $.removeData(this._element, DATA_KEY);
this._element = null;
};
// private
Tab.prototype._activate = function _activate(element, container, callback) {
- var _this21 = this;
+ var _this23 = this;
- var active = $(container).find(Selector.ACTIVE_CHILD)[0];
- var isTransitioning = callback && Util.supportsTransitionEnd() && (active && $(active).hasClass(ClassName.FADE) || Boolean($(container).find(Selector.FADE_CHILD)[0]));
+ var active = $(container).find(Selector.ACTIVE)[0];
+ var isTransitioning = callback && Util.supportsTransitionEnd() && active && $(active).hasClass(ClassName.FADE);
var complete = function complete() {
- return _this21._transitionComplete(element, active, isTransitioning, callback);
+ return _this23._transitionComplete(element, active, isTransitioning, callback);
};
if (active && isTransitioning) {
$(active).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
} else {
@@ -2728,78 +2955,80 @@
};
return Tab;
}(jQuery);
-/* global Tether */
+/* global Popper */
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.6): tooltip.js
+ * Bootstrap (v4.0.0-beta): tooltip.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
var Tooltip = function ($) {
/**
- * Check for Tether dependency
- * Tether - http://tether.io/
+ * Check for Popper dependency
+ * Popper - https://popper.js.org
*/
- if (typeof Tether === 'undefined') {
- throw new Error('Bootstrap tooltips require Tether (http://tether.io/)');
+ if (typeof Popper === 'undefined') {
+ throw new Error('Bootstrap tooltips require Popper.js (https://popper.js.org)');
}
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'tooltip';
- var VERSION = '4.0.0-alpha.6';
+ var VERSION = '4.0.0-beta';
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';
+ var CLASS_PREFIX = 'bs-tooltip';
+ var BSCLS_PREFIX_REGEX = new RegExp('(^|\\s)' + CLASS_PREFIX + '\\S+', 'g');
- var Default = {
- animation: true,
- template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-inner"></div></div>',
- trigger: 'hover focus',
- title: '',
- delay: 0,
- html: false,
- selector: false,
- placement: 'top',
- offset: '0 0',
- constraints: [],
- container: false
- };
-
var DefaultType = {
animation: 'boolean',
template: 'string',
title: '(string|element|function)',
trigger: 'string',
delay: '(number|object)',
html: 'boolean',
selector: '(string|boolean)',
placement: '(string|function)',
- offset: 'string',
- constraints: 'array',
- container: '(string|element|boolean)'
+ offset: '(number|string)',
+ container: '(string|element|boolean)',
+ fallbackPlacement: '(string|array)'
};
var AttachmentMap = {
- TOP: 'bottom center',
- RIGHT: 'middle left',
- BOTTOM: 'top center',
- LEFT: 'middle right'
+ AUTO: 'auto',
+ TOP: 'top',
+ RIGHT: 'right',
+ BOTTOM: 'bottom',
+ LEFT: 'left'
};
+ var Default = {
+ animation: true,
+ template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
+ trigger: 'hover focus',
+ title: '',
+ delay: 0,
+ html: false,
+ selector: false,
+ placement: 'top',
+ offset: 0,
+ container: false,
+ fallbackPlacement: 'flip'
+ };
+
var HoverState = {
SHOW: 'show',
OUT: 'out'
};
@@ -2821,42 +3050,37 @@
SHOW: 'show'
};
var Selector = {
TOOLTIP: '.tooltip',
- TOOLTIP_INNER: '.tooltip-inner'
+ TOOLTIP_INNER: '.tooltip-inner',
+ ARROW: '.arrow'
};
- var TetherClass = {
- element: false,
- enabled: false
- };
-
var Trigger = {
HOVER: 'hover',
FOCUS: 'focus',
CLICK: 'click',
MANUAL: 'manual'
- };
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
+ };
var Tooltip = function () {
function Tooltip(element, config) {
_classCallCheck(this, Tooltip);
// private
this._isEnabled = true;
this._timeout = 0;
this._hoverState = '';
this._activeTrigger = {};
- this._isTransitioning = false;
- this._tether = null;
+ this._popper = null;
// protected
this.element = element;
this.config = this._getConfig(config);
this.tip = null;
@@ -2909,12 +3133,10 @@
};
Tooltip.prototype.dispose = function dispose() {
clearTimeout(this._timeout);
- this.cleanupTether();
-
$.removeData(this.element, this.constructor.DATA_KEY);
$(this.element).off(this.constructor.EVENT_KEY);
$(this.element).closest('.modal').off('hide.bs.modal');
@@ -2924,29 +3146,29 @@
this._isEnabled = null;
this._timeout = null;
this._hoverState = null;
this._activeTrigger = null;
- this._tether = null;
+ if (this._popper !== null) {
+ this._popper.destroy();
+ }
+ this._popper = null;
this.element = null;
this.config = null;
this.tip = null;
};
Tooltip.prototype.show = function show() {
- var _this22 = this;
+ var _this24 = this;
if ($(this.element).css('display') === 'none') {
throw new Error('Please use show on visible elements');
}
var showEvent = $.Event(this.constructor.Event.SHOW);
if (this.isWithContent() && this._isEnabled) {
- if (this._isTransitioning) {
- throw new Error('Tooltip is transitioning');
- }
$(this.element).trigger(showEvent);
var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element);
if (showEvent.isDefaultPrevented() || !isInTheDom) {
@@ -2966,72 +3188,93 @@
}
var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
var attachment = this._getAttachment(placement);
+ this.addAttachmentClass(attachment);
var container = this.config.container === false ? document.body : $(this.config.container);
- $(tip).data(this.constructor.DATA_KEY, this).appendTo(container);
+ $(tip).data(this.constructor.DATA_KEY, this);
+ if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
+ $(tip).appendTo(container);
+ }
+
$(this.element).trigger(this.constructor.Event.INSERTED);
- this._tether = new Tether({
- attachment: attachment,
- element: tip,
- target: this.element,
- classes: TetherClass,
- classPrefix: CLASS_PREFIX,
- offset: this.config.offset,
- constraints: this.config.constraints,
- addTargetClasses: false
+ 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) {
+ _this24._handlePopperPlacementChange(data);
+ }
+ },
+ onUpdate: function onUpdate(data) {
+ _this24._handlePopperPlacementChange(data);
+ }
});
- Util.reflow(tip);
- this._tether.position();
-
$(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 = _this22._hoverState;
- _this22._hoverState = null;
- _this22._isTransitioning = false;
+ if (_this24.config.animation) {
+ _this24._fixTransition();
+ }
+ var prevHoverState = _this24._hoverState;
+ _this24._hoverState = null;
- $(_this22.element).trigger(_this22.constructor.Event.SHOWN);
+ $(_this24.element).trigger(_this24.constructor.Event.SHOWN);
if (prevHoverState === HoverState.OUT) {
- _this22._leave(null, _this22);
+ _this24._leave(null, _this24);
}
};
if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
- this._isTransitioning = true;
$(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION);
- return;
+ } else {
+ complete();
}
-
- complete();
}
};
Tooltip.prototype.hide = function hide(callback) {
- var _this23 = this;
+ var _this25 = this;
var tip = this.getTipElement();
var hideEvent = $.Event(this.constructor.Event.HIDE);
- if (this._isTransitioning) {
- throw new Error('Tooltip is transitioning');
- }
var complete = function complete() {
- if (_this23._hoverState !== HoverState.SHOW && tip.parentNode) {
+ if (_this25._hoverState !== HoverState.SHOW && tip.parentNode) {
tip.parentNode.removeChild(tip);
}
- _this23.element.removeAttribute('aria-describedby');
- $(_this23.element).trigger(_this23.constructor.Event.HIDDEN);
- _this23._isTransitioning = false;
- _this23.cleanupTether();
+ _this25._cleanTipClass();
+ _this25.element.removeAttribute('aria-describedby');
+ $(_this25.element).trigger(_this25.constructor.Event.HIDDEN);
+ if (_this25._popper !== null) {
+ _this25._popper.destroy();
+ }
if (callback) {
callback();
}
};
@@ -3042,42 +3285,54 @@
return;
}
$(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;
if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
- this._isTransitioning = true;
+
$(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
} else {
complete();
}
this._hoverState = '';
};
+ Tooltip.prototype.update = function update() {
+ if (this._popper !== null) {
+ this._popper.scheduleUpdate();
+ }
+ };
+
// protected
Tooltip.prototype.isWithContent = function isWithContent() {
return Boolean(this.getTitle());
};
+ Tooltip.prototype.addAttachmentClass = function addAttachmentClass(attachment) {
+ $(this.getTipElement()).addClass(CLASS_PREFIX + '-' + attachment);
+ };
+
Tooltip.prototype.getTipElement = function getTipElement() {
return this.tip = this.tip || $(this.config.template)[0];
};
Tooltip.prototype.setContent = function setContent() {
var $tip = $(this.getTipElement());
-
this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle());
-
$tip.removeClass(ClassName.FADE + ' ' + ClassName.SHOW);
-
- this.cleanupTether();
};
Tooltip.prototype.setElementContent = function setElementContent($element, content) {
var html = this.config.html;
if ((typeof content === 'undefined' ? 'undefined' : _typeof(content)) === 'object' && (content.nodeType || content.jquery)) {
@@ -3102,45 +3357,39 @@
}
return title;
};
- Tooltip.prototype.cleanupTether = function cleanupTether() {
- if (this._tether) {
- this._tether.destroy();
- }
- };
-
// private
Tooltip.prototype._getAttachment = function _getAttachment(placement) {
return AttachmentMap[placement.toUpperCase()];
};
Tooltip.prototype._setListeners = function _setListeners() {
- var _this24 = this;
+ var _this26 = this;
var triggers = this.config.trigger.split(' ');
triggers.forEach(function (trigger) {
if (trigger === 'click') {
- $(_this24.element).on(_this24.constructor.Event.CLICK, _this24.config.selector, function (event) {
- return _this24.toggle(event);
+ $(_this26.element).on(_this26.constructor.Event.CLICK, _this26.config.selector, function (event) {
+ return _this26.toggle(event);
});
} else if (trigger !== Trigger.MANUAL) {
- var eventIn = trigger === Trigger.HOVER ? _this24.constructor.Event.MOUSEENTER : _this24.constructor.Event.FOCUSIN;
- var eventOut = trigger === Trigger.HOVER ? _this24.constructor.Event.MOUSELEAVE : _this24.constructor.Event.FOCUSOUT;
+ var eventIn = trigger === Trigger.HOVER ? _this26.constructor.Event.MOUSEENTER : _this26.constructor.Event.FOCUSIN;
+ var eventOut = trigger === Trigger.HOVER ? _this26.constructor.Event.MOUSELEAVE : _this26.constructor.Event.FOCUSOUT;
- $(_this24.element).on(eventIn, _this24.config.selector, function (event) {
- return _this24._enter(event);
- }).on(eventOut, _this24.config.selector, function (event) {
- return _this24._leave(event);
+ $(_this26.element).on(eventIn, _this26.config.selector, function (event) {
+ return _this26._enter(event);
+ }).on(eventOut, _this26.config.selector, function (event) {
+ return _this26._leave(event);
});
}
- $(_this24.element).closest('.modal').on('hide.bs.modal', function () {
- return _this24.hide();
+ $(_this26.element).closest('.modal').on('hide.bs.modal', function () {
+ return _this26.hide();
});
});
if (this.config.selector) {
this.config = $.extend({}, this.config, {
@@ -3247,10 +3496,18 @@
show: config.delay,
hide: config.delay
};
}
+ if (config.title && typeof config.title === 'number') {
+ config.title = config.title.toString();
+ }
+
+ if (config.content && typeof config.content === 'number') {
+ config.content = config.content.toString();
+ }
+
Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
return config;
};
@@ -3266,10 +3523,36 @@
}
return config;
};
+ Tooltip.prototype._cleanTipClass = function _cleanTipClass() {
+ var $tip = $(this.getTipElement());
+ var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
+ if (tabClass !== null && tabClass.length > 0) {
+ $tip.removeClass(tabClass.join(''));
+ }
+ };
+
+ Tooltip.prototype._handlePopperPlacementChange = function _handlePopperPlacementChange(data) {
+ this._cleanTipClass();
+ this.addAttachmentClass(this._getAttachment(data.placement));
+ };
+
+ Tooltip.prototype._fixTransition = function _fixTransition() {
+ var tip = this.getTipElement();
+ var initConfigAnimation = this.config.animation;
+ if (tip.getAttribute('x-placement') !== null) {
+ return;
+ }
+ $(tip).removeClass(ClassName.FADE);
+ this.config.animation = false;
+ this.hide();
+ this.show();
+ this.config.animation = initConfigAnimation;
+ };
+
// static
Tooltip._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY);
@@ -3349,11 +3632,11 @@
return Tooltip;
}(jQuery);
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.6): popover.js
+ * Bootstrap (v4.0.0-beta): popover.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
var Popover = function ($) {
@@ -3363,20 +3646,22 @@
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'popover';
- var VERSION = '4.0.0-alpha.6';
+ var VERSION = '4.0.0-beta';
var DATA_KEY = 'bs.popover';
var EVENT_KEY = '.' + DATA_KEY;
var JQUERY_NO_CONFLICT = $.fn[NAME];
+ var CLASS_PREFIX = 'bs-popover';
+ var BSCLS_PREFIX_REGEX = new RegExp('(^|\\s)' + CLASS_PREFIX + '\\S+', 'g');
var Default = $.extend({}, Tooltip.Default, {
placement: 'right',
trigger: 'click',
content: '',
- template: '<div class="popover" role="tooltip">' + '<h3 class="popover-title"></h3>' + '<div class="popover-content"></div></div>'
+ template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
});
var DefaultType = $.extend({}, Tooltip.DefaultType, {
content: '(string|element|function)'
});
@@ -3385,12 +3670,12 @@
FADE: 'fade',
SHOW: 'show'
};
var Selector = {
- TITLE: '.popover-title',
- CONTENT: '.popover-content'
+ TITLE: '.popover-header',
+ CONTENT: '.popover-body'
};
var Event = {
HIDE: 'hide' + EVENT_KEY,
HIDDEN: 'hidden' + EVENT_KEY,
@@ -3400,18 +3685,18 @@
CLICK: 'click' + EVENT_KEY,
FOCUSIN: 'focusin' + EVENT_KEY,
FOCUSOUT: 'focusout' + EVENT_KEY,
MOUSEENTER: 'mouseenter' + EVENT_KEY,
MOUSELEAVE: 'mouseleave' + EVENT_KEY
- };
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
+ };
var Popover = function (_Tooltip) {
_inherits(Popover, _Tooltip);
function Popover() {
_classCallCheck(this, Popover);
@@ -3423,10 +3708,14 @@
Popover.prototype.isWithContent = function isWithContent() {
return this.getTitle() || this._getContent();
};
+ Popover.prototype.addAttachmentClass = function addAttachmentClass(attachment) {
+ $(this.getTipElement()).addClass(CLASS_PREFIX + '-' + attachment);
+ };
+
Popover.prototype.getTipElement = function getTipElement() {
return this.tip = this.tip || $(this.config.template)[0];
};
Popover.prototype.setContent = function setContent() {
@@ -3435,20 +3724,26 @@
// we use append for html objects to maintain js events
this.setElementContent($tip.find(Selector.TITLE), this.getTitle());
this.setElementContent($tip.find(Selector.CONTENT), this._getContent());
$tip.removeClass(ClassName.FADE + ' ' + ClassName.SHOW);
-
- this.cleanupTether();
};
// private
Popover.prototype._getContent = function _getContent() {
return this.element.getAttribute('data-content') || (typeof this.config.content === 'function' ? this.config.content.call(this.element) : this.config.content);
};
+ Popover.prototype._cleanTipClass = function _cleanTipClass() {
+ var $tip = $(this.getTipElement());
+ var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
+ if (tabClass !== null && tabClass.length > 0) {
+ $tip.removeClass(tabClass.join(''));
+ }
+ };
+
// static
Popover._jQueryInterface = function _jQueryInterface(config) {
return this.each(function () {
var data = $(this).data(DATA_KEY);
@@ -3530,6 +3825,7 @@
};
return Popover;
}(jQuery);
-}();
+
+})();
\ No newline at end of file