1/** 2 * Coin Slider - Unique jQuery Image Slider 3 * @version: 1.0 - (2010/04/04) 4 * @requires jQuery v1.2.2 or later 5 * @author Ivan Lazarevic 6 * Examples and documentation at: http://workshop.rs/projects/coin-slider/ 7 8 * Licensed under MIT licence: 9 * http://www.opensource.org/licenses/mit-license.php 10**/ 11 12(function($) { 13 14 var params = new Array; 15 var order = new Array; 16 var images = new Array; 17 var links = new Array; 18 var linksTarget = new Array; 19 var titles = new Array; 20 var interval = new Array; 21 var imagePos = new Array; 22 var appInterval = new Array; 23 var squarePos = new Array; 24 var reverse = new Array; 25 26 $.fn.coinslider= $.fn.CoinSlider = function(options){ 27 28 init = function(el){ 29 30 order[el.id] = new Array(); 31 images[el.id] = new Array(); 32 links[el.id] = new Array(); 33 linksTarget[el.id] = new Array(); 34 titles[el.id] = new Array(); 35 imagePos[el.id] = 0; 36 squarePos[el.id] = 0; 37 reverse[el.id] = 1; 38 39 params[el.id] = $.extend({}, $.fn.coinslider.defaults, options); 40 41 42 $.each($('#'+el.id+' img'), function(i,item){ 43 images[el.id][i] = $(item).attr('src'); 44 links[el.id][i] = $(item).parent().is('a') ? $(item).parent().attr('href') : ''; 45 linksTarget[el.id][i] = $(item).parent().is('a') ? $(item).parent().attr('target') : ''; 46 titles[el.id][i] = $(item).next().is('span') ? $(item).next().html() : ''; 47 $(item).hide(); 48 $(item).next().hide(); 49 }); 50 51 52 $(el).css({ 53 'background-image':'url('+images[el.id][0]+')', 54 'width': params[el.id].width, 55 'height': params[el.id].height, 56 'position': 'relative', 57 'background-position': 'top left' 58 }).wrap("<div class='coin-slider' id='coin-slider-"+el.id+"' />"); 59 60 61 // create title bar 62 $('#'+el.id).append("<div class='cs-title' id='cs-title-"+el.id+"' style='position: absolute; bottom:0; left: 0; z-index: 1000;'></div>"); 63 64 if(params[el.id].effect =='fade'){ 65 params[el.id].spw=1; 66 params[el.id].sph=1; 67 } 68 $.setFields(el); 69 70 if(params[el.id].navigation) 71 $.setNavigation(el); 72 73 $.transition(el,0); 74 $.transitionCall(el); 75 76 } 77 78 $.setFields = function(el){ 79 80 tWidth = sWidth = parseInt(params[el.id].width/params[el.id].spw); 81 tHeight = sHeight = parseInt(params[el.id].height/params[el.id].sph); 82 83 counter = sLeft = sTop = 0; 84 tgapx = gapx = params[el.id].width - params[el.id].spw*sWidth; 85 tgapy = gapy = params[el.id].height - params[el.id].sph*sHeight; 86 87 for(i=1;i <= params[el.id].sph;i++){ 88 gapx = tgapx; 89 90 if(gapy > 0){ 91 gapy--; 92 sHeight = tHeight+1; 93 } else { 94 sHeight = tHeight; 95 } 96 97 for(j=1; j <= params[el.id].spw; j++){ 98 99 if(gapx > 0){ 100 gapx--; 101 sWidth = tWidth+1; 102 } else { 103 sWidth = tWidth; 104 } 105 106 order[el.id][counter] = i+''+j; 107 counter++; 108 109 if(params[el.id].links) 110 $('#'+el.id).append("<a href='"+links[el.id][0]+"' class='cs-"+el.id+"' id='cs-"+el.id+i+j+"' style='width:"+sWidth+"px; height:"+sHeight+"px; float: left; position: absolute;'></a>"); 111 else 112 $('#'+el.id).append("<div class='cs-"+el.id+"' id='cs-"+el.id+i+j+"' style='width:"+sWidth+"px; height:"+sHeight+"px; float: left; position: absolute;'></div>"); 113 114 // positioning squares 115 $("#cs-"+el.id+i+j).css({ 116 'background-position': -sLeft +'px '+(-sTop+'px'), 117 'left' : sLeft , 118 'top': sTop 119 }); 120 121 sLeft += sWidth; 122 } 123 124 sTop += sHeight; 125 sLeft = 0; 126 127 } 128 129 if(params[el.id].stickynav){ 130 $('.cs-'+el.id).mouseover(function(){ 131 $('#cs-navigation-'+el.id).show(); 132 }); 133 134 $('.cs-'+el.id).mouseout(function(){ 135 $('#cs-navigation-'+el.id).show(); 136 }); 137 138 $('#cs-title-'+el.id).mouseover(function(){ 139 $('#cs-navigation-'+el.id).show(); 140 }); 141 142 $('#cs-title-'+el.id).mouseout(function(){ 143 $('#cs-navigation-'+el.id).show(); 144 }); 145 }else{ 146 $('.cs-'+el.id).mouseover(function(){ 147 $('#cs-navigation-'+el.id).show(); 148 });
149 150 $('.cs-'+el.id).mouseout(function(){ 151 $('#cs-navigation-'+el.id).hide(); 152 }); 153 154 $('#cs-title-'+el.id).mouseover(function(){ 155 $('#cs-navigation-'+el.id).show(); 156 }); 157 158 $('#cs-title-'+el.id).mouseout(function(){ 159 $('#cs-navigation-'+el.id).hide(); 160 }); 161 } 162 if(params[el.id].hoverPause){ 163 $('.cs-'+el.id).mouseover(function(){ 164 params[el.id].pause = true; 165 }); 166 167 $('.cs-'+el.id).mouseout(function(){ 168 params[el.id].pause = false; 169 }); 170 171 $('#cs-title-'+el.id).mouseover(function(){ 172 params[el.id].pause = true; 173 }); 174 175 $('#cs-title-'+el.id).mouseout(function(){ 176 params[el.id].pause = false; 177 }); 178 } 179 180 181 }; 182 183 //Note for Fade 184 185 $.transitionCall = function(el){ 186 187 clearInterval(interval[el.id]); 188 delay = params[el.id].delay + params[el.id].spw*params[el.id].sph*params[el.id].sDelay; 189 interval[el.id] = setInterval(function() { $.transition(el) }, delay); 190 191 } 192 193 // transitions 194 $.transition = function(el,direction){ 195 196 if(params[el.id].pause == true) return; 197 $.effect(el); 198 squarePos[el.id] = 0; 199 appInterval[el.id] = setInterval(function() { $.appereance(el,order[el.id][squarePos[el.id]]) },params[el.id].sDelay); 200 $(el).css({ 'background-image': 'url('+images[el.id][imagePos[el.id]]+')' }); 201 202 if(typeof(direction) == "undefined") 203 imagePos[el.id]++; 204 else 205 if(direction == 'prev') 206 imagePos[el.id]--; 207 else 208 imagePos[el.id] = direction; 209 210 if (imagePos[el.id] == images[el.id].length) { 211 imagePos[el.id] = 0; 212 } 213 214 if (imagePos[el.id] == -1){ 215 imagePos[el.id] = images[el.id].length-1; 216 } 217 218 $('.cs-button-'+el.id).removeClass('cs-active'); // CHECK 219 $('#cs-button-'+el.id+"-"+(imagePos[el.id]+1)).addClass('cs-active'); 220 221 if(titles[el.id][imagePos[el.id]]){ 222 $('#cs-title-'+el.id).css({ 'opacity' : 0 }).animate({ 'opacity' : params[el.id].opacity }, params[el.id].titleSpeed); 223 $('#cs-title-'+el.id).html(titles[el.id][imagePos[el.id]]); 224 } else { 225 $('#cs-title-'+el.id).css('opacity',0); 226 } 227 228 }; 229 230 $.appereance = function(el,sid){ 231 232 $('.cs-'+el.id).attr('href',links[el.id][imagePos[el.id]]).attr('target',linksTarget[el.id][imagePos[el.id]]); 233 234 if (squarePos[el.id] == params[el.id].spw*params[el.id].sph) { 235 clearInterval(appInterval[el.id]); 236 return; 237 } 238 239 $('#cs-'+el.id+sid).css({ opacity: 0, 'background-image': 'url('+images[el.id][imagePos[el.id]]+')' }); 240 $('#cs-'+el.id+sid).animate({ opacity: 1 }, params[el.id].sDelay); 241 squarePos[el.id]++; 242 243 }; 244 245 // navigation 246 $.setNavigation = function(el){ 247 // create prev and next 248 $(el).append("<div id='cs-navigation-"+el.id+"'></div>"); 249 if(params[el.id].stickynav){ $('#cs-navigation-'+el.id).show();} 250 else{ 251 $('#cs-navigation-'+el.id).hide();} 252 253 $('#cs-navigation-'+el.id).append("<a href='#' id='cs-prev-"+el.id+"' class='cs-prev'><</a>"); 254 $('#cs-navigation-'+el.id).append("<a href='#' id='cs-next-"+el.id+"' class='cs-next'>></a>"); 255 $('#cs-prev-'+el.id).css({ 256 'position' : 'absolute', 257 'top' : params[el.id].height/2 - 15, 258 'left' : '5px', 259 'z-index' : 1001, 260 'line-height': '40px', 261 'opacity' : params[el.id].opacity 262 }).click( function(e){ 263 e.preventDefault(); 264 $.transition(el,'prev'); 265 $.transitionCall(el); 266 }).mouseover( function(){ $('#cs-navigation-'+el.id).show() }); 267 268 $('#cs-next-'+el.id).css({ 269 'position' : 'absolute', 270 'top' : params[el.id].height/2 - 15, 271 'right' : '5px', 272 'z-index' : 1001, 273 'line-height': '40px', 274 'opacity' : params[el.id].opacity 275 }).click( function(e){ 276 e.preventDefault(); 277 $.transition(el); 278 $.transitionCall(el); 279 }).mouseover( function(){ $('#cs-navigation-'+el.id).show() }); 280 281 // image buttons 282 $("<div id='cs-buttons-"+el.id+"' class='cs-buttons'></div>").appendTo($('#coin-slider-'+el.id)); 283 284 285 for(k=1;k<images[el.id].length+1;k++){ 286 $('#cs-buttons-'+el.id).append("<a href='#' class='cs-button-"+el.id+"' id='cs-button-"+el.id+"-"+k+"'>"+k+"</a>"); 287 } 288 289 $.each($('.cs-button-'+el.id), function(i,item){ 290 $(item).click( function(e){
291 $('.cs-button-'+el.id).removeClass('cs-active'); 292 $(this).addClass('cs-active'); 293 e.preventDefault(); 294 $.transition(el,i); 295 $.transitionCall(el); 296 }) 297 }); 298 299 $('#cs-navigation-'+el.id+' a').mouseout(function(){ 300 $('#cs-navigation-'+el.id).hide(); 301 params[el.id].pause = false; 302 }); 303 304 } 305 306 $.randomize = function(arr) { 307 for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x); 308 return arr; 309 }; 310 // effects 311 $.effect = function(el){ 312 effA = ['random','swirl','fade','rain','vertical','altvertical','horizontal','althorizontal','diagonal']; 313 314 if(params[el.id].effect == '') 315 eff = effA[Math.floor(Math.random()*(effA.length))]; 316 else 317 eff = params[el.id].effect; 318 319 order[el.id] = new Array(); 320 321 if(eff == 'random'){ 322 counter = 0; 323 for(i=1;i <= params[el.id].sph;i++){ 324 for(j=1; j <= params[el.id].spw; j++){ 325 order[el.id][counter] = i+''+j; 326 counter++; 327 } 328 } 329 $.random(order[el.id]); 330 } 331 332 if(eff == 'rain') { 333 $.rain(el); 334 } 335 336 if(eff == 'swirl') 337 $.swirl(el); 338 339 // Added by MR. Vibe from Vibethemes.com 340 if(eff == 'fade') 341 $.fade(el); 342 343 if(eff == 'vertical') 344 $.vertical(el); 345 346 if(eff == 'altvertical') 347 $.altvertical(el); 348 349 if(eff == 'horizontal') 350 $.horizontal(el); 351 352 if(eff == 'althorizontal') 353 $.althorizontal(el); 354 355 if(eff == 'diagonal') 356 $.diagonal(el); 357 358 reverse[el.id] *= -1; 359 if(reverse[el.id] > 0){ 360 order[el.id].reverse(); 361 } 362 363 } 364 365 366 // shuffle array function 367 $.random = function(arr) { 368 369 var i = arr.length; 370 if ( i == 0 ) return false; 371 while ( --i ) { 372 var j = Math.floor( Math.random() * ( i + 1 ) ); 373 var tempi = arr[i]; 374 var tempj = arr[j]; 375 arr[i] = tempj; 376 arr[j] = tempi; 377 } 378 } 379 380 //swirl effect by milos popovic 381 $.swirl = function(el){ 382 383 var n = params[el.id].sph; 384 var m = params[el.id].spw; 385 386 var x = 1; 387 var y = 1; 388 var going = 0; 389 var num = 0; 390 var c = 0; 391 392 var dowhile = true; 393 394 while(dowhile) { 395 396 num = (going==0 || going==2) ? m : n; 397 398 for (i=1;i<=num;i++){ 399 400 order[el.id][c] = x+''+y; 401 c++; 402 403 if(i!=num){ 404 switch(going){ 405 case 0 : y++; break; 406 case 1 : x++; break; 407 case 2 : y--; break; 408 case 3 : x--; break; 409 410 } 411 } 412 } 413 414 going = (going+1)%4; 415 416 switch(going){ 417 case 0 : m--; y++; break; 418 case 1 : n--; x++; break; 419 case 2 : m--; y--; break; 420 case 3 : n--; x--; break; 421 } 422 423 check = $.max(n,m) - $.min(n,m); 424 if(m<=check && n<=check) 425 dowhile = false; 426 427 } 428 } 429 430 // rain effect 431 $.rain = function(el){ 432 var n = params[el.id].sph; 433 var m = params[el.id].spw; 434 435 var c = 0; 436 var to = to2 = from = 1; 437 var dowhile = true; 438 439 440 while(dowhile){ 441 442 for(i=from;i<=to;i++){ 443 order[el.id][c] = i+''+parseInt(to2-i+1); 444 c++; 445 } 446 447 to2++; 448 449 if(to < n && to2 < m && n<m){ 450 to++; 451 } 452 453 if(to < n && n>=m){ 454 to++; 455 } 456 457 if(to2 > m){ 458 from++; 459 } 460 461 if(from > to) dowhile= false; 462 463 } 464 465 } 466 467 //Diagonal effect by MrVibe from VibeThemes 468 $.diagonal = function(el){ 469 counter = 0; 470 for(i=1;i <= params[el.id].sph;i++){ 471 for(j=i; j <= params[el.id].spw; j++){ 472 order[el.id][counter] = i+''+j; 473 counter++; 474 } 475 } 476 for(i=1;i <= params[el.id].sph;i++){ 477 for(j=1; j <= i-1; j++){ 478 order[el.id][counter] = i+''+j; 479 counter++; 480 } 481 } 482 } 483 484 // altvertical effect by MrVibe from VibeThemes 485 $.altvertical = function(el){ 486 counter = 0; 487 for(i=1;i <= params[el.id].sph;i=i+2){ 488 for(j=1; j <= params[el.id].spw; j++){ 489 order[el.id][counter] = i+''+j; 490 counter++; 491 } 492 } 493 for(i=2;i <= params[el.id].sph;i=i+2){ 494 for(j=1; j <= params[el.id].spw; j++){ 495 order[el.id][counter] = i+''+j; 496 counter++; 497 } 498 } 499 } 500 501 //vertical effect 502 $.vertical = function(el){ 503 counter = 0; 504 for(i=1;i <= params[el.id].sph;i++){ 505 for(j=1; j <= params[el.id].spw; j++){ 506 order[el.id][counter] = i+''+j; 507 counter++; 508 } 509 510 } 511 } 512 513 $.fade = function(el){ 514 counter = 0; 515 for(i=1;i <= 1;i++){ 516 for(j=1; j <= 1; j++){ 517 order[el.id][counter] = i+''+j; 518 counter++; 519 } 520 } 521 } 522 523 // horizontal effect 524 $.horizontal = function(el){ 525 counter = 0; 526 for(j=1; j <= params[el.id].spw; j++){ 527 for(i=1;i <= params[el.id].sph;i++){ 528 order[el.id][counter] = i+''+j; 529 counter++; 530 } 531 532 } 533 } 534 535 // althorizontal effect 536 $.althorizontal = function(el){ 537 counter = 0; 538 for(j=1; j <= params[el.id].spw; j=j+2){ 539 for(i=1;i <= params[el.id].sph;i++){ 540 order[el.id][counter] = i+''+j; 541 counter++; 542 } 543 544 } 545 for(j=2; j <= params[el.id].spw; j=j+2){ 546 for(i=1;i <= params[el.id].sph;i++){ 547 order[el.id][counter] = i+''+j; 548 counter++; 549 } 550 551 } 552 } 553 554 $.min = function(n,m){ 555 if (n>m) return m; 556 else return n; 557 } 558 559 $.max = function(n,m){ 560 if (n<m) return m; 561 else return n; 562 } 563 564 this.each ( 565 function(){ init(this); } 566 ); 567 568 569 }; 570 571 572 // default values 573 $.fn.coinslider.defaults = { 574 width: 630, // width of slider panel 575 height: 280, // height of slider panel 576 spw: 7, // squares per width 577 sph: 5, // squares per height 578 delay: 3000, // delay between images in ms 579 sDelay: 30, // delay beetwen squares in ms 580 opacity: 0.7, // opacity of title and navigation 581 titleSpeed: 500, // speed of title appereance in ms 582 effect: '', // random, swirl, rain, straight 583 navigation: true, // prev next and buttons 584 links : true, // show images as links 585 hoverPause: true // pause on hover 586 }; 587 588})(jQuery); 589
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.