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
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.
10 * Built for jQuery library
16 * markup example for $("#slider").easySlider();
20 * <li><img src="images/01.jpg" alt="" /></li>
21 * <li><img src="images/02.jpg" alt="" /></li>
22 * <li><img src="images/03.jpg" alt="" /></li>
23 * <li><img src="images/04.jpg" alt="" /></li>
24 * <li><img src="images/05.jpg" alt="" /></li>
32 $.fn
.easySlider = function(options
){
34 // default configuration properties
59 var options
= $.extend(defaults
, options
);
61 this.each(function() {
63 var s
= $("li", obj
).length
;
64 var w
= $("li", obj
).width();
65 var h
= $("li", obj
).height();
69 obj
.css("overflow","hidden");
72 $("ul", obj
).css('width',s
*w
);
74 if(options
.continuous
){
75 $("ul", obj
).prepend($("ul li:last-child", obj
).clone().css("margin-left","-"+ w
+"px"));
76 $("ul", obj
).append($("ul li:nth-child(2)", obj
).clone());
77 $("ul", obj
).css('width',(s
+1)*w
);
80 if(!options
.vertical
) $("li", obj
).css('float','left');
82 if(options
.controlsShow
){
83 var html
= options
.controlsBefore
;
85 html
+= '<ol id="'+ options
.numericId
+'"></ol>';
87 if(options
.firstShow
) html
+= '<span id="'+ options
.firstId
+'"><a href=\"javascript:void(0);\">'+ options
.firstText
+'</a></span>';
88 html
+= ' <span id="'+ options
.prevId
+'"><a href=\"javascript:void(0);\">'+ options
.prevText
+'</a></span>';
89 html
+= ' <span id="'+ options
.nextId
+'"><a href=\"javascript:void(0);\">'+ options
.nextText
+'</a></span>';
90 if(options
.lastShow
) html
+= ' <span id="'+ options
.lastId
+'"><a href=\"javascript:void(0);\">'+ options
.lastText
+'</a></span>';
93 html
+= options
.controlsAfter
;
99 /* Ajout pour récupérer le texte de la balise h2 */
100 var elem
= document
.getElementById ("bouton_actu"+ (i
+1));
101 var texte_bouton
= "";
102 if (elem
.textContent
=== undefined) {
103 texte_bouton
+= elem
.innerText
;
106 texte_bouton
+= elem
.textContent
;
109 $(document
.createElement("li"))
110 .attr('id',options
.numericId
+ (i
+1))
111 //.html('<a rel='+ i +' href=\"javascript:void(0);\">'+ (i+1) +'</a>')
112 .html('<a rel='+ i
+' href=\"javascript:void(0);\" title=\"'+texte_bouton
+'\">'+ (i
+1) +'</a>')
113 .appendTo($("#"+ options
.numericId
))
115 animate($("a",$(this)).attr('rel'),true);
119 $("a","#"+options
.nextId
).click(function(){
120 animate("next",true);
122 $("a","#"+options
.prevId
).click(function(){
123 animate("prev",true);
125 $("a","#"+options
.firstId
).click(function(){
126 animate("first",true);
128 $("a","#"+options
.lastId
).click(function(){
129 animate("last",true);
133 function setCurrent(i
){
135 $("li", "#" + options
.numericId
).removeClass("current");
136 $("li#" + options
.numericId
+ i
).addClass("current");
142 if(!options
.vertical
) {
143 $("ul",obj
).css("margin-left",(t
*w
*-1));
145 $("ul",obj
).css("margin-left",(t
*h
*-1));
148 if(options
.numeric
) setCurrent(t
);
151 function animate(dir
,clicked
){
157 t
= (ot
>=ts
) ? (options
.continuous
? t
+1 : ts
) : t
+1;
160 t
= (t
<=0) ? (options
.continuous
? t
-1 : 0) : t
-1;
172 var diff
= Math
.abs(ot
-t
);
173 var speed
= diff
*options
.speed
;
174 if(!options
.vertical
) {
178 { queue
:false, duration
:speed
, complete
:adjust
}
184 { queue
:false, duration
:speed
, complete
:adjust
}
188 if(!options
.continuous
&& options
.controlsFade
){
190 $("a","#"+options
.nextId
).hide();
191 $("a","#"+options
.lastId
).hide();
193 $("a","#"+options
.nextId
).show();
194 $("a","#"+options
.lastId
).show();
197 $("a","#"+options
.prevId
).hide();
198 $("a","#"+options
.firstId
).hide();
200 $("a","#"+options
.prevId
).show();
201 $("a","#"+options
.firstId
).show();
205 if(clicked
) clearTimeout(timeout
);
206 if(options
.auto
&& dir
=="next" && !clicked
){;
207 timeout
= setTimeout(function(){
208 animate("next",false);
209 },diff
*options
.speed
+options
.pause
);
218 timeout
= setTimeout(function(){
219 animate("next",false);
223 if(options
.numeric
) setCurrent(0);
225 if(!options
.continuous
&& options
.controlsFade
){
226 $("a","#"+options
.prevId
).hide();
227 $("a","#"+options
.firstId
).hide();