Created
February 10, 2011 11:39
-
-
Save DimitarChristoff/820377 to your computer and use it in GitHub Desktop.
multiple files loading...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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