1/*//////////////////////////*/ 2/*//////////////////////////*/ 3/*/ JQuery FADELOADER /*/ 4/*/ beta /*/ 5/*/ developed by Periplo /*/ 6/*//////////////////////////*/ 7/*//////////////////////////*/ 8 9 10(function( $ ) { 11 $.fn.fadeloader = function(options) { 12 //Default setting 13 var opts = $.extend({}, $.fn.fadeloader.defaults, options); 14 15 //Public vars 16 var html = $('html'); 17 html.data('main', this); 18 html.data('statin', false); 19 html.data('statout', false); 20 html.data('alphain', ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']); 21 html.data('alphaout', ''); 22 html.data('mode', opts.mode); 23 html.data('fadespeed', opts.fadeSpeed); 24 html.data('easeload', opts.easeLoad); 25 26 //Private vars 27 var main = this; 28 var loaderImg = ''; 29 var objArray = []; 30 var childArr = []; 31 32 //Generate loader HTML 33 if(opts.preloadCustom === '') { 34 loaderImg = '<div class="preloader" style="position:absolute;top:50%;left:50%;width:'+opts.preloadWidth+'px;height:'+opts.preloadHeight+'px; margin:-'+Math.round(opts.loadHeight/2)+'px 0 0 -'+Math.round(opts.preloadWidth/2)+'px;"><img src="'+opts.preloadImg+'" border="0" width="'+opts.preloadWidth+'" height="'+opts.preloadHeight+'" /></div>'; 35 } 36 else { loaderImg = opts.preloadCustom; } 37 38 //Prepend loader to BODY 39 if(opts.preloader === true) { $('body').prepend(loaderImg); } 40 41 function animIn(start_index, call) { 42 if(html.data('statout') === false) { 43 html.data('statin', true); 44 var next_index = start_index+1; 45 46 if(opts.mode == 'children') { 47 object = $(childArr[start_index]); 48 } 49 else { 50 object = main.find('.'+html.data('alphain')[start_index]); 51 } 52 53 if(object.length > 0) { 54 object.css('opacity', '0'); 55 object.css('display', opts.displayType); 56 object.animate({ opacity: 1 }, opts.fadeSpeed, opts.easeLoad, function() { animIn(next_index,call); }); 57 objArray.push(html.data('alphain')[start_index]); 58 } 59 else { 60 html.data('alphaout', objArray.reverse()); 61 html.data('statin', false); 62 eval(call); 63 return false; 64 } 65 } 66 } 67 68 //First function call 69 $(window).load(function() { 70 $('.preloader').remove(); 71 72 if(opts.mode == 'children') { 73 var subsubchildArr = html.data('main').children(':not(script,br)'); 74 childArr = $.makeArray(subsubchildArr); 75 animIn(0 ,opts.onComplete); 76 } 77 else { 78 animIn(0 ,opts.onComplete); 79 } 80 }); 81 82 }; 83 84 85 $.fn.fadeloader.animOut = function(url) { 86 var html = $('html'); 87 var childArr = []; 88 function fadeOutClasses(pos) { 89 if(html.data('alphaout')[pos]) { 90 var newpos = pos + 1; 91 $('.'+html.data('alphaout')[pos]).animate({ opacity: 0 }, html.data('fadespeed'), html.data('easeload'), function() { $(this).css('display', 'none'); fadeOutClasses(newpos); }); 92 93 } 94 else { 95 html.data('statin', false); 96 if(url) { document.location.href = url; } 97 return false; 98 } 99 } 100 101 function fadeOutChildren(pos, arr) { 102 if(childArr[pos] && childArr[pos] != 'script' && childArr[pos] != 'br' && childArr[pos] != 'a') { 103 var newpos = pos + 1; 104 $(childArr[pos]).animate({ opacity: 0 }, html.data('fadespeed'), html.data('easeload'), function() { $(this).css('display', 'none'); fadeOutChildren(newpos, childArr); }); 105 } 106 else { 107 html.data('statin', false); 108 if(url) { document.location.href = url; } 109 return false; 110 } 111 } 112 113 if(html.data('statin') === false) { 114 html.data('statout', true); 115 if(html.data('mode') == 'children') { 116 var subsubchildArr = html.data('main').children(':not(script,br)'); 117 var subchildArr = $.makeArray(subsubchildArr); 118 childArr = subchildArr.reverse(); 119 120 fadeOutChildren(0, childArr); 121 } 122 else { 123 fadeOutClasses(0); 124 } 125 } 126 }; 127 128 129 $.fn.fadeloader.defaults = { 130 mode : 'class', //or 'children' 131 fadeSpeed : 500, 132 //fadeInOrder : 'desc', 133 //fadeOutOrder : 'asc', 134 easeLoad : 'linear', 135 displayType : 'block', 136 preloader : true, 137 preloadImg : 'loading.gif', 138 preloadWidth : 50, 139 preloadHeight : 50, 140 preloadCustom : '', //element must have class 'preloader' 141 onComplete : '' 142 }; 143 144})( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.