1/*! 2 * jQuery Cycle Plugin (with Transition Definitions) 3 * Examples and documentation at: http://jquery.malsup.com/cycle/ 4 * Copyright (c) 2007-2013 M. Alsup 5 * Version: 3.0.3 (11-JUL-2013) 6 * Dual licensed under the MIT and GPL licenses. 7 * http://jquery.malsup.com/license.html 8 * Requires: jQuery v1.7.1 or later 9 */ 10;(function($, undefined) { 11"use strict"; 12 13var ver = '3.0.3'; 14 15function debug(s) { 16 if ($.fn.cycle.debug) 17 log(s); 18} 19function log() { 20 /*global console */ 21 if (window.console && console.log) 22 console.log('[cycle] ' + Array.prototype.join.call(arguments,' ')); 23} 24$.expr[':'].paused = function(el) { 25 return el.cyclePause; 26}; 27 28 29// the options arg can be... 30// a number - indicates an immediate transition should occur to the given slide index 31// a string - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc) 32// an object - properties to control the slideshow 33// 34// the arg2 arg can be... 35// the name of an fx (only used in conjunction with a numeric value for 'options') 36// the value true (only used in first arg == 'resume') and indicates 37// that the resume should occur immediately (not wait for next timeout) 38 39$.fn.cycle = function(options, arg2) { 40 var o = { s: this.selector, c: this.context }; 41 42 // in 1.3+ we can fix mistakes with the ready state 43 if (this.length === 0 && options != 'stop') { 44 if (!$.isReady && o.s) { 45 log('DOM not ready, queuing slideshow'); 46 $(function() { 47 $(o.s,o.c).cycle(options,arg2); 48 }); 49 return this; 50 } 51 // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready() 52 log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); 53 return this; 54 } 55 56 // iterate the matched nodeset 57 return this.each(function() { 58 var opts = handleArguments(this, options, arg2); 59 if (opts === false) 60 return; 61 62 opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink; 63 64 // stop existing slideshow for this container (if there is one) 65 if (this.cycleTimeout) 66 clearTimeout(this.cycleTimeout); 67 this.cycleTimeout = this.cyclePause = 0; 68 this.cycleStop = 0; // issue #108 69 70 var $cont = $(this); 71 var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children(); 72 var els = $slides.get(); 73 74 if (els.length < 2) { 75 log('terminating; too few slides: ' + els.length); 76 return; 77 } 78 79 var opts2 = buildOptions($cont, $slides, els, opts, o); 80 if (opts2 === false) 81 return; 82 83 var startTime = opts2.continuous ? 10 : getTimeout(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.backwards); 84 85 // if it's an auto slideshow, kick it off 86 if (startTime) { 87 startTime += (opts2.delay || 0); 88 if (startTime < 10) 89 startTime = 10; 90 debug('first timeout: ' + startTime); 91 this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts.backwards);}, startTime); 92 } 93 }); 94}; 95 96function triggerPause(cont, byHover, onPager) { 97 var opts = $(cont).data('cycle.opts'); 98 if (!opts) 99 return; 100 var paused = !!cont.cyclePause; 101 if (paused && opts.paused) 102 opts.paused(cont, opts, byHover, onPager); 103 else if (!paused && opts.resumed) 104 opts.resumed(cont, opts, byHover, onPager); 105} 106 107// process the args that were passed to the plugin fn 108function handleArguments(cont, options, arg2) { 109 if (cont.cycleStop === undefined) 110 cont.cycleStop = 0; 111 if (options === undefined || options === null) 112 options = {}; 113 if (options.constructor == String) { 114 switch(options) { 115 case 'destroy': 116 case 'stop': 117 var opts = $(cont).data('cycle.opts'); 118 if (!opts) 119 return false; 120 cont.cycleStop++; // callbacks look for change 121 if (cont.cycleTimeout) 122 clearTimeout(cont.cycleTimeout); 123 cont.cycleTimeout = 0; 124 if (opts.elements) 125 $(opts.elements).stop(); 126 $(cont).removeData('cycle.opts'); 127 if (options == 'destroy') 128 destroy(cont, opts); 129 return false; 130 case 'toggle': 131 cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1; 132 checkInstantResume(cont.cyclePause, arg2, cont); 133 triggerPause(cont); 134 return false; 135 case 'pause': 136 cont.cyclePause = 1; 137 triggerPause(cont); 138 return false;
139 case 'resume': 140 cont.cyclePause = 0; 141 checkInstantResume(false, arg2, cont); 142 triggerPause(cont); 143 return false; 144 case 'prev': 145 case 'next': 146 opts = $(cont).data('cycle.opts'); 147 if (!opts) { 148 log('options not found, "prev/next" ignored'); 149 return false; 150 } 151 if (typeof arg2 == 'string') 152 opts.oneTimeFx = arg2; 153 $.fn.cycle[options](opts); 154 return false; 155 default: 156 options = { fx: options }; 157 } 158 return options; 159 } 160 else if (options.constructor == Number) { 161 // go to the requested slide 162 var num = options; 163 options = $(cont).data('cycle.opts'); 164 if (!options) { 165 log('options not found, can not advance slide'); 166 return false; 167 } 168 if (num < 0 || num >= options.elements.length) { 169 log('invalid slide index: ' + num); 170 return false; 171 } 172 options.nextSlide = num; 173 if (cont.cycleTimeout) { 174 clearTimeout(cont.cycleTimeout); 175 cont.cycleTimeout = 0; 176 } 177 if (typeof arg2 == 'string') 178 options.oneTimeFx = arg2; 179 go(options.elements, options, 1, num >= options.currSlide); 180 return false; 181 } 182 return options; 183 184 function checkInstantResume(isPaused, arg2, cont) { 185 if (!isPaused && arg2 === true) { // resume now! 186 var options = $(cont).data('cycle.opts'); 187 if (!options) { 188 log('options not found, can not resume'); 189 return false; 190 } 191 if (cont.cycleTimeout) { 192 clearTimeout(cont.cycleTimeout); 193 cont.cycleTimeout = 0; 194 } 195 go(options.elements, options, 1, !options.backwards); 196 } 197 } 198} 199 200function removeFilter(el, opts) { 201 if (!$.support.opacity && opts.cleartype && el.style.filter) { 202 try { el.style.removeAttribute('filter'); } 203 catch(smother) {} // handle old opera versions 204 } 205} 206 207// unbind event handlers 208function destroy(cont, opts) { 209 if (opts.next) 210 $(opts.next).unbind(opts.prevNextEvent); 211 if (opts.prev) 212 $(opts.prev).unbind(opts.prevNextEvent); 213 214 if (opts.pager || opts.pagerAnchorBuilder) 215 $.each(opts.pagerAnchors || [], function() { 216 this.unbind().remove(); 217 }); 218 opts.pagerAnchors = null; 219 $(cont).unbind('mouseenter.cycle mouseleave.cycle'); 220 if (opts.destroy) // callback 221 opts.destroy(opts); 222} 223 224// one-time initialization 225function buildOptions($cont, $slides, els, options, o) { 226 var startingSlideSpecified; 227 // support metadata plugin (v1.0 and v2.0) 228 var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {}); 229 var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null; 230 if (meta) 231 opts = $.extend(opts, meta); 232 if (opts.autostop) 233 opts.countdown = opts.autostopCount || els.length; 234 235 var cont = $cont[0]; 236 $cont.data('cycle.opts', opts); 237 opts.$cont = $cont; 238 opts.stopCount = cont.cycleStop; 239 opts.elements = els; 240 opts.before = opts.before ? [opts.before] : []; 241 opts.after = opts.after ? [opts.after] : []; 242 243 // push some after callbacks 244 if (!$.support.opacity && opts.cleartype) 245 opts.after.push(function() { removeFilter(this, opts); }); 246 if (opts.continuous) 247 opts.after.push(function() { go(els,opts,0,!opts.backwards); }); 248 249 saveOriginalOpts(opts); 250 251 // clearType corrections 252 if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) 253 clearTypeFix($slides); 254 255 // container requires non-static position so that slides can be position within 256 if ($cont.css('position') == 'static') 257 $cont.css('position', 'relative'); 258 if (opts.width) 259 $cont.width(opts.width); 260 if (opts.height && opts.height != 'auto') 261 $cont.height(opts.height); 262 263 if (opts.startingSlide !== undefined) { 264 opts.startingSlide = parseInt(opts.startingSlide,10); 265 if (opts.startingSlide >= els.length || opts.startSlide < 0) 266 opts.startingSlide = 0; // catch bogus input 267 else 268 startingSlideSpecified = true; 269 } 270 else if (opts.backwards) 271 opts.startingSlide = els.length - 1; 272 else 273 opts.startingSlide = 0; 274 275 // if random, mix up the slide array 276 if (opts.random) { 277 opts.randomMap = []; 278 for (var i = 0; i < els.length; i++) 279 opts.randomMap.push(i); 280 opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); 281 if (startingSlideSpecified) { 282 // try to find the specified starting slide and if found set start slide index in the map accordingly 283 for ( var cnt = 0; cnt < els.length; cnt++ ) { 284 if ( opts.startingSlide == opts.randomMap[cnt] ) { 285 opts.randomIndex = cnt; 286 } 287 } 288 } 289 else { 290 opts.randomIndex = 1; 291 opts.startingSlide = opts.randomMap[1]; 292 } 293 } 294 else if (opts.startingSlide >= els.length) 295 opts.startingSlide = 0; // catch bogus input 296 opts.currSlide = opts.startingSlide || 0; 297 var first = opts.startingSlide; 298 299 // set position and zIndex on all the slides
300 $slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) { 301 var z; 302 if (opts.backwards) 303 z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i; 304 else 305 z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i; 306 $(this).css('z-index', z); 307 }); 308 309 // make sure first slide is visible 310 $(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case 311 removeFilter(els[first], opts); 312 313 // stretch slides 314 if (opts.fit) { 315 if (!opts.aspect) { 316 if (opts.width) 317 $slides.width(opts.width); 318 if (opts.height && opts.height != 'auto') 319 $slides.height(opts.height); 320 } else { 321 $slides.each(function(){ 322 var $slide = $(this); 323 var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect; 324 if( opts.width && $slide.width() != opts.width ) { 325 $slide.width( opts.width ); 326 $slide.height( opts.width / ratio ); 327 } 328 329 if( opts.height && $slide.height() < opts.height ) { 330 $slide.height( opts.height ); 331 $slide.width( opts.height * ratio ); 332 } 333 }); 334 } 335 } 336 337 if (opts.center && ((!opts.fit) || opts.aspect)) { 338 $slides.each(function(){ 339 var $slide = $(this); 340 $slide.css({ 341 "margin-left": opts.width ? 342 ((opts.width - $slide.width()) / 2) + "px" : 343 0, 344 "margin-top": opts.height ? 345 ((opts.height - $slide.height()) / 2) + "px" : 346 0 347 }); 348 }); 349 } 350 351 if (opts.center && !opts.fit && !opts.slideResize) { 352 $slides.each(function(){ 353 var $slide = $(this); 354 $slide.css({ 355 "margin-left": opts.width ? ((opts.width - $slide.width()) / 2) + "px" : 0, 356 "margin-top": opts.height ? ((opts.height - $slide.height()) / 2) + "px" : 0 357 }); 358 }); 359 } 360 361 // stretch container 362 var reshape = (opts.containerResize || opts.containerResizeHeight) && $cont.innerHeight() < 1; 363 if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9 364 var maxw = 0, maxh = 0; 365 for(var j=0; j < els.length; j++) { 366 var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight(); 367 if (!w) w = e.offsetWidth || e.width || $e.attr('width'); 368 if (!h) h = e.offsetHeight || e.height || $e.attr('height'); 369 maxw = w > maxw ? w : maxw; 370 maxh = h > maxh ? h : maxh; 371 } 372 if (opts.containerResize && maxw > 0 && maxh > 0) 373 $cont.css({width:maxw+'px',height:maxh+'px'}); 374 if (opts.containerResizeHeight && maxh > 0) 375 $cont.css({height:maxh+'px'}); 376 } 377 378 var pauseFlag = false; // https://github.com/malsup/cycle/issues/44 379 if (opts.pause) 380 $cont.bind('mouseenter.cycle', function(){ 381 pauseFlag = true; 382 this.cyclePause++; 383 triggerPause(cont, true); 384 }).bind('mouseleave.cycle', function(){ 385 if (pauseFlag) 386 this.cyclePause--; 387 triggerPause(cont, true); 388 }); 389 390 if (supportMultiTransitions(opts) === false) 391 return false; 392 393 // apparently a lot of people use image slideshows without height/width attributes on the images. 394 // Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that. 395 var requeue = false; 396 options.requeueAttempts = options.requeueAttempts || 0; 397 $slides.each(function() { 398 // try to get height/width of each slide 399 var $el = $(this); 400 this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0); 401 this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0); 402 403 if ( $el.is('img') ) { 404 var loading = (this.cycleH === 0 && this.cycleW === 0 && !this.complete); 405 // don't requeue for images that are still loading but have a valid size 406 if (loading) { 407 if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever 408 log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH); 409 setTimeout(function() {$(o.s,o.c).cycle(options);}, opts.requeueTimeout); 410 requeue = true; 411 return false; // break each loop 412 } 413 else { 414 log('could not determine size of image: '+this.src, this.cycleW, this.cycleH); 415 } 416 } 417 } 418 return true; 419 }); 420 421 if (requeue) 422 return false;
423 424 opts.cssBefore = opts.cssBefore || {}; 425 opts.cssAfter = opts.cssAfter || {}; 426 opts.cssFirst = opts.cssFirst || {}; 427 opts.animIn = opts.animIn || {}; 428 opts.animOut = opts.animOut || {}; 429 430 $slides.not(':eq('+first+')').css(opts.cssBefore); 431 $($slides[first]).css(opts.cssFirst); 432 433 if (opts.timeout) { 434 opts.timeout = parseInt(opts.timeout,10); 435 // ensure that timeout and speed settings are sane 436 if (opts.speed.constructor == String) 437 opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed,10); 438 if (!opts.sync) 439 opts.speed = opts.speed / 2; 440 441 var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250; 442 while((opts.timeout - opts.speed) < buffer) // sanitize timeout 443 opts.timeout += opts.speed; 444 } 445 if (opts.easing) 446 opts.easeIn = opts.easeOut = opts.easing; 447 if (!opts.speedIn) 448 opts.speedIn = opts.speed; 449 if (!opts.speedOut) 450 opts.speedOut = opts.speed; 451 452 opts.slideCount = els.length; 453 opts.currSlide = opts.lastSlide = first; 454 if (opts.random) { 455 if (++opts.randomIndex == els.length) 456 opts.randomIndex = 0; 457 opts.nextSlide = opts.randomMap[opts.randomIndex]; 458 } 459 else if (opts.backwards) 460 opts.nextSlide = opts.startingSlide === 0 ? (els.length-1) : opts.startingSlide-1; 461 else 462 opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1; 463 464 // run transition init fn 465 if (!opts.multiFx) { 466 var init = $.fn.cycle.transitions[opts.fx]; 467 if ($.isFunction(init)) 468 init($cont, $slides, opts); 469 else if (opts.fx != 'custom' && !opts.multiFx) { 470 log('unknown transition: ' + opts.fx,'; slideshow terminating'); 471 return false; 472 } 473 } 474 475 // fire artificial events 476 var e0 = $slides[first]; 477 if (!opts.skipInitializationCallbacks) { 478 if (opts.before.length) 479 opts.before[0].apply(e0, [e0, e0, opts, true]); 480 if (opts.after.length) 481 opts.after[0].apply(e0, [e0, e0, opts, true]); 482 } 483 if (opts.next) 484 $(opts.next).bind(opts.prevNextEvent,function(){ 485 //ãã°ä»è¾¼ã¿ãkondo ua_log 486 if(typeof $.getClick == 'function') { 487 $.getClick($(opts.next),true); 488 } 489 return advance(opts,1); 490 }); 491 if (opts.prev) 492 $(opts.prev).bind(opts.prevNextEvent,function(){ 493 //ãã°ä»è¾¼ã¿ãkondo ua_log 494 if(typeof $.getClick == 'function') { 495 $.getClick($(opts.prev),true); 496 } 497 return advance(opts,0); 498 }); 499 if (opts.pager || opts.pagerAnchorBuilder) 500 buildPager(els,opts); 501 502 exposeAddSlide(opts, els); 503 504 return opts; 505} 506 507// save off original opts so we can restore after clearing state 508function saveOriginalOpts(opts) { 509 opts.original = { before: [], after: [] }; 510 opts.original.cssBefore = $.extend({}, opts.cssBefore); 511 opts.original.cssAfter = $.extend({}, opts.cssAfter); 512 opts.original.animIn = $.extend({}, opts.animIn); 513 opts.original.animOut = $.extend({}, opts.animOut); 514 $.each(opts.before, function() { opts.original.before.push(this); }); 515 $.each(opts.after, function() { opts.original.after.push(this); }); 516} 517 518function supportMultiTransitions(opts) { 519 var i, tx, txs = $.fn.cycle.transitions; 520 // look for multiple effects 521 if (opts.fx.indexOf(',') > 0) { 522 opts.multiFx = true; 523 opts.fxs = opts.fx.replace(/\s*/g,'').split(','); 524 // discard any bogus effect names 525 for (i=0; i < opts.fxs.length; i++) { 526 var fx = opts.fxs[i]; 527 tx = txs[fx]; 528 if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) { 529 log('discarding unknown transition: ',fx); 530 opts.fxs.splice(i,1); 531 i--; 532 } 533 } 534 // if we have an empty list then we threw everything away! 535 if (!opts.fxs.length) { 536 log('No valid transitions named; slideshow terminating.'); 537 return false; 538 } 539 } 540 else if (opts.fx == 'all') { // auto-gen the list of transitions 541 opts.multiFx = true; 542 opts.fxs = []; 543 for (var p in txs) { 544 if (txs.hasOwnProperty(p)) { 545 tx = txs[p]; 546 if (txs.hasOwnProperty(p) && $.isFunction(tx)) 547 opts.fxs.push(p); 548 } 549 } 550 } 551 if (opts.multiFx && opts.randomizeEffects) { 552 // munge the fxs array to make effect selection random 553 var r1 = Math.floor(Math.random() * 20) + 30; 554 for (i = 0; i < r1; i++) { 555 var r2 = Math.floor(Math.random() * opts.fxs.length); 556 opts.fxs.push(opts.fxs.splice(r2,1)[0]); 557 } 558 debug('randomized fx sequence: ',opts.fxs); 559 } 560 return true; 561} 562 563// provide a mechanism for adding slides after the slideshow has started 564function exposeAddSlide(opts, els) { 565 opts.addSlide = function(newSlide, prepend) {
566 var $s = $(newSlide), s = $s[0]; 567 if (!opts.autostopCount) 568 opts.countdown++; 569 els[prepend?'unshift':'push'](s); 570 if (opts.els) 571 opts.els[prepend?'unshift':'push'](s); // shuffle needs this 572 opts.slideCount = els.length; 573 574 // add the slide to the random map and resort 575 if (opts.random) { 576 opts.randomMap.push(opts.slideCount-1); 577 opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); 578 } 579 580 $s.css('position','absolute'); 581 $s[prepend?'prependTo':'appendTo'](opts.$cont); 582 583 if (prepend) { 584 opts.currSlide++; 585 opts.nextSlide++; 586 } 587 588 if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) 589 clearTypeFix($s); 590 591 if (opts.fit && opts.width) 592 $s.width(opts.width); 593 if (opts.fit && opts.height && opts.height != 'auto') 594 $s.height(opts.height); 595 s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height(); 596 s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width(); 597 598 $s.css(opts.cssBefore); 599 600 if (opts.pager || opts.pagerAnchorBuilder) 601 $.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts); 602 603 if ($.isFunction(opts.onAddSlide)) 604 opts.onAddSlide($s); 605 else 606 $s.hide(); // default behavior 607 }; 608} 609 610// reset internal state; we do this on every pass in order to support multiple effects 611$.fn.cycle.resetState = function(opts, fx) { 612 fx = fx || opts.fx; 613 opts.before = []; opts.after = []; 614 opts.cssBefore = $.extend({}, opts.original.cssBefore); 615 opts.cssAfter = $.extend({}, opts.original.cssAfter); 616 opts.animIn = $.extend({}, opts.original.animIn); 617 opts.animOut = $.extend({}, opts.original.animOut); 618 opts.fxFn = null; 619 $.each(opts.original.before, function() { opts.before.push(this); }); 620 $.each(opts.original.after, function() { opts.after.push(this); }); 621 622 // re-init 623 var init = $.fn.cycle.transitions[fx]; 624 if ($.isFunction(init)) 625 init(opts.$cont, $(opts.elements), opts); 626}; 627 628// this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt 629function go(els, opts, manual, fwd) { 630 var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide]; 631 632 // opts.busy is true if we're in the middle of an animation 633 if (manual && opts.busy && opts.manualTrump) { 634 // let manual transitions requests trump active ones 635 debug('manualTrump in go(), stopping active transition'); 636 $(els).stop(true,true); 637 opts.busy = 0; 638 clearTimeout(p.cycleTimeout); 639 } 640 641 // don't begin another timeout-based transition if there is one active 642 if (opts.busy) { 643 debug('transition active, ignoring new tx request'); 644 return; 645 } 646 647 648 // stop cycling if we have an outstanding stop request 649 if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual) 650 return; 651 652 // check to see if we should stop cycling based on autostop options 653 if (!manual && !p.cyclePause && !opts.bounce && 654 ((opts.autostop && (--opts.countdown <= 0)) || 655 (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) { 656 if (opts.end) 657 opts.end(opts); 658 return; 659 } 660 661 // if slideshow is paused, only transition on a manual trigger 662 var changed = false; 663 if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) { 664 changed = true; 665 var fx = opts.fx; 666 // keep trying to get the slide size if we don't have it yet 667 curr.cycleH = curr.cycleH || $(curr).height(); 668 curr.cycleW = curr.cycleW || $(curr).width(); 669 next.cycleH = next.cycleH || $(next).height(); 670 next.cycleW = next.cycleW || $(next).width(); 671 672 // support multiple transition types 673 if (opts.multiFx) { 674 if (fwd && (opts.lastFx === undefined || ++opts.lastFx >= opts.fxs.length)) 675 opts.lastFx = 0; 676 else if (!fwd && (opts.lastFx === undefined || --opts.lastFx < 0)) 677 opts.lastFx = opts.fxs.length - 1; 678 fx = opts.fxs[opts.lastFx]; 679 } 680 681 // one-time fx overrides apply to: $('div').cycle(3,'zoom'); 682 if (opts.oneTimeFx) { 683 fx = opts.oneTimeFx; 684 opts.oneTimeFx = null; 685 } 686 687 $.fn.cycle.resetState(opts, fx); 688 689 // run the before callbacks 690 if (opts.before.length) 691 $.each(opts.before, function(i,o) { 692 if (p.cycleStop != opts.stopCount) return; 693 o.apply(next, [curr, next, opts, fwd]); 694 }); 695 696 // stage the after callacks 697 var after = function() { 698 opts.busy = 0; 699 $.each(opts.after, function(i,o) { 700 if (p.cycleStop != opts.stopCount) return; 701 o.apply(next, [curr, next, opts, fwd]); 702 }); 703 if (!p.cycleStop) { 704 // queue next transition 705 queueNext(); 706 } 707 }; 708 709 debug('tx firing('+fx+'); currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide); 710 711 // get ready to perform the transition 712 opts.busy = 1; 713 if (opts.fxFn) // fx function provided? 714 opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent); 715 else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ? 716 $.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent); 717 else 718 $.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent); 719 } 720 else { 721 queueNext(); 722 } 723 724 if (changed || opts.nextSlide == opts.currSlide) { 725 // calculate the next slide 726 var roll; 727 opts.lastSlide = opts.currSlide; 728 if (opts.random) { 729 opts.currSlide = opts.nextSlide; 730 if (++opts.randomIndex == els.length) { 731 opts.randomIndex = 0; 732 opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); 733 } 734 opts.nextSlide = opts.randomMap[opts.randomIndex]; 735 if (opts.nextSlide == opts.currSlide) 736 opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1; 737 } 738 else if (opts.backwards) { 739 roll = (opts.nextSlide - 1) < 0; 740 if (roll && opts.bounce) { 741 opts.backwards = !opts.backwards; 742 opts.nextSlide = 1; 743 opts.currSlide = 0; 744 } 745 else { 746 opts.nextSlide = roll ? (els.length-1) : opts.nextSlide-1; 747 opts.currSlide = roll ? 0 : opts.nextSlide+1; 748 } 749 } 750 else { // sequence 751 roll = (opts.nextSlide + 1) == els.length; 752 if (roll && opts.bounce) { 753 opts.backwards = !opts.backwards; 754 opts.nextSlide = els.length-2; 755 opts.currSlide = els.length-1; 756 } 757 else { 758 opts.nextSlide = roll ? 0 : opts.nextSlide+1; 759 opts.currSlide = roll ? els.length-1 : opts.nextSlide-1; 760 } 761 } 762 } 763 if (changed && opts.pager) 764 opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass); 765 766 function queueNext() { 767 // stage the next transition 768 var ms = 0, timeout = opts.timeout; 769 if (opts.timeout && !opts.continuous) { 770 ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd); 771 if (opts.fx == 'shuffle') 772 ms -= opts.speedOut; 773 } 774 else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic 775 ms = 10; 776 if (ms > 0) 777 p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.backwards); }, ms); 778 } 779} 780 781// invoked after transition 782$.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) { 783 $(pager).each(function() { 784 $(this).children().removeClass(clsName).eq(currSlide).addClass(clsName); 785 }); 786}; 787 788// calculate timeout value for current transition 789function getTimeout(curr, next, opts, fwd) { 790 if (opts.timeoutFn) { 791 // call user provided calc fn 792 var t = opts.timeoutFn.call(curr,curr,next,opts,fwd); 793 while (opts.fx != 'none' && (t - opts.speed) < 250) // sanitize timeout 794 t += opts.speed;
795 debug('calculated timeout: ' + t + '; speed: ' + opts.speed); 796 if (t !== false) 797 return t; 798 } 799 return opts.timeout; 800} 801 802// expose next/prev function, caller must pass in state 803$.fn.cycle.next = function(opts) { advance(opts,1); }; 804$.fn.cycle.prev = function(opts) { advance(opts,0);}; 805 806// advance slide forward or back 807function advance(opts, moveForward) { 808 var val = moveForward ? 1 : -1; 809 var els = opts.elements; 810 var p = opts.$cont[0], timeout = p.cycleTimeout; 811 812 813 814 if (timeout) { 815 clearTimeout(timeout); 816 p.cycleTimeout = 0; 817 } 818 if (opts.random && val < 0) { 819 // move back to the previously display slide 820 opts.randomIndex--; 821 if (--opts.randomIndex == -2) 822 opts.randomIndex = els.length-2; 823 else if (opts.randomIndex == -1) 824 opts.randomIndex = els.length-1; 825 opts.nextSlide = opts.randomMap[opts.randomIndex]; 826 } 827 else if (opts.random) { 828 opts.nextSlide = opts.randomMap[opts.randomIndex]; 829 } 830 else { 831 opts.nextSlide = opts.currSlide + val; 832 if (opts.nextSlide < 0) { 833 if (opts.nowrap) return false; 834 opts.nextSlide = els.length - 1; 835 } 836 else if (opts.nextSlide >= els.length) { 837 if (opts.nowrap) return false; 838 opts.nextSlide = 0; 839 } 840 } 841 842 var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated 843 if ($.isFunction(cb)) 844 cb(val > 0, opts.nextSlide, els[opts.nextSlide]); 845 go(els, opts, 1, moveForward); 846 return false; 847} 848 849function buildPager(els, opts) { 850 var $p = $(opts.pager); 851 $.each(els, function(i,o) { 852 $.fn.cycle.createPagerAnchor(i,o,$p,els,opts); 853 }); 854 opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass); 855} 856 857$.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) { 858 var a; 859 if ($.isFunction(opts.pagerAnchorBuilder)) { 860 a = opts.pagerAnchorBuilder(i,el); 861 debug('pagerAnchorBuilder('+i+', el) returned: ' + a); 862 } 863 else 864 a = '<a href="#">'+(i+1)+'</a>'; 865 866 if (!a) 867 return; 868 var $a = $(a); 869 // don't reparent if anchor is in the dom 870 if ($a.parents('body').length === 0) { 871 var arr = []; 872 if ($p.length > 1) { 873 $p.each(function() { 874 var $clone = $a.clone(true); 875 $(this).append($clone); 876 arr.push($clone[0]); 877 }); 878 $a = $(arr); 879 } 880 else { 881 $a.appendTo($p); 882 } 883 } 884 885 opts.pagerAnchors = opts.pagerAnchors || []; 886 opts.pagerAnchors.push($a); 887 888 var pagerFn = function(e) { 889 e.preventDefault(); 890 opts.nextSlide = i; 891 var p = opts.$cont[0], timeout = p.cycleTimeout; 892 if (timeout) { 893 clearTimeout(timeout); 894 p.cycleTimeout = 0; 895 } 896 var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated 897 if ($.isFunction(cb)) 898 cb(opts.nextSlide, els[opts.nextSlide]); 899 go(els,opts,1,opts.currSlide < i); // trigger the trans 900// return false; // <== allow bubble 901 }; 902 903 if ( /mouseenter|mouseover/i.test(opts.pagerEvent) ) { 904 $a.hover(pagerFn, function(){/* no-op */} ); 905 } 906 else { 907 $a.bind(opts.pagerEvent, pagerFn); 908 } 909 910 if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble) 911 $a.bind('click.cycle', function(){return false;}); // suppress click 912 913 var cont = opts.$cont[0]; 914 var pauseFlag = false; // https://github.com/malsup/cycle/issues/44 915 if (opts.pauseOnPagerHover) { 916 $a.hover( 917 function() { 918 pauseFlag = true; 919 cont.cyclePause++; 920 triggerPause(cont,true,true); 921 }, function() { 922 if (pauseFlag) 923 cont.cyclePause--; 924 triggerPause(cont,true,true); 925 } 926 ); 927 } 928}; 929 930// helper fn to calculate the number of slides between the current and the next 931$.fn.cycle.hopsFromLast = function(opts, fwd) { 932 var hops, l = opts.lastSlide, c = opts.currSlide; 933 if (fwd) 934 hops = c > l ? c - l : opts.slideCount - l; 935 else 936 hops = c < l ? l - c : l + opts.slideCount - c; 937 return hops; 938}; 939 940// fix clearType problems in ie6 by setting an explicit bg color 941// (otherwise text slides look horrible during a fade transition) 942function clearTypeFix($slides) { 943 debug('applying clearType background-color hack'); 944 function hex(s) { 945 s = parseInt(s,10).toString(16); 946 return s.length < 2 ? '0'+s : s; 947 } 948 function getBg(e) { 949 for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) { 950 var v = $.css(e,'background-color'); 951 if (v && v.indexOf('rgb') >= 0 ) { 952 var rgb = v.match(/\d+/g); 953 return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]); 954 } 955 if (v && v != 'transparent') 956 return v; 957 } 958 return '#ffffff'; 959 } 960 $slides.each(function() { $(this).css('background-color', getBg(this)); }); 961} 962 963// reset common props before the next transition 964$.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) { 965 $(opts.elements).not(curr).hide(); 966 if (typeof opts.cssBefore.opacity == 'undefined') 967 opts.cssBefore.opacity = 1; 968 opts.cssBefore.display = 'block'; 969 if (opts.slideResize && w !== false && next.cycleW > 0) 970 opts.cssBefore.width = next.cycleW; 971 if (opts.slideResize && h !== false && next.cycleH > 0) 972 opts.cssBefore.height = next.cycleH; 973 opts.cssAfter = opts.cssAfter || {}; 974 opts.cssAfter.display = 'none'; 975 //2015-5-18 matsuuchi �X���C�hz-index����
976 //$(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0)); 977 //$(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1)); 978 $(curr).css('zIndex',1 + (rev === true ? 1 : 0)); 979 $(next).css('zIndex',1 + (rev === true ? 0 : 1)); 980 981}; 982 983// the actual fn for effecting a transition 984$.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) { 985 var $l = $(curr), $n = $(next); 986 var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut, animInDelay = opts.animInDelay, animOutDelay = opts.animOutDelay; 987 $n.css(opts.cssBefore); 988 if (speedOverride) { 989 if (typeof speedOverride == 'number') 990 speedIn = speedOut = speedOverride; 991 else 992 speedIn = speedOut = 1; 993 easeIn = easeOut = null; 994 } 995 var fn = function() { 996 $n.delay(animInDelay).animate(opts.animIn, speedIn, easeIn, function() { 997 cb(); 998 }); 999 }; 1000 $l.delay(animOutDelay).animate(opts.animOut, speedOut, easeOut, function() { 1001 $l.css(opts.cssAfter); 1002 if (!opts.sync) 1003 fn(); 1004 }); 1005 if (opts.sync) fn(); 1006}; 1007 1008// transition definitions - only fade is defined here, transition pack defines the rest 1009$.fn.cycle.transitions = { 1010 fade: function($cont, $slides, opts) { 1011 $slides.not(':eq('+opts.currSlide+')').css('opacity',0); 1012 opts.before.push(function(curr,next,opts) { 1013 $.fn.cycle.commonReset(curr,next,opts); 1014 opts.cssBefore.opacity = 0; 1015 }); 1016 opts.animIn = { opacity: 1 }; 1017 opts.animOut = { opacity: 0 }; 1018 opts.cssBefore = { top: 0, left: 0 }; 1019 } 1020}; 1021 1022$.fn.cycle.ver = function() { return ver; }; 1023 1024// override these globally if you like (they are all optional) 1025$.fn.cycle.defaults = { 1026 activePagerClass: 'activeSlide', // class name used for the active pager link 1027 after: null, // transition callback (scope set to element that was shown): function(currSlideElement, nextSlideElement, options, forwardFlag) 1028 allowPagerClickBubble: false, // allows or prevents click event on pager anchors from bubbling 1029 animIn: null, // properties that define how the slide animates in 1030 animInDelay: 0, // allows delay before next slide transitions in 1031 animOut: null, // properties that define how the slide animates out 1032 animOutDelay: 0, // allows delay before current slide transitions out 1033 aspect: false, // preserve aspect ratio during fit resizing, cropping if necessary (must be used with fit option) 1034 autostop: 0, // true to end slideshow after X transitions (where X == slide count) 1035 autostopCount: 0, // number of transitions (optionally used with autostop to define X) 1036 backwards: false, // true to start slideshow at last slide and move backwards through the stack 1037 before: null, // transition callback (scope set to element to be shown): function(currSlideElement, nextSlideElement, options, forwardFlag) 1038 center: null, // set to true to have cycle add top/left margin to each slide (use with width and height options) 1039 cleartype: !$.support.opacity, // true if clearType corrections should be applied (for IE) 1040 cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides) 1041 containerResize: 1, // resize container to fit largest slide 1042 containerResizeHeight: 0, // resize containers height to fit the largest slide but leave the width dynamic 1043 continuous: 0, // true to start next transition immediately after current one completes 1044 cssAfter: null, // properties that defined the state of the slide after transitioning out 1045 cssBefore: null, // properties that define the initial state of the slide before transitioning in 1046 delay: 0, // additional delay (in ms) for first transition (hint: can be negative) 1047 easeIn: null, // easing for "in" transition 1048 easeOut: null, // easing for "out" transition 1049 easing: null, // easing method for both in and out transitions 1050 end: null, // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options) 1051 fastOnEvent: 0, // force fast transitions when triggered manually (via pager or prev/next); value == time in ms 1052 fit: 0, // force slides to fit container 1053 fx: 'fade', // name of transition effect (or comma separated names, ex: 'fade,scrollUp,shuffle') 1054 fxFn: null, // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) 1055 height: 'auto', // container height (if the 'fit' option is true, the slides will be set to this height as well) 1056 manualTrump: true, // causes manual transition to stop an active transition instead of being ignored 1057 metaAttr: 'cycle', // data- attribute that holds the option data for the slideshow 1058 next: null, // element, jQuery object, or jQuery selector string for the element to use as event trigger for next slide 1059 nowrap: 0, // true to prevent slideshow from wrapping 1060 onPagerEvent: null, // callback fn for pager events: function(zeroBasedSlideIndex, slideElement) 1061 onPrevNextEvent: null, // callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement) 1062 pager: null, // element, jQuery object, or jQuery selector string for the element to use as pager container 1063 pagerAnchorBuilder: null, // callback fn for building anchor links: function(index, DOMelement) 1064 pagerEvent: 'click.cycle', // name of event which drives the pager navigation 1065 pause: 0, // true to enable "pause on hover" 1066 pauseOnPagerHover: 0, // true to pause when hovering over pager link 1067 prev: null, // element, jQuery object, or jQuery selector string for the element to use as event trigger for previous slide 1068 prevNextEvent: 'click.cycle',// event which drives the manual transition to the previous or next slide 1069 random: 0, // true for random, false for sequence (not applicable to shuffle fx) 1070 randomizeEffects: 1, // valid when multiple effects are used; true to make the effect sequence random 1071 requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded 1072 requeueTimeout: 250, // ms delay for requeue 1073 rev: 0, // causes animations to transition in reverse (for effects that support it such as scrollHorz/scrollVert/shuffle) 1074 shuffle: null, // coords for shuffle animation, ex: { top:15, left: 200 } 1075 skipInitializationCallbacks: false, // set to true to disable the first before/after callback that occurs prior to any transition 1076 slideExpr: null, // expression for selecting slides (if something other than all children is required) 1077 slideResize: 1, // force slide width/height to fixed size before every transition 1078 speed: 1000, // speed of the transition (any valid fx speed value) 1079 speedIn: null, // speed of the 'in' transition 1080 speedOut: null, // speed of the 'out' transition 1081 startingSlide: undefined,// zero-based index of the first slide to be displayed 1082 sync: 1, // true if in/out transitions should occur simultaneously 1083 timeout: 4000, // milliseconds between slide transitions (0 to disable auto advance) 1084 timeoutFn: null, // callback for determining per-slide timeout value: function(currSlideElement, nextSlideElement, options, forwardFlag) 1085 updateActivePagerLink: null,// callback fn invoked to update the active pager link (adds/removes activePagerClass style) 1086 width: null // container width (if the 'fit' option is true, the slides will be set to this width as well) 1087}; 1088 1089}
1089)(jQuery); 1090 1091 1092/*! 1093 * jQuery Cycle Plugin Transition Definitions 1094 * This script is a plugin for the jQuery Cycle Plugin 1095 * Examples and documentation at: http://malsup.com/jquery/cycle/ 1096 * Copyright (c) 2007-2010 M. Alsup 1097 * Version: 2.73 1098 * Dual licensed under the MIT and GPL licenses: 1099 * http://www.opensource.org/licenses/mit-license.php 1100 * http://www.gnu.org/licenses/gpl.html 1101 */ 1102(function($) { 1103"use strict"; 1104 1105// 1106// These functions define slide initialization and properties for the named 1107// transitions. To save file size feel free to remove any of these that you 1108// don't need. 1109// 1110$.fn.cycle.transitions.none = function($cont, $slides, opts) { 1111 opts.fxFn = function(curr,next,opts,after){ 1112 $(next).show(); 1113 $(curr).hide(); 1114 after(); 1115 }; 1116}; 1117 1118// not a cross-fade, fadeout only fades out the top slide 1119$.fn.cycle.transitions.fadeout = function($cont, $slides, opts) { 1120 $slides.not(':eq('+opts.currSlide+')').css({ display: 'block', 'opacity': 1 }); 1121 opts.before.push(function(curr,next,opts,w,h,rev) { 1122 //2015-5-18 matsuuchi �X���C�hz-index���� 1123 //$(curr).css('zIndex',opts.slideCount + (rev !== true ? 1 : 0)); 1124 //$(next).css('zIndex',opts.slideCount + (rev !== true ? 0 : 1)); 1125 $(curr).css('zIndex',1 + (rev !== true ? 1 : 0)); 1126 $(next).css('zIndex',1 + (rev !== true ? 0 : 1)); 1127 1128 }); 1129 opts.animIn.opacity = 1; 1130 opts.animOut.opacity = 0; 1131 opts.cssBefore.opacity = 1; 1132 opts.cssBefore.display = 'block'; 1133 opts.cssAfter.zIndex = 0; 1134}; 1135 1136// scrollUp/Down/Left/Right 1137$.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) { 1138 $cont.css('overflow','hidden'); 1139 opts.before.push($.fn.cycle.commonReset); 1140 var h = $cont.height(); 1141 opts.cssBefore.top = h; 1142 opts.cssBefore.left = 0; 1143 opts.cssFirst.top = 0; 1144 opts.animIn.top = 0; 1145 opts.animOut.top = -h; 1146}; 1147$.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) { 1148 $cont.css('overflow','hidden'); 1149 opts.before.push($.fn.cycle.commonReset); 1150 var h = $cont.height(); 1151 opts.cssFirst.top = 0; 1152 opts.cssBefore.top = -h; 1153 opts.cssBefore.left = 0; 1154 opts.animIn.top = 0; 1155 opts.animOut.top = h; 1156}; 1157$.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) { 1158 $cont.css('overflow','hidden'); 1159 opts.before.push($.fn.cycle.commonReset); 1160 var w = $cont.width(); 1161 opts.cssFirst.left = 0; 1162 opts.cssBefore.left = w; 1163 opts.cssBefore.top = 0; 1164 opts.animIn.left = 0; 1165 opts.animOut.left = 0-w; 1166}; 1167$.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) { 1168 $cont.css('overflow','hidden'); 1169 opts.before.push($.fn.cycle.commonReset); 1170 var w = $cont.width(); 1171 opts.cssFirst.left = 0; 1172 opts.cssBefore.left = -w; 1173 opts.cssBefore.top = 0; 1174 opts.animIn.left = 0; 1175 opts.animOut.left = w; 1176}; 1177$.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) { 1178 $cont.css('overflow','hidden').width(); 1179 opts.before.push(function(curr, next, opts, fwd) { 1180 if (opts.rev) 1181 fwd = !fwd; 1182 $.fn.cycle.commonReset(curr,next,opts); 1183 opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW); 1184 opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW; 1185 }); 1186 opts.cssFirst.left = 0; 1187 opts.cssBefore.top = 0; 1188 opts.animIn.left = 0; 1189 opts.animOut.top = 0; 1190}; 1191$.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) { 1192 $cont.css('overflow','hidden'); 1193 opts.before.push(function(curr, next, opts, fwd) { 1194 if (opts.rev) 1195 fwd = !fwd; 1196 $.fn.cycle.commonReset(curr,next,opts); 1197 opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1); 1198 opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH; 1199 }); 1200 opts.cssFirst.top = 0; 1201 opts.cssBefore.left = 0; 1202 opts.animIn.top = 0; 1203 opts.animOut.left = 0; 1204}; 1205 1206// slideX/slideY 1207$.fn.cycle.transitions.slideX = function($cont, $slides, opts) { 1208 opts.before.push(function(curr, next, opts) { 1209 $(opts.elements).not(curr).hide(); 1210 $.fn.cycle.commonReset(curr,next,opts,false,true); 1211 opts.animIn.width = next.cycleW; 1212 }); 1213 opts.cssBefore.left = 0; 1214 opts.cssBefore.top = 0; 1215 opts.cssBefore.width = 0; 1216 opts.animIn.width = 'show'; 1217 opts.animOut.width = 0; 1218}; 1219$.fn.cycle.transitions.slideY = function($cont, $slides, opts) { 1220 opts.before.push(function(curr, next, opts) { 1221 $(opts.elements).not(curr).hide(); 1222 $.fn.cycle.commonReset(curr,next,opts,true,false); 1223 opts.animIn.height = next.cycleH; 1224 }); 1225 opts.cssBefore.left = 0; 1226 opts.cssBefore.top = 0; 1227 opts.cssBefore.height = 0; 1228 opts.animIn.height = 'show'; 1229 opts.animOut.height = 0; 1230}; 1231 1232// shuffle 1233$.fn.cycle.transitions.shuffle = function($cont, $slides, opts) { 1234 var i, w = $cont.css('overflow', 'visible').width(); 1235 $slides.css({left: 0, top: 0}); 1236 opts.before.push(function(curr,next,opts) { 1237 $.fn.cycle.commonReset(curr,next,opts,true,true,true); 1238 }); 1239 // only adjust speed once! 1240 if (!opts.speedAdjusted) { 1241 opts.speed = opts.speed / 2; // shuffle has 2 transitions 1242 opts.speedAdjusted = true; 1243 } 1244 opts.random = 0; 1245 opts.shuffle = opts.shuffle || {left:-w, top:15}; 1246 opts.els = []; 1247 for (i=0; i < $slides.length; i++) 1248 opts.els.push($slides[i]); 1249 1250 for (i=0; i < opts.currSlide; i++) 1251 opts.els.push(opts.els.shift()); 1252 1253 // custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!) 1254 opts.fxFn = function(curr, next, opts, cb, fwd) { 1255 if (opts.rev) 1256 fwd = !fwd; 1257 var $el = fwd ? $(curr) : $(next); 1258 $(next).css(opts.cssBefore); 1259 var count = opts.slideCount; 1260 $el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() { 1261 var hops = $.fn.cycle.hopsFromLast(opts, fwd); 1262 for (var k=0; k < hops; k++) { 1263 if (fwd) 1264 opts.els.push(opts.els.shift()); 1265 else 1266 opts.els.unshift(opts.els.pop()); 1267 } 1268 if (fwd) { 1269 for (var i=0, len=opts.els.length; i < len; i++) 1270 $(opts.els[i]).css('z-index', len-i+count); 1271 //$(opts.els[i]).css('z-index', 1); 1272 } 1273 else { 1274 var z = $(curr).css('z-index'); 1275 $el.css('z-index', parseInt(z,10)+1+count); 1276 } 1277 $el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() {
1278 $(fwd ? this : curr).hide(); 1279 if (cb) cb(); 1280 }); 1281 }); 1282 }; 1283 $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 }); 1284}; 1285 1286// turnUp/Down/Left/Right 1287$.fn.cycle.transitions.turnUp = function($cont, $slides, opts) { 1288 opts.before.push(function(curr, next, opts) { 1289 $.fn.cycle.commonReset(curr,next,opts,true,false); 1290 opts.cssBefore.top = next.cycleH; 1291 opts.animIn.height = next.cycleH; 1292 opts.animOut.width = next.cycleW; 1293 }); 1294 opts.cssFirst.top = 0; 1295 opts.cssBefore.left = 0; 1296 opts.cssBefore.height = 0; 1297 opts.animIn.top = 0; 1298 opts.animOut.height = 0; 1299}; 1300$.fn.cycle.transitions.turnDown = function($cont, $slides, opts) { 1301 opts.before.push(function(curr, next, opts) { 1302 $.fn.cycle.commonReset(curr,next,opts,true,false); 1303 opts.animIn.height = next.cycleH; 1304 opts.animOut.top = curr.cycleH; 1305 }); 1306 opts.cssFirst.top = 0; 1307 opts.cssBefore.left = 0; 1308 opts.cssBefore.top = 0; 1309 opts.cssBefore.height = 0; 1310 opts.animOut.height = 0; 1311}; 1312$.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) { 1313 opts.before.push(function(curr, next, opts) { 1314 $.fn.cycle.commonReset(curr,next,opts,false,true); 1315 opts.cssBefore.left = next.cycleW; 1316 opts.animIn.width = next.cycleW; 1317 }); 1318 opts.cssBefore.top = 0; 1319 opts.cssBefore.width = 0; 1320 opts.animIn.left = 0; 1321 opts.animOut.width = 0; 1322}; 1323$.fn.cycle.transitions.turnRight = function($cont, $slides, opts) { 1324 opts.before.push(function(curr, next, opts) { 1325 $.fn.cycle.commonReset(curr,next,opts,false,true); 1326 opts.animIn.width = next.cycleW; 1327 opts.animOut.left = curr.cycleW; 1328 }); 1329 $.extend(opts.cssBefore, { top: 0, left: 0, width: 0 }); 1330 opts.animIn.left = 0; 1331 opts.animOut.width = 0; 1332}; 1333 1334// zoom 1335$.fn.cycle.transitions.zoom = function($cont, $slides, opts) { 1336 opts.before.push(function(curr, next, opts) { 1337 $.fn.cycle.commonReset(curr,next,opts,false,false,true); 1338 opts.cssBefore.top = next.cycleH/2; 1339 opts.cssBefore.left = next.cycleW/2; 1340 $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH }); 1341 $.extend(opts.animOut, { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 }); 1342 }); 1343 opts.cssFirst.top = 0; 1344 opts.cssFirst.left = 0; 1345 opts.cssBefore.width = 0; 1346 opts.cssBefore.height = 0; 1347}; 1348 1349// fadeZoom 1350$.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) { 1351 opts.before.push(function(curr, next, opts) { 1352 $.fn.cycle.commonReset(curr,next,opts,false,false); 1353 opts.cssBefore.left = next.cycleW/2; 1354 opts.cssBefore.top = next.cycleH/2; 1355 $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH }); 1356 }); 1357 opts.cssBefore.width = 0; 1358 opts.cssBefore.height = 0; 1359 opts.animOut.opacity = 0; 1360}; 1361 1362// blindX 1363$.fn.cycle.transitions.blindX = function($cont, $slides, opts) { 1364 var w = $cont.css('overflow','hidden').width(); 1365 opts.before.push(function(curr, next, opts) { 1366 $.fn.cycle.commonReset(curr,next,opts); 1367 opts.animIn.width = next.cycleW; 1368 opts.animOut.left = curr.cycleW; 1369 }); 1370 opts.cssBefore.left = w; 1371 opts.cssBefore.top = 0; 1372 opts.animIn.left = 0; 1373 opts.animOut.left = w; 1374}; 1375// blindY 1376$.fn.cycle.transitions.blindY = function($cont, $slides, opts) { 1377 var h = $cont.css('overflow','hidden').height(); 1378 opts.before.push(function(curr, next, opts) { 1379 $.fn.cycle.commonReset(curr,next,opts); 1380 opts.animIn.height = next.cycleH; 1381 opts.animOut.top = curr.cycleH; 1382 }); 1383 opts.cssBefore.top = h; 1384 opts.cssBefore.left = 0; 1385 opts.animIn.top = 0; 1386 opts.animOut.top = h; 1387}; 1388// blindZ 1389$.fn.cycle.transitions.blindZ = function($cont, $slides, opts) { 1390 var h = $cont.css('overflow','hidden').height(); 1391 var w = $cont.width(); 1392 opts.before.push(function(curr, next, opts) { 1393 $.fn.cycle.commonReset(curr,next,opts); 1394 opts.animIn.height = next.cycleH; 1395 opts.animOut.top = curr.cycleH; 1396 }); 1397 opts.cssBefore.top = h; 1398 opts.cssBefore.left = w; 1399 opts.animIn.top = 0; 1400 opts.animIn.left = 0; 1401 opts.animOut.top = h; 1402 opts.animOut.left = w; 1403}; 1404 1405// growX - grow horizontally from centered 0 width 1406$.fn.cycle.transitions.growX = function($cont, $slides, opts) { 1407 opts.before.push(function(curr, next, opts) { 1408 $.fn.cycle.commonReset(curr,next,opts,false,true); 1409 opts.cssBefore.left = this.cycleW/2; 1410 opts.animIn.left = 0; 1411 opts.animIn.width = this.cycleW; 1412 opts.animOut.left = 0; 1413 }); 1414 opts.cssBefore.top = 0; 1415 opts.cssBefore.width = 0; 1416}; 1417// growY - grow vertically from centered 0 height 1418$.fn.cycle.transitions.growY = function($cont, $slides, opts) { 1419 opts.before.push(function(curr, next, opts) { 1420 $.fn.cycle.commonReset(curr,next,opts,true,false); 1421 opts.cssBefore.top = this.cycleH/2; 1422 opts.animIn.top = 0; 1423 opts.animIn.height = this.cycleH; 1424 opts.animOut.top = 0; 1425 }); 1426 opts.cssBefore.height = 0; 1427 opts.cssBefore.left = 0; 1428}; 1429 1430// curtainX - squeeze in both edges horizontally 1431$.fn.cycle.transitions.curtainX = function($cont, $slides, opts) { 1432 opts.before.push(function(curr, next, opts) { 1433 $.fn.cycle.commonReset(curr,next,opts,false,true,true); 1434 opts.cssBefore.left = next.cycleW/2; 1435 opts.animIn.left = 0; 1436 opts.animIn.width = this.cycleW; 1437 opts.animOut.left = curr.cycleW/2; 1438 opts.animOut.width = 0; 1439 }); 1440 opts.cssBefore.top = 0; 1441 opts.cssBefore.width = 0; 1442}; 1443// curtainY - squeeze in both edges vertically 1444$.fn.cycle.transitions.curtainY = function($cont, $slides, opts) { 1445 opts.before.push(function(curr, next, opts) { 1446 $.fn.cycle.commonReset(curr,next,opts,true,false,true); 1447 opts.cssBefore.top = next.cycleH/2; 1448 opts.animIn.top = 0; 1449 opts.animIn.height = next.cycleH; 1450 opts.animOut.top = curr.cycleH/2; 1451 opts.animOut.height = 0; 1452 }); 1453 opts.cssBefore.height = 0; 1454 opts.cssBefore.left = 0; 1455}; 1456 1457// cover - curr slide covered by next slide
1458$.fn.cycle.transitions.cover = function($cont, $slides, opts) { 1459 var d = opts.direction || 'left'; 1460 var w = $cont.css('overflow','hidden').width(); 1461 var h = $cont.height(); 1462 opts.before.push(function(curr, next, opts) { 1463 $.fn.cycle.commonReset(curr,next,opts); 1464 opts.cssAfter.display = ''; 1465 if (d == 'right') 1466 opts.cssBefore.left = -w; 1467 else if (d == 'up') 1468 opts.cssBefore.top = h; 1469 else if (d == 'down') 1470 opts.cssBefore.top = -h; 1471 else 1472 opts.cssBefore.left = w; 1473 }); 1474 opts.animIn.left = 0; 1475 opts.animIn.top = 0; 1476 opts.cssBefore.top = 0; 1477 opts.cssBefore.left = 0; 1478}; 1479 1480// uncover - curr slide moves off next slide 1481$.fn.cycle.transitions.uncover = function($cont, $slides, opts) { 1482 var d = opts.direction || 'left'; 1483 var w = $cont.css('overflow','hidden').width(); 1484 var h = $cont.height(); 1485 opts.before.push(function(curr, next, opts) { 1486 $.fn.cycle.commonReset(curr,next,opts,true,true,true); 1487 if (d == 'right') 1488 opts.animOut.left = w; 1489 else if (d == 'up') 1490 opts.animOut.top = -h; 1491 else if (d == 'down') 1492 opts.animOut.top = h; 1493 else 1494 opts.animOut.left = -w; 1495 }); 1496 opts.animIn.left = 0; 1497 opts.animIn.top = 0; 1498 opts.cssBefore.top = 0; 1499 opts.cssBefore.left = 0; 1500}; 1501 1502// toss - move top slide and fade away 1503$.fn.cycle.transitions.toss = function($cont, $slides, opts) { 1504 var w = $cont.css('overflow','visible').width(); 1505 var h = $cont.height(); 1506 opts.before.push(function(curr, next, opts) { 1507 $.fn.cycle.commonReset(curr,next,opts,true,true,true); 1508 // provide default toss settings if animOut not provided 1509 if (!opts.animOut.left && !opts.animOut.top) 1510 $.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 }); 1511 else 1512 opts.animOut.opacity = 0; 1513 }); 1514 opts.cssBefore.left = 0; 1515 opts.cssBefore.top = 0; 1516 opts.animIn.left = 0; 1517}; 1518 1519// wipe - clip animation 1520$.fn.cycle.transitions.wipe = function($cont, $slides, opts) { 1521 var w = $cont.css('overflow','hidden').width(); 1522 var h = $cont.height(); 1523 opts.cssBefore = opts.cssBefore || {}; 1524 var clip; 1525 if (opts.clip) { 1526 if (/l2r/.test(opts.clip)) 1527 clip = 'rect(0px 0px '+h+'px 0px)'; 1528 else if (/r2l/.test(opts.clip)) 1529 clip = 'rect(0px '+w+'px '+h+'px '+w+'px)'; 1530 else if (/t2b/.test(opts.clip)) 1531 clip = 'rect(0px '+w+'px 0px 0px)'; 1532 else if (/b2t/.test(opts.clip)) 1533 clip = 'rect('+h+'px '+w+'px '+h+'px 0px)'; 1534 else if (/zoom/.test(opts.clip)) { 1535 var top = parseInt(h/2,10); 1536 var left = parseInt(w/2,10); 1537 clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)'; 1538 } 1539 } 1540 1541 opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)'; 1542 1543 var d = opts.cssBefore.clip.match(/(\d+)/g); 1544 var t = parseInt(d[0],10), r = parseInt(d[1],10), b = parseInt(d[2],10), l = parseInt(d[3],10); 1545 1546 opts.before.push(function(curr, next, opts) { 1547 if (curr == next) return; 1548 var $curr = $(curr), $next = $(next); 1549 $.fn.cycle.commonReset(curr,next,opts,true,true,false); 1550 opts.cssAfter.display = 'block'; 1551 1552 var step = 1, count = parseInt((opts.speedIn / 13),10) - 1; 1553 (function f() { 1554 var tt = t ? t - parseInt(step * (t/count),10) : 0; 1555 var ll = l ? l - parseInt(step * (l/count),10) : 0; 1556 var bb = b < h ? b + parseInt(step * ((h-b)/count || 1),10) : h; 1557 var rr = r < w ? r + parseInt(step * ((w-r)/count || 1),10) : w; 1558 $next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' }); 1559 (step++ <= count) ? setTimeout(f, 13) : $curr.css('display', 'none'); 1560 })(); 1561 }); 1562 $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 }); 1563 opts.animIn = { left: 0 }; 1564 opts.animOut = { left: 0 }; 1565}; 1566 1567})(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.