1/* 2* Slides, A Slideshow Plugin for jQuery 3* Intructions: http://slidesjs.com 4* By: Nathan Searles, http://nathansearles.com 5* Version: 1.1.6 6* Updated: March 23th, 2011 7* 8* Licensed under the Apache License, Version 2.0 (the "License"); 9* you may not use this file except in compliance with the License. 10* You may obtain a copy of the License at 11* 12* http://www.apache.org/licenses/LICENSE-2.0 13* 14* Unless required by applicable law or agreed to in writing, software 15* distributed under the License is distributed on an "AS IS" BASIS, 16* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17* See the License for the specific language governing permissions and 18* limitations under the License. 19*/ 20(function ($) { 21 $.fn.slides = function (g) { 22 g = $.extend({}, $.fn.slides.option, g); 23 return this.each(function () { 24 $('.' + g.container, $(this)).children().wrapAll('<div class="slides_control"/>'); 25 var d = $(this), 26 control = $('.slides_control', d), 27 total = control.children().size(), 28 width = control.children().outerWidth(), 29 height = control.children().outerHeight(), 30 start = g.start - 1, 31 effect = g.effect.indexOf(',') < 0 ? g.effect : g.effect.replace(' ', '').split(',')[0], 32 paginationEffect = g.effect.indexOf(',') < 0 ? effect : g.effect.replace(' ', '').split(',')[1], 33 next = 0, 34 prev = 0, 35 number = 0, 36 current = 0, 37 loaded, active, clicked, position, direction, imageParent, pauseTimeout, playInterval; 38 39 function animate(a, b, c) { 40 if (!active && loaded) { 41 active = true; 42 g.animationStart(current + 1); 43 switch (a) { 44 case 'next': 45 prev = current; 46 next = current + 1; 47 next = total === next ? 0 : next; 48 position = width * 2; 49 a = -width * 2; 50 current = next; 51 break; 52 case 'prev': 53 prev = current; 54 next = current - 1; 55 next = next === -1 ? total - 1 : next; 56 position = 0; 57 a = 0; 58 current = next; 59 break; 60 case 'pagination': 61 next = parseInt(c, 10); 62 prev = $('.' + g.paginationClass + ' li.current a', d).attr('href').match('[^#/]+$'); 63 if (next > prev) { 64 position = width * 2; 65 a = -width * 2 66 } else { 67 position = 0; 68 a = 0 69 } 70 current = next; 71 break 72 } 73 if (b === 'fade') { 74 if (g.crossfade) { 75 control.children(':eq(' + next + ')', d).css({ 76 zIndex: 10 77 }).fadeIn(g.fadeSpeed, g.fadeEasing, function () { 78 if (g.autoHeight) { 79 control.animate({ 80 height: control.children(':eq(' + next + ')', d).outerHeight() 81 }, g.autoHeightSpeed, function () { 82 control.children(':eq(' + prev + ')', d).css({ 83 display: 'none', 84 zIndex: 0 85 }); 86 control.children(':eq(' + next + ')', d).css({ 87 zIndex: 0 88 }); 89 g.animationComplete(next + 1); 90 active = false 91 }) 92 } else { 93 control.children(':eq(' + prev + ')', d).css({ 94 display: 'none', 95 zIndex: 0 96 }); 97 control.children(':eq(' + next + ')', d).css({ 98 zIndex: 0 99 }); 100 g.animationComplete(next + 1); 101 active = false 102 } 103 }) 104 } else { 105 control.children(':eq(' + prev + ')', d).fadeOut(g.fadeSpeed, g.fadeEasing, function () { 106 if (g.autoHeight) { 107 control.animate({ 108 height: control.children(':eq(' + next + ')', d).outerHeight() 109 }, g.autoHeightSpeed, function () { 110 control.children(':eq(' + next + ')', d).fadeIn(g.fadeSpeed, g.fadeEasing) 111 }) 112 } else { 113 control.children(':eq(' + next + ')', d).fadeIn(g.fadeSpeed, g.fadeEasing, function () { 114 if ($.browser.msie) { 115 $(this).get(0).style.removeAttribute('filter') 116 } 117 }) 118 } 119 g.animationComplete(next + 1); 120 active = false 121 }) 122 } 123 } else { 124 control.children(':eq(' + next + ')').css({ 125 left: position, 126 display: 'block' 127 }); 128 if (g.autoHeight) { 129 control.animate({ 130 left: a, 131 height: control.children(':eq(' + next + ')').outerHeight() 132 }, g.slideSpeed, g.slideEasing, function () { 133 control.css({ 134 left: -width 135 }); 136 control.children(':eq(' + next + ')').css({ 137 left: width, 138 zIndex: 5 139 }); 140 control.children(':eq(' + prev + ')').css({ 141 left: width, 142 display: 'none', 143 zIndex: 0 144 }); 145 g.animationComplete(next + 1); 146 active = false 147 }) 148 } else { 149 control.animate({ 150 left: a 151 }, g.slideSpeed, g.slideEasing, function () { 152 control.css({ 153 left: -width 154 }); 155 control.children(':eq(' + next + ')').css({ 156 left: width, 157 zIndex: 5 158 }); 159 control.children(':eq(' + prev + ')').css({ 160 left: width, 161 display: 'none', 162 zIndex: 0 163 }); 164 g.animationComplete(next + 1); 165 active = false 166 }) 167 } 168 } 169 if (g.pagination) { 170 $('.' + g.paginationClass + ' li.current', d).removeClass('current'); 171 $('.' + g.paginationClass + ' li:eq(' + next + ')', d).addClass('current') 172 } 173 } 174 } 175 function stop() { 176 clearInterval(d.data('interval')) 177 } 178 function pause() { 179 if (g.pause) { 180 clearTimeout(d.data('pause')); 181 clearInterval(d.data('interval')); 182 pauseTimeout = setTimeout(function () { 183 clearTimeout(d.data('pause')); 184 playInterval = setInterval(function () { 185 animate("next", effect) 186 }, g.play); 187 d.data('interval', playInterval) 188 }, g.pause); 189 d.data('pause', pauseTimeout) 190 } else { 191 stop() 192 } 193 } 194 if (total < 2) { 195 return 196 } 197 if (start < 0) { 198 start = 0 199 } 200 if (start > total) { 201 start = total - 1 202 } 203 if (g.start) { 204 current = start 205 } 206 if (g.randomize) { 207 control.randomize() 208 } 209 $('.' + g.container, d).css({ 210 overflow: 'hidden', 211 position: 'relative' 212 }); 213 control.children().css({ 214 position: 'absolute', 215 top: 0, 216 left: control.children().outerWidth(), 217 zIndex: 0, 218 display: 'none' 219 }); 220 control.css({ 221 position: 'relative', 222 width: (width * 3), 223 height: height, 224 left: -width 225 }); 226 $('.' + g.container, d).css({ 227 display: 'block' 228 }); 229 if (g.autoHeight) { 230 control.children().css({ 231 height: 'auto' 232 }); 233 control.animate({ 234 height: control.children(':eq(' + start + ')').outerHeight() 235 }, g.autoHeightSpeed) 236 } 237 if (g.preload && control.find('img').length) { 238 $('.' + g.container, d).css({
239 background: 'url(' + g.preloadImage + ') no-repeat 50% 50%' 240 }); 241 var f = control.find('img:eq(' + start + ')').attr('src'); 242 if ($('img', d).parent().attr('class') != 'slides_control') { 243 imageParent = control.children(':eq(0)')[0].tagName.toLowerCase() 244 } else { 245 imageParent = control.find('img:eq(' + start + ')') 246 } 247 control.find('img:eq(' + start + ')').attr('src', f).load(function () { 248 control.find(imageParent + ':eq(' + start + ')').fadeIn(g.fadeSpeed, g.fadeEasing, function () { 249 $(this).css({ 250 zIndex: 5 251 }); 252 $('.' + g.container, d).css({ 253 background: '' 254 }); 255 loaded = true; 256 g.slidesLoaded() 257 }) 258 }) 259 } else { 260 control.children(':eq(' + start + ')').fadeIn(g.fadeSpeed, g.fadeEasing, function () { 261 loaded = true; 262 g.slidesLoaded() 263 }) 264 } 265 if (g.bigTarget) { 266 control.children().css({ 267 cursor: 'pointer' 268 }); 269 control.children().click(function () { 270 animate('next', effect); 271 return false 272 }) 273 } 274 if (g.hoverPause && g.play) { 275 control.bind('mouseover', function () { 276 stop() 277 }); 278 control.bind('mouseleave', function () { 279 pause() 280 }) 281 } 282 if (g.generateNextPrev) { 283 $('.' + g.container, d).after('<a href="#" class="' + g.prev + '">Prev</a>'); 284 $('.' + g.prev, d).after('<a href="#" class="' + g.next + '">Next</a>') 285 } 286 $('.' + g.next, d).click(function (e) { 287 e.preventDefault(); 288 if (g.play) { 289 pause() 290 } 291 animate('next', effect) 292 }); 293 $('.' + g.prev, d).click(function (e) { 294 e.preventDefault(); 295 if (g.play) { 296 pause() 297 } 298 animate('prev', effect) 299 }); 300 if (g.generatePagination) { 301 d.append('<ul class=' + g.paginationClass + '></ul>'); 302 control.children().each(function () { 303 $('.' + g.paginationClass, d).append('<li><a href="#' + number + '">' + (number + 1) + '</a></li>'); 304 number++ 305 }) 306 } else { 307 $('.' + g.paginationClass + ' li a', d).each(function () { 308 $(this).attr('href', '#' + number); 309 number++ 310 }) 311 } 312 $('.' + g.paginationClass + ' li:eq(' + start + ')', d).addClass('current'); 313 $('.' + g.paginationClass + ' li a', d).click(function () { 314 if (g.play) { 315 pause() 316 } 317 clicked = $(this).attr('href').match('[^#/]+$'); 318 if (current != clicked) { 319 animate('pagination', paginationEffect, clicked) 320 } 321 return false 322 }); 323 $('a.link', d).click(function () { 324 if (g.play) { 325 pause() 326 } 327 clicked = $(this).attr('href').match('[^#/]+$') - 1; 328 if (current != clicked) { 329 animate('pagination', paginationEffect, clicked) 330 } 331 return false 332 }); 333 if (g.play) { 334 playInterval = setInterval(function () { 335 animate('next', effect) 336 }, g.play); 337 d.data('interval', playInterval) 338 } 339 }) 340 }; 341 $.fn.slides.option = { 342 preload: false, 343 preloadImage: '/img/loading.gif', 344 container: 'slides_container', 345 generateNextPrev: false, 346 next: 'next', 347 prev: 'prev', 348 pagination: true, 349 generatePagination: true, 350 paginationClass: 'pagination', 351 fadeSpeed: 350, 352 fadeEasing: '', 353 slideSpeed: 350, 354 slideEasing: '', 355 start: 1, 356 effect: 'slide', 357 crossfade: false, 358 randomize: false, 359 play: 0, 360 pause: 0, 361 hoverPause: false, 362 autoHeight: false, 363 autoHeightSpeed: 350, 364 bigTarget: false, 365 animationStart: function () {}, 366 animationComplete: function () {}, 367 slidesLoaded: function () {} 368 }; 369 $.fn.randomize = function (c) { 370 function randomizeOrder() { 371 return (Math.round(Math.random()) - 0.5) 372 } 373 return ($(this).each(function () { 374 var $this = $(this); 375 var $children = $this.children(); 376 var a = $children.length; 377 if (a > 1) { 378 $children.hide(); 379 var b = []; 380 for (i = 0; i < a; i++) { 381 b[b.length] = i 382 } 383 b = b.sort(randomizeOrder); 384 $.each(b, function (j, k) { 385 var $child = $children.eq(k); 386 var $clone = $child.clone(true); 387 $clone.show().appendTo($this); 388 if (c !== undefined) { 389 c($child, $clone) 390 } 391 $child.remove() 392 }) 393 } 394 })) 395 } 396})(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.