public
Created

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
(function (w) {
 
// Define two queues for handlers
w.readyQ = [];
w.bindReadyQ = [];
 
// Define the fake jQuery function to capture handlers
w.$ = w.jQuery = function (handler) {
 
// Push a handler into the correct queue
function pushToQ(x, y) {
if (x == "ready") {
w.bindReadyQ.push(y);
} else {
w.readyQ.push(x);
}
}
 
if (handler === document || handler === undefined) {
// Queue $(document).ready(handler), $().ready(handler)
// and $(document).bind("ready", handler) by returning
// an object with alias methods for pushToQ
return {
ready: pushToQ,
bind: pushToQ
};
} else {
// Queue $(handler)
pushToQ(handler);
}
}
 
})(window);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.