Skip to content

Instantly share code, notes, and snippets.

@gamanox
Created April 2, 2012 22:16
Show Gist options
  • Save gamanox/2287589 to your computer and use it in GitHub Desktop.
Save gamanox/2287589 to your computer and use it in GitHub Desktop.
Batch Img jquery Preloader
/************* PRELOADER ***********/
(function($) {
var imgList = [];
var _seccion='';
$.extend({
preload: function(imgArr, option,seccion) {
var setting = $.extend({
init: function(loaded, total) {},
loaded: function(img, loaded, total) {},
loaded_all: function(loaded, total) {}
}, option);
var total = imgArr.length;
var loaded = 0;
setting.init(0, total);
for(var i in imgArr) {
imgList.push($("<img />")
.attr("src", imgArr[i])
.load(function() {
loaded++;
setting.loaded(this, loaded, total);
if(loaded == total) {
setting.loaded_all(loaded, total, seccion);
}
})
);
}
}
});
})(jQuery);
$(function() {
if($)
$.preload([
//"img/Seccion_Stats/"+resolucion_fondo+"/bck_stars_stats.jpg",
"img/Seccion_Stats/"+resolucion+"/bck_stats/bck_stats1.png",
"img/Seccion_Stats/"+resolucion+"/bck_stats/bck_stats2.png",
"img/Seccion_Stats/"+resolucion+"/bck_stats/bck_stats3.png",
"img/Seccion_Stats/"+resolucion+"/bck_stats/bck_stats4.png",
"img/Seccion_Stats/"+resolucion+"/bck_stats/bck_stats5.png",
"img/Seccion_Stats/"+resolucion+"/header_CuadroNombre_"+resolucion+".png",
"img/Seccion_Stats/"+resolucion+"/tit_Statusfera"+resolucion+".png",
"img/Seccion_Stats/"+resolucion+"/tit_instruccion"+resolucion+".png",
"img/Seccion_Stats/"+resolucion+"/compitiendo/header_compitiendo3B.png",
"img/Seccion_Stats/"+resolucion+"/btn_redesSociales/btn_conectarTwitter_"+resolucion+".png",
"img/Seccion_Stats/"+resolucion+"/btn_competir_"+resolucion+".png",
"img/Seccion_Stats/"+resolucion+"/rayaPunteada_"+resolucion+".png",
"img/Seccion_Stats/"+resolucion+"/btn_ver_"+resolucion+".png",
"img/Seccion_Stats/"+resolucion+"/btn_redesSociales/btn_conectarFacebook_"+resolucion+".png",
"img/Seccion_Stats/"+resolucion+"/Mono/photo_mono"+resolucion+"_3.png",
"img/Seccion_Stats/"+resolucion+"/Mono/photo_mono"+resolucion+"b.png"
], {
init: function(loaded, total) {
entrada_loader();
},
loaded: function(img, loaded, total) {
},
loaded_all: function(loaded, total,seccion) {
}
},"stats");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment