1// Simple JavaScript Rotating Banner Using jQuery 2// www.mclelun.com 3 4// Edit jqb_eff to change transition effect. 5// 1 - FadeIn FadeOut 6// 2 - Horizontal Scroll 7// 3 - Vertical Scroll 8// 4 - Infinity Horizontal Scroll 9// 5 - Infinity Vertical Scroll 10var jqb_eff = 4; 11 12//Variables 13var jqb_vCurrent = 0; 14var jqb_vTotal = 0; 15var jqb_vSpeed = 500; 16var jqb_vDuration = 8000; 17var jqb_intInterval = 0; 18var jqb_vGo = 1; 19var jqb_vBusy = false; 20var jqb_vIsPause = false; 21var jqb_tmp = 20; 22var jqb_title; 23var jqb_imgW = 910; 24var jqb_imgH = 250; 25jQuery(document).ready(function() { 26 jqb_vTotal = jQuery(".jqb_slides").children().size() -1; 27 if(jqb_vTotal<=0 || jqb_title==0){ 28 jQuery("#btn_next").css('display', 'none'); 29 jQuery("#btn_pauseplay").css('display', 'none'); 30 jQuery("#btn_prev").css('display', 'none'); 31 jQuery(".jqb_bar").css('display', 'none'); 32 } else { 33 jQuery(".jqb_info").text(jQuery(".jqb_slide").attr("title")); 34 } 35 jqb_intInterval = setInterval(jqb_fnLoop, jqb_vDuration); 36 37 if(jqb_eff == 2 || jqb_eff == 4)//Horizontal Alignment 38 { 39 jQuery("#jqb_object").find(".jqb_slide").each(function(i) { 40 jqb_tmp = ((i - 1)*jqb_imgW) - ((jqb_vCurrent -1)*jqb_imgW); 41 jQuery(this).animate({"left": jqb_tmp+"px"}, 0); 42 }); 43 } 44 else if(jqb_eff == 3 || jqb_eff == 5)//Vertical Alignment 45 { 46 jQuery("#jqb_object").find(".jqb_slide").each(function(i) { 47 jqb_tmp = ((i - 1)*jqb_imgH) - ((jqb_vCurrent -1)*jqb_imgH); 48 jQuery(this).animate({"top": jqb_tmp+"px"}, 0); 49 }); 50 } 51 52 jQuery("#btn_pauseplay").click(function() { 53 if(jqb_vIsPause){ 54 jqb_fnChange(); 55 jqb_vIsPause = false; 56 jQuery("#btn_pauseplay").removeClass("jqb_btn_play"); 57 jQuery("#btn_pauseplay").addClass("jqb_btn_pause"); 58 } else { 59 clearInterval(jqb_intInterval); 60 jqb_vIsPause = true; 61 jQuery("#btn_pauseplay").removeClass("jqb_btn_pause"); 62 jQuery("#btn_pauseplay").addClass("jqb_btn_play"); 63 } 64 }); 65 jQuery("#btn_prev").click(function() { 66 if(!jqb_vBusy) 67 { 68 jqb_vBusy = true; 69 jqb_vGo = -1; 70 jqb_fnChange(); 71 } 72 }); 73 74 jQuery("#btn_next").click(function() { 75 if(!jqb_vBusy) 76 { 77 jqb_vBusy = true; 78 jqb_vGo = 1; 79 jqb_fnChange(); 80 } 81 }); 82}); 83 84function jqb_fnChange(){ 85 if(jqb_vTotal>0){ 86 clearInterval(jqb_intInterval); 87 jqb_fnLoop(); 88 jqb_intInterval = setInterval(jqb_fnLoop, jqb_vDuration); 89 } 90} 91 92function jqb_fnLoop(){ 93if(jqb_vTotal>0){ 94 if(jqb_vGo == 1){ 95 jqb_vCurrent == jqb_vTotal ? jqb_vCurrent = 0 : jqb_vCurrent++; 96 } else { 97 jqb_vCurrent == 0 ? jqb_vCurrent = jqb_vTotal : jqb_vCurrent--; 98 } 99 100 jQuery("#jqb_object").find(".jqb_slide").each(function(i) { 101 if(i == jqb_vCurrent){ 102 jqb_title = jQuery(this).attr("title"); 103 jQuery(".jqb_info").animate({ opacity: 'hide', "left": "-50px"}, 250,function(){ 104 jQuery(".jqb_info").text(jqb_title).animate({ opacity: 'show', "left"
104: "0px"}, 500); 105 }); 106 } 107 108 109 if(jqb_eff == 2)//Horizontal Scrolling 110 { 111 jQuery(this).css('display', 'block'); 112 jqb_tmp = ((i - 1)*jqb_imgW) - ((jqb_vCurrent -1)*jqb_imgW); 113 jQuery(this).animate({"left": jqb_tmp+"px"}, jqb_vSpeed, function() { jqb_vBusy = false; }); 114 } 115 else if(jqb_eff == 3)//Vertical Scrolling 116 { 117 jQuery(this).css('display', 'block'); 118 jqb_tmp = ((i - 1)*jqb_imgH) - ((jqb_vCurrent -1)*jqb_imgH); 119 jQuery(this).animate({"top": jqb_tmp+"px"}, jqb_vSpeed, function() { jqb_vBusy = false; }); 120 } 121 else if(jqb_eff == 4)//Infinity Horizontal Scrolling 122 { 123 if(jqb_vTotal == 1) //IF 2 SLIDE ONLY, FIX 124 { 125 if(jqb_vGo == 1){ 126 if((jQuery(this).position().left) < 0 ) 127 { 128 jQuery(this).animate({"left": jqb_imgW +"px"}, 0); 129 } 130 } else { 131 if((jQuery(this).position().left) > (jqb_imgW * (jqb_vTotal - 1))) 132 { 133 jQuery(this).animate({"left": (-1 * jqb_imgW)+"px"}, 0); 134 } 135 } 136 } 137 jQuery(this).css('display', 'block'); 138 jqb_tmp = jQuery(this).position().left - (jqb_imgW * jqb_vGo); 139 jQuery(this).animate({"left": jqb_tmp+"px"}, jqb_vSpeed, function() { 140 141 if((jQuery(this).position().left) < -jqb_imgW ) 142 { 143 jQuery(this).animate({"left": (jqb_imgW * (jqb_vTotal - 1))+"px"}, 0); 144 } 145 else if((jQuery(this).position().left) > (jqb_imgW * (jqb_vTotal - 1))) 146 { 147 jQuery(this).animate({"left": (-1 * jqb_imgW)+"px"}, 0); 148 } 149 150 jqb_vBusy = false; 151 }); 152 } 153 else if(jqb_eff == 5)//Infinity Vertical Scrolling 154 { 155 if(jqb_vTotal == 1) //IF 2 SLIDE ONLY, FIX 156 { 157 if(jqb_vGo == 1){ 158 if((jQuery(this).position().top) < 0 ) 159 { 160 jQuery(this).animate({"top": jqb_imgH +"px"}, 0); 161 } 162 } else { 163 if((jQuery(this).position().top) > (jqb_imgH * (jqb_vTotal - 1))) 164 { 165 jQuery(this).animate({"top": (-1 * jqb_imgH)+"px"}, 0); 166 } 167 } 168 } 169 jQuery(this).css('display', 'block'); 170 jqb_tmp = jQuery(this).position().top - (jqb_imgH * jqb_vGo); 171 jQuery(this).animate({"top": jqb_tmp+"px"}, jqb_vSpeed, function() { 172 173 if((jQuery(this).position().top) < -jqb_imgH ) 174 { 175 jQuery(this).animate({"top": (jqb_imgH * (jqb_vTotal - 1))+"px"}, 0); 176 } 177 else if((jQuery(this).position().top) > (jqb_imgH * (jqb_vTotal - 1))) 178 { 179 jQuery(this).animate({"top": (-1 * jqb_imgH)+"px"}, 0); 180 } 181 182 jqb_vBusy = false; 183 }); 184 } 185 else //if(jqb_eff == 1)//Fade In & Fade Out 186 { 187 if(i == jqb_vCurrent){ 188 jQuery(this).animate({ opacity: 'show'}, jqb_vSpeed, function() { jqb_vBusy = false; }); 189 } else { 190 jQuery(this).animate({ opacity: 'hide'}, jqb_vSpeed, function() { jqb_vBusy = false; }); 191 } 192 } 193 194 }); 195} 196}
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.