-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.loader.js
7 lines (6 loc) · 2.05 KB
/
jquery.loader.js
1
2
3
4
5
6
7
/*!
* jQuery loader plugin
* Version BETA 2 (17-JUNE-2011)
* Copyright (c) 2011 Guilherme Mori {guilherme.danna.mori}@gmail.com
*/
;(function($){$.preLoadGUI=function(l){if($.isArray(l)){for(var el in l){if($.isArray(l[el])){i='preLoadGUIBeta2';c=$('#'+i).size();if(c==0){$('<div></div>').attr('id',i).css({width:'100%',height:'100%',backgroundColor:'#000000',zIndex:99999999,position:'fixed',opacity:0.85,left:0,top:0}).appendTo('body');$('<div></div>').attr('id',i+'loader').attr('rel',l.length).attr('loaded',0).css({width:'0',height:'1px',backgroundColor:'#ffffff',zIndex:999999999,position:'fixed',left:0,top:'50%'}).appendTo('body');$('<div></div>').attr('id',i+'loaderText').css({fontSize:'11px',fontFamily:"Verdana, Geneva, sans-serif",width:'100%',color:'#ffffff',height:'12px',zIndex:999999999,position:'fixed',left:0,top:'50%',marginTop:'-20px'}).appendTo('body')} switch(l[el][1]){case'js':$.getScript(l[el][0],function(){$.preLoadGUI(l)});break;case'img':$("<img />").css({visibility:'hidden'}).attr("src",l[el][0]).load(function(){$.preLoadGUI(l)});break;case'css':$("<style></style>").attr({type:"text/css"}).load(l[el][0],function(){$(this).appendTo('head');$.preLoadGUI(l)});break;case'html':$('<div></div>').attr('rel',l[el][2]).load(l[el][0],function(){$($(this).attr('rel')).append($(this).html());$.preLoadGUI(l)});break;case'run':$.getScript(l[el][0],function(){$.preLoadGUI(l)});break;default:delete l[el];$.preLoadGUI(l);return;break}$.preLoadGUIUpdate(l[el][0]);delete l[el];return}} $('#'+i+'loaderText').text('Uma vez carregado o site não irá mais ser carregado.');$('#'+i+'loader').animate({width:'100%'},0,'swing',function(){i='preLoadGUIBeta2';$('#'+i+'loader, #'+i+', #'+i+'loaderText').fadeOut()})}else{alert('preLoad() must receive an array!')}}; $.preLoadGUIUpdate=function(f){i='preLoadGUIBeta2';ld=$('#'+i+'loader').attr('loaded')*1;t=$('#'+i+'loader').attr('rel')*1;$('#'+i+'loader').attr('loaded',(ld+1)).css({width:(ld/t*100)+'%'});$('#'+i+'loaderText').html('Aguarde! Carregando o site: '+f+" ("+(Math.round(ld/t*100))+"% | "+ld+" de "+t+")")}})(jQuery);