1/* **************************************************************************** 2 * slider.css 3 * Author : David Liverneaux 4 * Action : Gestion du slider. 5 * Structure : 6 * <div class="slider"> 7 * 8 * <div class="view-content"> 9 * <ul class="controle"> 10 * <li>1</li> 11 * <li>2</li> 12 * <li>3</li> 13 * ... 14 * </ul> 15 * <div class="slide"> 16 * <div class="bandeau"> 17 * <div class="slider-zone-visuel">..</div> 18 * <div class="slider-zone-texte" >..</div> 19 * </div> 20 * </div> 21 * .... 22 * </div> 23 * </div> 24 *****************************************************************************/ 25 26jQuery(function($){ 27/////////////////////////////////////////////////////////////// 28//Initialisations des constantes 29 30 // Variables de temps 31 var timeDisplay = 4500; // Temps d'affichage 32 var timeEffect = 400; // Temps de l'effet de transition 33 34 // Variables Système 35 var nbSlide = 0; // Nombre total de slide 36 37 // Calcul du nombre de slide 38 $("div.slider div.slide").each(function(){ 39 nbSlide = nbSlide + 1; // Nombre total de slide 40 }); 41 42 //Initialisation d'affichage 43 var currentSlide = $("div.slide:first"); 44 45 currentSlide.addClass('active'); 46 47 48 $("div.slider").append('<span id="slider-zone-texte-arrow"></span>'); 49 50/////////////////////////////////////////////////////////////// 51/////////////////////////////////////////////////////////////// 52// Fonctions 53 54 //$.fn.mafonction = function(){}; 55 56 57 58 59/////////////////////////////////////////////////////////////// 60/////////////////////////////////////////////////////////////// 61//Insertion de la liste de controle 62 63 if ( nbSlide > 1 ) { 64 $("div.slider").append('<ul class="controle"></ul>'); 65 for (var i = 1; i <= nbSlide; i++) { 66 if( i == nbSlide ){ 67 $("div.slider>ul.controle").append('<li id="'+(i-1)+'" class="last"></li>'); 68 }else{ 69 $("div.slider>ul.controle").append('<li id="'+(i-1)+'"></li>'); 70 } 71 }; 72 $("div.slider>ul.controle>li:first").addClass("active"); 73 }; 74 75 76/////////////////////////////////////////////////////////////// 77/////////////////////////////////////////////////////////////// 78//Actions au click sur les Fléches de controle 79 80 $("div.slider>ul.controle>li").click(function(){ 81 if ( !$(this).hasClass('active') ) { 82 83 // Rang de l'élément sur lequel l'action est passée 84 var rang = $(this).attr('id'); 85 // Slide courant 86 var currentSlide = $("div.slide.active"); 87 // Slide demandé 88 var nextSlide = $("div.slide:eq("+rang+")"); 89 90 // On active/desactive les boutons de controle 91 $("div.slider>ul.controle>li.active").removeClass('active'); 92 $(this).addClass('active'); 93 94 95 // Actions 96 currentSlide.fadeOut(timeEffect).removeClass('active'); 97 nextSlide.fadeIn(timeEffect).addClass('active'); 98 99 } 100 }); 101 102 103 104/////////////////////////////////////////////////////////////// 105/////////////////////////////////////////////////////////////// 106//Gestion du Timer 107 108 /////////////////////////////////////////////////////////////// 109 // Initialisation -> automatisme du slider 110 var timer = setInterval( function(){ 111 112 var currentSlide = $("div.slide.active"); //Slide courrant 113 var rang = $("div.slider>ul.controle>li.active").attr("id"); 114 115 // si c'est le dernier slide alors le prochain slide sera le 1er 116 if( rang >= (nbSlide-1) ){ 117 118 rang = 0; 119 var nextSlide = $("div.slide:eq("+rang+")"); 120 121 }else{ 122 123 rang++; 124 var nextSlide = $("div.slide:eq("+rang+")"); 125 126 } 127 128 // On active/desactive les boutons de controle 129 $("div.slider>ul.controle>li.active").removeClass('active'); 130 $("div.slider>ul.controle>li:eq("+rang+")").addClass('active'); 131 132 // Actions 133 currentSlide.fadeOut(timeEffect).removeClass('active'); 134 nextSlide.fadeIn(timeEffect).addClass('active'); 135 136 }, timeDisplay); 137 138 // /////////////////////////////////////////////////////////////// 139 // //Coupure du Timer au survol du slider 140 $("div.slider").live('mouseenter', function() { 141 142 timer = clearInterval(timer); 143 144 // mouseout -> reprise du Timer 145 }).live('mouseleave', function() { 146 147 timer = setInterval( function(){ 148 var currentSlide = $("div.slide.active"); //Slide courrant 149 var rang = $("div.slider>ul.controle>li.active").attr("id"); 150 151 // si c'est le dernier slide alors le prochain slide sera le 1er
152 if( rang >= (nbSlide-1) ){ 153 154 rang = 0; 155 var nextSlide = $("div.slide:eq("+rang+")"); 156 157 }else{ 158 159 rang++; 160 var nextSlide = $("div.slide:eq("+rang+")"); 161 162 } 163 164 // On active/desactive les boutons de controle 165 $("div.slider>ul.controle>li.active").removeClass('active'); 166 $("div.slider>ul.controle>li:eq("+rang+")").addClass('active'); 167 168 // Actions 169 currentSlide.fadeOut(timeEffect).removeClass('active'); 170 nextSlide.fadeIn(timeEffect).addClass('active'); 171 172 }, timeDisplay); 173 174 }); 175 176/////////////////////////////////////////////////////////////// 177});;; 178/*! 179 * jQuery Cycle Plugin (with Transition Definitions) 180 * Examples and documentation at: http://jquery.malsup.com/cycle/ 181 * Copyright (c) 2007-2013 M. Alsup 182 * Version: 3.0.3 (11-JUL-2013) 183 * Dual licensed under the MIT and GPL licenses. 184 * http://jquery.malsup.com/license.html 185 * Requires: jQuery v1.7.1 or later 186 */ 187;(function($, undefined) { 188"use strict"; 189 190var ver = '3.0.3'; 191 192function debug(s) { 193 if ($.fn.cycle.debug) 194 log(s); 195} 196function log() { 197 /*global console */ 198 if (window.console && console.log) 199 console.log('[cycle] ' + Array.prototype.join.call(arguments,' ')); 200} 201$.expr[':'].paused = function(el) { 202 return el.cyclePause; 203}; 204 205 206// the options arg can be... 207// a number - indicates an immediate transition should occur to the given slide index 208// a string - 'pause', 'resume', 'toggle', 'next', 'prev', 'stop', 'destroy' or the name of a transition effect (ie, 'fade', 'zoom', etc) 209// an object - properties to control the slideshow 210// 211// the arg2 arg can be... 212// the name of an fx (only used in conjunction with a numeric value for 'options') 213// the value true (only used in first arg == 'resume') and indicates 214// that the resume should occur immediately (not wait for next timeout) 215 216$.fn.cycle = function(options, arg2) { 217 var o = { s: this.selector, c: this.context }; 218 219 // in 1.3+ we can fix mistakes with the ready state 220 if (this.length === 0 && options != 'stop') { 221 if (!$.isReady && o.s) { 222 log('DOM not ready, queuing slideshow'); 223 $(function() { 224 $(o.s,o.c).cycle(options,arg2); 225 }); 226 return this; 227 } 228 // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready() 229 log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)')); 230 return this; 231 } 232 233 // iterate the matched nodeset 234 return this.each(function() { 235 var opts = handleArguments(this, options, arg2); 236 if (opts === false) 237 return; 238 239 opts.updateActivePagerLink = opts.updateActivePagerLink || $.fn.cycle.updateActivePagerLink; 240 241 // stop existing slideshow for this container (if there is one) 242 if (this.cycleTimeout) 243 clearTimeout(this.cycleTimeout); 244 this.cycleTimeout = this.cyclePause = 0; 245 this.cycleStop = 0; // issue #108 246 247 var $cont = $(this); 248 var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children(); 249 var els = $slides.get(); 250 251 if (els.length < 2) { 252 log('terminating; too few slides: ' + els.length); 253 return; 254 } 255 256 var opts2 = buildOptions($cont, $slides, els, opts, o); 257 if (opts2 === false) 258 return; 259 260 var startTime = opts2.continuous ? 10 : getTimeout(els[opts2.currSlide], els[opts2.nextSlide], opts2, !opts2.backwards); 261 262 // if it's an auto slideshow, kick it off 263 if (startTime) { 264 startTime += (opts2.delay || 0); 265 if (startTime < 10) 266 startTime = 10; 267 debug('first timeout: ' + startTime); 268 this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts.backwards);}, startTime); 269 } 270 }); 271}; 272 273function triggerPause(cont, byHover, onPager) { 274 var opts = $(cont).data('cycle.opts'); 275 if (!opts) 276 return; 277 var paused = !!cont.cyclePause; 278 if (paused && opts.paused) 279 opts.paused(cont, opts, byHover, onPager); 280 else if (!paused && opts.resumed) 281 opts.resumed(cont, opts, byHover, onPager); 282} 283 284// process the args that were passed to the plugin fn 285function handleArguments(cont, options, arg2) { 286 if (cont.cycleStop === undefined) 287 cont.cycleStop = 0; 288 if (options === undefined || options === null) 289 options = {}; 290 if (options.constructor == String) { 291 switch(options) { 292 case 'destroy': 293 case 'stop': 294 var opts = $(cont).data('cycle.opts'); 295 if (!opts) 296 return false; 297 cont.cycleStop++; // callbacks look for change 298 if (cont.cycleTimeout) 299 clearTimeout(cont.cycleTimeout);
300 cont.cycleTimeout = 0; 301 if (opts.elements) 302 $(opts.elements).stop(); 303 $(cont).removeData('cycle.opts'); 304 if (options == 'destroy') 305 destroy(cont, opts); 306 return false; 307 case 'toggle': 308 cont.cyclePause = (cont.cyclePause === 1) ? 0 : 1; 309 checkInstantResume(cont.cyclePause, arg2, cont); 310 triggerPause(cont); 311 return false; 312 case 'pause': 313 cont.cyclePause = 1; 314 triggerPause(cont); 315 return false; 316 case 'resume': 317 cont.cyclePause = 0; 318 checkInstantResume(false, arg2, cont); 319 triggerPause(cont); 320 return false; 321 case 'prev': 322 case 'next': 323 opts = $(cont).data('cycle.opts'); 324 if (!opts) { 325 log('options not found, "prev/next" ignored'); 326 return false; 327 } 328 if (typeof arg2 == 'string') 329 opts.oneTimeFx = arg2; 330 $.fn.cycle[options](opts); 331 return false; 332 default: 333 options = { fx: options }; 334 } 335 return options; 336 } 337 else if (options.constructor == Number) { 338 // go to the requested slide 339 var num = options; 340 options = $(cont).data('cycle.opts'); 341 if (!options) { 342 log('options not found, can not advance slide'); 343 return false; 344 } 345 if (num < 0 || num >= options.elements.length) { 346 log('invalid slide index: ' + num); 347 return false; 348 } 349 options.nextSlide = num; 350 if (cont.cycleTimeout) { 351 clearTimeout(cont.cycleTimeout); 352 cont.cycleTimeout = 0; 353 } 354 if (typeof arg2 == 'string') 355 options.oneTimeFx = arg2; 356 go(options.elements, options, 1, num >= options.currSlide); 357 return false; 358 } 359 return options; 360 361 function checkInstantResume(isPaused, arg2, cont) { 362 if (!isPaused && arg2 === true) { // resume now! 363 var options = $(cont).data('cycle.opts'); 364 if (!options) { 365 log('options not found, can not resume'); 366 return false; 367 } 368 if (cont.cycleTimeout) { 369 clearTimeout(cont.cycleTimeout); 370 cont.cycleTimeout = 0; 371 } 372 go(options.elements, options, 1, !options.backwards); 373 } 374 } 375} 376 377function removeFilter(el, opts) { 378 if (!$.support.opacity && opts.cleartype && el.style.filter) { 379 try { el.style.removeAttribute('filter'); } 380 catch(smother) {} // handle old opera versions 381 } 382} 383 384// unbind event handlers 385function destroy(cont, opts) { 386 if (opts.next) 387 $(opts.next).unbind(opts.prevNextEvent); 388 if (opts.prev) 389 $(opts.prev).unbind(opts.prevNextEvent); 390 391 if (opts.pager || opts.pagerAnchorBuilder) 392 $.each(opts.pagerAnchors || [], function() { 393 this.unbind().remove(); 394 }); 395 opts.pagerAnchors = null; 396 $(cont).unbind('mouseenter.cycle mouseleave.cycle'); 397 if (opts.destroy) // callback 398 opts.destroy(opts); 399} 400 401// one-time initialization 402function buildOptions($cont, $slides, els, options, o) { 403 var startingSlideSpecified; 404 // support metadata plugin (v1.0 and v2.0) 405 var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {}); 406 var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null; 407 if (meta) 408 opts = $.extend(opts, meta); 409 if (opts.autostop) 410 opts.countdown = opts.autostopCount || els.length; 411 412 var cont = $cont[0]; 413 $cont.data('cycle.opts', opts); 414 opts.$cont = $cont; 415 opts.stopCount = cont.cycleStop; 416 opts.elements = els; 417 opts.before = opts.before ? [opts.before] : []; 418 opts.after = opts.after ? [opts.after] : []; 419 420 // push some after callbacks 421 if (!$.support.opacity && opts.cleartype) 422 opts.after.push(function() { removeFilter(this, opts); }); 423 if (opts.continuous) 424 opts.after.push(function() { go(els,opts,0,!opts.backwards); }); 425 426 saveOriginalOpts(opts); 427 428 // clearType corrections 429 if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) 430 clearTypeFix($slides); 431 432 // container requires non-static position so that slides can be position within 433 if ($cont.css('position') == 'static') 434 $cont.css('position', 'relative'); 435 if (opts.width) 436 $cont.width(opts.width); 437 if (opts.height && opts.height != 'auto') 438 $cont.height(opts.height); 439 440 if (opts.startingSlide !== undefined) { 441 opts.startingSlide = parseInt(opts.startingSlide,10);
442 if (opts.startingSlide >= els.length || opts.startSlide < 0) 443 opts.startingSlide = 0; // catch bogus input 444 else 445 startingSlideSpecified = true; 446 } 447 else if (opts.backwards) 448 opts.startingSlide = els.length - 1; 449 else 450 opts.startingSlide = 0; 451 452 // if random, mix up the slide array 453 if (opts.random) { 454 opts.randomMap = []; 455 for (var i = 0; i < els.length; i++) 456 opts.randomMap.push(i); 457 opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); 458 if (startingSlideSpecified) { 459 // try to find the specified starting slide and if found set start slide index in the map accordingly 460 for ( var cnt = 0; cnt < els.length; cnt++ ) { 461 if ( opts.startingSlide == opts.randomMap[cnt] ) { 462 opts.randomIndex = cnt; 463 } 464 } 465 } 466 else { 467 opts.randomIndex = 1; 468 opts.startingSlide = opts.randomMap[1]; 469 } 470 } 471 else if (opts.startingSlide >= els.length) 472 opts.startingSlide = 0; // catch bogus input 473 opts.currSlide = opts.startingSlide || 0; 474 var first = opts.startingSlide; 475 476 // set position and zIndex on all the slides 477 $slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) { 478 var z; 479 if (opts.backwards) 480 z = first ? i <= first ? els.length + (i-first) : first-i : els.length-i; 481 else 482 z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i; 483 $(this).css('z-index', z); 484 }); 485 486 // make sure first slide is visible 487 $(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case 488 removeFilter(els[first], opts); 489 490 // stretch slides 491 if (opts.fit) { 492 if (!opts.aspect) { 493 if (opts.width) 494 $slides.width(opts.width); 495 if (opts.height && opts.height != 'auto') 496 $slides.height(opts.height); 497 } else { 498 $slides.each(function(){ 499 var $slide = $(this); 500 var ratio = (opts.aspect === true) ? $slide.width()/$slide.height() : opts.aspect; 501 if( opts.width && $slide.width() != opts.width ) { 502 $slide.width( opts.width ); 503 $slide.height( opts.width / ratio ); 504 } 505 506 if( opts.height && $slide.height() < opts.height ) { 507 $slide.height( opts.height ); 508 $slide.width( opts.height * ratio ); 509 } 510 }); 511 } 512 } 513 514 if (opts.center && ((!opts.fit) || opts.aspect)) { 515 $slides.each(function(){ 516 var $slide = $(this); 517 $slide.css({ 518 "margin-left": opts.width ? 519 ((opts.width - $slide.width()) / 2) + "px" : 520 0, 521 "margin-top": opts.height ? 522 ((opts.height - $slide.height()) / 2) + "px" : 523 0 524 }); 525 }); 526 } 527 528 if (opts.center && !opts.fit && !opts.slideResize) { 529 $slides.each(function(){ 530 var $slide = $(this); 531 $slide.css({ 532 "margin-left": opts.width ? ((opts.width - $slide.width()) / 2) + "px" : 0, 533 "margin-top": opts.height ? ((opts.height - $slide.height()) / 2) + "px" : 0 534 }); 535 }); 536 } 537 538 // stretch container 539 var reshape = (opts.containerResize || opts.containerResizeHeight) && $cont.innerHeight() < 1; 540 if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9 541 var maxw = 0, maxh = 0; 542 for(var j=0; j < els.length; j++) { 543 var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight(); 544 if (!w) w = e.offsetWidth || e.width || $e.attr('width'); 545 if (!h) h = e.offsetHeight || e.height || $e.attr('height'); 546 maxw = w > maxw ? w : maxw; 547 maxh = h > maxh ? h : maxh; 548 } 549 if (opts.containerResize && maxw > 0 && maxh > 0) 550 $cont.css({width:maxw+'px',height:maxh+'px'}); 551 if (opts.containerResizeHeight && maxh > 0) 552 $cont.css({height:maxh+'px'}); 553 } 554 555 var pauseFlag = false; // https://github.com/malsup/cycle/issues/44 556 if (opts.pause) 557 $cont.bind('mouseenter.cycle', function(){ 558 pauseFlag = true; 559 this.cyclePause++; 560 triggerPause(cont, true); 561 }).bind('mouseleave.cycle', function(){ 562 if (pauseFlag) 563 this.cyclePause--; 564 triggerPause(cont, true); 565 }); 566 567 if (supportMultiTransitions(opts) === false) 568 return false; 569 570 // apparently a lot of people use image slideshows without height/width attributes on the images. 571 // Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that. 572 var requeue = false; 573 options.requeueAttempts = options.requeueAttempts || 0; 574 $slides.each(function() { 575 // try to get height/width of each slide 576 var $el = $(this); 577 this.cycleH = (opts.fit && opts.height) ? opts.height : ($el.height() || this.offsetHeight || this.height || $el.attr('height') || 0); 578 this.cycleW = (opts.fit && opts.width) ? opts.width : ($el.width() || this.offsetWidth || this.width || $el.attr('width') || 0); 579 580 if ( $el.is('img') ) { 581 var loading = (this.cycleH === 0 && this.cycleW === 0 && !this.complete); 582 // don't requeue for images that are still loading but have a valid size 583 if (loading) { 584 if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever 585 log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
586 setTimeout(function() {$(o.s,o.c).cycle(options);}, opts.requeueTimeout); 587 requeue = true; 588 return false; // break each loop 589 } 590 else { 591 log('could not determine size of image: '+this.src, this.cycleW, this.cycleH); 592 } 593 } 594 } 595 return true; 596 }); 597 598 if (requeue) 599 return false; 600 601 opts.cssBefore = opts.cssBefore || {}; 602 opts.cssAfter = opts.cssAfter || {}; 603 opts.cssFirst = opts.cssFirst || {}; 604 opts.animIn = opts.animIn || {}; 605 opts.animOut = opts.animOut || {}; 606 607 $slides.not(':eq('+first+')').css(opts.cssBefore); 608 $($slides[first]).css(opts.cssFirst); 609 610 if (opts.timeout) { 611 opts.timeout = parseInt(opts.timeout,10); 612 // ensure that timeout and speed settings are sane 613 if (opts.speed.constructor == String) 614 opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed,10); 615 if (!opts.sync) 616 opts.speed = opts.speed / 2; 617 618 var buffer = opts.fx == 'none' ? 0 : opts.fx == 'shuffle' ? 500 : 250; 619 while((opts.timeout - opts.speed) < buffer) // sanitize timeout 620 opts.timeout += opts.speed; 621 } 622 if (opts.easing) 623 opts.easeIn = opts.easeOut = opts.easing; 624 if (!opts.speedIn) 625 opts.speedIn = opts.speed; 626 if (!opts.speedOut) 627 opts.speedOut = opts.speed; 628 629 opts.slideCount = els.length; 630 opts.currSlide = opts.lastSlide = first; 631 if (opts.random) { 632 if (++opts.randomIndex == els.length) 633 opts.randomIndex = 0; 634 opts.nextSlide = opts.randomMap[opts.randomIndex]; 635 } 636 else if (opts.backwards) 637 opts.nextSlide = opts.startingSlide === 0 ? (els.length-1) : opts.startingSlide-1; 638 else 639 opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1; 640 641 // run transition init fn 642 if (!opts.multiFx) { 643 var init = $.fn.cycle.transitions[opts.fx]; 644 if ($.isFunction(init)) 645 init($cont, $slides, opts); 646 else if (opts.fx != 'custom' && !opts.multiFx) { 647 log('unknown transition: ' + opts.fx,'; slideshow terminating'); 648 return false; 649 } 650 } 651 652 // fire artificial events 653 var e0 = $slides[first]; 654 if (!opts.skipInitializationCallbacks) { 655 if (opts.before.length) 656 opts.before[0].apply(e0, [e0, e0, opts, true]); 657 if (opts.after.length) 658 opts.after[0].apply(e0, [e0, e0, opts, true]); 659 } 660 if (opts.next) 661 $(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,1);}); 662 if (opts.prev) 663 $(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,0);}); 664 if (opts.pager || opts.pagerAnchorBuilder) 665 buildPager(els,opts); 666 667 exposeAddSlide(opts, els); 668 669 return opts; 670} 671 672// save off original opts so we can restore after clearing state 673function saveOriginalOpts(opts) { 674 opts.original = { before: [], after: [] }; 675 opts.original.cssBefore = $.extend({}, opts.cssBefore); 676 opts.original.cssAfter = $.extend({}, opts.cssAfter); 677 opts.original.animIn = $.extend({}, opts.animIn); 678 opts.original.animOut = $.extend({}, opts.animOut); 679 $.each(opts.before, function() { opts.original.before.push(this); }); 680 $.each(opts.after, function() { opts.original.after.push(this); }); 681} 682 683function supportMultiTransitions(opts) { 684 var i, tx, txs = $.fn.cycle.transitions; 685 // look for multiple effects 686 if (opts.fx.indexOf(',') > 0) { 687 opts.multiFx = true; 688 opts.fxs = opts.fx.replace(/\s*/g,'').split(','); 689 // discard any bogus effect names 690 for (i=0; i < opts.fxs.length; i++) { 691 var fx = opts.fxs[i]; 692 tx = txs[fx]; 693 if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) { 694 log('discarding unknown transition: ',fx); 695 opts.fxs.splice(i,1); 696 i--; 697 } 698 } 699 // if we have an empty list then we threw everything away! 700 if (!opts.fxs.length) { 701 log('No valid transitions named; slideshow terminating.'); 702 return false; 703 } 704 } 705 else if (opts.fx == 'all') { // auto-gen the list of transitions 706 opts.multiFx = true; 707 opts.fxs = []; 708 for (var p in txs) { 709 if (txs.hasOwnProperty(p)) { 710 tx = txs[p]; 711 if (txs.hasOwnProperty(p) && $.isFunction(tx)) 712 opts.fxs.push(p); 713 } 714 } 715 } 716 if (opts.multiFx && opts.randomizeEffects) { 717 // munge the fxs array to make effect selection random 718 var r1 = Math.floor(Math.random() * 20) + 30; 719 for (i = 0; i < r1; i++) { 720 var r2 = Math.floor(Math.random() * opts.fxs.length); 721 opts.fxs.push(opts.fxs.splice(r2,1)[0]); 722 } 723 debug('randomized fx sequence: ',opts.fxs); 724 } 725 return true; 726} 727 728// provide a mechanism for adding slides after the slideshow has started 729function exposeAddSlide(opts, els) { 730 opts.addSlide = function(newSlide, prepend) {
731 var $s = $(newSlide), s = $s[0]; 732 if (!opts.autostopCount) 733 opts.countdown++; 734 els[prepend?'unshift':'push'](s); 735 if (opts.els) 736 opts.els[prepend?'unshift':'push'](s); // shuffle needs this 737 opts.slideCount = els.length; 738 739 // add the slide to the random map and resort 740 if (opts.random) { 741 opts.randomMap.push(opts.slideCount-1); 742 opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); 743 } 744 745 $s.css('position','absolute'); 746 $s[prepend?'prependTo':'appendTo'](opts.$cont); 747 748 if (prepend) { 749 opts.currSlide++; 750 opts.nextSlide++; 751 } 752 753 if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg) 754 clearTypeFix($s); 755 756 if (opts.fit && opts.width) 757 $s.width(opts.width); 758 if (opts.fit && opts.height && opts.height != 'auto') 759 $s.height(opts.height); 760 s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height(); 761 s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width(); 762 763 $s.css(opts.cssBefore); 764 765 if (opts.pager || opts.pagerAnchorBuilder) 766 $.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts); 767 768 if ($.isFunction(opts.onAddSlide)) 769 opts.onAddSlide($s); 770 else 771 $s.hide(); // default behavior 772 }; 773} 774 775// reset internal state; we do this on every pass in order to support multiple effects 776$.fn.cycle.resetState = function(opts, fx) { 777 fx = fx || opts.fx; 778 opts.before = []; opts.after = []; 779 opts.cssBefore = $.extend({}, opts.original.cssBefore); 780 opts.cssAfter = $.extend({}, opts.original.cssAfter); 781 opts.animIn = $.extend({}, opts.original.animIn); 782 opts.animOut = $.extend({}, opts.original.animOut); 783 opts.fxFn = null; 784 $.each(opts.original.before, function() { opts.before.push(this); }); 785 $.each(opts.original.after, function() { opts.after.push(this); }); 786 787 // re-init 788 var init = $.fn.cycle.transitions[fx]; 789 if ($.isFunction(init)) 790 init(opts.$cont, $(opts.elements), opts); 791}; 792 793// this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt 794function go(els, opts, manual, fwd) { 795 var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide]; 796 797 // opts.busy is true if we're in the middle of an animation 798 if (manual && opts.busy && opts.manualTrump) { 799 // let manual transitions requests trump active ones 800 debug('manualTrump in go(), stopping active transition'); 801 $(els).stop(true,true); 802 opts.busy = 0; 803 clearTimeout(p.cycleTimeout); 804 } 805 806 // don't begin another timeout-based transition if there is one active 807 if (opts.busy) { 808 debug('transition active, ignoring new tx request'); 809 return; 810 } 811 812 813 // stop cycling if we have an outstanding stop request 814 if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual) 815 return; 816 817 // check to see if we should stop cycling based on autostop options 818 if (!manual && !p.cyclePause && !opts.bounce && 819 ((opts.autostop && (--opts.countdown <= 0)) || 820 (opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) { 821 if (opts.end) 822 opts.end(opts); 823 return; 824 } 825 826 // if slideshow is paused, only transition on a manual trigger 827 var changed = false; 828 if ((manual || !p.cyclePause) && (opts.nextSlide != opts.currSlide)) { 829 changed = true; 830 var fx = opts.fx; 831 // keep trying to get the slide size if we don't have it yet 832 curr.cycleH = curr.cycleH || $(curr).height(); 833 curr.cycleW = curr.cycleW || $(curr).width(); 834 next.cycleH = next.cycleH || $(next).height(); 835 next.cycleW = next.cycleW || $(next).width(); 836 837 // support multiple transition types 838 if (opts.multiFx) { 839 if (fwd && (opts.lastFx === undefined || ++opts.lastFx >= opts.fxs.length)) 840 opts.lastFx = 0; 841 else if (!fwd && (opts.lastFx === undefined || --opts.lastFx < 0)) 842 opts.lastFx = opts.fxs.length - 1; 843 fx = opts.fxs[opts.lastFx]; 844 } 845 846 // one-time fx overrides apply to: $('div').cycle(3,'zoom'); 847 if (opts.oneTimeFx) { 848 fx = opts.oneTimeFx; 849 opts.oneTimeFx = null; 850 } 851 852 $.fn.cycle.resetState(opts, fx); 853 854 // run the before callbacks 855 if (opts.before.length) 856 $.each(opts.before, function(i,o) { 857 if (p.cycleStop != opts.stopCount) return; 858 o.apply(next, [curr, next, opts, fwd]); 859 }); 860 861 // stage the after callacks 862 var after = function() { 863 opts.busy = 0; 864 $.each(opts.after, function(i,o) { 865 if (p.cycleStop != opts.stopCount) return; 866 o.apply(next, [curr, next, opts, fwd]); 867 }); 868 if (!p.cycleStop) { 869 // queue next transition 870 queueNext(); 871 } 872 }; 873 874 debug('tx firing('+fx+'); currSlide: ' + opts.currSlide + '; nextSlide: ' + opts.nextSlide); 875 876 // get ready to perform the transition 877 opts.busy = 1; 878 if (opts.fxFn) // fx function provided? 879 opts.fxFn(curr, next, opts, after, fwd, manual && opts.fastOnEvent); 880 else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ? 881 $.fn.cycle[opts.fx](curr, next, opts, after, fwd, manual && opts.fastOnEvent); 882 else 883 $.fn.cycle.custom(curr, next, opts, after, fwd, manual && opts.fastOnEvent); 884 } 885 else { 886 queueNext(); 887 } 888 889 if (changed || opts.nextSlide == opts.currSlide) { 890 // calculate the next slide 891 var roll; 892 opts.lastSlide = opts.currSlide; 893 if (opts.random) { 894 opts.currSlide = opts.nextSlide; 895 if (++opts.randomIndex == els.length) { 896 opts.randomIndex = 0; 897 opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;}); 898 } 899 opts.nextSlide = opts.randomMap[opts.randomIndex]; 900 if (opts.nextSlide == opts.currSlide) 901 opts.nextSlide = (opts.currSlide == opts.slideCount - 1) ? 0 : opts.currSlide + 1; 902 } 903 else if (opts.backwards) { 904 roll = (opts.nextSlide - 1) < 0; 905 if (roll && opts.bounce) { 906 opts.backwards = !opts.backwards; 907 opts.nextSlide = 1; 908 opts.currSlide = 0; 909 } 910 else { 911 opts.nextSlide = roll ? (els.length-1) : opts.nextSlide-1; 912 opts.currSlide = roll ? 0 : opts.nextSlide+1; 913 } 914 } 915 else { // sequence 916 roll = (opts.nextSlide + 1) == els.length; 917 if (roll && opts.bounce) { 918 opts.backwards = !opts.backwards; 919 opts.nextSlide = els.length-2; 920 opts.currSlide = els.length-1; 921 } 922 else { 923 opts.nextSlide = roll ? 0 : opts.nextSlide+1; 924 opts.currSlide = roll ? els.length-1 : opts.nextSlide-1; 925 } 926 } 927 } 928 if (changed && opts.pager) 929 opts.updateActivePagerLink(opts.pager, opts.currSlide, opts.activePagerClass); 930 931 function queueNext() { 932 // stage the next transition 933 var ms = 0, timeout = opts.timeout; 934 if (opts.timeout && !opts.continuous) { 935 ms = getTimeout(els[opts.currSlide], els[opts.nextSlide], opts, fwd); 936 if (opts.fx == 'shuffle') 937 ms -= opts.speedOut; 938 } 939 else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic 940 ms = 10; 941 if (ms > 0) 942 p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.backwards); }, ms); 943 } 944} 945 946// invoked after transition 947$.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) { 948 $(pager).each(function() { 949 $(this).children().removeClass(clsName).eq(currSlide).addClass(clsName); 950 }); 951}; 952 953// calculate timeout value for current transition 954function getTimeout(curr, next, opts, fwd) { 955 if (opts.timeoutFn) { 956 // call user provided calc fn 957 var t = opts.timeoutFn.call(curr,curr,next,opts,fwd); 958 while (opts.fx != 'none' && (t - opts.speed) < 250) // sanitize timeout 959 t += opts.speed;
960 debug('calculated timeout: ' + t + '; speed: ' + opts.speed); 961 if (t !== false) 962 return t; 963 } 964 return opts.timeout; 965} 966 967// expose next/prev function, caller must pass in state 968$.fn.cycle.next = function(opts) { advance(opts,1); }; 969$.fn.cycle.prev = function(opts) { advance(opts,0);}; 970 971// advance slide forward or back 972function advance(opts, moveForward) { 973 var val = moveForward ? 1 : -1; 974 var els = opts.elements; 975 var p = opts.$cont[0], timeout = p.cycleTimeout; 976 if (timeout) { 977 clearTimeout(timeout); 978 p.cycleTimeout = 0; 979 } 980 if (opts.random && val < 0) { 981 // move back to the previously display slide 982 opts.randomIndex--; 983 if (--opts.randomIndex == -2) 984 opts.randomIndex = els.length-2; 985 else if (opts.randomIndex == -1) 986 opts.randomIndex = els.length-1; 987 opts.nextSlide = opts.randomMap[opts.randomIndex]; 988 } 989 else if (opts.random) { 990 opts.nextSlide = opts.randomMap[opts.randomIndex]; 991 } 992 else { 993 opts.nextSlide = opts.currSlide + val; 994 if (opts.nextSlide < 0) { 995 if (opts.nowrap) return false; 996 opts.nextSlide = els.length - 1; 997 } 998 else if (opts.nextSlide >= els.length) { 999 if (opts.nowrap) return false; 1000 opts.nextSlide = 0; 1001 } 1002 } 1003 1004 var cb = opts.onPrevNextEvent || opts.prevNextClick; // prevNextClick is deprecated 1005 if ($.isFunction(cb)) 1006 cb(val > 0, opts.nextSlide, els[opts.nextSlide]); 1007 go(els, opts, 1, moveForward); 1008 return false; 1009} 1010 1011function buildPager(els, opts) { 1012 var $p = $(opts.pager); 1013 $.each(els, function(i,o) { 1014 $.fn.cycle.createPagerAnchor(i,o,$p,els,opts); 1015 }); 1016 opts.updateActivePagerLink(opts.pager, opts.startingSlide, opts.activePagerClass); 1017} 1018 1019$.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) { 1020 var a; 1021 if ($.isFunction(opts.pagerAnchorBuilder)) { 1022 a = opts.pagerAnchorBuilder(i,el); 1023 debug('pagerAnchorBuilder('+i+', el) returned: ' + a); 1024 } 1025 else 1026 a = '<a href="#">'+(i+1)+'</a>'; 1027 1028 if (!a) 1029 return; 1030 var $a = $(a); 1031 // don't reparent if anchor is in the dom 1032 if ($a.parents('body').length === 0) { 1033 var arr = []; 1034 if ($p.length > 1) { 1035 $p.each(function() { 1036 var $clone = $a.clone(true); 1037 $(this).append($clone); 1038 arr.push($clone[0]); 1039 }); 1040 $a = $(arr); 1041 } 1042 else { 1043 $a.appendTo($p); 1044 } 1045 } 1046 1047 opts.pagerAnchors = opts.pagerAnchors || []; 1048 opts.pagerAnchors.push($a); 1049 1050 var pagerFn = function(e) { 1051 e.preventDefault(); 1052 opts.nextSlide = i; 1053 var p = opts.$cont[0], timeout = p.cycleTimeout; 1054 if (timeout) { 1055 clearTimeout(timeout); 1056 p.cycleTimeout = 0; 1057 } 1058 var cb = opts.onPagerEvent || opts.pagerClick; // pagerClick is deprecated 1059 if ($.isFunction(cb)) 1060 cb(opts.nextSlide, els[opts.nextSlide]); 1061 go(els,opts,1,opts.currSlide < i); // trigger the trans 1062// return false; // <== allow bubble 1063 }; 1064 1065 if ( /mouseenter|mouseover/i.test(opts.pagerEvent) ) { 1066 $a.hover(pagerFn, function(){/* no-op */} ); 1067 } 1068 else { 1069 $a.bind(opts.pagerEvent, pagerFn); 1070 } 1071 1072 if ( ! /^click/.test(opts.pagerEvent) && !opts.allowPagerClickBubble) 1073 $a.bind('click.cycle', function(){return false;}); // suppress click 1074 1075 var cont = opts.$cont[0]; 1076 var pauseFlag = false; // https://github.com/malsup/cycle/issues/44 1077 if (opts.pauseOnPagerHover) { 1078 $a.hover( 1079 function() { 1080 pauseFlag = true; 1081 cont.cyclePause++; 1082 triggerPause(cont,true,true); 1083 }, function() { 1084 if (pauseFlag) 1085 cont.cyclePause--; 1086 triggerPause(cont,true,true); 1087 } 1088 ); 1089 } 1090}; 1091 1092// helper fn to calculate the number of slides between the current and the next 1093$.fn.cycle.hopsFromLast = function(opts, fwd) { 1094 var hops, l = opts.lastSlide, c = opts.currSlide; 1095 if (fwd) 1096 hops = c > l ? c - l : opts.slideCount - l; 1097 else 1098 hops = c < l ? l - c : l + opts.slideCount - c; 1099 return hops; 1100}; 1101 1102// fix clearType problems in ie6 by setting an explicit bg color 1103// (otherwise text slides look horrible during a fade transition) 1104function clearTypeFix($slides) { 1105 debug('applying clearType background-color hack'); 1106 function hex(s) { 1107 s = parseInt(s,10).toString(16); 1108 return s.length < 2 ? '0'+s : s; 1109 } 1110 function getBg(e) { 1111 for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) { 1112 var v = $.css(e,'background-color'); 1113 if (v && v.indexOf('rgb') >= 0 ) { 1114 var rgb = v.match(/\d+/g); 1115 return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]); 1116 } 1117 if (v && v != 'transparent') 1118 return v; 1119 } 1120 return '#ffffff'; 1121 } 1122 $slides.each(function() { $(this).css('background-color', getBg(this)); }); 1123} 1124 1125// reset common props before the next transition 1126$.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) { 1127 $(opts.elements).not(curr).hide(); 1128 if (typeof opts.cssBefore.opacity == 'undefined') 1129 opts.cssBefore.opacity = 1; 1130 opts.cssBefore.display = 'block'; 1131 if (opts.slideResize && w !== false && next.cycleW > 0) 1132 opts.cssBefore.width = next.cycleW; 1133 if (opts.slideResize && h !== false && next.cycleH > 0) 1134 opts.cssBefore.height = next.cycleH; 1135 opts.cssAfter = opts.cssAfter || {}; 1136 opts.cssAfter.display = 'none'; 1137 $(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0)); 1138 $(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1)); 1139}; 1140 1141// the actual fn for effecting a transition 1142$.fn.cycle.custom = function(curr, next, opts, cb, fwd, speedOverride) { 1143 var $l = $(curr), $n = $(next); 1144 var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut, animInDelay = opts.animInDelay, animOutDelay = opts.animOutDelay; 1145 $n.css(opts.cssBefore); 1146 if (speedOverride) { 1147 if (typeof speedOverride == 'number') 1148 speedIn = speedOut = speedOverride; 1149 else 1150 speedIn = speedOut = 1; 1151 easeIn = easeOut = null; 1152 } 1153 var fn = function() { 1154 $n.delay(animInDelay).animate(opts.animIn, speedIn, easeIn, function() { 1155 cb(); 1156 }); 1157 }; 1158 $l.delay(animOutDelay).animate(opts.animOut, speedOut, easeOut, function() { 1159 $l.css(opts.cssAfter); 1160 if (!opts.sync) 1161 fn(); 1162 }); 1163 if (opts.sync) fn(); 1164}; 1165 1166// transition definitions - only fade is defined here, transition pack defines the rest 1167$.fn.cycle.transitions = { 1168 fade: function($cont, $slides, opts) { 1169 $slides.not(':eq('+opts.currSlide+')').css('opacity',0); 1170 opts.before.push(function(curr,next,opts) { 1171 $.fn.cycle.commonReset(curr,next,opts); 1172 opts.cssBefore.opacity = 0; 1173 }); 1174 opts.animIn = { opacity: 1 }; 1175 opts.animOut = { opacity: 0 }; 1176 opts.cssBefore = { top: 0, left: 0 }; 1177 } 1178}; 1179 1180$.fn.cycle.ver = function() { return ver; }; 1181 1182// override these globally if you like (they are all optional) 1183$.fn.cycle.defaults = {
1184 activePagerClass: 'activeSlide', // class name used for the active pager link 1185 after: null, // transition callback (scope set to element that was shown): function(currSlideElement, nextSlideElement, options, forwardFlag) 1186 allowPagerClickBubble: false, // allows or prevents click event on pager anchors from bubbling 1187 animIn: null, // properties that define how the slide animates in 1188 animInDelay: 0, // allows delay before next slide transitions in 1189 animOut: null, // properties that define how the slide animates out 1190 animOutDelay: 0, // allows delay before current slide transitions out 1191 aspect: false, // preserve aspect ratio during fit resizing, cropping if necessary (must be used with fit option) 1192 autostop: 0, // true to end slideshow after X transitions (where X == slide count) 1193 autostopCount: 0, // number of transitions (optionally used with autostop to define X) 1194 backwards: false, // true to start slideshow at last slide and move backwards through the stack 1195 before: null, // transition callback (scope set to element to be shown): function(currSlideElement, nextSlideElement, options, forwardFlag) 1196 center: null, // set to true to have cycle add top/left margin to each slide (use with width and height options) 1197 cleartype: !$.support.opacity, // true if clearType corrections should be applied (for IE) 1198 cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides) 1199 containerResize: 1, // resize container to fit largest slide 1200 containerResizeHeight: 0, // resize containers height to fit the largest slide but leave the width dynamic 1201 continuous: 0, // true to start next transition immediately after current one completes 1202 cssAfter: null, // properties that defined the state of the slide after transitioning out 1203 cssBefore: null, // properties that define the initial state of the slide before transitioning in 1204 delay: 0, // additional delay (in ms) for first transition (hint: can be negative) 1205 easeIn: null, // easing for "in" transition 1206 easeOut: null, // easing for "out" transition 1207 easing: null, // easing method for both in and out transitions 1208 end: null, // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options) 1209 fastOnEvent: 0, // force fast transitions when triggered manually (via pager or prev/next); value == time in ms 1210 fit: 0, // force slides to fit container 1211 fx: 'fade', // name of transition effect (or comma separated names, ex: 'fade,scrollUp,shuffle') 1212 fxFn: null, // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) 1213 height: 'auto', // container height (if the 'fit' option is true, the slides will be set to this height as well) 1214 manualTrump: true, // causes manual transition to stop an active transition instead of being ignored 1215 metaAttr: 'cycle', // data- attribute that holds the option data for the slideshow 1216 next: null, // element, jQuery object, or jQuery selector string for the element to use as event trigger for next slide 1217 nowrap: 0, // true to prevent slideshow from wrapping 1218 onPagerEvent: null, // callback fn for pager events: function(zeroBasedSlideIndex, slideElement) 1219 onPrevNextEvent: null, // callback fn for prev/next events: function(isNext, zeroBasedSlideIndex, slideElement) 1220 pager: null, // element, jQuery object, or jQuery selector string for the element to use as pager container 1221 pagerAnchorBuilder: null, // callback fn for building anchor links: function(index, DOMelement) 1222 pagerEvent: 'click.cycle', // name of event which drives the pager navigation 1223 pause: 0, // true to enable "pause on hover" 1224 pauseOnPagerHover: 0, // true to pause when hovering over pager link 1225 prev: null, // element, jQuery object, or jQuery selector string for the element to use as event trigger for previous slide 1226 prevNextEvent: 'click.cycle',// event which drives the manual transition to the previous or next slide 1227 random: 0, // true for random, false for sequence (not applicable to shuffle fx) 1228 randomizeEffects: 1, // valid when multiple effects are used; true to make the effect sequence random 1229 requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded 1230 requeueTimeout: 250, // ms delay for requeue 1231 rev: 0, // causes animations to transition in reverse (for effects that support it such as scrollHorz/scrollVert/shuffle) 1232 shuffle: null, // coords for shuffle animation, ex: { top:15, left: 200 } 1233 skipInitializationCallbacks: false, // set to true to disable the first before/after callback that occurs prior to any transition 1234 slideExpr: null, // expression for selecting slides (if something other than all children is required) 1235 slideResize: 1, // force slide width/height to fixed size before every transition 1236 speed: 1000, // speed of the transition (any valid fx speed value) 1237 speedIn: null, // speed of the 'in' transition 1238 speedOut: null, // speed of the 'out' transition 1239 startingSlide: undefined,// zero-based index of the first slide to be displayed 1240 sync: 1, // true if in/out transitions should occur simultaneously 1241 timeout: 4000, // milliseconds between slide transitions (0 to disable auto advance) 1242 timeoutFn: null, // callback for determining per-slide timeout value: function(currSlideElement, nextSlideElement, options, forwardFlag) 1243 updateActivePagerLink: null,// callback fn invoked to update the active pager link (adds/removes activePagerClass style) 1244 width: null // container width (if the 'fit' option is true, the slides will be set to this width as well) 1245}; 1246 1247})(jQuery); 1248 1249 1250/*! 1251 * jQuery Cycle Plugin Transition Definitions 1252 * This script is a plugin for the jQuery Cycle Plugin 1253 * Examples and documentation at: http://malsup.com/jquery/cycle/ 1254 * Copyright (c) 2007-2010 M. Alsup 1255 * Version: 2.73 1256 * Dual licensed under the MIT and GPL licenses: 1257 * http://www.opensource.org/licenses/mit-license.php 1258 * http://www.gnu.org/licenses/gpl.html 1259 */ 1260(function($) { 1261"use strict"; 1262 1263// 1264// These functions define slide initialization and properties for the named 1265// transitions. To save file size feel free to remove any of these that you 1266// don't need. 1267// 1268$.fn.cycle.transitions.none = function($cont, $slides, opts) { 1269 opts.fxFn = function(curr,next,opts,after){
1270 $(next).show(); 1271 $(curr).hide(); 1272 after(); 1273 }; 1274}; 1275 1276// not a cross-fade, fadeout only fades out the top slide 1277$.fn.cycle.transitions.fadeout = function($cont, $slides, opts) { 1278 $slides.not(':eq('+opts.currSlide+')').css({ display: 'block', 'opacity': 1 }); 1279 opts.before.push(function(curr,next,opts,w,h,rev) { 1280 $(curr).css('zIndex',opts.slideCount + (rev !== true ? 1 : 0)); 1281 $(next).css('zIndex',opts.slideCount + (rev !== true ? 0 : 1)); 1282 }); 1283 opts.animIn.opacity = 1; 1284 opts.animOut.opacity = 0; 1285 opts.cssBefore.opacity = 1; 1286 opts.cssBefore.display = 'block'; 1287 opts.cssAfter.zIndex = 0; 1288}; 1289 1290// scrollUp/Down/Left/Right 1291$.fn.cycle.transitions.scrollUp = function($cont, $slides, opts) { 1292 $cont.css('overflow','hidden'); 1293 opts.before.push($.fn.cycle.commonReset); 1294 var h = $cont.height(); 1295 opts.cssBefore.top = h; 1296 opts.cssBefore.left = 0; 1297 opts.cssFirst.top = 0; 1298 opts.animIn.top = 0; 1299 opts.animOut.top = -h; 1300}; 1301$.fn.cycle.transitions.scrollDown = function($cont, $slides, opts) { 1302 $cont.css('overflow','hidden'); 1303 opts.before.push($.fn.cycle.commonReset); 1304 var h = $cont.height(); 1305 opts.cssFirst.top = 0; 1306 opts.cssBefore.top = -h; 1307 opts.cssBefore.left = 0; 1308 opts.animIn.top = 0; 1309 opts.animOut.top = h; 1310}; 1311$.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) { 1312 $cont.css('overflow','hidden'); 1313 opts.before.push($.fn.cycle.commonReset); 1314 var w = $cont.width(); 1315 opts.cssFirst.left = 0; 1316 opts.cssBefore.left = w; 1317 opts.cssBefore.top = 0; 1318 opts.animIn.left = 0; 1319 opts.animOut.left = 0-w; 1320}; 1321$.fn.cycle.transitions.scrollRight = function($cont, $slides, opts) { 1322 $cont.css('overflow','hidden'); 1323 opts.before.push($.fn.cycle.commonReset); 1324 var w = $cont.width(); 1325 opts.cssFirst.left = 0; 1326 opts.cssBefore.left = -w; 1327 opts.cssBefore.top = 0; 1328 opts.animIn.left = 0; 1329 opts.animOut.left = w; 1330}; 1331$.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) { 1332 $cont.css('overflow','hidden').width(); 1333 opts.before.push(function(curr, next, opts, fwd) { 1334 if (opts.rev) 1335 fwd = !fwd; 1336 $.fn.cycle.commonReset(curr,next,opts); 1337 opts.cssBefore.left = fwd ? (next.cycleW-1) : (1-next.cycleW); 1338 opts.animOut.left = fwd ? -curr.cycleW : curr.cycleW; 1339 }); 1340 opts.cssFirst.left = 0; 1341 opts.cssBefore.top = 0; 1342 opts.animIn.left = 0; 1343 opts.animOut.top = 0; 1344}; 1345$.fn.cycle.transitions.scrollVert = function($cont, $slides, opts) { 1346 $cont.css('overflow','hidden'); 1347 opts.before.push(function(curr, next, opts, fwd) { 1348 if (opts.rev) 1349 fwd = !fwd; 1350 $.fn.cycle.commonReset(curr,next,opts); 1351 opts.cssBefore.top = fwd ? (1-next.cycleH) : (next.cycleH-1); 1352 opts.animOut.top = fwd ? curr.cycleH : -curr.cycleH; 1353 }); 1354 opts.cssFirst.top = 0; 1355 opts.cssBefore.left = 0; 1356 opts.animIn.top = 0; 1357 opts.animOut.left = 0; 1358}; 1359 1360// slideX/slideY 1361$.fn.cycle.transitions.slideX = function($cont, $slides, opts) { 1362 opts.before.push(function(curr, next, opts) { 1363 $(opts.elements).not(curr).hide(); 1364 $.fn.cycle.commonReset(curr,next,opts,false,true); 1365 opts.animIn.width = next.cycleW; 1366 }); 1367 opts.cssBefore.left = 0; 1368 opts.cssBefore.top = 0; 1369 opts.cssBefore.width = 0; 1370 opts.animIn.width = 'show'; 1371 opts.animOut.width = 0; 1372}; 1373$.fn.cycle.transitions.slideY = function($cont, $slides, opts) { 1374 opts.before.push(function(curr, next, opts) { 1375 $(opts.elements).not(curr).hide(); 1376 $.fn.cycle.commonReset(curr,next,opts,true,false); 1377 opts.animIn.height = next.cycleH; 1378 }); 1379 opts.cssBefore.left = 0; 1380 opts.cssBefore.top = 0; 1381 opts.cssBefore.height = 0; 1382 opts.animIn.height = 'show'; 1383 opts.animOut.height = 0; 1384}; 1385 1386// shuffle 1387$.fn.cycle.transitions.shuffle = function($cont, $slides, opts) { 1388 var i, w = $cont.css('overflow', 'visible').width(); 1389 $slides.css({left: 0, top: 0}); 1390 opts.before.push(function(curr,next,opts) { 1391 $.fn.cycle.commonReset(curr,next,opts,true,true,true); 1392 }); 1393 // only adjust speed once! 1394 if (!opts.speedAdjusted) { 1395 opts.speed = opts.speed / 2; // shuffle has 2 transitions 1396 opts.speedAdjusted = true; 1397 } 1398 opts.random = 0; 1399 opts.shuffle = opts.shuffle || {left:-w, top:15}; 1400 opts.els = []; 1401 for (i=0; i < $slides.length; i++) 1402 opts.els.push($slides[i]); 1403 1404 for (i=0; i < opts.currSlide; i++) 1405 opts.els.push(opts.els.shift()); 1406 1407 // custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!) 1408 opts.fxFn = function(curr, next, opts, cb, fwd) { 1409 if (opts.rev) 1410 fwd = !fwd; 1411 var $el = fwd ? $(curr) : $(next); 1412 $(next).css(opts.cssBefore); 1413 var count = opts.slideCount; 1414 $el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() { 1415 var hops = $.fn.cycle.hopsFromLast(opts, fwd); 1416 for (var k=0; k < hops; k++) { 1417 if (fwd) 1418 opts.els.push(opts.els.shift()); 1419 else 1420 opts.els.unshift(opts.els.pop()); 1421 } 1422 if (fwd) { 1423 for (var i=0, len=opts.els.length; i < len; i++) 1424 $(opts.els[i]).css('z-index', len-i+count); 1425 } 1426 else { 1427 var z = $(curr).css('z-index'); 1428 $el.css('z-index', parseInt(z,10)+1+count); 1429 } 1430 $el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() {
1431 $(fwd ? this : curr).hide(); 1432 if (cb) cb(); 1433 }); 1434 }); 1435 }; 1436 $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 }); 1437}; 1438 1439// turnUp/Down/Left/Right 1440$.fn.cycle.transitions.turnUp = function($cont, $slides, opts) { 1441 opts.before.push(function(curr, next, opts) { 1442 $.fn.cycle.commonReset(curr,next,opts,true,false); 1443 opts.cssBefore.top = next.cycleH; 1444 opts.animIn.height = next.cycleH; 1445 opts.animOut.width = next.cycleW; 1446 }); 1447 opts.cssFirst.top = 0; 1448 opts.cssBefore.left = 0; 1449 opts.cssBefore.height = 0; 1450 opts.animIn.top = 0; 1451 opts.animOut.height = 0; 1452}; 1453$.fn.cycle.transitions.turnDown = function($cont, $slides, opts) { 1454 opts.before.push(function(curr, next, opts) { 1455 $.fn.cycle.commonReset(curr,next,opts,true,false); 1456 opts.animIn.height = next.cycleH; 1457 opts.animOut.top = curr.cycleH; 1458 }); 1459 opts.cssFirst.top = 0; 1460 opts.cssBefore.left = 0; 1461 opts.cssBefore.top = 0; 1462 opts.cssBefore.height = 0; 1463 opts.animOut.height = 0; 1464}; 1465$.fn.cycle.transitions.turnLeft = function($cont, $slides, opts) { 1466 opts.before.push(function(curr, next, opts) { 1467 $.fn.cycle.commonReset(curr,next,opts,false,true); 1468 opts.cssBefore.left = next.cycleW; 1469 opts.animIn.width = next.cycleW; 1470 }); 1471 opts.cssBefore.top = 0; 1472 opts.cssBefore.width = 0; 1473 opts.animIn.left = 0; 1474 opts.animOut.width = 0; 1475}; 1476$.fn.cycle.transitions.turnRight = function($cont, $slides, opts) { 1477 opts.before.push(function(curr, next, opts) { 1478 $.fn.cycle.commonReset(curr,next,opts,false,true); 1479 opts.animIn.width = next.cycleW; 1480 opts.animOut.left = curr.cycleW; 1481 }); 1482 $.extend(opts.cssBefore, { top: 0, left: 0, width: 0 }); 1483 opts.animIn.left = 0; 1484 opts.animOut.width = 0; 1485}; 1486 1487// zoom 1488$.fn.cycle.transitions.zoom = function($cont, $slides, opts) { 1489 opts.before.push(function(curr, next, opts) { 1490 $.fn.cycle.commonReset(curr,next,opts,false,false,true); 1491 opts.cssBefore.top = next.cycleH/2; 1492 opts.cssBefore.left = next.cycleW/2; 1493 $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH }); 1494 $.extend(opts.animOut, { width: 0, height: 0, top: curr.cycleH/2, left: curr.cycleW/2 }); 1495 }); 1496 opts.cssFirst.top = 0; 1497 opts.cssFirst.left = 0; 1498 opts.cssBefore.width = 0; 1499 opts.cssBefore.height = 0; 1500}; 1501 1502// fadeZoom 1503$.fn.cycle.transitions.fadeZoom = function($cont, $slides, opts) { 1504 opts.before.push(function(curr, next, opts) { 1505 $.fn.cycle.commonReset(curr,next,opts,false,false); 1506 opts.cssBefore.left = next.cycleW/2; 1507 opts.cssBefore.top = next.cycleH/2; 1508 $.extend(opts.animIn, { top: 0, left: 0, width: next.cycleW, height: next.cycleH }); 1509 }); 1510 opts.cssBefore.width = 0; 1511 opts.cssBefore.height = 0; 1512 opts.animOut.opacity = 0; 1513}; 1514 1515// blindX 1516$.fn.cycle.transitions.blindX = function($cont, $slides, opts) { 1517 var w = $cont.css('overflow','hidden').width(); 1518 opts.before.push(function(curr, next, opts) { 1519 $.fn.cycle.commonReset(curr,next,opts); 1520 opts.animIn.width = next.cycleW; 1521 opts.animOut.left = curr.cycleW; 1522 }); 1523 opts.cssBefore.left = w; 1524 opts.cssBefore.top = 0; 1525 opts.animIn.left = 0; 1526 opts.animOut.left = w; 1527}; 1528// blindY 1529$.fn.cycle.transitions.blindY = function($cont, $slides, opts) { 1530 var h = $cont.css('overflow','hidden').height(); 1531 opts.before.push(function(curr, next, opts) { 1532 $.fn.cycle.commonReset(curr,next,opts); 1533 opts.animIn.height = next.cycleH; 1534 opts.animOut.top = curr.cycleH; 1535 }); 1536 opts.cssBefore.top = h; 1537 opts.cssBefore.left = 0; 1538 opts.animIn.top = 0; 1539 opts.animOut.top = h; 1540}; 1541// blindZ 1542$.fn.cycle.transitions.blindZ = function($cont, $slides, opts) { 1543 var h = $cont.css('overflow','hidden').height(); 1544 var w = $cont.width(); 1545 opts.before.push(function(curr, next, opts) { 1546 $.fn.cycle.commonReset(curr,next,opts); 1547 opts.animIn.height = next.cycleH; 1548 opts.animOut.top = curr.cycleH; 1549 }); 1550 opts.cssBefore.top = h; 1551 opts.cssBefore.left = w; 1552 opts.animIn.top = 0; 1553 opts.animIn.left = 0; 1554 opts.animOut.top = h; 1555 opts.animOut.left = w; 1556}; 1557 1558// growX - grow horizontally from centered 0 width 1559$.fn.cycle.transitions.growX = function($cont, $slides, opts) { 1560 opts.before.push(function(curr, next, opts) { 1561 $.fn.cycle.commonReset(curr,next,opts,false,true); 1562 opts.cssBefore.left = this.cycleW/2; 1563 opts.animIn.left = 0; 1564 opts.animIn.width = this.cycleW; 1565 opts.animOut.left = 0; 1566 }); 1567 opts.cssBefore.top = 0; 1568 opts.cssBefore.width = 0; 1569}; 1570// growY - grow vertically from centered 0 height 1571$.fn.cycle.transitions.growY = function($cont, $slides, opts) { 1572 opts.before.push(function(curr, next, opts) { 1573 $.fn.cycle.commonReset(curr,next,opts,true,false); 1574 opts.cssBefore.top = this.cycleH/2; 1575 opts.animIn.top = 0; 1576 opts.animIn.height = this.cycleH; 1577 opts.animOut.top = 0; 1578 }); 1579 opts.cssBefore.height = 0; 1580 opts.cssBefore.left = 0; 1581}; 1582 1583// curtainX - squeeze in both edges horizontally 1584$.fn.cycle.transitions.curtainX = function($cont, $slides, opts) { 1585 opts.before.push(function(curr, next, opts) { 1586 $.fn.cycle.commonReset(curr,next,opts,false,true,true); 1587 opts.cssBefore.left = next.cycleW/2; 1588 opts.animIn.left = 0; 1589 opts.animIn.width = this.cycleW; 1590 opts.animOut.left = curr.cycleW/2; 1591 opts.animOut.width = 0; 1592 }); 1593 opts.cssBefore.top = 0; 1594 opts.cssBefore.width = 0; 1595}; 1596// curtainY - squeeze in both edges vertically 1597$.fn.cycle.transitions.curtainY = function($cont, $slides, opts) { 1598 opts.before.push(function(curr, next, opts) { 1599 $.fn.cycle.commonReset(curr,next,opts,true,false,true); 1600 opts.cssBefore.top = next.cycleH/2; 1601 opts.animIn.top = 0; 1602 opts.animIn.height = next.cycleH; 1603 opts.animOut.top = curr.cycleH/2; 1604 opts.animOut.height = 0; 1605 }); 1606 opts.cssBefore.height = 0; 1607 opts.cssBefore.left = 0; 1608}; 1609 1610// cover - curr slide covered by next slide 1611$.fn.cycle.transitions.cover = function($cont, $slides, opts) { 1612 var d = opts.direction || 'left'; 1613 var w = $cont.css('overflow','hidden').width(); 1614 var h = $cont.height(); 1615 opts.before.push(function(curr, next, opts) { 1616 $.fn.cycle.commonReset(curr,next,opts); 1617 opts.cssAfter.display = ''; 1618 if (d == 'right') 1619 opts.cssBefore.left = -w; 1620 else if (d == 'up') 1621 opts.cssBefore.top = h; 1622 else if (d == 'down') 1623 opts.cssBefore.top = -h; 1624 else 1625 opts.cssBefore.left = w; 1626 }); 1627 opts.animIn.left = 0; 1628 opts.animIn.top = 0; 1629 opts.cssBefore.top = 0; 1630 opts.cssBefore.left = 0; 1631}; 1632 1633// uncover - curr slide moves off next slide 1634$.fn.cycle.transitions.uncover = function($cont, $slides, opts) { 1635 var d = opts.direction || 'left'; 1636 var w = $cont.css('overflow','hidden').width(); 1637 var h = $cont.height(); 1638 opts.before.push(function(curr, next, opts) { 1639 $.fn.cycle.commonReset(curr,next,opts,true,true,true); 1640 if (d == 'right') 1641 opts.animOut.left = w; 1642 else if (d == 'up') 1643 opts.animOut.top = -h; 1644 else if (d == 'down') 1645 opts.animOut.top = h; 1646 else 1647 opts.animOut.left = -w; 1648 }); 1649 opts.animIn.left = 0; 1650 opts.animIn.top = 0; 1651 opts.cssBefore.top = 0; 1652 opts.cssBefore.left = 0; 1653}; 1654 1655// toss - move top slide and fade away 1656$.fn.cycle.transitions.toss = function($cont, $slides, opts) { 1657 var w = $cont.css('overflow','visible').width(); 1658 var h = $cont.height(); 1659 opts.before.push(function(curr, next, opts) { 1660 $.fn.cycle.commonReset(curr,next,opts,true,true,true); 1661 // provide default toss settings if animOut not provided 1662 if (!opts.animOut.left && !opts.animOut.top) 1663 $.extend(opts.animOut, { left: w*2, top: -h/2, opacity: 0 }); 1664 else 1665 opts.animOut.opacity = 0; 1666 }); 1667 opts.cssBefore.left = 0; 1668 opts.cssBefore.top = 0; 1669 opts.animIn.left = 0; 1670}; 1671 1672// wipe - clip animation 1673$.fn.cycle.transitions.wipe = function($cont, $slides, opts) { 1674 var w = $cont.css('overflow','hidden').width(); 1675 var h = $cont.height(); 1676 opts.cssBefore = opts.cssBefore || {}; 1677 var clip; 1678 if (opts.clip) { 1679 if (/l2r/.test(opts.clip)) 1680 clip = 'rect(0px 0px '+h+'px 0px)'; 1681 else if (/r2l/.test(opts.clip)) 1682 clip = 'rect(0px '+w+'px '+h+'px '+w+'px)'; 1683 else if (/t2b/.test(opts.clip)) 1684 clip = 'rect(0px '+w+'px 0px 0px)'; 1685 else if (/b2t/.test(opts.clip)) 1686 clip = 'rect('+h+'px '+w+'px '+h+'px 0px)'; 1687 else if (/zoom/.test(opts.clip)) { 1688 var top = parseInt(h/2,10); 1689 var left = parseInt(w/2,10); 1690 clip = 'rect('+top+'px '+left+'px '+top+'px '+left+'px)'; 1691 } 1692 } 1693 1694 opts.cssBefore.clip = opts.cssBefore.clip || clip || 'rect(0px 0px 0px 0px)'; 1695 1696 var d = opts.cssBefore.clip.match(/(\d+)/g); 1697 var t = parseInt(d[0],10), r = parseInt(d[1],10), b = parseInt(d[2],10), l = parseInt(d[3],10); 1698 1699 opts.before.push(function(curr, next, opts) { 1700 if (curr == next) return; 1701 var $curr = $(curr), $next = $(next); 1702 $.fn.cycle.commonReset(curr,next,opts,true,true,false); 1703 opts.cssAfter.display = 'block'; 1704 1705 var step = 1, count = parseInt((opts.speedIn / 13),10) - 1; 1706 (function f() { 1707 var tt = t ? t - parseInt(step * (t/count),10) : 0; 1708 var ll = l ? l - parseInt(step * (l/count),10) : 0; 1709 var bb = b < h ? b + parseInt(step * ((h-b)/count || 1),10) : h; 1710 var rr = r < w ? r + parseInt(step * ((w-r)/count || 1),10) : w; 1711 $next.css({ clip: 'rect('+tt+'px '+rr+'px '+bb+'px '+ll+'px)' }); 1712 (step++ <= count) ? setTimeout(f, 13) : $curr.css('display', 'none'); 1713 })();
1714 }); 1715 $.extend(opts.cssBefore, { display: 'block', opacity: 1, top: 0, left: 0 }); 1716 opts.animIn = { left: 0 }; 1717 opts.animOut = { left: 0 }; 1718}; 1719 1720})(jQuery);; 1721/*! Sidr - v1.1.1 - 2013-03-14 1722 * https://github.com/artberri/sidr 1723 * Copyright (c) 2013 Alberto Varela; Licensed MIT */ 1724(function(e){var t=!1,i=!1,o={isUrl:function(e){var t=RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$","i");return t.test(e)?!0:!1},loadContent:function(e,t){e.html(t)},addPrefix:function(e){var t=e.attr("id"),i=e.attr("class");"string"==typeof t&&""!==t&&e.attr("id",t.replace(/([A-Za-z0-9_.\-]+)/g,"sidr-id-$1")),"string"==typeof i&&""!==i&&"sidr-inner"!==i&&e.attr("class",i.replace(/([A-Za-z0-9_.\-]+)/g,"sidr-class-$1")),e.removeAttr("style")},execute:function(o,n,s){"function"==typeof n?(s=n,n="sidr"):n||(n="sidr");var a,d,l,c=e("#"+n),f=e(c.data("body")),u=e("html"),p=c.outerWidth(!0),y=c.data("speed"),v=c.data("side");if("open"===o||"toogle"===o&&!c.is(":visible")){if(c.is(":visible")||t)return;if(i!==!1)return r.close(i,function(){r.open(n)}),void 0;t=!0,"left"===v?(a={left:p+"px"},d={left:"0px"}):(a={right:p+"px"},d={right:"0px"}),l=u.scrollTop(),u.css("overflow-x","hidden").scrollTop(l),f.css({width:f.width(),position:"absolute"}).animate(a,y),c.css("display","block").animate(d,y,function(){t=!1,i=n,"function"==typeof s&&s(n)})}else{if(!c.is(":visible")||t)return;t=!0,"left"===v?(a={left:0},d={left:"-"+p+"px"}):(a={right:0},d={right:"-"+p+"px"}),l=u.scrollTop(),u.removeAttr("style").scrollTop(l),f.animate(a,y),c.animate(d,y,function(){c.removeAttr("style"),f.removeAttr("style"),e("html").removeAttr("style"),t=!1,i=!1,"function"==typeof s&&s(n)})}}},r={open:function(e,t){o.execute("open",e,t)},close:function(e,t){o.execute("close",e,t)},toogle:function(e,t){o.execute("toogle",e,t)}};e.sidr=function(t){return r[t]?r[t].apply(this,Array.prototype.slice.call(arguments,1)):"function"!=typeof t&&"string"!=typeof t&&t?(e.error("Method "+t+" does not exist on jQuery.sidr"),void 0):r.toogle.apply(this,arguments)},e.fn.sidr=function(t){var i=e.extend({name:"sidr",speed:200,side:"left",source:null,renaming:!0,body:"body"},t),n=i.name,s=e("#"+n);if(0===s.length&&(s=e("<div />").attr("id",n).appendTo(e("body"))),s.addClass("sidr").addClass(i.side).data({speed:i.speed,side:i.side,body:i.body}),"function"==typeof i.source){var a=i.source(n);o.loadContent(s,a)}else if("string"==typeof i.source&&o.isUrl(i.source))e.get(i.source,function(e){o.loadContent(s,e)});else if("string"==typeof i.source){var d="",l=i.source.split(",");if(e.each(l,function(t,i){d+='<div class="sidr-inner">'+e(i).html()+"</div>"}),i.renaming){var c=e("<div />").html(d);c.find("*").each(function(t,i){var r=e(i);o.addPrefix(r)}),d=c.html()}o.loadContent(s,d)}else null!==i.source&&e.error("Invalid Sidr Source");return this.each(function(){var t=e(this),i=t.data("sidr");i||(t.data("sidr",n),t.click(function(e){e.preventDefault(),r.toogle(n)}))})}})(jQuery);; 1725(function($) { 1726/////////////////////////////////////////////////////////////////////////////////////// 1727// Début script 1728 1729 // GLOSSAIRE : Désactiver le click des ancres unavailable 1730 /////////////////////////////////////////////// 1731 Drupal.behaviors.glossary = { 1732 attach: function (context, settings) { 1733 1734 $('div.glossary span.unavailable>a').click(function(e) { 1735 e.preventDefault(); 1736 }); 1737 1738 } 1739 }; 1740 1741 1742 // Background sous-menu 1743 /////////////////////////////////////////////// 1744 Drupal.behaviors.bgsousmenu = { 1745 attach: function (context, settings) { 1746 1747 $('header#section-header div#zone-menu-wrapper ul.menu>li:eq(0)').addClass('menu-1'); 1748 $('header#section-header div#zone-menu-wrapper ul.menu>li:eq(1)').addClass('menu-2'); 1749 $('header#section-header div#zone-menu-wrapper ul.menu>li:eq(2)').addClass('menu-3'); 1750 $('header#section-header div#zone-menu-wrapper ul.menu>li:eq(3)').addClass('menu-4'); 1751 $('header#section-header div#zone-menu-wrapper ul.menu>li:eq(4)').addClass('menu-5'); 1752 $('header#section-header div#zone-menu-wrapper ul.menu>
1752li:eq(5)').addClass('menu-6'); 1753 $('header#section-header div#zone-menu-wrapper ul.menu>li:eq(6)').addClass('menu-7'); 1754 $('header#section-header div#zone-menu-wrapper ul.menu>li:eq(7)').addClass('menu-8'); 1755 $('header#section-header div#zone-menu-wrapper ul.menu>li:eq(9)').addClass('menu-10'); 1756 1757 } 1758 }; 1759 1760 1761 1762 1763 //////////////////////////////////////////////// 1764 // Block accessibilité 1765 //////////////////////////////////////////////// 1766 Drupal.behaviors.accessibilite = { 1767 attach: function (context, settings) { 1768 var section = new Array( '#region-content p','#region-content strong' ,'#region-content h3', '#region-content h1', '#region-content span' 1769 ); 1770 section = section.join(',' ); 1771 1772 // Augmenter la taille 1773 $("#aplus").click(function(){ 1774 var currentFontSize = $(section).css('font-size'); 1775 var currentFontSizeNum = parseFloat(currentFontSize, 10); 1776 var newFontSize = currentFontSizeNum*1.1; 1777 $(section).css('font-size', newFontSize); 1778 return false; 1779 }); 1780 // Diminuer la taille 1781 $("#amoins").click(function(){ 1782 var currentFontSize = $(section).css('font-size'); 1783 var currentFontSizeNum = parseFloat(currentFontSize, 10); 1784 var newFontSize = currentFontSizeNum*0.8; 1785 $(section).css('font-size', newFontSize); 1786 return false; 1787 }); 1788 } 1789 }; 1790 1791 1792 1793 // Partenaire slider/ en footer 1794 /////////////////////////////////////////////// 1795 Drupal.behaviors.partenairecycle = { 1796 attach: function (context, settings) { 1797 1798 slider = $('.slider-partenaire .wrapper-list'); 1799 slider.append('<span id="cycle-prev"></span><span id="cycle-next"></span>'); 1800 slider.find('ul').cycle({ 1801 speed: 600, 1802 manualSpeed: 100, 1803 swipe: true, 1804 next: '#cycle-next', 1805 prev: '#cycle-prev' 1806 }); 1807 1808 1809 } 1810 }; 1811 1812 1813 // Input Newsletter 1814 /////////////////////////////////////////////// 1815 Drupal.behaviors.inputNewsletter = { 1816 attach: function (context, settings) { 1817 1818 1819 texte = "<p>Lâessentiel de la Qualité et de la Performance dans votre boite e-mail !</p>"; 1820 1821 $("#block-mailchimp-lists-afqp-nl-echange-digital h2 ").after(texte); 1822 1823 input = $("#block-mailchimp-lists-afqp-nl-echange-digital .form-item-mailchimp-lists-mailchimp-afqp-nl-echange-digital-mergevars-EMAIL input[type='text']"); 1824 1825 input.val('Email'); 1826 1827 1828 input.focus( function() { 1829 if( $(this).val() == 'Email' ){ 1830 $(this).val(' '); 1831 } 1832 }); 1833 input.blur( function() { 1834 if( $(this).val() == ' ' ){ 1835 $(this).val('Email'); 1836 } 1837 }); 1838 1839 1840 } 1841 }; 1842 1843 1844 1845 1846 1847 // Sous menu : menu les espaces 1848 /////////////////////////////////////////////// 1849 Drupal.behaviors.espacesousmenu = { 1850 attach: function (context, settings) { 1851 1852 // .logged-in 1853 // .not-logged-in 1854 submenu = $("header#section-header div#zone-user-wrapper #block-menu-menu-les-espaces ul.menu li>ul"); 1855 menuadherent = $("header#section-header div#zone-user-wrapper #block-menu-menu-les-espaces ul.menu li:eq(1)>a"); 1856 submenu = $("header#section-header div#zone-user-wrapper #block-menu-menu-les-espaces ul.menu li:eq(1)").find("ul"); 1857 1858 menuadherent.click(function(){ 1859 if( $("body").hasClass('logged-in') ){ 1860 submenu.stop( true, true ).slideToggle(200); 1861 return false; 1862 } 1863 }); 1864 //console.log(menuadherent.html()); 1865 1866 1867 1868 1869 } 1870 }; 1871 1872 1873 1874 Drupal.behaviors.facetGroupeDocs = { 1875 attach: function (context, settings) { 1876 $('.block-facetapi li.expanded').append('<span class="more-facette">(+)</span>'); 1877 $('.more-facette').click(function(){ 1878 $(this).parent().find('.item-list').toggle(200); 1879 }); 1880 $(document).click(function(e){ 1881 console.log(e); 1882 if ($('.block-facetapi .liste-criteres').is(':visible') && (e.target.className != "more-facette" || e.srcElement.className != "more-facette")) 1883 $('.block-facetapi .liste-criteres').slideUp(200); 1884 1885 }); 1886 $('.block-facetapi h3').click(function(){ 1887 if ($(this).parent().find('.liste-criteres').hasClass('liste-ouverte')) {
1888 $(this).parent().find('.liste-criteres').slideUp(200); 1889 $(this).parent().find('.liste-criteres').removeClass('liste-ouverte'); 1890 } else { 1891 $('.block-facetapi .liste-criteres.liste-ouverte').slideUp(200); 1892 $('.block-facetapi .liste-criteres.liste-ouverte').removeClass('liste-ouverte'); 1893 $(this).parent().find('.liste-criteres').addClass('liste-ouverte'); 1894 $(this).parent().find('.liste-criteres').slideDown(100); 1895 return false; 1896 } 1897 1898 }); 1899 1900 } 1901 }; 1902 1903 1904 1905 // .node-document-partage #comments h2.title 1906 // => article 1907 // .comment-form 1908 // => form 1909 // Sous menu : menu les espaces 1910 /////////////////////////////////////////////// 1911 Drupal.behaviors.doccomments = { 1912 attach: function (context, settings) { 1913 1914 1915 comment = $(".node-document-partage #comments h2.title:first"); 1916 article = $(".node-document-partage #comments article"); 1917 cform = $(".node-document-partage #comments h2.comment-form"); 1918 form = $(".node-document-partage #comments form"); 1919 1920 1921 1922 comment.click(function(){ 1923 1924 article.stop( true, true ).slideToggle(200); 1925 return false; 1926 1927 }); 1928 1929 1930 cform.click(function(){ 1931 1932 form.stop( true, true ).slideToggle(200); 1933 return false; 1934 1935 }); 1936 //console.log(menuadherent.html()); 1937 1938 1939 1940 1941 } 1942 }; 1943 1944 1945 1946 // Menu sidR 1947 //////////////////////////////////////////// 1948 Drupal.behaviors.menuMobile = { 1949 attach: function (context, settings) { 1950 $('body').bind('responsivelayout', function(e, d) { 1951 1952 if( $(this).hasClass("responsive-layout-mobile") ) { 1953 logo = 'http://www.qualiteperformance.org/sites/www.qualiteperformance.org/themes/afqp/css/images/logo-mobile.png'; 1954 }else{ 1955 logo = 'http://www.qualiteperformance.org/sites/www.qualiteperformance.org/themes/afqp/logo.png'; 1956 } 1957 1958 //Menus 1959 1960 menus = $('a#responsive-main-menu-btn, a#responsive-header-menu-btn, a#responsive-espaces-menu-btn'); 1961 1962 mainmenu = $('a#responsive-main-menu-btn'); 1963 mainmenu.sidr({ 1964 name: 'sidr-main', 1965 source: '#region-menu' 1966 }); 1967 1968 headermenu = $('a#responsive-header-menu-btn'); 1969 headermenu.sidr({ 1970 name: 'sidr-header', 1971 source: '#block-menu-menu-header-menu-identite' 1972 }); 1973 1974 espacesmenu = $('a#responsive-espaces-menu-btn'); 1975 espacesmenu.sidr({ 1976 name: 'sidr-espaces', 1977 source: '#block-menu-menu-les-espaces', 1978 side:'right' 1979 }); 1980 1981 1982 //Formulaire de recherche 1983 searchmenu = $('a#responsive-search-btn'); 1984 seachbloc = $('#block-afqp-bloc-search'); 1985 1986 searchmenu.click(function(){ 1987 seachbloc.slideToggle(400); 1988 }); 1989 menus.click(function(){ 1990 seachbloc.fadeOut(100); 1991 }); 1992 1993 // Modification du logo 1994 $('#logo').attr('src',logo); 1995 1996 }); 1997 } 1998 }; 1999 2000 // Carrousel image 2001 /////////////////////////////////////////////// 2002 Drupal.behaviors.actucycle = { 2003 attach: function (context, settings) { 2004 2005 slider = $('.carrousel'); 2006 slider.append('<span class="prev"></span><span class="next"></span>'); 2007 slider.find('ul').cycle({ 2008 speed: 600, 2009 manualSpeed: 100, 2010 swipe: true, 2011 next: '.carrousel .next', 2012 prev: '.carrousel .prev' 2013 }); 2014 2015 2016 } 2017 }; 2018 2019/////////////////////////////////////////////////////////////////////////////////////// 2020// Fin script 2021})(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.