1function DiaporamaSimpleSlideshowTransitionSlide($) 2{ 3 this.$ = $; 4} 5DiaporamaSimpleSlideshowTransitionSlide.prototype.init = function(diaporama) 6{ 7 // positionne toutes les slides à zéro 8 this.$.each(diaporama.config.diapos, function(index, diapo) 9 { 10 diapo.slide.css({left: diaporama.currentWidth}); 11 }); 12 13 // positionne la première slide visible 14 diaporama.config.diapos[diaporama.currentSlide].slide.css({left: 0}).show(); 15}; 16DiaporamaSimpleSlideshowTransitionSlide.prototype.resize = function(diaporama) 17{ 18 // positionne toutes les slides à zéro sauf le courant 19 this.$.each(diaporama.config.diapos, function(index, diapo) 20 { 21 if (index == diaporama.currentSlide) { 22 return; 23 } 24 25 diapo.slide.css({left: diaporama.currentWidth}); 26 }); 27}; 28DiaporamaSimpleSlideshowTransitionSlide.prototype.next = function(diaporama) 29{ 30 this.animNext(diaporama, diaporama.diapoNext()); 31}; 32DiaporamaSimpleSlideshowTransitionSlide.prototype.prev = function(diaporama) 33{ 34 this.animPrev(diaporama, diaporama.diapoPrev()); 35}; 36DiaporamaSimpleSlideshowTransitionSlide.prototype.to = function(diaporama, slide) 37{ 38 var diapo = diaporama.diapoTo(slide); 39 40 if (diapo.next.order < diapo.prev.order) { 41 this.animPrev(diaporama, diapo); 42 } else { 43 this.animNext(diaporama, diapo); 44 } 45}; 46DiaporamaSimpleSlideshowTransitionSlide.prototype.animNext = function(diaporama, diapo) 47{ 48 diapo.prev.slide.stop().animate({left: -diaporama.currentWidth}, 1000, function() 49 { 50 diapo.prev.slide.hide().css({left: diaporama.currentWidth}); 51 }); 52 53 diapo.next.slide.stop().show().animate({left: 0}, 1000); 54}; 55DiaporamaSimpleSlideshowTransitionSlide.prototype.animPrev = function(diaporama, diapo) 56{ 57 diapo.prev.slide.stop().animate({left: diaporama.currentWidth}, 1000, function() 58 { 59 diapo.prev.slide.hide(); 60 }); 61 62 if (diapo.next.slide.queue().length) { 63 diapo.next.slide.stop().show().animate({left: 0}, 1000); 64 } else { 65 diapo.next.slide.css({left: -diaporama.currentWidth}).show().animate({left: 0}, 1000); 66 } 67}; 68 69function DiaporamaSimpleSlideshowTransitionFall($) 70{ 71 this.$ = $; 72} 73diaporamaExtend(DiaporamaSimpleSlideshowTransitionFall, DiaporamaSimpleSlideshowTransitionSlide); 74DiaporamaSimpleSlideshowTransitionFall.prototype.init = function(diaporama) 75{ 76 // positionne toutes les slides à zéro 77 this.$.each(diaporama.config.diapos, function(index, diapo) 78 { 79 diapo.slide.css({top: -diaporama.currentHeight }); 80 }); 81 82 // positionne la première slide visible 83 diaporama.config.diapos[diaporama.currentSlide].slide.css({top: 0}).show(); 84}; 85DiaporamaSimpleSlideshowTransitionFall.prototype.resize = function(diaporama) 86{ 87 // positionne toutes les slides à zéro 88 this.$.each(diaporama.config.diapos, function(index, diapo) 89 { 90 if (index == diaporama.currentSlide) { 91 return; 92 } 93 diapo.slide.css({top: -diaporama.currentHeight }); 94 }); 95}; 96DiaporamaSimpleSlideshowTransitionFall.prototype.animNext = function(diaporama, diapo) 97{ 98 diapo.prev.slide.stop().animate({top: diaporama.currentHeight}, 1000, function() 99 { 100 diapo.prev.slide.hide().css({top: -diaporama.currentHeight}); 101 }); 102 103 diapo.next.slide.stop().show().animate({top: 0}, 1000); 104}; 105DiaporamaSimpleSlideshowTransitionFall.prototype.animPrev = function(diaporama, diapo) 106{ 107 diapo.prev.slide.stop().animate({top: -diaporama.currentHeight}, 1000, function() 108 { 109 diapo.prev.slide.hide(); 110 }); 111 112 if (diapo.next.slide.queue().length) { 113 diapo.next.slide.stop().show().animate({top: 0}, 1000); 114 } else { 115 diapo.next.slide.css({top: diaporama.currentHeight}).show().animate({top: 0}, 1000); 116 } 117}; 118 119function DiaporamaSimpleSlideshowTransitionFade($) 120{ 121 this.$ = $; 122} 123DiaporamaSimpleSlideshowTransitionFade.prototype.init = function(diaporama) 124{ 125 // positionne la première slide visible 126 diaporama.config.diapos[diaporama.currentSlide].slide.show(); 127}; 128DiaporamaSimpleSlideshowTransitionFade.prototype.next = function(diaporama) 129{ 130 this.fade(diaporama.diapoNext()); 131}; 132DiaporamaSimpleSlideshowTransitionFade.prototype.prev = function(diaporama) 133{ 134 this.fade(diaporama.diapoPrev()); 135 136}; 137DiaporamaSimpleSlideshowTransitionFade.prototype.to = function(diaporama, slide) 138{ 139 this.fade(diaporama.diapoTo(slide)); 140 141}; 142DiaporamaSimpleSlideshowTransitionFade.prototype.fade = function(diapo) 143{ 144 diapo.prev.slide.stop().fadeOut(1200); 145 diapo.next.slide.stop().fadeIn(1200); 146}; 147DiaporamaSimpleSlideshowTransitionFade.prototype.resize = function(diaporama) 148{}; 149 150function DiaporamaSimpleSlideshow(container, config, $) 151{ 152 this.$ = $; 153 this.start(container, config); 154} 155 156// Démarre le diaporama 157DiaporamaSimpleSlideshow.prototype.start = function(container, config) 158{ 159 this.config = config; 160 this.uniqId = 'diaporamaInstance' + Math.floor(1 + Math.random() * 100000); 161 this.container = container.addClass('diaporama'); 162 this.wrapper = this.$('<div>').addClass('diaporamaWrapper').appendTo(this.container), 163 this.dotsContainer = this.$('<div>').addClass('diaporamaDots'), 164 this.currentWidth = 0; 165 this.currentHeight = 0; 166 this.currentSlide = 0; 167 this.autoplayTimeout = null; 168 this.isPreloaded = false;
169 this.transition = null; 170 this.loaded = false; 171 this.readyCallback = null; 172 this.container.data('diaporama', this); 173 this.random(); 174 this.preload(); 175 this.wait(); 176}; 177 178// Appelle la méthode parente pour les objets hérités 179DiaporamaSimpleSlideshow.prototype.parent = function(name, params) 180{ 181 return Object.getPrototypeOf(Object.getPrototypeOf(this))[name].apply(this, params); 182}; 183 184// Renvoie une callback vers la méthode fournie 185DiaporamaSimpleSlideshow.prototype.callback = function(name, params) 186{ 187 var self = this; 188 189 return function() 190 { 191 if (typeof self[name] == 'function') { 192 self[name].apply(self, params); 193 } 194 }; 195}; 196 197// Précharge les images 198DiaporamaSimpleSlideshow.prototype.preload = function() 199{ 200 var self = this, 201 totalImagesToLoad = this.config.diapos.length; 202 203 this.$.each(this.config.diapos, function(index, diapo) 204 { 205 if (diapo.type == 'image') { 206 self.config.diapos[index].img = new Image(); 207 self.config.diapos[index].img.onload = function() 208 { 209 self.isPreloaded = (--totalImagesToLoad == 0); 210 } 211 self.config.diapos[index].img.src = diapo.src; 212 if (diapo.title != '') { 213 self.config.diapos[index].img.alt = diapo.title.replace('"', '').replace("\n", ''); 214 } 215 } else { 216 self.$(diapo.content).on('canplay', function() 217 { 218 diapo.video = { 219 width : self.$(this).prop('videoWidth'), 220 height : self.$(this).prop('videoHeight') 221 }; 222 self.isPreloaded = (--totalImagesToLoad == 0); 223 }); 224 } 225 }); 226}; 227 228// Attend le préchargement des images 229DiaporamaSimpleSlideshow.prototype.wait = function() 230{ 231 if (this.isPreloaded) { 232 return this.init(); 233 } 234 setTimeout(this.callback('wait'), 100); 235}; 236 237// Création du diaporama 238DiaporamaSimpleSlideshow.prototype.init = function() 239{ 240 // Charge l'effet demandé 241 switch (this.config.param.slideEffect) { 242 default: 243 case 'slide' : this.transition = new DiaporamaSimpleSlideshowTransitionSlide(this.$); break; 244 case 'fade' : this.transition = new DiaporamaSimpleSlideshowTransitionFade(this.$); break; 245 case 'fall' : this.transition = new DiaporamaSimpleSlideshowTransitionFall(this.$); break; 246 } 247 // Dimensionne le diaporama 248 this.resize(); 249 // Prépare le diaporama visuellement 250 this.container.addClass(this.config.effect).addClass(this.uniqId).css({position:'relative'}); 251 // prépare le wrapper 252 this.wrapper.css({position:'absolute', overflow: 'hidden', width:'100%', height:'100%'}); 253 // crée les slides 254 this.slides(); 255 // Dimensionne les slides 256 this.resizeSlides(); 257 // positionne toute les slides à zéro 258 this.transition.init(this); 259 // affiche les puces 260 this.dots(); 261 // affiche les textes s'ils sont actifs 262 this.extras(); 263 // positionne les textes s'ils sont actifs 264 this.resizeExtras(); 265 // affiche les liens s'ils sont actifs 266 this.links(); 267 // affiche les contrôles s'il sont actifs 268 this.controls(); 269 // positionne les contrôles s'il sont actifs 270 this.resizeControls(); 271 // Initialise la puce active 272 this.updateActiveDot(); 273 // Lance l'autoplay s'il est actif 274 this.autoplay(); 275 // Informe que le diaporama est chargé 276 this.ready(); 277 // Action au redimensionnement 278 $(window).on('resize.diaporama.' + this.uniqId, this.callback('reinitSize')); 279}; 280 281DiaporamaSimpleSlideshow.prototype.ready = function() 282{ 283 this.loaded = true; 284 this.callback('readyCallback', [this.container])(); 285} 286 287DiaporamaSimpleSlideshow.prototype.onReady = function(callback) 288{ 289 this.readyCallback = callback; 290 if (this.loaded) { 291 this.callback('readyCallback', [this.container])(); 292 } 293} 294 295DiaporamaSimpleSlideshow.prototype.destroy = function() 296{ 297 this.autoplayClean(); 298 this.container.remove(); 299 delete this; 300} 301 302// Click sur le control suivant 303DiaporamaSimpleSlideshow.prototype.displayNext = function() 304{ 305 this.autoplayStop(); 306 this.slideNext(); 307}; 308 309// Click sur le control précédent 310DiaporamaSimpleSlideshow.prototype.displayPrev = function() 311{ 312 this.autoplayStop(); 313 this.slidePrev(); 314}; 315 316// Click sur une puce 317DiaporamaSimpleSlideshow.prototype.displaySlide = function(slide) 318{ 319 this.autoplayStop(); 320 this.slideTo(slide); 321}; 322 323// Passe à la silde précédente 324DiaporamaSimpleSlideshow.prototype.slidePrev = function() 325{ 326 this.transition.prev(this); 327 this.autoplay(); 328}; 329 330// Passe à la slide suivante 331DiaporamaSimpleSlideshow.prototype.slideNext = function() 332{ 333 this.transition.next(this); 334 this.autoplay(); 335}; 336 337// Passe à la slide indiquée 338DiaporamaSimpleSlideshow.prototype.slideTo = function(slide) 339{ 340 if (this.currentSlide == slide) { 341 return; 342 } 343 344 this.transition.to(this, slide); 345 this.autoplay(); 346} 347 348// Change la puce active 349DiaporamaSimpleSlideshow.prototype.updateActiveDot = function() 350{ 351 this.dotsContainer.find('.diaporamaDot') 352 .removeClass('diaporamaDotActive') 353 .eq(this.currentSlide).addClass('diaporamaDotActive'); 354}; 355 356// Passe la slide courante à la précédente 357DiaporamaSimpleSlideshow.prototype.slideDec = function() 358{ 359 if (this.config.param.random) { 360 return this.random(); 361 } 362 363 --(this.currentSlide); 364
365 if (this.currentSlide < 0) { 366 this.currentSlide = this.config.diapos.length - 1; 367 } 368 369 this.updateActiveDot(); 370 371 return this.currentSlide; 372}; 373 374// Passe la slide courtante à la suivante 375DiaporamaSimpleSlideshow.prototype.slideInc = function() 376{ 377 if (this.config.param.random) { 378 return this.random(); 379 } 380 381 ++(this.currentSlide); 382 383 if (this.currentSlide >= this.config.diapos.length) { 384 this.currentSlide = 0; 385 } 386 387 this.updateActiveDot(); 388 389 return this.currentSlide; 390}; 391 392// Passe la slide courtante à la suivante 393DiaporamaSimpleSlideshow.prototype.slideSet = function(slide) 394{ 395 this.currentSlide = slide; 396 397 if (this.currentSlide < 0 || this.currentSlide >= this.config.diapos.length) { 398 this.currentSlide = 0; 399 } 400 401 this.updateActiveDot(); 402 403 return this.currentSlide; 404}; 405 406// Retourne une diapo aléatoirement 407DiaporamaSimpleSlideshow.prototype.random = function() 408{ 409 if (this.config.param.random) { 410 this.currentSlide = Math.floor(Math.random() * this.config.diapos.length); 411 this.updateActiveDot(); 412 } 413 414 return this.currentSlide; 415}; 416 417// Renvoie le jeu de diapo (ancienne et nouvelle) correspondant à l'action précédent 418DiaporamaSimpleSlideshow.prototype.diapoPrev = function() 419{ 420 return { 421 prev: this.config.diapos[this.currentSlide], 422 next: this.config.diapos[this.slideDec()] 423 }; 424}; 425 426// Renvoie le jeu de diapo (ancienne et nouvelle) correspondant à l'action suivant 427DiaporamaSimpleSlideshow.prototype.diapoNext = function() 428{ 429 return { 430 prev: this.config.diapos[this.currentSlide], 431 next: this.config.diapos[this.slideInc()] 432 }; 433}; 434 435// Renvoie le jeu de diapo (ancienne et nouvelle) correspondant à l'action aller à 436DiaporamaSimpleSlideshow.prototype.diapoTo = function(slide) 437{ 438 return { 439 prev: this.config.diapos[this.currentSlide], 440 next: this.config.diapos[this.slideSet(slide)] 441 }; 442}; 443 444// Joue l'autoplay s'il est activé 445DiaporamaSimpleSlideshow.prototype.autoplay = function() 446{ 447 if (this.$('.' + this.uniqId).length == 0) { 448 // stop le diapo s'il n'existe plus 449 return this.destroy(); 450 } 451 452 if (this.config.param.autoplay) { 453 this.autoplayClean(); 454 this.autoplayTimeout = setTimeout(this.callback('slideNext'), this.config.param.autoplayDelay * 1000); 455 } 456}; 457 458// Arrête l'autoplay 459DiaporamaSimpleSlideshow.prototype.autoplayStop = function() 460{ 461 this.config.param.autoplay = false; 462 this.autoplayClean(); 463}; 464 465// Démarre l'autoplay 466DiaporamaSimpleSlideshow.prototype.autoplayStart = function() 467{ 468 this.config.param.autoplay = true; 469 this.autoplay(); 470}; 471 472// Reset la temporisation de l'autoplay 473DiaporamaSimpleSlideshow.prototype.autoplayClean = function() 474{ 475 if (this.autoplayTimeout !== null) { 476 clearTimeout(this.autoplayTimeout); 477 } 478}; 479 480// Calcul la dimension maximum du diaporama et la taille normalisée des diapos 481DiaporamaSimpleSlideshow.prototype.resize = function() 482{ 483 this.container.css({width:'100%', height:'auto'}); 484 485 this.currentWidth = this.container.width(); 486 this.currentHeight = 0; 487 488 var normal = this.normalise(); 489 490 this.currentWidth = normal.width; 491 this.currentHeight = normal.height; 492 493 // Taille finale du diaporama 494 this.container.css({ 495 width : this.currentWidth, 496 height : this.currentHeight 497 }); 498}; 499 500// Calcul la dimension maximum du diaporama et la taille normalisée des diapos 501DiaporamaSimpleSlideshow.prototype.reinitSize = function() 502{ 503 // On remet les slides dans leur état initial 504 this.reinitSlides(); 505 // On calcule la nouvelle taille du diaporama 506 this.resize(); 507 // On assigne une nouvelle taille aux slides 508 this.resizeSlides(); 509 // On assigne une nouvelle position aux controles 510 this.resizeControls(); 511 // On assigne une nouvelle position aux extras 512 this.resizeExtras(); 513 // On redimensionne la transition 514 this.transition.resize(this); 515}; 516 517// normalise les tailles des diapos en fonction du maximum admissible 518DiaporamaSimpleSlideshow.prototype.normalise = function() 519{ 520 var self = this, maxWidth = 0, maxHeight = 0; 521 522 // cas du diaporama à 100% de largeur 523 maxWidth = this.currentWidth; 524 525 this.$.each(this.config.diapos, function(index, diapo) 526 { 527 if (diapo.type != 'image') { 528 diapo.width = diapo.video.width; 529 diapo.height = diapo.video.height; 530 } else { 531 diapo.width = diapo.img.width; 532 diapo.height = diapo.img.height; 533 } 534 535 if (diapo.width > self.currentWidth && self.currentWidth > 0) { 536 diapo.height = Math.round(diapo.height * (self.currentWidth / diapo.width)); 537 diapo.width = self.currentWidth; 538 } 539 540 if (diapo.height > self.currentHeight && self.currentHeight > 0) { 541 diapo.width = Math.round(diapo.width * (self.currentHeight / diapo.height)); 542 diapo.height = self.currentHeight; 543 } 544 545 if (maxWidth < diapo.width) { 546 maxWidth = diapo.width; 547 } 548 549 if (maxHeight < diapo.height) { 550 maxHeight = diapo.height; 551 } 552 }); 553 554 return { width: maxWidth, height: maxHeight }; 555}; 556 557// Création des slides 558DiaporamaSimpleSlideshow.prototype.slides = function() 559{ 560 var self = this; 561 562 this.$.each(this.config.diapos, function(index, diapo) 563 { 564 diapo.slide = self.$('<div>') 565 .addClass('diaporamaSlide') 566 .hide() 567 .appendTo(self.wrapper) 568 .css({ 569 position : 'absolute', 570 width : '100%', 571 height : '100%' 572 }); 573 574 if (diapo.type == 'image') { 575 var img = self.$(diapo.img); 576 diapo.slide.addClass('diaporamaImage').append(img); 577 if (diapo.href != '') { 578 diapo.slide.addClass('diaporamaImageLink'); 579 } 580 } 581 }); 582}; 583 584// Dimensionnement des slides 585DiaporamaSimpleSlideshow.prototype.resizeSlides = function() 586{ 587 var self = this; 588 589 this.$.each(this.config.diapos, function(index, diapo) 590 { 591 if (diapo.type == 'image') { 592 diapo.posX = Math.floor((self.currentWidth - diapo.width) / 2); 593 diapo.posY = Math.floor((self.currentHeight - diapo.height) / 2); 594 595 var img = self.$(diapo.img).css({ width: diapo.width, height: diapo.height }); 596 597 diapo.slide.css({ 598 paddingLeft: diapo.posX, 599 paddingTop : diapo.posY 600 }); 601 } else { 602 diapo.posX = Math.floor((self.currentWidth - diapo.width) / 2); 603 diapo.posY = Math.floor((self.currentHeight - diapo.height) / 2); 604 605 var video = self.$(diapo.content).css({width : diapo.width, height: diapo.height }); 606 607 diapo.slide.addClass('diaporamaVideo').append(video).css({ 608 paddingLeft: diapo.posX, 609 paddingTop : diapo.posY, 610 }); 611 } 612 }); 613}; 614 615// Dimensionnement des slides 616DiaporamaSimpleSlideshow.prototype.reinitSlides = function() 617{ 618 var self = this; 619 620 this.$.each(this.config.diapos, function(index, diapo) 621 { 622 if (diapo.type == 'image') { 623 self.$(diapo.img).css({ width: 'auto', height: 'auto', paddingLeft: 0, paddingTop: 0 }); 624 } else { 625 self.$(diapo.content).css({width : 'auto', height: 'auto', paddingLeft: 0, paddingTop: 0 }); 626 } 627 }); 628}; 629 630// Crée les controls 631DiaporamaSimpleSlideshow.prototype.controls = function() 632{ 633 this.config.btnPrev = this.$('<div>').addClass('diaporamaControlPrev').hide().appendTo(this.container); 634 this.config.btnNext = this.$('<div>').addClass('diaporamaControlNext').hide().appendTo(this.container); 635 636 this.config.btnPrev.append(this.$('<span>').text('Précédent')).on('click', this.callback('displayPrev'));
637 this.config.btnNext.append(this.$('<span>').text('Suivant')).on('click', this.callback('displayNext')); 638 639 if (this.config.param.controls) { 640 this.config.btnPrev.show(); 641 this.config.btnNext.show(); 642 } 643}; 644 645// Positionne les controles 646DiaporamaSimpleSlideshow.prototype.resizeControls = function() 647{ 648 this.config.btnPrev.css({ position:'absolute', left : 0, top: Math.floor(this.currentHeight / 2)}); 649 this.config.btnNext.css({ position:'absolute', right: 0, top: Math.floor(this.currentHeight / 2)}); 650}; 651 652// Affiche les puces du diaporama 653DiaporamaSimpleSlideshow.prototype.dots = function() 654{ 655 var self = this; 656 657 this.dotsContainer.css({ 658 position: 'absolute', 659 left: 0, 660 bottom : 0, 661 zIndex : 10, 662 width: '100%', 663 textAlign : 'center' 664 }).append(this.$('<div>')); 665 666 this.$.each(this.config.diapos, function(index, diapo) 667 { 668 self.dotsContainer.find('div').append(self.$('<span>') 669 .addClass('diaporamaDot') 670 .text('diapositive : ' + diapo.order) 671 .on('click', self.callback('displaySlide', [index]))); 672 }); 673 674 if (this.config.param.dots) { 675 this.dotsContainer.appendTo(this.container); 676 } 677}; 678 679// Affiche les textes (titre et description) du slide 680DiaporamaSimpleSlideshow.prototype.extras = function() 681{ 682 if (!this.config.param.extraDisplay) { 683 return; 684 } 685 686 var self = this, 687 pos = this.config.param.extraPosition; 688 689 this.$.each(this.config.diapos, function(index, diapo) 690 { 691 if (diapo.title == '' && diapo.description == '') { 692 return; 693 } 694 695 diapo.slide.append(self.$('<div>') 696 .addClass('diaporamaExtra') 697 .addClass('diaporamaExtra' + pos.charAt(0).toUpperCase() + pos.slice(1)) 698 .css({ 699 position: 'absolute', 700 width : '100%' 701 }) 702 .append(self.$('<div>') 703 .append( 704 self.$('<strong>').text(diapo.title), 705 self.$('<span>').text(diapo.description) 706 ))); 707 }); 708}; 709 710// Affiche les textes (titre et description) du slide 711DiaporamaSimpleSlideshow.prototype.resizeExtras = function() 712{ 713 if (!this.config.param.extraDisplay) { 714 return; 715 } 716 717 switch (this.config.param.extraPosition) { 718 case 'topLeft' : var css = { top: 0, left: 0 }; break; 719 case 'topCenter' : var css = { top: 0, left: 0 }; break; 720 case 'topRight' : var css = { top: 0, left: 0 }; break; 721 case 'middleLeft' : var css = { top: this.currentHeight / 2, left: 0 }; break; 722 case 'middleCenter' : var css = { top: this.currentHeight / 2, left: 0 }; break; 723 case 'middleRight' : var css = { top: this.currentHeight / 2, left: 0 }; break; 724 default : 725 case 'bottomLeft' : var css = { bottom: 0, left: 0 }; break; 726 case 'bottomCenter' : var css = { bottom: 0, left: 0 }; break; 727 case 'bottomRight' : var css = { bottom: 0, left: 0 }; break; 728 } 729 730 var self = this, 731 pos = this.config.param.extraPosition; 732 733 this.$.each(this.config.diapos, function(index, diapo) 734 { 735 if (diapo.title == '' && diapo.description == '') { 736 return; 737 } 738 739 diapo.slide.find('.diaporamaExtra').css(css); 740 }); 741}; 742 743// Affiche les textes (titre et description) du slide 744DiaporamaSimpleSlideshow.prototype.links = function() 745{ 746 var self = this, 747 isLocalLink = function(link) 748 { 749 return ((new RegExp(location.host)).test(link) || link.slice(0, 1) == '#'); 750 }; 751 752 this.$.each(this.config.diapos, function(index, diapo) 753 { 754 if (diapo.type != 'image') { 755 return; 756 } 757 758 diapo.slide.on('click', function() 759 { 760 if (self.config.param.clicAction == 'openLink') { 761 if (diapo.href == '') { 762 return; 763 } 764 if (isLocalLink(diapo.href)) { 765 window.open(diapo.href, '_self'); 766 } else { 767 window.open(diapo.href, '_blank'); 768 } 769 } else if (self.config.param.clicAction == 'openImage') { 770 if (diapo.href == '') { 771 self.$.fancybox.open({type: 'image', href: diapo.src}); 772 } else { 773 var link = self.$('<a>') 774 .attr('href', diapo.href) 775 .append(self.$('<img>') 776 .attr('src', diapo.src)); 777 778 if (!isLocalLink(diapo.href)) { 779 link.attr('target', '_blank'); 780 } 781 782 self.$.fancybox(self.$('<div>').append(link)); 783 } 784 } 785 }); 786 }); 787}; 788 789// Création du diaporama 790function createDiaporama(config) 791{ 792 var $ = jQuery, 793 container = $('#' + config.id, 'div'); 794 795 if (container.length > 1) { 796 var found = false;
797 container.each(function() { 798 if (!found && !$(this).data('diaporamaInstanceLoaded')) { 799 found = $(this); 800 } 801 }); 802 container = found; 803 } 804 805 container.data('diaporamaInstanceLoaded', true); 806 807 if (typeof window[config.effect + 'Custom'] == 'function') { 808 if (window[config.effect + 'Custom'].apply(container, [config, $])) { 809 return; 810 } 811 } 812 813 if (typeof window[config.effect + 'Loader'] == 'function') { 814 window[config.effect + 'Loader'].apply(container, [config, $]); 815 } 816} 817 818// Permet d'étendre un diaporama ou toute autre contructeur... 819function diaporamaExtend(child, parent) 820{ 821 var Surrogate = function() {}; 822 Surrogate.prototype = parent.prototype; 823 child.prototype = new Surrogate(); 824} 825 826// Charge un diaporama de type slider 827function diaporamaSimpleSlideshowLoader(config, $) 828{ 829 new DiaporamaSimpleSlideshow(this, config, $); 830} 831 832/** 833function diaporamaSimpleSlideshowCustom(config, $) 834{ 835 // Le code éxécuté dans cette fonction se substitue au diaporama standard si la fonction retourne TRUE : 836 // - this est le contener du diaporama 837 // - config contient les slides et toutes les informations sur le diaporama 838 // - $ est l'objet jQuery courant 839 840 if (this.attr('id') == 'diaporama_1234') { 841 // Création d'un diaporama personnalisé appelé "MyDiapo" pour le "diaporama_1234" 842 // qui hérite du diaporama standard "DiaporamaSimpleSlideshow" 843 844 // Constructeur 845 function MyDiapo(container, config, $) 846 { 847 this.$ = $; // Nécessaire à l'objet DiaporamaSimpleSlideshow 848 this.start(container, config); 849 } 850 851 // Héritage 852 diaporamaExtend(MyDiapo, DiaporamaSimpleSlideshow); 853 854 // Personnalisation 855 MyDiapo.prototype.displayNext = function() 856 { 857 this.config.param.autoplay = false; 858 this.autoplayStop(); 859 this.slideNext(); 860 }; 861 862 // Lancement du diaporama 863 new MyDiapo(this, config, $); 864 return true; 865 } else { 866 return false; 867 } 868} 869**/
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.