1// ========================================================================== 2// FUNCTIONS 3// ========================================================================== 4 5/* 6* Permet de transformer une string en camel case 7*/ 8function toCamelCase(string) { 9 return string.replace(/[-_]([a-z])/g, function (g) { return g[1].toUpperCase(); }); 10} 11 12 13/* 14* Permet de merger 2 tableaux de paramètres 15*/ 16function dataAttrToParams(initParams, newParams) { 17 delete newParams.ride; 18 delete newParams.toggle; 19 20 $.each(newParams, function(index, val) { 21 var newIndex = toCamelCase(index); 22 initParams[newIndex] = newParams[index]; 23 }); 24 25 return initParams; 26} 27 28 29function throttle(callback, delay) { 30 var last; 31 var timer; 32 return function () { 33 var context = this; 34 var now = +new Date(); 35 var args = arguments; 36 if (last && now < last + delay) { 37 clearTimeout(timer); 38 timer = setTimeout(function () { 39 last = now; 40 callback.apply(context, args); 41 }, delay); 42 } else { 43 last = now; 44 callback.apply(context, args); 45 } 46 }; 47} 48 49function debounce(callback, delay){ 50 var timer; 51 return function(){ 52 var args = arguments; 53 var context = this; 54 clearTimeout(timer); 55 timer = setTimeout(function(){ 56 callback.apply(context, args); 57 }, delay); 58 }; 59} 60 61function is_front_page() { 62 if ( $('body').hasClass('home')) { 63 return true; 64 } else { 65 return false; 66 } 67} 68 69/* 70* Permet d'égaliser la hauteur des éléments passés en paramètre 71*/ 72function equalize( $items, resizable ) { 73 74 if ( typeof resizable == 'undefined') { 75 resizable = true; 76 } 77 78 $items.css( 'height', 'auto' ); 79 var maxHeight = 0; 80 $items.each(function(index, el) { 81 if ($(el).outerHeight() > maxHeight) { 82 maxHeight = $(el).outerHeight(); 83 } 84 }); 85 // Si et seulement si la hauteur max est supérieur à 0 86 if ( maxHeight > 0 ) { 87 $items.css('height', maxHeight); 88 } 89 90 $( window ).on('load', function() { 91 setTimeout( function () { 92 equalize( $items, resizable ); 93 }, 150 ); 94 }); 95 96 if ( resizable ) { 97 98 window.addEventListener('resize', debounce(function(e){ 99 equalize( $items, false ); 100 }, 300)); 101 102 } 103} 104 105 106/* 107* Permet d'afficher un coverflow sur owlcarousel 108*/ 109function coverflowCarousel( $carousel, breakpoint ) { 110 if (typeof breakpoint == 'undefined') { 111 breakpoint = 1200; 112 } 113 if (typeof $carousel !== 'undefined') { 114 if ($(window).width() > (breakpoint - 1) ) { 115 if (!$carousel.hasClass('owl-carousel-coverflow')) { 116 $carousel.addClass('owl-carousel-coverflow'); 117 } 118 $carousel 119 .removeClass('owl-carousel-inline') 120 .find('.main-active').removeClass('main-active'); 121 122 setTimeout(function() { 123 var $activeItem = $carousel.find('.owl-item.active'), 124 activeLength = $activeItem.length; 125 126 if ( activeLength > 1 ) { 127 $activeItem.eq( Math.ceil(activeLength / 2 - 1)).addClass('main-active'); 128 } 129 }, 1); 130 131 } else { 132 $carousel.removeClass('owl-carousel-coverflow').addClass('owl-carousel-inline'); 133 } 134 } 135} 136 137 138 139// ========================================================================== 140// CUSTOMS SCRIPTS 141// ========================================================================== 142$(function() { 143 144 145 /* 146 * Instance du plugin Fancybox 147 */ 148 Fancybox.bind( '[data-fancybox]', { 149 l10n: Fancybox.l10n.fr 150 } ); 151 152 153 /* 154 * Instance du plugin OWL Carousel (v2) 155 */ 156 if ( $.fn.owlCarousel ) { 157 $('[data-ride="owl-carousel"]').each(function() { 158 159 var initParams = { 160 autoplaySpeed: 750, 161 dotsSpeed: 450, 162 autoplayTimeout: 5000, 163 autoplayHoverPause : true, 164 autoplay: false, 165 dots: false, 166 navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'], 167 nav: true, 168 items: 1, 169 loop: true 170 }, 171 newParams = $(this).data(); 172 173 newParams = dataAttrToParams(initParams, newParams); 174 $(this).owlCarousel(newParams); 175 }); 176 } 177 178 179 /* 180 * Instance (via data-attrs) du plugin FatMenu 181 */ 182 if($.fn.FatMenu) { 183 $('[data-toggle="fatmenu"]').each(function(index, el) { 184 var initParams = { 185 pushOnShow : false, 186 overlay : true, 187 mobileBreakpoint : 1200, 188 BackButtonContent : '<i class="fa fa-angle-left"></i> Retour', 189 }, 190 newParams = $(this).data(); 191 192 newParams = dataAttrToParams(initParams, newParams); 193 $(this).FatMenu(newParams); 194 }); 195 } 196 197 198 /* 199 * Instance de la fonction de hauteur d'élement automatique 200 */ 201 $('[data-equalize]').each(function(index, el) { 202 var $el = $(el), 203 children = $(el).data('equalize'), 204 $modals = $el.parents('.modal'); 205 206 if ( $el.find(children).length ) { 207 if ( $modals.length > 0 ) { 208 $modals.on('shown.bs.modal', function (event) { 209 equalize( $el.find(children) ); 210 }); 211 } else { 212 equalize( $el.find(children) ); 213 } 214 } 215 }); 216 217 218 /* 219 * Permet d'éviter de remonter en haut de la page lors de l'ouverture du offcanvas 220 */ 221 $('[data-toggle="offcanvas"]').on('click', function(event) { 222 event.preventDefault(); 223 }); 224 225 226 /* 227 * Permet d'instancier les popover 228 */ 229 $('[data-toggle="popover"]').popover(); 230 231 232 /* 233 * Ajoute une classe sur le bouton (déclencheur) quand un élément collaspe est affiché 234 */ 235 $('.panel-collapse') 236 .on('show.bs.collapse', function () { 237 var id = $(this).attr('id'); 238 $('[href="#' + id + '"]').addClass('active'); 239 }) 240 .on('hide.bs.collapse', function () { 241 var id = $(this).attr('id'); 242 $('[href="#' + id + '"]').removeClass('active'); 243 }); 244 245 246 247 248 /* 249 * Gestion de l'élement fixe social-toolbar 250 */ 251 function fixSocialShare() { 252 253 var $socialFixed = $('.social-toolbar-fixed'), 254 $article = $('.article'), 255 breakpoint = $socialFixed.data('breakpoint'); 256 257 if (typeof breakpoint == 'undefined') { 258 breakpoint = 1350; 259 } 260 261 $socialFixed.each(function(index, el) { 262 var $el = $(el); 263 264 if ( $el.parents('.modal').length ) { 265 266 $el 267 .removeClass('social-toolbar-fixed') 268 .removeData("bs.affix") 269 .removeClass("affix affix-top affix-bottom") 270 .removeAttr("style"); 271 272 } else { 273 274 // Si la fenêtre est plus large que le breakpoint défini en data-attr 275 if ( $(window).width() > breakpoint ) { 276 277 // Si il y a un article sur la page 278 if ($article.length) { 279 280 var affixTop = 130, 281 articleHeight = $article.outerHeight(), 282 articleTop = $article.offset().top - affixTop, 283 articleBottom = articleTop + affixTop - 15 + articleHeight, 284 documentLength = $(document).outerHeight(), 285 286 aTop = articleTop, 287 aBottom = documentLength - articleBottom; 288 289 // Si l'article fait plus de 360 pixels de hauteur 290 if (articleHeight > 360) { 291 292 $el 293 .addClass('social-toolbar-fixed') 294 .affix({ 295 offset: { 296 top: aTop, 297 bottom: aBottom, 298 } 299 }).on('affix.bs.affix', function () { // before affix 300 $(this).css({ 301 /*'top': headerHeight,*/ // for fixed height 302 'width': $(this).outerWidth() // variable widths 303 }); 304 }); 305 306 } else { 307 308 $el 309 .removeClass('social-toolbar-fixed'); 310 311 } 312 313 } 314 315 } else { 316 317 // $(window).off('.affix'); 318 $el 319 .removeClass('social-toolbar-fixed') 320 .removeData("bs.affix") 321 .removeClass("affix affix-top affix-bottom") 322 .removeAttr("style"); 323 324 } 325 } 326 327 }); 328 329 } 330 331 332 /* 333 * Gestion de l'élement fixe back to top 334 */ 335 function fixBackToTop() { 336 337 var $backToTop = $('#back-to-top'); 338 339 // Si il y a l'élement back to top 340 if ( $backToTop.length ) { 341 if ( ($(window).height() + 100) < $(document).height() ) { 342 $backToTop.removeClass('hidden').affix({ 343 offset: { 344 top: 100,
345 } 346 }); 347 } 348 } 349 350 } 351 352 353 /* 354 * Gestion de l'élement fixe navigation 355 */ 356 function fixNavigation() { 357 358 var $nav = $('#layout-navigation'); 359 360 // Si le data-attr affix est égal à true 361 if ( $nav.data('affix') ) { 362 363 $nav 364 .removeData('bs.affix') 365 .removeClass('affix affix-top affix-bottom') 366 .removeAttr('style'); 367 368 var top = $nav.offset().top; 369 $nav.affix({ offset: { top: top } }); 370 371 } 372 373 } 374 375 376 var affixResizeBound = false; 377 378 /* 379 * Lancement de différentes fonctions (attends le chargement de toutes les images) 380 */ 381 function initAffixFeatures() { 382 383 fixNavigation(); 384 385 fixBackToTop(); 386 387 fixSocialShare(); 388 389 $('.gallery').each(function(index, el) { 390 equalize( $(el).find('.gallery-item') ); 391 }); 392 393 } 394 395 function onPageFullyLoaded() { 396 397 initAffixFeatures(); 398 399 if ( ! affixResizeBound ) { 400 affixResizeBound = true; 401 $(window).on('resize', throttle(function(e){ 402 fixSocialShare(); 403 }, 100)).resize(); 404 } 405 406 } 407 408 if ( document.readyState === 'complete' ) { 409 onPageFullyLoaded(); 410 } else { 411 $(window).on('load', onPageFullyLoaded); 412 } 413 414 $(window).on('pageshow', function(event) { 415 if ( event.originalEvent && event.originalEvent.persisted ) { 416 initAffixFeatures(); 417 } 418 }); 419 420 421 422 423 // Permet d'activer les fonctions de partage sur la classe .sharer 424 $('.sharer').click(function(e){ 425 e.preventDefault(); 426 v_this = $(this); 427 428 var leftPosition, topPosition; 429 leftPosition = (window.screen.width / 2) - ((width / 2) + 10); 430 topPosition = (window.screen.height / 2) - ((height / 2) + 50); 431 var width = 520; 432 var height = 350; 433 var windowFeatures = 'status=no,height=' + height + ',width=' + width + ',resizable=yes,left=' + leftPosition + ',top=' + topPosition + ',screenX=' + leftPosition + ',screenY=' + topPosition + ',toolbar=no,menubar=no,scrollbars=no,location=no,directories=no'; 434 var t = document.title; 435 436 if( v_this.data('share-network') == 'facebook'){ 437 window.open( 'http://www.facebook.com/sharer.php?u=' + v_this.data('share-link') + '&t=' + v_this.data('share-title'), 'sharer', windowFeatures ); 438 } 439 if( v_this.data('share-network') == 'google'){ 440 window.open( 'https://plus.google.com/share?url==' + v_this.data('share-link'), 'sharer', windowFeatures); 441 } 442 if( v_this.data('share-network') == 'twitter'){ 443 window.open( 'https://twitter.com/intent/tweet?url=' + v_this.data('share-link') + '&text=' + v_this.data('share-title'), 'sharer', windowFeatures ); 444 } 445 if( v_this.data('share-network') == 'mail'){ 446 window.open( v_this.attr( 'href' ), 'sharer', windowFeatures ); 447 } 448 if( v_this.data('share-network') == 'linkedin'){ 449 window.open( 'https://www.linkedin.com/shareArticle?mini=true&url=' + v_this.data('share-link') + '&title=' + v_this.data('share-title'), 'sharer', windowFeatures ); 450 } 451 452 return false; 453 }); 454 455 456 // Fait une copie cachée des modals à l'ouverture pour permettre une impression optimale 457 var $modal = $('.modal'), 458 $layoutMain = $('.layout-main'); 459 $modal.on('show.bs.modal', function (e) { 460 $(this).clone().attr('id', 'print_modal').addClass('visible-print-block in').appendTo('body'); 461 $layoutMain.addClass('hidden-print'); 462 }); 463 $modal.on('hide.bs.modal', function (e) { 464 $('#print_modal').remove(); 465 $layoutMain.removeClass('hidden-print'); 466 }); 467 468});
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.