Skip to content

Instantly share code, notes, and snippets.

@DimitarChristoff
Created February 10, 2011 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DimitarChristoff/820377 to your computer and use it in GitHub Desktop.
Save DimitarChristoff/820377 to your computer and use it in GitHub Desktop.
multiple files loading...
// extend Asset.js
Asset.javascripts = function(sources, options) {
// multiple js load
options = $merge({
onComplete: $empty,
onProgress: function() {}
}, options);
var sources = $splat(sources), counter = 0, todo = sources.length;
sources.each(function(source) {
Asset.javascript(source, {
onload: function() {
counter++;
options.onProgress.call(this, counter, source);
if (counter == todo)
options.onComplete.call(this, counter);
}
});
});
};
new Asset.javascripts([
"/js/admin/source/Swiff.Uploader.js",
"/js/admin/source/Fx.ProgressBar.js",
"/js/admin/source/FancyUpload2.js",
"/js/admin/source/prodEdit.js"
], {
onComplete: function() {
// all done.
},
onProgress: function() {
// loaded some file.
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment