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(function($) { 16 17 $.fn.easySlider = function(options){ 18 19 // default configuration properties 20 var defaults = { 21 prevId: 'prevBtn', 22 prevText: 'Previous', 23 nextId: 'nextBtn', 24 nextText: 'Next', 25 controlsShow: true, 26 controlsBefore: '', 27 controlsAfter: '', 28 controlsFade: true, 29 firstId: 'firstBtn', 30 firstText: 'First', 31 firstShow: false, 32 lastId: 'lastBtn', 33 lastText: 'Last', 34 lastShow: false, 35 vertical: false, 36 speed: 800, 37 auto: false, 38 pause: 2000, 39 continuous: false, 40 numeric: false, 41 numericId: 'controls' 42 }; 43 44 var options = $.extend(defaults, options); 45 46 this.each(function() { 47 var obj = $(this); 48 var s = $("li", obj).length; 49 var w = $("li", obj).width(); 50 var h = $("li", obj).height(); 51 var clickable = true; 52 obj.width(w); 53 obj.height(h); 54 obj.css("overflow","hidden"); 55 var ts = s-1; 56 var t = 0; 57 $("ul", obj).css('width',s*w); 58 59 if(options.continuous){ 60 $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px")); 61 $("ul", obj).append($("ul li:nth-child(2)", obj).clone()); 62 $("ul", obj).css('width',(s+1)*w); 63 }; 64 65 if(!options.vertical) $("li", obj).css('float','left'); 66 67 if(options.controlsShow){ 68 var html = options.controlsBefore; 69 if(options.numeric){ 70 html += '<ol id="'+ options.numericId +'"></ol>'; 71 } else { 72 if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>'; 73 html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>'; 74 html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>'; 75 if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>'; 76 }; 77 78 html += options.controlsAfter; 79 $(obj).after(html); 80 }; 81 82 if(options.numeric){ 83 for(var i=0;i<s;i++){ 84 $(document.createElement("li")) 85 .attr('id',options.numericId + (i+1)) 86 .html('<a rel='+ i +' href=\"javascript:void(0);\">'+ (i+1) +'</a>') 87 .appendTo($("#"+ options.numericId)) 88 .click(function(){ 89 animate($("a",$(this)).attr('rel'),true); 90 }); 91 }; 92 } else { 93 $("a","#"+options.nextId).click(function(){ 94 animate("next",true); 95 }); 96 $("a","#"+options.prevId).click(function(){ 97 animate("prev",true); 98 }); 99 $("a","#"+options.firstId).click(function(){ 100 animate("first",true); 101 }); 102 $("a","#"+options.lastId).click(function(){ 103 animate("last",true); 104 }); 105 }; 106 107 function setCurrent(i){ 108 i = parseInt(i)+1; 109 $("li", "#" + options.numericId).removeClass("current"); 110 $("li#" + options.numericId + i).addClass("current"); 111 }; 112 113 function adjust(){ 114 if(t>ts) t=0; 115 if(t<0) t=ts; 116 if(!options.vertical) { 117 $("ul",obj).css("margin-left",(t*w*-1)); 118 } else { 119 $("ul",obj).css("margin-left",(t*h*-1)); 120 } 121 clickable = true; 122 if(options.numeric) setCurrent(t); 123 }; 124 125 function animate(dir,clicked){ 126 if (clickable){ 127 clickable = false; 128 var ot = t; 129 switch(dir){ 130 case "next": 131 t = (ot>=ts) ? (options.continuous ? t+1 : ts) : t+1; 132 break; 133 case "prev": 134 t = (t<=0) ? (options.continuous ? t-1 : 0) : t-1; 135 break; 136 case "first": 137 t = 0; 138 break; 139 case "last": 140 t = ts; 141 break; 142 default: 143 t = dir; 144 break; 145 }; 146 var diff = Math.abs(ot-t); 147 var speed = diff*options.speed; 148 if(!options.vertical) { 149 p = (t*w*-1); 150 $("ul",obj).animate( 151 { marginLeft: p }, 152 { queue:false, duration:speed, complete:adjust } 153 ); 154 } else { 155 p = (t*h*-1); 156 $("ul",obj).animate( 157 { marginTop: p }, 158 { queue:false, duration:speed, complete:adjust } 159 ); 160 }; 161 162 if(!options.continuous && options.controlsFade){ 163 if(t==ts){ 164 $("a","#"+options.nextId).hide(); 165 $("a","#"+options.lastId).hide(); 166 } else { 167 $("a","#"+options.nextId).show(); 168 $("a","#"+options.lastId).show(); 169 }; 170 if(t==0){ 171 $("a","#"+options.prevId).hide(); 172 $("a","#"+options.firstId).hide(); 173 } else { 174 $("a","#"+options.prevId).show(); 175 $("a","#"+options.firstId).show(); 176 }; 177 }; 178 179 if(clicked) clearTimeout(timeout); 180 if(options.auto && dir=="next" && !clicked){; 181 timeout = setTimeout(function(){ 182 animate("next",false); 183 },diff*options.speed+options.pause); 184 }; 185 186 }; 187 188 }; 189 // init 190 var timeout; 191 if(options.auto){; 192 timeout = setTimeout(function(){ 193 animate("next",false); 194 },options.pause); 195 }; 196 197 if(options.numeric) setCurrent(0); 198 199 if(!options.continuous && options.controlsFade){ 200 $("a","#"+options.prevId).hide(); 201 $("a","#"+options.firstId).hide(); 202 }; 203 204 }); 205 206 }; 207 208})(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.