basic smoke test script

This commit is contained in:
Sam Saffron
2013-02-21 16:01:18 +11:00
parent 250bd3cd21
commit 012941ea62
3 changed files with 125 additions and 69 deletions
@@ -1,33 +1,32 @@
(function() {
window.Discourse.debounce = function(func, wait, trickle) {
var timeout;
window.Discourse.debounce = function(func, wait, trickle) {
var timeout;
timeout = null;
return function() {
var args, context, currentWait, later;
context = this;
args = arguments;
later = function() {
timeout = null;
return func.apply(context, args);
};
if (timeout && trickle) {
/* already queued, let it through
*/
return;
}
if (typeof wait === "function") {
currentWait = wait();
} else {
currentWait = wait;
}
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(later, currentWait);
return timeout;
timeout = null;
return function() {
var args, context, currentWait, later;
context = this;
args = arguments;
later = function() {
timeout = null;
return func.apply(context, args);
};
};
}).call(this);
if (timeout && trickle) {
/* already queued, let it through */
return;
}
if (typeof wait === "function") {
currentWait = wait();
} else {
currentWait = wait;
}
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(later, currentWait);
return timeout;
};
};