Skip to content

Instantly share code, notes, and snippets.

@getify
Created May 8, 2010 23:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getify/394836 to your computer and use it in GitHub Desktop.
Save getify/394836 to your computer and use it in GitHub Desktop.
// LABjs.jquery.ready -- adds .ready() to $LAB api for wrapping a .wait() and a $(document).ready(...) together
// v0.0.1 (c) Kyle Simpson
// MIT License
(function(global){
var oDOC = global.document;
if (!global.$LAB || !global.jQuery) return; // only adapt LABjs if LABjs exists and jQuery is present
function wrap_API(obj) {
var ret = {
setOptions:function(){
return wrap_API(obj.setOptions.apply(this,arguments));
},
script:function(){
return wrap_API(obj.script.apply(this,arguments));
},
wait:function(){
return wrap_API(obj.wait.apply(this,arguments));
},
ready:function(fn){
return wrap_API(obj.wait(function(){
global.jQuery(oDOC).ready(fn);
}));
}
};
if (obj.setGlobalDefaults) ret.setGlobalDefaults = obj.setGlobalDefaults;
ret.block = ret.wait;
return ret;
}
global.$LAB = wrap_API(global.$LAB);
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment