1/* PRINCIPES DU FONTIONS SITE 2 - toutes les instructions habituelles doiventa ller dans site_init(); 3 - les instructions liées à smoothstate doivent s'initialiser dans site_onPageLoad() 4 - pour le chgt de page en AJAX, caler des update / restart dans le site_onAjaxLoad 5 */ 6 7/*// DEMARRAGE ///////////////////////////////*/ 8$.jgo.prm = { 9 defaultActiveClass: 'active', 10 replaceSVGtoPNG: true, 11 aspireSVG: true, 12 handleIframeWmode: true, 13 watchScroll: true, 14 scrollPoint: $('header').height() 15}; 16 17$(document).ready(function () { 18 $.jgo.init(); // init le .scrolled 19 site_init(); 20 // MiniScript Additionels // 21 $('.txt_masque').each(function () { 22 let height = $(this).height(); // on récupère la hauteur de l'élément 23 $(this).css('margin-bottom', '-' + height + 'px'); // on injecte à l'élément une margin negative = à sa hauter (let height) 24 }); 25 26 $('.encart_select').hover(function () { 27 let dataSelect = $(this).attr('data-slide'); 28 $(this).addClass('active').siblings().removeClass('active'); 29 console.log(dataSelect); 30 $('.encart-slide .screen').removeClass('active'); 31 $('.encart-slide .screen[data-slide="' + dataSelect + '"').addClass('active'); 32 }); 33 34 // ALEX tableau villes // 35 $('.city-bloc .city').hover(function(){ 36 let mydata = $(this).attr('data-cursor'); 37 $('.mapmap .cursor').removeClass('active'); 38 $('.mapmap .cursor[data-cursor='+ mydata +']').addClass('active'); 39 }); 40 41 $('.mapmap .cursor').hover(function(){ 42 let mydata = $(this).attr('data-cursor'); 43 $('.city-bloc .city').removeClass('active'); 44 $('.city-bloc .city[data-cursor='+ mydata +']').addClass('active'); 45 }); 46 // ALEX FIN tableau villes // 47 48 // JAY Hover Plat Image // 49 $('.carteJs').hover(function(){ 50 let mydata = $(this).attr('data-slide'); 51 console.log(mydata); 52 $('.slide-back .slider').removeClass('active'); 53 $('.slide-back .slider[data-slide="'+ mydata +'"]').addClass('active'); 54 }) 55 // JAY FIN Hover Plat Image // 56 57 // Vérifier si .bloc-tri-gauche existe 58 if ($.jgo.elementExiste('.bloc-tri-gauche')) { 59 // Pour chaque case à cocher dans .filtre 60 $('.filtre input[type="checkbox"]').each(function() { 61 // Si la case est cochée, ajouter la classe 'active' à l'élément parent ayant la classe 'tri-elem-filtre' 62 if ($(this).is(':checked')) { 63 $(this).closest('.tri-elem-filtre').addClass('active'); 64 } 65 }); 66 67 // Compter le nombre de cases à cocher disponibles dans chaque .tri-elem-filtre et l'afficher dans le label .titleFilter 68 $('.tri-elem-filtre').each(function() { 69 var nombreCasesCochées = $(this).find('input[type="checkbox"]').length; 70 $(this).find('.titleFilter').append(" (" + nombreCasesCochées + ")"); 71 }); 72 73 // Au clic sur .filtre_accordeon, basculer la classe 'ouvre' 74 $(document).on("click", ".filtre_accordeon", function() { 75 $(this).toggleClass("ouvre"); 76 }); 77 78 // Au clic sur .titleFilter, basculer la classe 'active' 79 $(document).on("click", ".titleFilter", function(e) { 80 $(this).toggleClass("active"); 81 }); 82 83 // Filtre gauche 84 $(document).on("click", "#filtrerOuvre", function() { 85 $(this).toggleClass("ouvre-filtre"); 86 $(".ouvreFiltre").toggleClass("ouvre-filtre"); 87 $('body').addClass('ouvre-filtre'); 88 //$('.diaporama--annonce').slick('refresh'); 89 }); 90 91 $(document).on("click", "#filterClose", function() { 92 $(this).toggleClass("ouvre-filtre"); 93 $(".ouvreFiltre").toggleClass("ouvre-filtre"); 94 $('body').removeClass('ouvre-filtre'); 95 // $('.diaporama--annonce').slick('refresh'); 96 }); 97 } 98 // Fin Filtre gauche 99 100 // JAY Defilement texte // 101 if ($.jgo.elementExiste('.defilement_texte')) { 102 $('body').addClass('hauteur-defilement-texte'); 103 } 104 // JAY FIN Defilement texte // 105 106 // JAY Lire moins/plus // 107 $("#lireplus").click(function(){ 108 $(".accordeonContenu").toggleClass("active"); 109 $(".accordeon").toggleClass("active"); 110 }); 111 // JAY FIN Lire moins/plus // 112 113 // JAY Premier mot // 114 $(".firstWord").html(function(){ 115 var text= $(this).text().trim().split(" "); 116 var first = text.shift(); 117 return (text.length > 0 ? "<span class='font-300'>"+ first + "</span> " : first) + text.join(" "); 118 }); 119 // JAY FIN Premier mot // 120 121 // JAY Dernier mot // 122 $(".lastWord").html(function(){ 123 var text= $(this).text().trim().split(" "); 124 var last = text[text.length - 1]; 125 text.pop(); 126 return text.join(" ") + (text.length > 0 ? " <span class='font-300'>"+ last + "</span> " : last) ; 127 }); 128 // JAY FIN Dernier mot // 129 130}); 131 132// JAY Encart bg fond // 133$('.bloc-btn-encart a').mouseover( function(){ 134 var idattribute = $(this).attr('id'); 135 var newid = '.img-encart #' + idattribute ; 136 var newida = '.bloc-btn-encart #' + idattribute ; 137 138 $('.bloc-btn-encart a').removeClass('active'); 139 $(newida).addClass('active'); 140 141 $('.bloc-img-encart').removeClass('active'); 142 $(newid).addClass('active'); 143 144 console.log(idattribute); 145}) 146// JAY FIN Encart bg fond // 147 148$(window).on("load", site_onPageLoad); 149 150 151/*// INITIALISATION /////////////////////////////// 152 -> tous les codes qui s'executent au demarrage 153 */ 154 155/* JAY Reassurance Compteur */ 156/* exemple sur : https://www.brignolescasse.fr/ */ 157if ($.jgo.elementExiste('.section-rea')) { 158 const rotation_1 = document.querySelectorAll('.section-rea');
159 rotation_1.forEach((section) => { 160 gsap.to(section, { 161 scrollTrigger: { 162 trigger: section, 163 start: 'top bottom-=300', // [trigger] [scroller] positions 164 scrub: 0, 165 toggleActions: 'play none none reverse', 166 onEnter:finalcountdown 167 // markers: true 168 } 169 }); 170 }); 171} 172function finalcountdown() { 173 console.log("ok finalcountdown"); 174 $(".counter").each(function () { 175 var $this = $(this), 176 countTo = $this.attr("data-count"); 177 178 $({ countNum: $this.text() }).animate( 179 { 180 countNum: countTo, 181 }, 182 { 183 duration: 1500, 184 easing: "linear", 185 step: function () { 186 $this.text(Math.floor(this.countNum)); 187 }, 188 complete: function () { 189 $this.text(this.countNum); 190 //alert('finished'); 191 }, 192 } 193 ); 194 }); 195} 196/* JAY FIN Reassurance Compteur */ 197 198function site_init() { 199 200 $('body').addClass('ready'); 201 // cas ios7 202 if (is_iOs()) { 203 $('html').addClass('badios'); 204 } 205 206 /* Header_multisites*/ 207 if ($(window).width() <= 1025) { 208 $( ".domaines > li > a" ).click(function(e) { 209 e.preventDefault(); 210 }); 211 } 212 const arrowRotate = document.querySelectorAll('.arrowRotate') 213 arrowRotate.forEach(toto => { 214 toto.addEventListener('click', () => { 215 toto.classList.toggle('aRotate') 216 }) 217 }); 218 219 $('img:not([src])').addClass('lazyload'); 220 221 /*///// CODE JQUERY HORS JGO*/ ///// 222 223 /* AJOUTE UNE CLASSE is-scrolled au header quand le menu est scrollé (mobile) */ 224 $('nav.nav > ul').on('scroll', function (e) { 225 if ($('nav.nav > ul').scrollTop() > 0) { 226 $('header').addClass('is-scrolled'); 227 } else { 228 $('header').removeClass('is-scrolled'); 229 } 230 }); 231 232 /* AJOUTE OU ENLEVE une classe au body selon si le menu doit apparaitre ou non */ 233 $("#btMenu").click(function (e) { 234 $('body').toggleClass("menu-active"); 235 }); 236 237 // scrolle la fenetre toujours en bas de page quand on altère le checkbox du pdp (bug sous EDGE : le site remonte en haut dès qu'on clique) 238 $('input[name="ouvre-footer"]').off('change'); 239 $('input[name="ouvre-footer"]').on('change', function (e) { 240 $('html, body').scrollTop($(document).height()); 241 }); 242 243 244 $('iframe').each((i, el) => { 245 $(el).attr({ 246 loading: "lazy" 247 }).addClass('lazyload'); 248 }) 249 250 //retrait de l'intro une fois le scroll fait 251 if ($('body').hasClass('accueil')) { 252 if ($('body').hasClass('header-transparent')) { 253 var hauteurHeader = 0; 254 }else{ 255 var hauteurHeader = ($('header').height() + 1); 256 } 257 $('.windows-intro').attr('data-go-shift', hauteurHeader+'px'); 258 //console.log(hauteurHeader); 259 260 $(window).scroll(function () { 261 if ($(window).scrollTop() >= $(window).height() && $.jgo.elementExiste('.intro')) { 262 $('.intro').remove(); 263 ScrollTrigger.refresh(); 264 $('body, html').scrollTop(0); 265 $.jgo.prm.scrollPoint = $('nav.nav').offset().top; 266 } 267 }); 268 } 269 270 271 //gestion de l'intro 272 if ($.jgo.elementExiste('.diaporama--intro')) { 273 $(".diaporama--intro").slick({ 274 lazyLoad: 'anticipated', // ondemand progressive anticipated 275 infinite: true, 276 arrows: false, 277 fade: true, 278 speed: 400, 279 autoplay: false 280 }); 281 282 // le survol des liens de l'intro affiche l'image correspondante 283 $('.intro_url').each((i, el) => { 284 // detect la class active du site sur lequel on est et affiche l'image correspondante dés le chargement 285 if ($(el).hasClass('active')) { 286 $('.diaporama--intro').slick('slickGoTo', [i]); 287 /* console.log([i]); */ 288 } 289 // afficher au survol des liens de l'intro l'image correspondante 290 $(el).on('mouseenter', () => { 291 $('.diaporama--intro').slick('slickGoTo', [i]); 292 }); 293 }); 294 295 //gestion suppression de l'intro au scroll 296 if ($('body').hasClass('accueil')) { 297 $(window).scroll(function () { 298 if ($(window).scrollTop() >= $(window).height() && $.jgo.elementExiste('.intro')) { 299 $('.intro').remove(); 300 $('html, body').scrollTop(0); 301 ScrollTrigger.refresh() 302 $.jgo.prm.scrollPoint = $('#accueil').offset().top; 303 } 304 }); 305 } 306 } 307 //en option : ajoute une ancre sur l'url accueil quand on vient d'une autre page ( évite de retomber sur l'intro) 308 if (!$('nav.nav_multi > ul.sites.panel.active > li').eq(0).hasClass('active')) { 309 var href = "/"; 310 $('nav.nav_multi > ul.sites.panel.active > li:first-child > a ').attr('href', href + '#accueil'); 311 } 312 var ancre = $(location).attr('hash'); 313 if (ancre == "#accueil") { 314 $('.intro').remove(); 315 ScrollTrigger.refresh() 316 } 317 318 319 if ($.jgo.elementExiste('#delete_sort')) { 320 $([document.documentElement, document.body]).animate({ 321 scrollTop: $("#delete_sort").offset().top - 200 322 }, 500); 323 } 324 325 326 // rajoute un flex end quand il n'y a qu'un enfant dans la pagination 327 /*$('.bts--flex.pagination').each(function(){ 328 var bloc = $(this); 329 if(bloc.children('*').length == 1 && bloc.children('.pagination').length == 1){ 330 bloc.children('*').addClass('margin-auto-left'); 331 } 332 });*/ 333 334 335 336 337 /*///// CODE SLICK /////*/ 338 $('.diaporama--accueil').slick({ 339 dots: false, 340 lazyLoad: 'ondemand', // a décommenter pour gagner en perf 341 infinite: false,
342 arrows: false, 343 speed: 700, 344 fade: true, 345 cssEase: 'linear', 346 autoplay: true, 347 pauseOnHover: false, 348 autoplaySpeed: 3000, 349 350 responsive: [ 351 { 352 breakpoint: 800, 353 settings: { 354 arrows: false, 355 } 356 } 357 ] 358 }); 359 360 $('.diaporama, .diaporama--laius, .diaporama--fond').slick({ 361 dots: false, 362 lazyLoad: 'ondemand', // a décommenter pour gagner en perf 363 infinite: false, 364 arrows: false, 365 speed: 700, 366 fade: true, 367 cssEase: 'linear', 368 autoplay: true, 369 pauseOnHover: false, 370 autoplaySpeed: 3000 371 }); 372 373 $(".diaporama--annonce").slick({ 374 dots: false, 375 lazyLoad: "ondemand", 376 infinite: false, 377 arrows: true, 378 speed: 700, 379 fade: true, 380 autoplay: false, 381 }); 382 383 // JAY diaporama--flash-infos // 384 $(".diaporama--flash-infos").slick({ 385 dots: false, 386 lazyLoad: "ondemand", // a décommenter pour gagner en perf 387 infinite: false, 388 arrows: true, 389 speed: 700, 390 fade: true, 391 cssEase: "linear", 392 autoplay: true, 393 autoplaySpeed: 5000, 394 pauseOnHover: false, 395 }); 396 // JAY FIN diaporama--flash-infos // 397 398 399 if ($.jgo.elementExiste('.diaporama--fiche')) { 400 401 $(".diaporama--fiche").slick({ 402 pauseOnHover: false, 403 lazyLoad: 'ondemand', 404 dots: false, 405 infinite: true, 406 arrows: true, 407 speed: 700, 408 fade: true, 409 cssEase: 'linear', 410 autoplay: true, // a commenter pour avoir une transition horizontal 411 autoplaySpeed: 5000, 412 413 responsive: [ //ici on customise le responsive du diaporama--fiche en vesion mobile tactile ;) 414 { 415 breakpoint: 640, 416 settings: { 417 centerMode: true, 418 centerPadding: '60px', 419 arrows: false, 420 fade: false, 421 autoplay: false, 422 slidesToShow: 1, 423 speed: 300, 424 adaptiveHeight: true 425 } 426 } 427 ] 428 429 430 }); 431 432 } 433 434 if ($.jgo.elementExiste('.slideshow')) { 435 $(".slideshow").slick({ 436 lazyLoad: 'anticipated', // ondemand progressive anticipated 437 infinite: false, 438 arrows: true, 439 autoplay: true, 440 dots: true, 441 autoplaySpeed: 6000, 442 pauseOnHover: false, 443 444 responsive: [{ 445 breakpoint: 600, 446 settings: { 447 adaptiveHeight: true 448 } 449 }] 450 }); 451 } 452 453 if ($.jgo.elementExiste('.slideshow-diapo')) { 454 $(".slideshow-diapo").slick({ 455 lazyLoad: 'anticipated', // ondemand progressive anticipated 456 infinite: false, 457 arrows: false, 458 autoplay: true, 459 dots: false, 460 autoplaySpeed: 6000, 461 pauseOnHover: false, 462 }); 463 } 464 465 if ($.jgo.elementExiste('.slideshow-duo')) { 466 $(".slideshow-duo").slick({ 467 lazyLoad: 'anticipated', // ondemand progressive anticipated 468 infinite: false, 469 arrows: false, 470 autoplay: true, 471 dots: true, 472 autoplaySpeed: 5000, 473 pauseOnHover: false, 474 475 responsive: [{ 476 breakpoint: 600, 477 settings: { 478 adaptiveHeight: true 479 } 480 }] 481 }); 482 } 483 484 if ($.jgo.elementExiste('.slide-annonce')) { 485 486 $(".slide-annonce").slick({ 487 lazyLoad: 'anticipated', // ondemand progressive anticipated 488 infinite: true, 489 arrows: true, 490 dots: false, 491 autoplay:true, 492 autoplaySpeed: 4000, 493 pauseOnHover: false, 494 // centerMode: true, 495 // centerPadding: '60px', 496 slidesToShow: 4, 497 498 responsive: [ 499 { 500 breakpoint: 1250, 501 settings: { 502 adaptiveHeight: true, 503 centerMode: true, 504 slidesToShow: 3, 505 centerPadding: '0' 506 } 507 }, 508 { 509 breakpoint: 900, 510 settings: { 511 adaptiveHeight: true, 512 centerMode: true, 513 slidesToShow: 2, 514 centerPadding: '0' 515 } 516 }, 517 { 518 breakpoint: 650, 519 settings: { 520 adaptiveHeight: true, 521 centerMode: true, 522 slidesToShow: 1, 523 centerPadding: '0' 524 } 525 } 526 ] 527 }); 528 } 529 530// JAY Slideshow center // 531if ($.jgo.elementExiste('.slideshow-center')) { 532 $(".slideshow-center").slick({ 533 lazyLoad: 'anticipated', // ondemand progressive anticipated 534 arrows: true, 535 autoplay:true, 536 dots: false, 537 autoplaySpeed: 6000, 538 pauseOnHover:false, 539 centerMode: true, 540 centerPadding: '13%', 541 542 responsive: [ 543 { 544 breakpoint: 600, 545 settings: { 546 adaptiveHeight: true, 547 centerPadding: '0px' 548 } 549 } 550 ] 551 }); 552} 553 // JAY FIN Slideshow center // 554 555 if ($.jgo.elementExiste('.slide-avis')) { 556 $(".slide-avis").slick({ 557 lazyLoad: 'anticipated',
558 arrows: false, 559 autoplay:true, 560 dots: true, 561 autoplaySpeed: 6000, 562 pauseOnHover:false, 563 slidesToShow: 3, 564 slidesToScroll: 3, 565 centerPadding: '13%', 566 567 responsive: [ 568 { 569 breakpoint: 1023, 570 settings: { 571 slidesToShow: 1, 572 slidesToScroll: 1, 573 adaptiveHeight: true, // Commenter cette ligne si : truncate // 574 centerPadding: '0px' 575 } 576 } 577 ] 578 }); 579 } 580 581 if ($.jgo.elementExiste('.slide-avis-50-50')) { 582 $(".slide-avis-50-50").slick({ 583 lazyLoad: 'anticipated', 584 arrows: false, 585 autoplay:true, 586 dots: false, 587 autoplaySpeed: 6000, 588 pauseOnHover:false, 589 slidesToShow: 1, 590 slidesToScroll: 1, 591 centerPadding: '13%', 592 }); 593 } 594 595 // JAY Slide logo // 596 if ($.jgo.elementExiste('.slide-logo')) { 597 598 $(".slide-logo").slick({ 599 lazyLoad: 'anticipated', // ondemand progressive anticipated 600 infinite: true, 601 arrows: false, 602 dots: false, 603 autoplay:true, 604 autoplaySpeed: 2000, 605 // centerMode: true, 606 // centerPadding: '60px', 607 slidesToShow: 7, 608 609 responsive: [ 610 { 611 breakpoint: 800, 612 settings: { 613 adaptiveHeight: true, 614 centerMode: true, 615 slidesToShow: 2, 616 centerPadding: '0' 617 } 618 } 619 ] 620 }); 621 } 622 // JAY FIN Slide logo // 623 624 /*///// CODE PLUGINS ///// 625 -> plugins = nouveaux blocs de jgo rendus independants 626 tu peux les appeller au besoin dans n'importe quelle situtation 627 */ 628 629 /*fourrage en background-image d'un img 630 ------------ 631 *: n'execute pas le code si on met la classe no-js a un img--back*/ 632 633 if (!Modernizr.objectfit) { 634 $.site.imgback = $('*[class*="img--back"], .slick-slide > div ').jalisImgBack(); 635 } else { 636 //il faut imperativement traiter le img--back avant le .slide 637 $.site.imgback = $('*[class*="img--back"]:not(.no-js)').jalisImgBack(); 638 639 } 640 641 642 // VSY -> ajoute ( et peut enlever ) une classe quand un element arrive à l'écran 643 ScrollTrigger.batch(".vsy", { 644 toggleClass: "view-on", 645 once: true 646 }); 647 648 ScrollTrigger.batch(".incrementation", { 649 onEnter: () => finalcountdown(), 650 }); 651 652 // clic & scroll (ancien goclic) 653 $.site.scrollto = $('.go').jalisScrollTo(); 654 655 656 // zoom quand survol 657 $.site.zoom = $('.zoom').jalisZoom({ 658 zoomCssClass: 'fiche-img-cover' 659 }); 660 661 662 //sticky 663 // $.site.sticky = $('.sticky').jalisSticky({ 664 // topModulator: function () { 665 // return $('body.scrolled header').outerHeight(true) + 36; 666 // } 667 // }); 668 669 670 // liens miniatures / img 671 $('.grille-images .miniatures *[class*="img"]').mouseover(function (e) { 672 $('.fiche-img img, .fiche-img > .zoom > img').attr('src', $(e.target).attr('href')); 673 $('.fiche-img .zoom').attr('href', $(e.target).attr('href')); 674 $('.zoom > img').attr('style', 'opacity:1'); 675 676 try { 677 $.site.zoom.update() 678 } catch (e) {} 679 }); 680 681 // => survol des miniatures 682/* $('body *[class*="img--back"]').each((i, el) => { 683 $(el).on('mouseenter', () => { 684 $('.diaporama--fiche').slick('slickGoTo', [i]); 685 }); 686 }) */ 687 688 689// pour l'extension web2store : 690 deleteNoScriptTag(); 691 $(".click").click(function () { 692 $('.cnt').toggleClass('ouvre'); 693 $('.shut').toggleClass('show'); 694 }); 695 696 $(".plan--premier").click(function () { 697 $('.cnt').removeClass('ouvre'); 698 $('.shut').removeClass('show'); 699 }); 700} 701 702 703/*// LOAD /////////////////////////////// 704 -> tous les codes qui s'executent lors du load du DOM 705 */ 706 707function site_onPageLoad() { 708 $('body').addClass('loaded'); 709 710 711 //pour changer la class par défault : 712 /* lazySizes.cfg.lazyClass = 'img:not([src])'; */ 713} 714 715 716 717/*// AJAX /////////////////////////////// 718 -> ici les instructions à placer quand un site est rafraichi par l'ajax 719 */ 720function site_onAjaxLoad() { 721 tryRefresh($.site.imgback.update, 'img back update'); 722} 723 724/*===== FONCTIONS EXTERNES CAPTAIN 6.0 =====*/ 725 726//execute dans un try les methodes update puis restart (utile pour l'ajax) 727function tryRefresh(fn, msg) { 728 try { 729 fn(); 730 } catch (e) { 731 console.log('REFRESH ERR. : ' + msg + ' - ' + e); 732 } 733} 734 735// determine si ios7 736function is_iOs() { 737 return navigator.userAgent.match('Version/7.0'); 738} 739 740/*===== PLUGINS JALIS CAPTAIN 6.0 =====*/ 741(function ($) { 742 /** JALIS SCROLLTO 1.0 CAPTAIN 743 * Scroll vers un point determine quand on clic sur un autre 744 * ex : <div class="go" data-go="#contact">contact</div> 745 * rajouter data-go-origin="top|middle|bottom" pour lui dire ou placer le piont visé dans la page (middle par defaut) 746 * rajouter $(jQueryObject).jalisScrollTo(); dans le ready pour activer 747 * @param {String} scrollzone element ou s'applique le scroll ['html, body'] 748 * @param {String} anim_duration durée de l'animation 749 */ 750 $.fn.jalisScrollTo = function (options) { 751 752 function setListener() { 753 elems.each(function () { 754 var obj = $(this); 755 unset_listener(obj); 756 757 obj.on("click", function (e) { 758 var desc = $(obj.attr('data-go')); 759 var origin = obj.attr('data-go-origin');
760 var shift = obj.attr('data-go-shift'); 761 desc = $(obj.attr('data-go')); 762 e.preventDefault(); 763 var h; 764 if (obj.attr('data-go') == "top") { 765 h = 0; 766 } else { 767 768 var pos = desc.offset().top - $(prm.scrollzone).offset().top; 769 770 if (prm.scrollzone != 'html, body') { 771 pos += $(prm.scrollzone).scrollTop(); 772 } 773 774 if (desc.outerHeight() > ($(window).height() * 0.8)) { 775 h = pos - ($(window).height() / 2); 776 } else { 777 h = pos - (($(window).height() - desc.innerHeight()) / 2); 778 } 779 if (origin != undefined) { 780 if (origin == "top") { 781 h = pos; 782 } else if (origin == "bottom") { 783 h = pos - (desc.offset().top - desc.innerHeight()); 784 } 785 } 786 787 if (shift != undefined) { 788 h -= parseFloat(shift); 789 } 790 } 791 $(prm.scrollzone).animate({ 792 scrollTop: h 793 }, { 794 queue: false, 795 duration: prm.anim_duration 796 }); 797 }); 798 }); 799 } 800 801 function unset_listener(item) { 802 item.off('click'); 803 } 804 805 var defaults = { 806 scrollzone: 'html, body', 807 anim_duration: 750 808 } 809 810 var elems = this; 811 var selector = this.selector; 812 var prm = $.extend(defaults, options); 813 this.prm = prm; 814 815 816 this.init = function () { 817 setListener(); 818 } 819 820 this.update = function () { 821 //check le nb d'elements 822 if (elems.length != $(selector).length) { 823 elems = $(selector); 824 setListener(); 825 } 826 } 827 828 this.kill = function () { 829 unset_listener(elems); 830 } 831 832 this.init(); 833 834 return this; 835 } 836 837 838 839 /* 840 JALISZOOM 1.0 CAPTAIN 841 */ 842 $.fn.jalisZoom = function (options) { 843 844 var elems = this.each(function () { 845 846 var defaults = { 847 imgSelector: 'img', 848 zoomCssClass: 'fiche-image-cover', 849 autoupdate: true 850 } 851 852 var prm = $.extend(defaults, options); 853 854 var container = $(this); 855 var img = $(this).find(prm.imgSelector); 856 var frontCover; 857 858 init(); 859 860 function init() { 861 frontCover = "<span class='" + prm.zoomCssClass + "' style='background-image:url(" + img.attr('src') + ");'></span>"; 862 container.append(frontCover); 863 setMouseEnter(); 864 } 865 866 867 function onMouseMove(e) { 868 var offset = container.offset(); 869 var sizes = { 870 width: container.width(), 871 height: container.height() 872 } 873 var mousePos = { 874 top: e.pageY - offset.top, 875 left: e.pageX - offset.left 876 } 877 878 var ratios = { 879 top: (mousePos.top / sizes.height) * 100, 880 left: (mousePos.left / sizes.width) * 100 881 } 882 883 container.find('.' + prm.zoomCssClass).css('background-position', ratios.left + '% ' + ratios.top + '%'); 884 } 885 886 function onMouseEnter(e) { 887 unsetMouseEnter(); 888 if (prm.autoupdate) { 889 update(); 890 } 891 setMouseLeave(); 892 setMouseMove(); 893 } 894 895 function onMouseLeave(e) { 896 unsetMouseLeave(); 897 unsetMouseMove(); 898 setMouseEnter(); 899 } 900 901 902 function setMouseEnter() { 903 container.on('mouseenter', onMouseEnter); 904 } 905 906 function unsetMouseEnter() { 907 container.off('mouseenter', onMouseEnter); 908 } 909 910 911 function setMouseLeave() { 912 container.on('mouseleave', onMouseLeave); 913 } 914 915 function unsetMouseLeave() { 916 container.off('mouseleave', onMouseLeave); 917 } 918 919 920 function setMouseMove() { 921 container.on('mousemove', onMouseMove); 922 } 923 924 function unsetMouseMove() { 925 container.off('mousemove', onMouseMove); 926 } 927 928 929 function update() { 930 var cover = container.find('.' + prm.zoomCssClass); 931 var img = container.find(prm.imgSelector); 932 if (!cover.css('background-image').match(img.attr('src'))) { 933 cover.css('background-image', "url(" + img.attr('src')); 934 } 935 } 936 937 this.update = update; 938 939 this.stop = function () { 940 unsetMouseEnter(); 941 unsetMouseLeave(); 942 unsetMouseMove(); 943 $('.' + prm.zoomCssClass).remove(); 944 } 945 946 this.reset = function () { 947 this.stop(); 948 init(); 949 } 950 951 return this; 952 953 }); 954 955 this.update = function () { 956 for (var i = 0; i < elems.length; i++) { 957 $(elems[i])[0].update(); 958 } 959 } 960 961 return this; 962 963 964 } 965 966 967 /*JALIS IMG BACK 1.0 CAPTAIN 968 pushes <img>'s src to background-image 969 */ 970 $.fn.jalisImgBack = function (options) { 971 972 var defaults = { 973 bgSize: 'cover', 974 bgPos: 'center center', 975 bgRpt: 'no-repeat' 976 } 977 978 var prm = $.extend(defaults, options); 979 var elems = this; 980 var selector = this.selector; 981 982 set(); 983 984 /* look for a direct child img tag inside the selector, 985 * put the src attribute as inline background-image, 986 * removes the img tag 987 */ 988 function set() { 989 //parcours les images 990 elems.each(function () { 991 var img = $(this).find('img'); 992 img = img[0]; 993 994 if (img === undefined) { 995 return; 996 } 997 //si le src de l'image est défini 998 var src = img.getAttribute('src'); 999 //si le data-src est rempli pour le chargement différé des images lazyload 1000 if (typeof src === 'undefined' || src == null) { 1001 var src = img.getAttribute('data-src'); 1002 } 1003 1004 //si le data-src-slide est rempli pour le chargement différé des sliders 1005 var dataSrcSlide = img.getAttribute('data-src-slide'); 1006 1007 if (typeof src !== 'undefined' && src != null) { 1008 src = src.replace(new RegExp(' ', "gi"), '%20'); 1009 $(this).css({ 1010 'background-image': 'url("' + src + '")', 1011 'background-size': prm.bgSize, 1012 //'background-size': 'cover cover', 1013 'background-position': prm.bgPos, 1014 'background-repeat': prm.bgRpt 1015 }); 1016 img.remove(); 1017 1018 } 1019 1020 if (typeof dataSrcSlide !== 'undefined' && dataSrcSlide != null) { 1021 dataSrcSlide = dataSrcSlide.replace(new RegExp(' ', "gi"), '%20'); 1022 $(this).css({ 1023 'background-image': 'url("' + dataSrcSlide + '")', 1024 'background-size': prm.bgSize, 1025 //'background-size': 'cover cover', 1026 'background-position': prm.bgPos, 1027 'background-repeat': prm.bgRpt 1028 }); 1029 img.remove(); 1030 } 1031 }); 1032 } 1033 /*function set() { 1034 elems.each(function () { 1035 var img = $(this).children('img'); 1036 var src = img.attr('src'); 1037 if (src != undefined) { 1038 src = src.replace(new RegExp(' ', "gi"), '%20'); 1039 img.remove(); 1040 $(this).css({ 1041 'background-image': 'url("' + src + '")', 1042 'background-size': prm.bgSize, 1043 'background-position': prm.bgPos, 1044 'background-repeat': prm.bgRpt 1045 }); 1046 } 1047 }); 1048 }*/ 1049 1050 /* reverses the process by retrieving the img url, 1051 * adding it to a new child img tag with the parsed src, 1052 * removes inline style 1053 */ 1054 function unset() { 1055 elems.each(function () { 1056 var obj = $(this); 1057 var src = obj.css('background-image').slice(4, -1); // removes url() 1058 1059 //parse url in case of quotes inside the url 1060 if (src.substring(0, 1) == '"' || src.substring(0, 1) == "'") { 1061 src = src.substring(1); 1062 } 1063 1064 if (src.slice(-1) == '"' || src.slice(-1) == "'") { 1065 src = src.slice(0, -1); 1066 } 1067 1068 if (src != undefined) { 1069 var img = "<img src='" + src + "' />"; 1070 obj.append(img); 1071 obj.css({ 1072 'background-image': 'none', 1073 'background-size': 'inherit', 1074 'background-position': 'inherit', 1075 'background-repeat': 'inherit' 1076 }); 1077 } 1078 }); 1079 } 1080 1081 // updates the list of container, in case you would like to use AJAX ;) 1082 this.update = function () { 1083 if (elems.length != $(selector).length) { 1084 elems = $(selector); 1085 } 1086 set(); 1087 return elems; 1088 } 1089 1090 this.reset = function () { 1091 unset(); 1092 return elems; 1093 } 1094 1095 this.restart = function () { 1096 unset(); 1097 this.update(); 1098 set(); 1099 } 1100 1101 return this; 1102 1103 } 1104 1105 /** 1106 * methode qui permet un declenchement après un timeout sur la fin d'un scroll 1107 * @param callback l'action a declenché 1108 * @param timeout le de pause de scroll qu'il faut pour que l'action se déclenche 1109 */ 1110 $.fn.scrollEnd = function (callback, timeout) { 1111 $(this).scroll(function () { 1112 var $this = $(this); 1113 if ($this.data('scrollTimeout')) { 1114 clearTimeout($this.data('scrollTimeout')); 1115 } 1116 $this.data('scrollTimeout', setTimeout(callback, timeout)); 1117 }); 1118 }; 1119 1120})(jQuery); 1121 1122 1123 1124 1125 1126/*===== DELETE <noscript> =====*/ 1127function deleteNoScriptTag() { 1128 var noscript = document.getElementsByTagName('noscript'); 1129 var om = noscript.length - 1; 1130 for (om; om >= 0; om--) { 1131 noscript[om].parentNode.removeChild(noscript[om]); 1132 } 1133}
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.