mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Tooltip: Renamed show to open and open to _show (based on spec), changed trigger(show) to trigger(open) and added trigger(close); always use element as target, enabling programmatic opening and closing
This commit is contained in:
parent
744343a6e6
commit
ebac9717fd
14
ui/jquery.ui.tooltip.js
vendored
14
ui/jquery.ui.tooltip.js
vendored
@ -49,7 +49,7 @@ $.widget("ui.tooltip", {
|
|||||||
this.opacity = this.tooltip.css("opacity");
|
this.opacity = this.tooltip.css("opacity");
|
||||||
this.element
|
this.element
|
||||||
.bind("focus.tooltip mouseenter.tooltip", function(event) {
|
.bind("focus.tooltip mouseenter.tooltip", function(event) {
|
||||||
self.show($(event.target));
|
self.open();
|
||||||
})
|
})
|
||||||
.bind("blur.tooltip mouseleave.tooltip", function(event) {
|
.bind("blur.tooltip mouseleave.tooltip", function(event) {
|
||||||
self.close();
|
self.close();
|
||||||
@ -73,7 +73,8 @@ $.widget("ui.tooltip", {
|
|||||||
return this.tooltip;
|
return this.tooltip;
|
||||||
},
|
},
|
||||||
|
|
||||||
show: function(target) {
|
open: function() {
|
||||||
|
var target = this.element;
|
||||||
// already visible? possible when both focus and mouseover events occur
|
// already visible? possible when both focus and mouseover events occur
|
||||||
if (this.current && this.current[0] == target[0])
|
if (this.current && this.current[0] == target[0])
|
||||||
return;
|
return;
|
||||||
@ -83,14 +84,14 @@ $.widget("ui.tooltip", {
|
|||||||
var content = this.options.content.call(target[0], function(response) {
|
var content = this.options.content.call(target[0], function(response) {
|
||||||
// ignore async responses that come in after the tooltip is already hidden
|
// ignore async responses that come in after the tooltip is already hidden
|
||||||
if (self.current == target)
|
if (self.current == target)
|
||||||
self.open(target, response);
|
self._show(target, response);
|
||||||
});
|
});
|
||||||
if (content) {
|
if (content) {
|
||||||
self.open(target, content);
|
self._show(target, content);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
open: function(target, content) {
|
_show: function(target, content) {
|
||||||
if (!content)
|
if (!content)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -115,7 +116,7 @@ $.widget("ui.tooltip", {
|
|||||||
else
|
else
|
||||||
this.tooltip.is(':visible') ? this.tooltip.fadeTo("normal", this.opacity) : this.tooltip.fadeIn();
|
this.tooltip.is(':visible') ? this.tooltip.fadeTo("normal", this.opacity) : this.tooltip.fadeIn();
|
||||||
|
|
||||||
this._trigger("show", null, { target: target });
|
this._trigger( "open" );
|
||||||
},
|
},
|
||||||
|
|
||||||
close: function() {
|
close: function() {
|
||||||
@ -136,6 +137,7 @@ $.widget("ui.tooltip", {
|
|||||||
else
|
else
|
||||||
this.tooltip.stop().fadeOut();
|
this.tooltip.stop().fadeOut();
|
||||||
|
|
||||||
|
this._trigger( "close" );
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user