HTML and CSS Reference
In-Depth Information
// Asset hash storing any loaded assets
Q.assets = {};
// Getter method to return an asset
Q.asset = function(name) {
return Q.assets[name];
};
// Load assets, and call our callback when done
Q.load = function(assets,callback,options) {
var assetObj = {};
// Make sure we have an options hash to work with
if(!options) { options = {}; }
// Get our progressCallback if we have one
var progressCallback = options.progressCallback;
var errors = false,
errorCallback = function(itm) {
errors = true;
(options.errorCallback ||
function(itm) { alert("Error Loading: " + itm ); })(itm);
};
// If the user passed in an array, convert it
// to a hash with lookups by filename
if(_.isArray(assets)) {
_.each(assets,function(itm) {
if(_.isObject(itm)) {
_.extend(assetObj,itm);
} else {
assetObj[itm] = itm;
}
});
} else if(_.isString(assets)) {
// Turn assets into an object if it's a string
assetObj[assets] = assets;
} else {
// Otherwise just use the assets as is
assetObj = assets;
}
// Find the # of assets we're loading
var assetsTotal = _(assetObj).keys().length,
Search WWH ::




Custom Search