1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-09 07:06:36 +02:00
This commit is contained in:
Mark Otto
2015-08-18 20:28:28 -07:00
parent 1c19ded8c1
commit 3dd48b8d47
21 changed files with 97 additions and 67 deletions

38
js/dist/tooltip.js vendored
View File

@@ -154,11 +154,9 @@ var Tooltip = (function ($) {
}, {
key: 'toggle',
value: function toggle(event) {
var context = this;
var dataKey = this.constructor.DATA_KEY;
if (event) {
context = $(event.currentTarget).data(dataKey);
var dataKey = this.constructor.DATA_KEY;
var context = $(event.currentTarget).data(dataKey);
if (!context) {
context = new this.constructor(event.currentTarget, this._getDelegateConfig());
@@ -173,7 +171,13 @@ var Tooltip = (function ($) {
context._leave(null, context);
}
} else {
$(context.getTipElement()).hasClass(ClassName.IN) ? context._leave(null, context) : context._enter(null, context);
if ($(this.getTipElement()).hasClass(ClassName.IN)) {
this._leave(null, this);
return;
}
this._enter(null, this);
}
}
}, {
@@ -238,9 +242,9 @@ var Tooltip = (function ($) {
$(this.element).trigger(this.constructor.Event.INSERTED);
this._tether = new Tether({
attachment: attachment,
element: tip,
target: this.element,
attachment: attachment,
classes: TetherClass,
classPrefix: CLASS_PREFIX,
offset: this.config.offset,
@@ -263,7 +267,12 @@ var Tooltip = (function ($) {
}
};
Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE) ? $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION) : complete();
if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
$(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION);
return;
}
complete();
}
}
}, {
@@ -310,7 +319,7 @@ var Tooltip = (function ($) {
}, {
key: 'isWithContent',
value: function isWithContent() {
return !!this.getTitle();
return Boolean(this.getTitle());
}
}, {
key: 'getTipElement',
@@ -373,8 +382,8 @@ var Tooltip = (function ($) {
if (trigger === 'click') {
$(_this3.element).on(_this3.constructor.Event.CLICK, _this3.config.selector, $.proxy(_this3.toggle, _this3));
} else if (trigger !== Trigger.MANUAL) {
var eventIn = trigger == Trigger.HOVER ? _this3.constructor.Event.MOUSEENTER : _this3.constructor.Event.FOCUSIN;
var eventOut = trigger == Trigger.HOVER ? _this3.constructor.Event.MOUSELEAVE : _this3.constructor.Event.FOCUSOUT;
var eventIn = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSEENTER : _this3.constructor.Event.FOCUSIN;
var eventOut = trigger === Trigger.HOVER ? _this3.constructor.Event.MOUSELEAVE : _this3.constructor.Event.FOCUSOUT;
$(_this3.element).on(eventIn, _this3.config.selector, $.proxy(_this3._enter, _this3)).on(eventOut, _this3.config.selector, $.proxy(_this3._leave, _this3));
}
@@ -416,7 +425,7 @@ var Tooltip = (function ($) {
}
if (event) {
context._activeTrigger[event.type == 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
}
if ($(context.getTipElement()).hasClass(ClassName.IN) || context._hoverState === HoverState.IN) {
@@ -452,7 +461,7 @@ var Tooltip = (function ($) {
}
if (event) {
context._activeTrigger[event.type == 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
}
if (context._isWithActiveTrigger()) {
@@ -508,9 +517,8 @@ var Tooltip = (function ($) {
if (this.config) {
for (var key in this.config) {
var value = this.config[key];
if (this.constructor.Default[key] !== value) {
config[key] = value;
if (this.constructor.Default[key] !== this.config[key]) {
config[key] = this.config[key];
}
}
}