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

Commit

Permalink
Merge pull request #228 from texel/infinite-timer
Browse files Browse the repository at this point in the history
Basic sanity check to make sure dimension polling doesn't wait forever.
  • Loading branch information
Craga89 committed Aug 30, 2011
2 parents 5257521 + 8e997d7 commit cf537c5
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 15 deletions.
1 change: 0 additions & 1 deletion dist/comment

This file was deleted.

15 changes: 11 additions & 4 deletions dist/jquery.qtip.basic.js
Expand Up @@ -9,7 +9,7 @@
* http://en.wikipedia.org/wiki/MIT_License
* http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Sat Aug 27 17:34:23 2011 +0100
* Date: Sun Aug 28 14:05:44 2011 -0700
*/

/*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
Expand Down Expand Up @@ -389,13 +389,20 @@ function QTip(target, options, id, attr)
// Skip if the src is already present
if(srcs[elem.src] !== undefined) { return; }

// Keep track of how many times we poll for image dimensions.
// If it doesn't return in a reasonable amount of time, it's better
// to display the tooltip, rather than hold up the queue.
var iterations = 0, maxIterations = 3;

(function timer(){
// When the dimensions are found, remove the image from the queue
if(elem.height || elem.width) { return imageLoad(elem); }
if(elem.height || elem.width || (iterations > maxIterations)) { return imageLoad(elem); }

iterations += 1;

// Restart timer
self.timers.img[elem.src] = setTimeout(timer, 700);
}());
}());

// Also apply regular load/error event handlers
$(elem).bind('error'+namespace+' load'+namespace, function(){ imageLoad(this); });
Expand Down Expand Up @@ -1932,4 +1939,4 @@ QTIP.defaults = {
};


}(jQuery, window));
}(jQuery, window));
4 changes: 2 additions & 2 deletions 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: Sat Aug 27 17:34:23 2011 +0100
* Date: Sun Aug 28 14:05:44 2011 -0700
*/

/* Core qTip styles */
Expand Down Expand Up @@ -559,4 +559,4 @@
.ui-tooltip:not(.ie9haxors) div.ui-tooltip-titlebar{
filter: none;
-ms-filter: none;
}
}
15 changes: 11 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: Sat Aug 27 17:34:23 2011 +0100
* Date: Sun Aug 28 14:05:44 2011 -0700
*/

/*jslint browser: true, onevar: true, undef: true, nomen: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: true */
Expand Down Expand Up @@ -389,13 +389,20 @@ function QTip(target, options, id, attr)
// Skip if the src is already present
if(srcs[elem.src] !== undefined) { return; }

// Keep track of how many times we poll for image dimensions.
// If it doesn't return in a reasonable amount of time, it's better
// to display the tooltip, rather than hold up the queue.
var iterations = 0, maxIterations = 3;

(function timer(){
// When the dimensions are found, remove the image from the queue
if(elem.height || elem.width) { return imageLoad(elem); }
if(elem.height || elem.width || (iterations > maxIterations)) { return imageLoad(elem); }

iterations += 1;

// Restart timer
self.timers.img[elem.src] = setTimeout(timer, 700);
}());
}());

// Also apply regular load/error event handlers
$(elem).bind('error'+namespace+' load'+namespace, function(){ imageLoad(this); });
Expand Down Expand Up @@ -3169,4 +3176,4 @@ $.extend(TRUE, QTIP.defaults, {
});


}(jQuery, window));
}(jQuery, window));
4 changes: 2 additions & 2 deletions dist/jquery.qtip.min.js

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/core.js
Expand Up @@ -326,13 +326,20 @@ function QTip(target, options, id, attr)
// Skip if the src is already present
if(srcs[elem.src] !== undefined) { return; }

// Keep track of how many times we poll for image dimensions.
// If it doesn't return in a reasonable amount of time, it's better
// to display the tooltip, rather than hold up the queue.
var iterations = 0, maxIterations = 3;

(function timer(){
// When the dimensions are found, remove the image from the queue
if(elem.height || elem.width) { return imageLoad(elem); }
if(elem.height || elem.width || (iterations > maxIterations)) { return imageLoad(elem); }

iterations += 1;

// Restart timer
self.timers.img[elem.src] = setTimeout(timer, 700);
}());
}());

// Also apply regular load/error event handlers
$(elem).bind('error'+namespace+' load'+namespace, function(){ imageLoad(this); });
Expand Down

0 comments on commit cf537c5

Please sign in to comment.