1/* 2 * Easy Slider 1.7 - jQuery plugin 3 * written by Alen Grakalic 4 * http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding 5 * 6 * Copyright (c) 2009 Alen Grakalic (http://cssglobe.com) 7 * Dual licensed under the MIT (MIT-LICENSE.txt) 8 * and GPL (GPL-LICENSE.txt) licenses. 9 * 10 * Built for jQuery library 11 * http://jquery.com 12 * 13 */ 14 15 16(function($) { 17 18 $.fn.easySlider = function(options){ 19 20 // default configuration properties 21 var defaults = { 22 prevId: 'prevBtn', 23 prevText: '', 24 nextId: 'nextBtn', 25 nextText: '', 26 controlsShow: true, 27 controlsBefore: '', 28 controlsAfter: '', 29 controlsFade: true, 30 firstId: 'firstBtn', 31 firstText: 'First', 32 firstShow: false, 33 lastId: 'lastBtn', 34 lastText: 'Last', 35 lastShow: false, 36 vertical: false, 37 speed: 800, 38 auto: false, 39 scrollback: false, 40 pause: 5000, 41 continuous: false, 42 numeric: false, 43 numericId: 'controls', 44//modif alice : variable nombremax pour nombre maximum d'images/de li qui s'affichent dans le slider 45 nombremax: 1, 46 // pour automatiser la largeur et le positionnement des petits carr�s 47 ol_width: 0, 48 li_width: 16, 49 retour: false 50 }; 51 52 var options = $.extend(defaults, options); 53 54 this.each(function() { 55 var obj = $(this); 56 var s = $("li", obj).length; //nombre de li 57 var w = $("li", obj).width(); // largeur li 58 var h = $("li", obj).height(); // hauteur li 59 var clickable = true; 60 obj.width(w); 61 obj.height(h); 62 obj.css("overflow","hidden"); 63 var ts = Math.ceil(s/options.nombremax)-1; // avant : s-1; 64 var t = 0; 65 $("ul", obj).css('width',s*w); 66 67 if(options.continuous){ 68 $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px")); 69 $("ul", obj).append($("ul li:nth-child(2)", obj).clone()); 70 $("ul", obj).css('width',(s+1)*w); 71 }; 72 73 if(!options.vertical) $("li", obj).css('float','left'); 74 75 if(options.controlsShow){ 76 var html = options.controlsBefore; 77 if(options.numeric){ 78 html += '<ol id="'+ options.numericId +'" style="width: '+(options.li_width*s)+'px;margin-right: -'+(options.ol_width*(s/2))+'px;"></ol>'; 79 } else { 80 if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>'; 81 html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>'; 82 html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>'; 83 if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>'; 84 }; 85 86 html += options.controlsAfter; 87 $(obj).after(html); 88 }; 89 90 if(options.numeric){ 91 for(var i=0;i<s;i++){ 92 $(document.createElement("li")) 93 .attr('id',options.numericId + (i+1)) 94 .html('<a rel='+ i +' href=\"javascript:void(0);\"></a>') 95 .appendTo($("#"+ options.numericId)) 96 .click(function(){ 97 animate($("a",$(this)).attr('rel'),true); 98 }); 99 }; 100 } else { 101 $("a","#"+options.nextId).click(function(){ 102 animate("next",true); 103 }); 104 $("a","#"+options.prevId).click(function(){ 105 animate("prev",true); 106 }); 107 $("a","#"+options.firstId).click(function(){ 108 animate("first",true); 109 }); 110 $("a","#"+options.lastId).click(function(){ 111 animate("last",true); 112 }); 113 }; 114 115 function setCurrent(i){ 116 i = parseInt(i)+1; 117 $("li", "#" + options.numericId).removeClass("current"); 118 $("li#" + options.numericId + i).addClass("current"); 119 }; 120 121 function adjust(){ 122 if(t>ts) t=0; 123 if(t<0) t=ts; 124 125 if(!options.vertical) { 126 $("ul",obj).css("margin-left",(t*options.nombremax*w*-1)); 127 128 } else { 129 $("ul",obj).css("margin-left",(t*h*-1)); 130 } 131 clickable = true; 132 if(options.numeric) setCurrent(t); 133 }; 134 135 function animate(dir,clicked){ 136 if (clickable){ 137 clickable = false; 138 var ot = t; 139 switch(dir){ 140 case "next": 141 t = (ot>=ts) ? (options.continuous ? t+1 : ts) : t+1; 142 break; 143 case "prev": 144 t = (t<=0) ? (options.continuous ? t-1 : 0) : t-1; 145 break; 146 case "first": 147 t = 0; 148 break; 149 case "last": 150 t = ts; 151 break; 152 default: 153 t = dir; 154 break; 155 }; 156 var diff = Math.abs(ot-t); 157 var speed = diff*options.speed; 158 if(!options.vertical) { 159 p = (t*options.nombremax*w*-1); 160 $("ul",obj).animate( 161 { marginLeft: p }, 162 { queue:false, duration:speed, complete:adjust } 163 ); 164 } else { 165 p = (t*h*-1); 166 $("ul",obj).animate( 167 { marginTop: p }, 168 { queue:false, duration:speed, complete:adjust } 169 ); 170 }; 171 172 173 if(!options.continuous && options.controlsFade){
174//modif alice pour non-affichage du bouton suivant si on arrive � la derni�re image/au dernier li (anciennement (t=ts)) 175 if(t >= Math.ceil(s/options.nombremax)-1){ 176 $("a","#"+options.nextId).hide(); 177 $("a","#"+options.lastId).hide(); 178 } else { 179 $("a","#"+options.nextId).show(); 180 $("a","#"+options.lastId).show(); 181 }; 182 if(t==0){ 183 $("a","#"+options.prevId).hide(); 184 $("a","#"+options.firstId).hide(); 185 } else { 186 $("a","#"+options.prevId).show(); 187 $("a","#"+options.firstId).show(); 188 }; 189 }; 190 191 if(clicked) clearTimeout(timeout); 192 if(options.auto && options.scrollback && !clicked){ 193 if(t>=ts) 194 { 195 timeout = setTimeout(function(){ 196 animate("prev",false); 197 },diff*options.speed+options.pause); 198 } 199 else 200 { 201 if(ot>t && t>0) 202 { 203 timeout = setTimeout(function(){ 204 animate("prev",false); 205 },diff*options.speed+options.pause); 206 }else 207 { 208 timeout = setTimeout(function(){ 209 animate("next",false); 210 },diff*options.speed+options.pause); 211 } 212 } 213 } 214 else if(options.auto && dir=="next" && !clicked){; 215 timeout = setTimeout(function(){ 216 animate("next",false); 217 },diff*options.speed+options.pause); 218 } 219 ; 220 221 }; 222 223 }; 224 // init 225 var timeout; 226 if(options.auto){; 227 timeout = setTimeout(function(){ 228 animate("next",false); 229 },options.pause); 230 }; 231 232 if(options.numeric) setCurrent(0); 233 234 if(!options.continuous && options.controlsFade){ 235 $("a","#"+options.prevId).hide(); 236 $("a","#"+options.firstId).hide(); 237//modif alice pour non-affichage du bouton precedent si nombre d'images/li est inf�rieur au nombre d'images/li qui s'affichent dans le slider 238 if(s <= options.nombremax){ 239 $("a","#"+options.nextId).hide(); 240 $("a","#"+options.lastId).hide(); 241 }; 242 243 }; 244 245 246 }); 247 248 }; 249 250})(jQuery); 251 252 253
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.