Skip to content

Commit

Permalink
new data-tooltip attribute for tooltip trigger element
Browse files Browse the repository at this point in the history
  • Loading branch information
tipiirai committed Aug 17, 2010
1 parent a128c0e commit 0970f42
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/tooltip/tooltip.js
Expand Up @@ -114,6 +114,7 @@
timer = 0,
pretimer = 0,
title = trigger.attr("title"),
tipAttr = trigger.attr("data-tooltip"),
effect = effects[conf.effect],
shown,

Expand Down Expand Up @@ -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);

Expand Down
20 changes: 20 additions & 0 deletions test/tooltip/index.html
Expand Up @@ -61,6 +61,26 @@ <h3>Title attribute</h3>

</div>

<div id="attr" class="test">

<h3>Data-tooltip attribute</h3>

<a class="trigger" data-tooltip="#attr .tooltip">trigger 1</a>
<a class="trigger" data-tooltip="#attr .tooltip">trigger 2</a>
<a class="trigger">trigger 3</a>

<span></span>

<div><div class="tooltip">Manual #3</div></div>

<script>
$("#attr a").tooltip({
delay: 300
});
</script>

</div>

<div id="manual" class="test">

<h3>Manual tooltip</h3>
Expand Down

0 comments on commit 0970f42

Please sign in to comment.