mod/bootstrap/vendor/bootstrap/js/src/tooltip.js in card-1.93.2 vs mod/bootstrap/vendor/bootstrap/js/src/tooltip.js in card-1.93.3

- old
+ new

@@ -1,18 +1,18 @@ -/* global Popper */ - +import $ from 'jquery' +import Popper from 'popper.js' import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-beta): tooltip.js + * Bootstrap (v4.0.0-beta.2): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ -const Tooltip = (($) => { +const Tooltip = (() => { /** * Check for Popper dependency * Popper - https://popper.js.org */ @@ -26,11 +26,11 @@ * Constants * ------------------------------------------------------------------------ */ const NAME = 'tooltip' - const VERSION = '4.0.0-beta' + const VERSION = '4.0.0-beta.2' const DATA_KEY = 'bs.tooltip' const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] const TRANSITION_DURATION = 150 const CLASS_PREFIX = 'bs-tooltip' @@ -182,10 +182,14 @@ toggleEnabled() { this._isEnabled = !this._isEnabled } toggle(event) { + if (!this._isEnabled) { + return + } + if (event) { const dataKey = this.constructor.DATA_KEY let context = $(event.currentTarget).data(dataKey) if (!context) { @@ -232,12 +236,12 @@ this._hoverState = null this._activeTrigger = null if (this._popper !== null) { this._popper.destroy() } - this._popper = null + this._popper = null this.element = null this.config = null this.tip = null } @@ -413,11 +417,12 @@ addAttachmentClass(attachment) { $(this.getTipElement()).addClass(`${CLASS_PREFIX}-${attachment}`) } getTipElement() { - return this.tip = this.tip || $(this.config.template)[0] + this.tip = this.tip || $(this.config.template)[0] + return this.tip } setContent() { const $tip = $(this.getTipElement()) this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle()) @@ -615,22 +620,22 @@ this.constructor.Default, $(this.element).data(), config ) - if (config.delay && typeof config.delay === 'number') { + if (typeof config.delay === 'number') { config.delay = { show : config.delay, hide : config.delay } } - if (config.title && typeof config.title === 'number') { + if (typeof config.title === 'number') { config.title = config.title.toString() } - if (config.content && typeof config.content === 'number') { + if (typeof config.content === 'number') { config.content = config.content.toString() } Util.typeCheckConfig( NAME, @@ -696,18 +701,17 @@ data = new Tooltip(this, _config) $(this).data(DATA_KEY, data) } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() } }) } - } /** * ------------------------------------------------------------------------ @@ -722,8 +726,8 @@ return Tooltip._jQueryInterface } return Tooltip -})(jQuery) +})($, Popper) export default Tooltip