diff options
Diffstat (limited to 'js/src/tooltip.js')
| -rw-r--r-- | js/src/tooltip.js | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/js/src/tooltip.js b/js/src/tooltip.js index c7c7b9f9d..8d262f4ad 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -1,16 +1,16 @@ -/* global Popper */ - +import $ from 'jquery' +import Popper from 'popper.js' import Util from './util' /** * -------------------------------------------------------------------------- - * 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) * -------------------------------------------------------------------------- */ -const Tooltip = (($) => { +const Tooltip = (() => { /** * Check for Popper dependency @@ -28,7 +28,7 @@ const Tooltip = (($) => { */ const NAME = 'tooltip' - const VERSION = '4.0.0-alpha.6' + const VERSION = '4.0.0-beta' const DATA_KEY = 'bs.tooltip' const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] @@ -184,6 +184,10 @@ const Tooltip = (($) => { } toggle(event) { + if (!this._isEnabled) { + return + } + if (event) { const dataKey = this.constructor.DATA_KEY let context = $(event.currentTarget).data(dataKey) @@ -234,8 +238,8 @@ const Tooltip = (($) => { if (this._popper !== null) { this._popper.destroy() } - this._popper = null + this._popper = null this.element = null this.config = null this.tip = null @@ -415,7 +419,8 @@ const Tooltip = (($) => { } getTipElement() { - return this.tip = this.tip || $(this.config.template)[0] + this.tip = this.tip || $(this.config.template)[0] + return this.tip } setContent() { @@ -617,18 +622,18 @@ const Tooltip = (($) => { 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() } @@ -698,14 +703,13 @@ const Tooltip = (($) => { } if (typeof config === 'string') { - if (data[config] === undefined) { + if (typeof data[config] === 'undefined') { throw new Error(`No method named "${config}"`) } data[config]() } }) } - } @@ -724,6 +728,6 @@ const Tooltip = (($) => { return Tooltip -})(jQuery) +})($, Popper) export default Tooltip |
