From 0970f4235f506e89b8ffcc8732a74fae7d192090 Mon Sep 17 00:00:00 2001 From: tipiirai Date: Tue, 17 Aug 2010 05:51:56 +0000 Subject: [PATCH] new data-tooltip attribute for tooltip trigger element --- src/tooltip/tooltip.js | 9 +++++++-- test/tooltip/index.html | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index ef165f2..7761dca 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -114,6 +114,7 @@ timer = 0, pretimer = 0, title = trigger.attr("title"), + tipAttr = trigger.attr("data-tooltip"), effect = effects[conf.effect], shown, @@ -163,13 +164,17 @@ $.extend(self, { - show: function(e) { + show: function(e) { // tip not initialized yet if (!tip) { + // data-tooltip + if (tipAttr) { + tip = $(tipAttr); + // autogenerated tooltip - if (title) { + } else if (title) { tip = $(conf.layout).addClass(conf.tipClass).appendTo(document.body) .hide().append(title); diff --git a/test/tooltip/index.html b/test/tooltip/index.html index fe9be4c..2261d9a 100644 --- a/test/tooltip/index.html +++ b/test/tooltip/index.html @@ -61,6 +61,26 @@

Title attribute

+
+ +

Data-tooltip attribute

+ + trigger 1 + trigger 2 + trigger 3 + + + +
Manual #3
+ + + +
+

Manual tooltip