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

Commit

Permalink
Fixed a few problems with the .attr() override
Browse files Browse the repository at this point in the history
  • Loading branch information
Craga89 committed Jan 19, 2011
1 parent 7e6eb50 commit 731b9e6
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 23 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: Wed Jan 19 14:45:32 2011 +0000
* Date: Wed Jan 19 14:48:58 2011 +0000
*/

/* Fluid class for determining actual width in IE */
Expand Down
13 changes: 9 additions & 4 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: Wed Jan 19 14:45:32 2011 +0000
* Date: Wed Jan 19 14:48:58 2011 +0000
*/

"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 @@ -1478,18 +1478,23 @@ $.each({
/* Allow other plugins to successfully retrieve the title of an element with a qTip applied */
attr: function(attr, val) {
var self = this[0],
title = 'title',
api = $.data(self, 'qtip');

if(attr === 'title') {
if(attr === title) {
if(arguments.length === 1) {
return $.data(self, oldtitle);
}
else {
// If qTip is rendered and title was originally used as content, update it
if(api && api.rendered && api.options.content.attr === 'title' && api.cache.attr) {
if(api && api.rendered && api.options.content.attr === title && api.cache.attr) {
api.set('content.text', val);
}
return $.data(self, oldtitle, val);

// 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');
}
}
},
Expand Down
26 changes: 13 additions & 13 deletions dist/jquery.qtip.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions src/core.js
Expand Up @@ -1441,18 +1441,23 @@ $.each({
/* Allow other plugins to successfully retrieve the title of an element with a qTip applied */
attr: function(attr, val) {
var self = this[0],
title = 'title',
api = $.data(self, 'qtip');

if(attr === 'title') {
if(attr === title) {
if(arguments.length === 1) {
return $.data(self, oldtitle);
}
else {
// If qTip is rendered and title was originally used as content, update it
if(api && api.rendered && api.options.content.attr === 'title' && api.cache.attr) {
if(api && api.rendered && api.options.content.attr === title && api.cache.attr) {
api.set('content.text', val);
}
return $.data(self, oldtitle, val);

// 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');
}
}
},
Expand Down

0 comments on commit 731b9e6

Please sign in to comment.