Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
oldtitle now stored as an element attribute rather than $.data, so ot…
Browse files Browse the repository at this point in the history
…her non-jQuery JS can grab it easily.
  • Loading branch information
Craga89 committed Mar 28, 2011
1 parent 95ce67e commit c174c69
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion dist/jquery.qtip.css
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Mon Mar 21 18:22:45 2011 +0000
* Date: Mon Mar 28 15:15:02 2011 +0100
*/

/* Fluid class for determining actual width in IE */
Expand Down
24 changes: 13 additions & 11 deletions dist/jquery.qtip.js
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Mon Mar 21 18:22:45 2011 +0000
* Date: Mon Mar 28 15:15:02 2011 +0100
*/

"use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
Expand Down Expand Up @@ -1250,7 +1250,7 @@ function QTip(target, options, id, attr)
destroy: function()
{
var t = target[0],
title = $.data(t, oldtitle);
title = $.attr(t, oldtitle);

// Destroy tooltip and any associated plugins if rendered
if(self.rendered) {
Expand All @@ -1271,6 +1271,7 @@ function QTip(target, options, id, attr)

// Reset old title attribute if removed
if(title) {
target.removeAttr(oldtitle);
$.attr(t, 'title', title);
}

Expand Down Expand Up @@ -1354,8 +1355,8 @@ function init(id, opts)

// Remove title attribute and store it if present
if($.attr(this, 'title')) {
$.data(this, oldtitle, $.attr(this, 'title'));
elem.removeAttr('title');
$.attr(this, oldtitle, $.attr(this, 'title'));
this.removeAttribute('title');
}

// Initialize the tooltip and add API reference
Expand Down Expand Up @@ -1561,7 +1562,7 @@ PLUGINS = QTIP.plugins = {

if(attr === title) {
if(arguments.length < 2) {
return $.data(self, oldtitle);
return $.attr(self, oldtitle);
}
else if(typeof api === 'object') {
// If qTip is rendered and title was originally used as content, update it
Expand All @@ -1571,21 +1572,22 @@ PLUGINS = QTIP.plugins = {

// Use the regular attr method to set, then cache the result
$.fn['attr'+replaceSuffix].apply(this, arguments);
$.data(self, oldtitle, $.attr(self, title));
return this.removeAttr('title');
$.attr(self, oldtitle, $.attr(self, title));
return this.removeAttr(title);
}
}
},

/* Allow clone to correctly retrieve cached title attributes */
clone: function(keepData) {
var titles = $([]), elem;
var titles = $([]), title = 'title', elem;

// Re-add cached titles before we clone
$('*', this).add(this).each(function() {
var title = $.data(this, oldtitle);
var t = $.attr(this, oldtitle);
if(title) {
$.attr(this, 'title', title);
$.attr(this, title, t);
this.removeAttribute(oldtitle);
titles = titles.add(this);
}
});
Expand All @@ -1594,7 +1596,7 @@ PLUGINS = QTIP.plugins = {
elem = $.fn['clone'+replaceSuffix].apply(this, arguments);

// Remove the old titles again
titles.removeAttr('title');
titles.removeAttr(title);

return elem;
},
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.qtip.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/jquery.qtip.pack.js

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions src/core.js
Expand Up @@ -1208,7 +1208,7 @@ function QTip(target, options, id, attr)
destroy: function()
{
var t = target[0],
title = $.data(t, oldtitle);
title = $.attr(t, oldtitle);

// Destroy tooltip and any associated plugins if rendered
if(self.rendered) {
Expand All @@ -1229,6 +1229,7 @@ function QTip(target, options, id, attr)

// Reset old title attribute if removed
if(title) {
target.removeAttr(oldtitle);
$.attr(t, 'title', title);
}

Expand Down Expand Up @@ -1312,8 +1313,8 @@ function init(id, opts)

// Remove title attribute and store it if present
if($.attr(this, 'title')) {
$.data(this, oldtitle, $.attr(this, 'title'));
elem.removeAttr('title');
$.attr(this, oldtitle, $.attr(this, 'title'));
this.removeAttribute('title');
}

// Initialize the tooltip and add API reference
Expand Down Expand Up @@ -1519,7 +1520,7 @@ PLUGINS = QTIP.plugins = {

if(attr === title) {
if(arguments.length < 2) {
return $.data(self, oldtitle);
return $.attr(self, oldtitle);
}
else if(typeof api === 'object') {
// If qTip is rendered and title was originally used as content, update it
Expand All @@ -1529,21 +1530,22 @@ PLUGINS = QTIP.plugins = {

// Use the regular attr method to set, then cache the result
$.fn['attr'+replaceSuffix].apply(this, arguments);
$.data(self, oldtitle, $.attr(self, title));
return this.removeAttr('title');
$.attr(self, oldtitle, $.attr(self, title));
return this.removeAttr(title);
}
}
},

/* Allow clone to correctly retrieve cached title attributes */
clone: function(keepData) {
var titles = $([]), elem;
var titles = $([]), title = 'title', elem;

// Re-add cached titles before we clone
$('*', this).add(this).each(function() {
var title = $.data(this, oldtitle);
var t = $.attr(this, oldtitle);
if(title) {
$.attr(this, 'title', title);
$.attr(this, title, t);
this.removeAttribute(oldtitle);
titles = titles.add(this);
}
});
Expand All @@ -1552,7 +1554,7 @@ PLUGINS = QTIP.plugins = {
elem = $.fn['clone'+replaceSuffix].apply(this, arguments);

// Remove the old titles again
titles.removeAttr('title');
titles.removeAttr(title);

return elem;
},
Expand Down

0 comments on commit c174c69

Please sign in to comment.