Ox.Tooltip: use html() or append(); test for arguments.length, not object; factor out setTitle; missing semicolon

This commit is contained in:
rlx 2014-09-20 12:33:54 +02:00
parent 7f83cd9495
commit 930f9ab4e7

View file

@ -18,16 +18,26 @@ Ox.Tooltip = function(options, self) {
.options(options || {}) .options(options || {})
.update({ .update({
title: function() { title: function() {
that.html(self.options.title); setTitle();
self.options.title === '' && that.detach(); self.options.title === '' && that.detach();
} }
}) })
.addClass('OxTooltip') .addClass('OxTooltip')
.html(self.options.title); [Ox.isString(self.options.title) ? 'html' : 'append'](
self.options.title
);
self.options.animate && that.css({ self.options.animate && that.css({opacity: 0});
opacity: 0
}); setTitle();
function setTitle() {
if (Ox.isString(self.options.title)) {
that.html(self.options.title);
} else {
that.empty().append(self.options.title);
}
}
/*@ /*@
hide <f> hide tooltip hide <f> hide tooltip
@ -61,12 +71,12 @@ Ox.Tooltip = function(options, self) {
var last = Ox.last(arguments), var last = Ox.last(arguments),
left, top, width, height; left, top, width, height;
if (self.options.title) { if (self.options.title) {
if (Ox.isObject(arguments[0])) { if (arguments.length == 1) {
self.x = arguments[0].clientX; self.x = arguments[0].clientX;
self.y = arguments[0].clientY; self.y = arguments[0].clientY;
} else { } else {
self.x = x; self.x = x;
self.y = y self.y = y;
} }
$('.OxTooltip').detach(); // fixme: don't use DOM $('.OxTooltip').detach(); // fixme: don't use DOM
that.appendTo(Ox.UI.$body); that.appendTo(Ox.UI.$body);