mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-12 00:24:03 +02:00
build
This commit is contained in:
3
js/dist/button.js
vendored
3
js/dist/button.js
vendored
@@ -82,6 +82,9 @@ var Button = function ($) {
|
||||
}
|
||||
|
||||
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');
|
||||
}
|
||||
|
2
js/dist/button.js.map
vendored
2
js/dist/button.js.map
vendored
File diff suppressed because one or more lines are too long
16
js/dist/collapse.js
vendored
16
js/dist/collapse.js
vendored
@@ -58,9 +58,8 @@ var Collapse = function ($) {
|
||||
};
|
||||
|
||||
var Selector = {
|
||||
ACTIVES: '.card > .show, .card > .collapsing',
|
||||
DATA_TOGGLE: '[data-toggle="collapse"]',
|
||||
DATA_CHILDREN: 'data-children'
|
||||
ACTIVES: '.show, .collapsing',
|
||||
DATA_TOGGLE: '[data-toggle="collapse"]'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -77,20 +76,13 @@ var Collapse = function ($) {
|
||||
this._element = element;
|
||||
this._config = this._getConfig(config);
|
||||
this._triggerArray = $.makeArray($('[data-toggle="collapse"][href="#' + element.id + '"],' + ('[data-toggle="collapse"][data-target="#' + element.id + '"]')));
|
||||
|
||||
this._parent = this._config.parent ? this._getParent() : null;
|
||||
|
||||
if (!this._config.parent) {
|
||||
this._addAriaAndCollapsedClass(this._element, this._triggerArray);
|
||||
}
|
||||
|
||||
this._selectorActives = Selector.ACTIVES;
|
||||
if (this._parent) {
|
||||
var childrenSelector = this._parent.hasAttribute(Selector.DATA_CHILDREN) ? this._parent.getAttribute(Selector.DATA_CHILDREN) : null;
|
||||
if (childrenSelector !== null) {
|
||||
this._selectorActives = childrenSelector + ' > .show, ' + childrenSelector + ' > .collapsing';
|
||||
}
|
||||
}
|
||||
|
||||
if (this._config.toggle) {
|
||||
this.toggle();
|
||||
}
|
||||
@@ -119,7 +111,7 @@ var Collapse = function ($) {
|
||||
var activesData = void 0;
|
||||
|
||||
if (this._parent) {
|
||||
actives = $.makeArray($(this._parent).find(this._selectorActives));
|
||||
actives = $.makeArray($(this._parent).children().children(Selector.ACTIVES));
|
||||
if (!actives.length) {
|
||||
actives = null;
|
||||
}
|
||||
|
2
js/dist/collapse.js.map
vendored
2
js/dist/collapse.js.map
vendored
File diff suppressed because one or more lines are too long
141
js/dist/dropdown.js
vendored
141
js/dist/dropdown.js
vendored
@@ -1,3 +1,5 @@
|
||||
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
@@ -11,6 +13,14 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
||||
|
||||
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
|
||||
@@ -55,6 +65,23 @@ var Dropdown = function ($) {
|
||||
VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled)'
|
||||
};
|
||||
|
||||
var AttachmentMap = {
|
||||
TOP: 'top-start',
|
||||
BOTTOM: 'bottom-start'
|
||||
};
|
||||
|
||||
var Default = {
|
||||
placement: AttachmentMap.BOTTOM,
|
||||
offset: 0,
|
||||
flip: true
|
||||
};
|
||||
|
||||
var DefaultType = {
|
||||
placement: 'string',
|
||||
offset: '(number|string)',
|
||||
flip: 'boolean'
|
||||
};
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Class Definition
|
||||
@@ -62,10 +89,13 @@ var Dropdown = function ($) {
|
||||
*/
|
||||
|
||||
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._addEventListeners();
|
||||
}
|
||||
@@ -75,30 +105,44 @@ var Dropdown = function ($) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
var relatedTarget = {
|
||||
relatedTarget: this
|
||||
relatedTarget: this._element
|
||||
};
|
||||
var showEvent = $.Event(Event.SHOW, relatedTarget);
|
||||
|
||||
$(parent).trigger(showEvent);
|
||||
|
||||
if (showEvent.isDefaultPrevented()) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle dropup
|
||||
var dropdownPlacement = $(this._element).parent().hasClass('dropup') ? AttachmentMap.TOP : this._config.placement;
|
||||
this._popper = new Popper(this._element, this._menu, {
|
||||
placement: dropdownPlacement,
|
||||
modifiers: {
|
||||
offset: {
|
||||
offset: this._config.offset
|
||||
},
|
||||
flip: {
|
||||
enabled: this._config.flip
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 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
|
||||
@@ -107,25 +151,61 @@ var Dropdown = function ($) {
|
||||
$('body').children().on('mouseover', null, $.noop);
|
||||
}
|
||||
|
||||
this.focus();
|
||||
this.setAttribute('aria-expanded', true);
|
||||
this._element.focus();
|
||||
this._element.setAttribute('aria-expanded', true);
|
||||
|
||||
$(parent).toggleClass(ClassName.SHOW);
|
||||
$(parent).trigger($.Event(Event.SHOWN, relatedTarget));
|
||||
|
||||
return false;
|
||||
$(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() {
|
||||
if (this._popper !== null) {
|
||||
this._popper.scheduleUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
// private
|
||||
|
||||
Dropdown.prototype._addEventListeners = function _addEventListeners() {
|
||||
$(this._element).on(Event.CLICK, this.toggle);
|
||||
var _this = this;
|
||||
|
||||
$(this._element).on(Event.CLICK, function (event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
_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);
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
// static
|
||||
@@ -133,9 +213,10 @@ var Dropdown = function ($) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -143,7 +224,7 @@ var Dropdown = function ($) {
|
||||
if (data[config] === undefined) {
|
||||
throw new Error('No method named "' + config + '"');
|
||||
}
|
||||
data[config].call(this);
|
||||
data[config]();
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -154,13 +235,18 @@ var Dropdown = function ($) {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -183,6 +269,7 @@ var Dropdown = function ($) {
|
||||
|
||||
toggles[i].setAttribute('aria-expanded', 'false');
|
||||
|
||||
$(dropdownMenu).removeClass(ClassName.SHOW);
|
||||
$(parent).removeClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget));
|
||||
}
|
||||
};
|
||||
@@ -254,6 +341,16 @@ var Dropdown = function ($) {
|
||||
get: function get() {
|
||||
return VERSION;
|
||||
}
|
||||
}, {
|
||||
key: 'Default',
|
||||
get: function get() {
|
||||
return Default;
|
||||
}
|
||||
}, {
|
||||
key: 'DefaultType',
|
||||
get: function get() {
|
||||
return DefaultType;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Dropdown;
|
||||
@@ -265,7 +362,11 @@ var Dropdown = function ($) {
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$(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, 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();
|
||||
});
|
||||
|
||||
@@ -283,5 +384,5 @@ var Dropdown = function ($) {
|
||||
};
|
||||
|
||||
return Dropdown;
|
||||
}(jQuery);
|
||||
}(jQuery); /* global Popper */
|
||||
//# sourceMappingURL=dropdown.js.map
|
2
js/dist/dropdown.js.map
vendored
2
js/dist/dropdown.js.map
vendored
File diff suppressed because one or more lines are too long
18
js/dist/popover.js
vendored
18
js/dist/popover.js
vendored
@@ -28,12 +28,14 @@ var Popover = function ($) {
|
||||
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-title"></h3>' + '<div class="popover-content"></div></div>'
|
||||
});
|
||||
|
||||
var DefaultType = $.extend({}, Tooltip.DefaultType, {
|
||||
@@ -84,6 +86,10 @@ var Popover = function ($) {
|
||||
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];
|
||||
};
|
||||
@@ -96,8 +102,6 @@ var Popover = function ($) {
|
||||
this.setElementContent($tip.find(Selector.CONTENT), this._getContent());
|
||||
|
||||
$tip.removeClass(ClassName.FADE + ' ' + ClassName.SHOW);
|
||||
|
||||
this.cleanupTether();
|
||||
};
|
||||
|
||||
// private
|
||||
@@ -106,6 +110,14 @@ var Popover = function ($) {
|
||||
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) {
|
||||
|
2
js/dist/popover.js.map
vendored
2
js/dist/popover.js.map
vendored
File diff suppressed because one or more lines are too long
2
js/dist/tab.js
vendored
2
js/dist/tab.js
vendored
@@ -129,7 +129,7 @@ var Tab = function ($) {
|
||||
};
|
||||
|
||||
Tab.prototype.dispose = function dispose() {
|
||||
$.removeClass(this._element, DATA_KEY);
|
||||
$.removeData(this._element, DATA_KEY);
|
||||
this._element = null;
|
||||
};
|
||||
|
||||
|
2
js/dist/tab.js.map
vendored
2
js/dist/tab.js.map
vendored
File diff suppressed because one or more lines are too long
167
js/dist/tooltip.js
vendored
167
js/dist/tooltip.js
vendored
@@ -14,11 +14,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
||||
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)');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,22 +33,8 @@ var Tooltip = function ($) {
|
||||
var EVENT_KEY = '.' + DATA_KEY;
|
||||
var JQUERY_NO_CONFLICT = $.fn[NAME];
|
||||
var TRANSITION_DURATION = 150;
|
||||
var CLASS_PREFIX = 'bs-tether';
|
||||
var TETHER_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 CLASS_PREFIX = 'bs-tooltip';
|
||||
var BSCLS_PREFIX_REGEX = new RegExp('(^|\\s)' + CLASS_PREFIX + '\\S+', 'g');
|
||||
|
||||
var DefaultType = {
|
||||
animation: 'boolean',
|
||||
@@ -59,16 +45,30 @@ var Tooltip = function ($) {
|
||||
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'
|
||||
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 = {
|
||||
@@ -99,11 +99,6 @@ var Tooltip = function ($) {
|
||||
TOOLTIP_INNER: '.tooltip-inner'
|
||||
};
|
||||
|
||||
var TetherClass = {
|
||||
element: false,
|
||||
enabled: false
|
||||
};
|
||||
|
||||
var Trigger = {
|
||||
HOVER: 'hover',
|
||||
FOCUS: 'focus',
|
||||
@@ -126,7 +121,7 @@ var Tooltip = function ($) {
|
||||
this._timeout = 0;
|
||||
this._hoverState = '';
|
||||
this._activeTrigger = {};
|
||||
this._tether = null;
|
||||
this._popper = null;
|
||||
|
||||
// protected
|
||||
this.element = element;
|
||||
@@ -183,8 +178,6 @@ var Tooltip = function ($) {
|
||||
Tooltip.prototype.dispose = function dispose() {
|
||||
clearTimeout(this._timeout);
|
||||
|
||||
this.cleanupTether();
|
||||
|
||||
$.removeData(this.element, this.constructor.DATA_KEY);
|
||||
|
||||
$(this.element).off(this.constructor.EVENT_KEY);
|
||||
@@ -198,7 +191,10 @@ var Tooltip = function ($) {
|
||||
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;
|
||||
@@ -237,6 +233,7 @@ var Tooltip = function ($) {
|
||||
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);
|
||||
|
||||
@@ -248,20 +245,26 @@ var Tooltip = function ($) {
|
||||
|
||||
$(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
|
||||
}
|
||||
},
|
||||
onCreate: function onCreate(data) {
|
||||
if (data.originalPlacement !== data.placement) {
|
||||
_this._handlePopperPlacementChange(data);
|
||||
}
|
||||
},
|
||||
onUpdate: function onUpdate(data) {
|
||||
_this._handlePopperPlacementChange(data);
|
||||
}
|
||||
});
|
||||
|
||||
Util.reflow(tip);
|
||||
this._tether.position();
|
||||
|
||||
$(tip).addClass(ClassName.SHOW);
|
||||
|
||||
// if this is a touch-enabled device we add extra
|
||||
@@ -273,6 +276,9 @@ var Tooltip = function ($) {
|
||||
}
|
||||
|
||||
var complete = function complete() {
|
||||
if (_this.config.animation) {
|
||||
_this._fixTransition();
|
||||
}
|
||||
var prevHoverState = _this._hoverState;
|
||||
_this._hoverState = null;
|
||||
|
||||
@@ -285,10 +291,9 @@ var Tooltip = function ($) {
|
||||
|
||||
if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
|
||||
$(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION);
|
||||
return;
|
||||
} else {
|
||||
complete();
|
||||
}
|
||||
|
||||
complete();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -305,7 +310,9 @@ var Tooltip = function ($) {
|
||||
_this2._cleanTipClass();
|
||||
_this2.element.removeAttribute('aria-describedby');
|
||||
$(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
|
||||
_this2.cleanupTether();
|
||||
if (_this2._popper !== null) {
|
||||
_this2._popper.destroy();
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
callback();
|
||||
@@ -340,24 +347,30 @@ var Tooltip = function ($) {
|
||||
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) {
|
||||
@@ -386,26 +399,12 @@ var Tooltip = function ($) {
|
||||
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._cleanTipClass = function _cleanTipClass() {
|
||||
var $tip = $(this.getTipElement());
|
||||
var tabClass = $tip.attr('class').match(TETHER_PREFIX_REGEX);
|
||||
if (tabClass !== null && tabClass.length > 0) {
|
||||
$tip.removeClass(tabClass.join(''));
|
||||
}
|
||||
};
|
||||
|
||||
Tooltip.prototype._setListeners = function _setListeners() {
|
||||
var _this3 = this;
|
||||
|
||||
@@ -566,6 +565,32 @@ var Tooltip = function ($) {
|
||||
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) {
|
||||
@@ -645,5 +670,5 @@ var Tooltip = function ($) {
|
||||
};
|
||||
|
||||
return Tooltip;
|
||||
}(jQuery); /* global Tether */
|
||||
}(jQuery); /* global Popper */
|
||||
//# sourceMappingURL=tooltip.js.map
|
2
js/dist/tooltip.js.map
vendored
2
js/dist/tooltip.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user