r3584 committed - tooltip: code formatting; fix for when both focus and mouseover events...
Revision: 3584
Author: joern.zaefferer
Date: Fri Jan 1 05:15:34 2010
Log: tooltip: code formatting; fix for when both focus and mouseover events
are triggered on a single element; cleanup of destroy method, Widget
handles unbinding events
http://code.google.com/p/jquery-ui/source/detail?r=3584
Modified:
/branches/dev/ui/jquery.ui.tooltip.js
=======================================
--- /branches/dev/ui/jquery.ui.tooltip.js Tue Dec 22 20:30:15 2009
+++ /branches/dev/ui/jquery.ui.tooltip.js Fri Jan 1 05:15:34 2010
@@ -30,16 +30,25 @@
},
_init: function() {
var self = this;
- this.tooltip = $("<div/>").attr("id", "ui-tooltip-" +
increments++).attr("role", "tooltip").attr("aria-hidden", "true").addClass("ui-tooltip
ui-widget
ui-corner-all").addClass(this.options.tooltipClass).appendTo(document.body).hide();
- this.tooltipContent =
$("<div/>").addClass("ui-tooltip-content").appendTo(this.tooltip);
+ this.tooltip = $("<div></div>")
+ .attr("id", "ui-tooltip-" + increments++)
+ .attr("role", "tooltip")
+ .attr("aria-hidden", "true")
+ .addClass("ui-tooltip ui-widget ui-corner-all")
+ .addClass(this.options.tooltipClass)
+ .appendTo(document.body)
+ .hide();
+ this.tooltipContent = $("<div></div>")
+ .addClass("ui-tooltip-content")
+ .appendTo(this.tooltip);
this.opacity = this.tooltip.css("opacity");
this.element
- .bind("focus.tooltip mouseover.tooltip", function(event) {
- self.show($(event.target));
- })
- .bind("blur.tooltip mouseout.tooltip", function(event) {
- self.close();
- });
+ .bind("focus.tooltip mouseover.tooltip", function(event) {
+ self.show($(event.target));
+ })
+ .bind("blur.tooltip mouseout.tooltip", function(event) {
+ self.close();
+ });
},
enable: function() {
@@ -51,7 +60,6 @@
},
destroy: function() {
- this.element.unbind(".tooltip");
this.tooltip.remove();
$.Widget.prototype.destroy.apply(this, arguments);
},
@@ -61,6 +69,9 @@
},
show: function(target) {
+ // already visible? possible when both focus and mouseover events occur
+ if (this.current && this.current[0] == target[0])
+ return;
var self = this;
this.current = target;
this.currentTitle = target.attr("title");
--