mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-08 22:56:46 +02:00
Dist (#28392)
This commit is contained in:
71
js/dist/popover.js
vendored
71
js/dist/popover.js
vendored
@@ -4,12 +4,13 @@
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
*/
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./tooltip.js')) :
|
||||
typeof define === 'function' && define.amd ? define(['jquery', './tooltip.js'], factory) :
|
||||
(global = global || self, global.Popover = factory(global.jQuery, global.Tooltip));
|
||||
}(this, function ($, Tooltip) { 'use strict';
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/selectorEngine.js'), require('./tooltip.js')) :
|
||||
typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/selectorEngine.js', './tooltip.js'], factory) :
|
||||
(global = global || self, global.Popover = factory(global.Data, global.SelectorEngine, global.Tooltip));
|
||||
}(this, function (Data, SelectorEngine, Tooltip) { 'use strict';
|
||||
|
||||
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
|
||||
Data = Data && Data.hasOwnProperty('default') ? Data['default'] : Data;
|
||||
SelectorEngine = SelectorEngine && SelectorEngine.hasOwnProperty('default') ? SelectorEngine['default'] : SelectorEngine;
|
||||
Tooltip = Tooltip && Tooltip.hasOwnProperty('default') ? Tooltip['default'] : Tooltip;
|
||||
|
||||
function _defineProperties(target, props) {
|
||||
@@ -68,6 +69,14 @@
|
||||
subClass.__proto__ = superClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap (v4.3.1): util/index.js
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
var jQuery = window.jQuery; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
|
||||
|
||||
/**
|
||||
* ------------------------------------------------------------------------
|
||||
* Constants
|
||||
@@ -78,7 +87,6 @@
|
||||
var VERSION = '4.3.1';
|
||||
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');
|
||||
|
||||
@@ -86,7 +94,7 @@
|
||||
placement: 'right',
|
||||
trigger: 'click',
|
||||
content: '',
|
||||
template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
|
||||
template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
|
||||
});
|
||||
|
||||
var DefaultType = _objectSpread({}, Tooltip.DefaultType, {
|
||||
@@ -137,18 +145,13 @@
|
||||
};
|
||||
|
||||
_proto.addAttachmentClass = function addAttachmentClass(attachment) {
|
||||
$(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
|
||||
};
|
||||
|
||||
_proto.getTipElement = function getTipElement() {
|
||||
this.tip = this.tip || $(this.config.template)[0];
|
||||
return this.tip;
|
||||
this.getTipElement().classList.add(CLASS_PREFIX + "-" + attachment);
|
||||
};
|
||||
|
||||
_proto.setContent = function setContent() {
|
||||
var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
|
||||
var tip = this.getTipElement(); // we use append for html objects to maintain js events
|
||||
|
||||
this.setElementContent($tip.find(Selector.TITLE), this.getTitle());
|
||||
this.setElementContent(SelectorEngine.findOne(Selector.TITLE, tip), this.getTitle());
|
||||
|
||||
var content = this._getContent();
|
||||
|
||||
@@ -156,8 +159,9 @@
|
||||
content = content.call(this.element);
|
||||
}
|
||||
|
||||
this.setElementContent($tip.find(Selector.CONTENT), content);
|
||||
$tip.removeClass(ClassName.FADE + " " + ClassName.SHOW);
|
||||
this.setElementContent(SelectorEngine.findOne(Selector.CONTENT, tip), content);
|
||||
tip.classList.remove(ClassName.FADE);
|
||||
tip.classList.remove(ClassName.SHOW);
|
||||
} // Private
|
||||
;
|
||||
|
||||
@@ -166,18 +170,22 @@
|
||||
};
|
||||
|
||||
_proto._cleanTipClass = function _cleanTipClass() {
|
||||
var $tip = $(this.getTipElement());
|
||||
var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
|
||||
var tip = this.getTipElement();
|
||||
var tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX);
|
||||
|
||||
if (tabClass !== null && tabClass.length > 0) {
|
||||
$tip.removeClass(tabClass.join(''));
|
||||
tabClass.map(function (token) {
|
||||
return token.trim();
|
||||
}).forEach(function (tClass) {
|
||||
return tip.classList.remove(tClass);
|
||||
});
|
||||
}
|
||||
} // Static
|
||||
;
|
||||
|
||||
Popover._jQueryInterface = function _jQueryInterface(config) {
|
||||
return this.each(function () {
|
||||
var data = $(this).data(DATA_KEY);
|
||||
var data = Data.getData(this, DATA_KEY);
|
||||
|
||||
var _config = typeof config === 'object' ? config : null;
|
||||
|
||||
@@ -187,7 +195,7 @@
|
||||
|
||||
if (!data) {
|
||||
data = new Popover(this, _config);
|
||||
$(this).data(DATA_KEY, data);
|
||||
Data.setData(this, DATA_KEY, data);
|
||||
}
|
||||
|
||||
if (typeof config === 'string') {
|
||||
@@ -200,6 +208,10 @@
|
||||
});
|
||||
};
|
||||
|
||||
Popover._getInstance = function _getInstance(element) {
|
||||
return Data.getData(element, DATA_KEY);
|
||||
};
|
||||
|
||||
_createClass(Popover, null, [{
|
||||
key: "VERSION",
|
||||
// Getters
|
||||
@@ -247,13 +259,16 @@
|
||||
*/
|
||||
|
||||
|
||||
$.fn[NAME] = Popover._jQueryInterface;
|
||||
$.fn[NAME].Constructor = Popover;
|
||||
if (typeof jQuery !== 'undefined') {
|
||||
var JQUERY_NO_CONFLICT = jQuery.fn[NAME];
|
||||
jQuery.fn[NAME] = Popover._jQueryInterface;
|
||||
jQuery.fn[NAME].Constructor = Popover;
|
||||
|
||||
$.fn[NAME].noConflict = function () {
|
||||
$.fn[NAME] = JQUERY_NO_CONFLICT;
|
||||
return Popover._jQueryInterface;
|
||||
};
|
||||
jQuery.fn[NAME].noConflict = function () {
|
||||
jQuery.fn[NAME] = JQUERY_NO_CONFLICT;
|
||||
return Popover._jQueryInterface;
|
||||
};
|
||||
}
|
||||
|
||||
return Popover;
|
||||
|
||||
|
Reference in New Issue
Block a user