From 930f9ab4e72216530c333311980646b78ee7e433 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Sat, 20 Sep 2014 12:33:54 +0200 Subject: [PATCH] Ox.Tooltip: use html() or append(); test for arguments.length, not object; factor out setTitle; missing semicolon --- source/Ox.UI/js/Window/Tooltip.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/source/Ox.UI/js/Window/Tooltip.js b/source/Ox.UI/js/Window/Tooltip.js index cc97447f..c6fc1e71 100644 --- a/source/Ox.UI/js/Window/Tooltip.js +++ b/source/Ox.UI/js/Window/Tooltip.js @@ -18,16 +18,26 @@ Ox.Tooltip = function(options, self) { .options(options || {}) .update({ title: function() { - that.html(self.options.title); + setTitle(); self.options.title === '' && that.detach(); } }) .addClass('OxTooltip') - .html(self.options.title); + [Ox.isString(self.options.title) ? 'html' : 'append']( + self.options.title + ); - self.options.animate && that.css({ - opacity: 0 - }); + self.options.animate && that.css({opacity: 0}); + + setTitle(); + + function setTitle() { + if (Ox.isString(self.options.title)) { + that.html(self.options.title); + } else { + that.empty().append(self.options.title); + } + } /*@ hide hide tooltip @@ -61,12 +71,12 @@ Ox.Tooltip = function(options, self) { var last = Ox.last(arguments), left, top, width, height; if (self.options.title) { - if (Ox.isObject(arguments[0])) { + if (arguments.length == 1) { self.x = arguments[0].clientX; self.y = arguments[0].clientY; } else { self.x = x; - self.y = y + self.y = y; } $('.OxTooltip').detach(); // fixme: don't use DOM that.appendTo(Ox.UI.$body);