1 2(function($) { 3 Drupal.behaviors.ssks_core = { 4 5 attach: function(context, settings) { 6 7 // Drupal.behaviors.ssks_core.ssksLoader(); 8 Drupal.behaviors.ssks_core.blocsVides(); 9 Drupal.behaviors.ssks_core.browserObsolete(); 10 Drupal.behaviors.ssks_core.browserDetection(); 11 Drupal.behaviors.ssks_core.fixBtnFlex(); 12 Drupal.behaviors.ssks_core.resetIcone(); 13 14 Drupal.behaviors.ssks_core.wrapTableResponsive(); 15 16 Drupal.behaviors.ssks_core.menuIcones(); 17 Drupal.behaviors.ssks_core.stylesDrupal(); 18 19 Drupal.behaviors.ssks_core.chargementImage(); 20 21 Drupal.behaviors.ssks_core.initUpButton(); 22 Drupal.behaviors.ssks_core.dropdownInit(); 23 Drupal.behaviors.ssks_core.addClassImgLink(); 24 Drupal.behaviors.ssks_core.tooltipInit(); 25 Drupal.behaviors.ssks_core.embedResponsive(); 26 Drupal.behaviors.ssks_core.fixTargetBlankVunerability(); 27 28 Drupal.behaviors.ssks_core.checkToolbarHeight(); 29 30 Drupal.behaviors.ssks_core.resizeListeBlock(); 31 Drupal.behaviors.ssks_core.updateFiltresUrl(); 32 33 $(window).resize(function () { 34 Drupal.behaviors.ssks_core.checkToolbarHeight(); 35 Drupal.behaviors.ssks_core.resizeListeBlock(); 36 }); 37 38 39 // TRI DES LISTES 40 Drupal.behaviors.ssks_core.listeTris(); 41 42 // deplace les ancres d'agenda 43 Drupal.behaviors.ssks_core.lb_filtresEvenements(); 44 Drupal.behaviors.ssks_core.lb_separateurs_mois_invisibile(); 45 46 47 48 Drupal.behaviors.ssks_core.blocVideClass(".js-hide-if-empty"); 49 50 51 Drupal.behaviors.ssks_core.titreCollapse(); 52 53 54 }, 55 56 onAjaxComplete: function () { 57 58 if (Modernizr.history) { 59 history.replaceState(null, null, location.protocol + '//' + location.host + location.pathname + '?' + 60 (Drupal.settings.ssks ? Drupal.settings.ssks.parametres : '')); 61 } 62 63 Drupal.behaviors.ssks_core.fixBtnFlex(); 64 Drupal.behaviors.ssks_core.resetIcone(); 65 Drupal.behaviors.ssks_core.stylesDrupal(); 66 Drupal.behaviors.ssks_core.dropdownInit(); 67 Drupal.behaviors.ssks_core.tooltipInit(); 68 Drupal.behaviors.ssks_core.chargementImage(); 69 Drupal.behaviors.ssks_core.resizeListeBlock(); 70 Drupal.behaviors.ssks_core.listeTris(); 71 72 // deplace les ancres d'agenda 73 Drupal.behaviors.ssks_core.lb_filtresEvenements(); 74 75 if (typeof Drupal.behaviors.ssks_calendrier != 'undefined') Drupal.behaviors.ssks_calendrier.vueCalendrier(); 76 if (typeof Drupal.behaviors.ssks_date != 'undefined') Drupal.behaviors.ssks_date.initDateTimePicker(); 77 78 Drupal.behaviors.ssks_core.blocVideClass(".js-hide-if-empty"); 79 80 81 }, 82 83 84 85 /*--------------------------------------------------------------------- 86 :: 87 :: ANCRE AGENDA 88 :: 89 ---------------------------------------------------------------------*/ 90 updateFiltresUrl : function () { 91 92 if(Drupal.settings.ssks_liste && Drupal.settings.ssks_liste.parametres != ''){ 93 history.replaceState(null, null, 94 location.protocol + '//' + location.host + location.pathname 95 + '?' + 96 Drupal.settings.ssks_liste.parametres 97 ) 98 } 99 }, 100 101 /*--------------------------------------------------------------------- 102 :: 103 :: ANCRE AGENDA 104 :: 105 ---------------------------------------------------------------------*/ 106 lb_filtresEvenements: function () { 107 108 var ancreAgenda = $('.js-ancre-agenda:not(.processed)').last(); // On prend le dernier car à chaque chargement ajax, une ancre supplémentaire est générée 109 110 if (! ancreAgenda.length ) return; 111 112 // on teste si les ancres ont une liste juste à côté. Afin de ne pas déplacé les ancres si elles sont en séparated. 113 // MAIS ON POURSUIT POUR RETIRER LA CLASSE "hidden".. 114 if ($('.prerender-separated').length == 0) { 115 var listeEvenement = $('.liste-evenements'); 116 var destination = listeEvenement.find('form > div'); 117 118 if( destination.length == 0 ) { 119 destination = listeEvenement; 120 } 121 // DEPLACE LES ANCRES DE L'AGENDA 122 ancreAgenda.prependTo(destination).addClass('processed') 123 } 124 125 126 ancreAgenda.removeClass('hidden'); 127 128 }, 129 /*--------------------------------------------------------------------- 130 :: 131 :: ANCRE AGENDA 132 :: 133 ---------------------------------------------------------------------*/
134 lb_separateurs_mois_invisibile: function () { 135 var separateurs = $('.separateur-mois-jour.visuallyhidden, .separateur-mois-invisible .separateur-mois-jour'); 136 if (!separateurs.length) return; 137 separateurs.once('separateur',function(){ 138 139 $(this).each(function(){ 140 141 $(this).prependTo( $(this).next() ); 142 143 $(this).addClass('visuallyhidden'); 144 }); 145 146 }); 147 148 }, 149 150 /*--------------------------------------------------------------------- 151 :: 152 :: ANCRE AGENDA 153 :: 154 ---------------------------------------------------------------------*/ 155 /** 156 * Loader commenté dans le attach de ce JS, mais peut-être appelé par site pour avoir ou non un loader 157 */ 158 ssksLoader: function () { 159 160 161 var loaderElt = 162 '<div id="ssks-loader" class="ajax-progress hidden">\ 163 <div class="throbber"></div>\ 164 </div>'; 165 166 if ($("#ssks-loader").length) return; 167 168 //Creation de l'element 169 $(".website-container").append(loaderElt); 170 171 // $(document) 172 // .ajaxStart(function (e) { 173 // Drupal.behaviors.ssks_core.ssksLoaderStart(); 174 // }) 175 // .ajaxStop(function (e) { 176 // Drupal.behaviors.ssks_core.ssksLoaderEnd(); 177 // }); 178 // 179 // $(document).ajaxError(function (e) { 180 // Drupal.behaviors.ssks_core.ssksLoaderEnd(); 181 // }); 182 183 184 }, 185 ssksLoaderStart: function(){ 186 $("#ssks-loader").removeClass("hidden"); 187 }, 188 ssksLoaderEnd: function(){ 189 $("#ssks-loader").addClass("hidden"); 190 }, 191 192 193 /*--------------------------------------------------------------------- 194 :: 195 :: Hauteur Drupal ToolBar 196 :: 197 ---------------------------------------------------------------------*/ 198 checkToolbarHeight: function() { 199 if( $('#toolbar').length){ 200 var hauteurtoolbar = $('#toolbar').height(); 201 document.documentElement.style.setProperty('--drupal-toolbar-height', hauteurtoolbar + 'px'); 202 } else { 203 document.documentElement.style.setProperty('--drupal-toolbar-height', '0px'); // Avec unité car "0" ne fonctionne pas dans calc() 204 }; 205 }, 206 207 208 /*--------------------------------------------------------------------- 209 :: 210 :: Tri des listes 211 :: 212 ---------------------------------------------------------------------*/ 213 listeTris: function() { 214 if( $('.liste-tri').length == 0) return; 215 216 //Change le texte du bouton de tri pour mettre l'actif 217 $(".btn-tris-texte").html( $(".listbox-link.active").html() ); 218 219 $("input[name='order']").attr("value", $(".listbox-link.active").data("order") ); 220 221 }, 222 223 224 /*--------------------------------------------------------------------- 225 :: 226 :: Tri des listes 227 :: 228 ---------------------------------------------------------------------*/ 229 titreCollapse: function() { 230 $titre = $('.w_titre-collapse'); 231 separateur = '<span class="w_titre-collapse-separateur"></span>'; 232 chevron = '<span class="w_titre-collapse-chevron"></span>'; 233 234 if($titre.length ) { 235 $titre.not('.collapse-processed').addClass('collapse-processed').each(function(){ 236 237 var titresSuivants = "h2"; 238 239 if($(this).is('h3')){ 240 titresSuivants = "h2, h3" ; 241 } 242 if($(this).is('h4')){ 243 titresSuivants = "h2, h3, h4" ; 244 } 245 246 $(this).nextUntil(titresSuivants).wrapAll('<div class="w_titre-collapse-content" style="display:none;"/>'); 247 $(this).addClass('w_titre-is-collapsed'); 248 249 $(this).append(separateur); 250 $(this).append(chevron); 251 252 }); 253 254 $titre.on('click',function(){ 255 256 var titre = $(this); 257 258 titre.toggleClass('w_titre-is-collapsed'); 259 $(this).next('.w_titre-collapse-content').slideToggle(400); 260 261 }); 262 263 } 264 265 }, 266 267 268 /*--------------------------------------------------------------------- 269 :: 270 :: Fix btn 271 :: 272 ---------------------------------------------------------------------*/ 273 resetIcone: function () { 274 // Ajoute tooltip au bouton reset et le déplace 275 $('.btn-reset-icone:not(.processed)').each(function () { 276 var btnResetValue = $(this).val(); 277 $(this).attr('data-original-title', btnResetValue); 278 $(this).addClass('processed').html('<i class="fa fa-undo"></i>'); 279 }) 280 }, 281 282 /*--------------------------------------------------------------------- 283 :: 284 :: Fix btn 285 :: 286 ---------------------------------------------------------------------*/ 287 fixBtnFlex: function () { 288 289 if($('body.node-type-newsletter').length ){ 290 return 291 } 292
293 $('.btn:not(.flex-processed):not(input)').addClass('flex-processed').each(function () { 294 295 // Ne wrap pas si bootstrap select 296 if ($(this).parent('.bootstrap-select').length) return; 297 298 var contenuBtn = $(this).html(); 299 if ($(this).is('button')) { 300 $(this).html('<span>' + contenuBtn + '</span>'); 301 } else { 302 $(this).html('<div>' + contenuBtn + '</div>'); 303 } 304 }); 305 }, 306 307 308 /*--------------------------------------------------------------------- 309 :: 310 :: Wrap table responsive 311 :: 312 ---------------------------------------------------------------------*/ 313 wrapTableResponsive: function() { 314 var table = $('table.is-responsive'); 315 316 if (!table.length) return 317 table.not('.resp-processed').addClass('resp-processed').wrap('<div class="table-responsive"/>') 318 }, 319 320 /*--------------------------------------------------------------------- 321 :: 322 :: chargementImage 323 :: 324 ---------------------------------------------------------------------*/ 325 chargementImage: function() { 326 $('.image-loaded img').addClass('is-loading'); 327 $('.image-loaded').imagesLoaded().progress( function(imgLoad, image) { 328 $(image.img).removeClass('is-loading').addClass('is-loaded'); 329 }); 330 }, 331 332 333 /*--------------------------------------------------------------------- 334 :: Dropdown Init 335 ---------------------------------------------------------------------*/ 336 dropdownInit: function() { 337 $('.dropdown-toggle:not(.dropdown-processed)').addClass('dropdown-processed').dropdown(); 338 }, 339 340 /*--------------------------------------------------------------------- 341 :: Ajout class image-link 342 -------------------------------------------------------------------*/ 343 addClassImgLink: function() { 344 $('.cke_editable img').parent('a').addClass('image-link'); 345 }, 346 347 348 /*--------------------------------------------------------------------- 349 :: Tooltip init 350 -------------------------------------------------------------------*/ 351 tooltipInit: function() { 352 // if ($('.is-safari-mobile').length) return; // #35266 - Le Kiosque Nantais - Fix tooltip info mobile 353 $('.tooltip-item:not(.tooltip-processed)').addClass('tooltip-processed').tooltip(); 354 }, 355 356 357 /*--------------------------------------------------------------------- 358 :: Ajoute une icone dans un lien de menu <a> 359 ---------------------------------------------------------------------*/ 360 menuIcones: function() { 361 362 $('a[class*="menu-fa-"], a[class*="menu-zmdi-"]').not('.i-processed').each(function(i, el){ 363 364 $(this).addClass('i-processed'); 365 366 var menuClass = (el.className.match(/(^|\s)(menu\-(fa|zmdi)\-[^\s]*)/) || [,,'']) ; 367 var fontClass = menuClass[2]; 368 var fontPrefix = menuClass[3]; 369 if(fontClass){ 370 var iconeClass = fontClass.substr('menu-'.length); 371 var icone = '<i class="'+ fontPrefix +' '+ iconeClass +'"></i>'; 372 $(this).prepend(icone); 373 } 374 }); 375 376 }, 377 378 379 /*--------------------------------------------------------------------- 380 :: Verifie si certains blocs sont vides 381 ---------------------------------------------------------------------*/ 382 blocsVides: function() { 383 384 //Cache fil d'ariane 385 if( $('.breadcrumb > li').length <= 1 ){ 386 $('.fil-ariane').addClass('no-children').addClass('hidden'); 387 $('.fil-ariane').removeClass('has-children'); 388 } else{ 389 $('.fil-ariane').removeClass('no-children').removeClass('hidden'); 390 $('.fil-ariane').addClass('has-children'); 391 } 392 393 // TEST SI UNE COLONNE DANS LE NODE 394 var nodeColonne = $('.node-aside-colonne'); 395 if (nodeColonne.length && nodeColonne.children().length ) { 396 $('body').removeClass('no-node-aside-colonne').addClass('has-node-aside-colonne'); 397 } 398 else { 399 $('body').removeClass('has-node-aside-colonne').addClass('no-node-aside-colonne'); 400 }; 401 402 403 Drupal.behaviors.ssks_core.blocVide("sous-menu-container"); 404 Drupal.behaviors.ssks_core.blocVide("node-aside"); 405 Drupal.behaviors.ssks_core.blocVide("node-content-bottom"); 406 Drupal.behaviors.ssks_core.blocVide("node-medias"); 407 }, 408 409 410 blocVide: function(idBloc) { 411 var id = "#"+ idBloc; 412 413 if (jQuery(id).length == 0 || jQuery(id).children().length == 0) { 414 jQuery(id).hide(); 415 jQuery("body").addClass('no-' + idBloc); 416 } else { 417 jQuery(id).show(); 418 jQuery("body").removeClass('no-' + idBloc); 419 } 420 }, 421 422 423 424 blocVideClass: function(classBloc) { 425 var selecteur = classBloc; 426 427 jQuery(selecteur).each(function(){ 428 if (jQuery(this).children().length == 0) { 429 jQuery(this).hide(); 430 } 431 else { 432 jQuery(this).show(); 433 } 434 }); 435 }, 436 437 /*--------------------------------------------------------------------- 438 :: 439 :: Obsolescence 440 :: 441 ---------------------------------------------------------------------*/ 442 browserObsolete: function() { 443 var browser = window.detect(); 444 var version = parseFloat(browser.version); 445 var versionsObsoletes = { 446 "safari" : 10, 447 "ie" : 10, 448 "firefox" : 30, 449 } 450 451 if (versionsObsoletes.hasOwnProperty(browser.name) && versionsObsoletes[browser.name] > version) { 452 $('.browser-warning').addClass('is-visible'); 453 } 454 }, 455 456 /*--------------------------------------------------------------------- 457 :: 458 :: Détection du navigateur 459 :: 460 ---------------------------------------------------------------------*/ 461 browserDetection: function() { 462 // Detect mobile device 463 if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { 464 $('body').addClass('mobile-device'); 465 } 466 467 // Opera 8.0+ 468 var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; 469 470 // Firefox 1.0+ 471 var isFirefox = typeof InstallTrigger !== 'undefined'; 472 473 // Safari 3.0+ "[object HTMLElementConstructor]" 474 var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification); 475 var isSafariMobile = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/); 476 477 // Internet Explorer 6-11 478 var isIE = /*@cc_on!@*/false || !!document.documentMode; 479 480 // Edge 20+ 481 var isEdge = !isIE && !!window.StyleMedia; 482 483 // Chrome 1+ 484 var isChrome = !!window.chrome && !!window.chrome.webstore; 485 486 switch (true) { 487 488 case isChrome: 489 $('html').addClass('is-chrome'); 490 break; 491 492 case isFirefox: 493 $('html').addClass('is-firefox'); 494 break; 495 496 case isEdge: 497 $('html').addClass('is-edge'); 498 break; 499 500 case isIE: 501 $('html').addClass('is-ie'); 502 break; 503 504 case isSafari: 505 $('html').addClass('is-safari'); 506 break; 507 508 case isSafariMobile: 509 $('html').addClass('is-safari is-safari-mobile'); 510 break; 511 512 513 case isOpera: 514 $('html').addClass('is-opera'); 515 break; 516 } 517 518 }, 519 520 521 /*--------------------------------------------------------------------- 522 :: 523 :: Fix the target="_blank" vulnerability 524 :: (https://dev.to/ben/the-targetblank-vulnerability-by-example?utm_source=codropscollective) 525 :: 526 ---------------------------------------------------------------------*/ 527 fixTargetBlankVunerability: function() { 528 $('a[target="_blank"]').attr("rel", "noopener noreferrer"); 529 }, 530 531 532 /*--------------------------------------------------------------------- 533 :: EMBED RESPONSIVE DANS CKEDITOR 534 -------------------------------------------------------------------*/ 535 embedResponsive: function() { 536 537 // fix si iframe mise dans le wysiwyg sans fonction media 538 $('.cke_editable p > iframe').parent().addClass('media_embed'); 539 540 var $selecteurs = [ 541 '.media_embed iframe[src*="youtu"]', 542 '.media_embed iframe[src*="facebook"]', 543 '.media_embed iframe[src*="vimeo"]', 544 '.media_embed iframe[src*="calameo"]', 545 '.media_embed iframe[src*="soundsgood"]', 546 '.embed-audio iframe[src*="youtu"]', 547 '.embed-audio iframe[src*="vimeo"]', 548 ].join(', '); 549 var iframeResponsive = $($selecteurs); 550 551 if ( iframeResponsive.length > 0 ) { 552 553 iframeResponsive.not('.resp-processed').each(function(){ 554 555 $(this).addClass('resp-processed'); 556 557 var ratio = $(this).height() / $(this).width() * 100; 558 $(this).closest('.media_embed, .embed-audio').addClass('responsive').css({ 559 'padding-top' : ratio +'%'
560 }); 561 562 }); 563 } 564 }, 565 566 567 568 /*--------------------------------------------------------------------- 569 :: 570 :: Liste de block 571 :: les blocks ont la hauteur du plus haut de la liste 572 :: 573 ---------------------------------------------------------------------*/ 574 575 resizeListeBlock: function() { 576 577 if ($('[class*=hauteur-liste]').length == 0) return; 578 579 jQuery('.hauteur-liste, .hauteur-liste-sm, .hauteur-liste-md, .hauteur-liste-lg').imagesLoaded(function() { 580 Drupal.behaviors.ssks_core.hauteurListe(".hauteur-liste", ".hauteur-item", 0); 581 Drupal.behaviors.ssks_core.hauteurListe(".hauteur-liste-sm", ".hauteur-item", 768); 582 Drupal.behaviors.ssks_core.hauteurListe(".hauteur-liste-md", ".hauteur-item", 992); 583 Drupal.behaviors.ssks_core.hauteurListe(".hauteur-liste-lg", ".hauteur-item", 1200); 584 }); 585 586 }, 587 588 hauteurListe: function(selecteur, enfant, largeurFenetre) { 589 590 if ( Modernizr.mq('(min-width: ' + largeurFenetre + 'px)')){ 591 592 jQuery(selecteur).each(function() { 593 var maxheight = 0; 594 jQuery(enfant, this).each(function() { 595 jQuery(this).css('height', 'auto'); 596 if (this.offsetHeight > maxheight) { 597 maxheight = this.offsetHeight; 598 } 599 }); 600 jQuery(enfant, this).css('height', maxheight + 'px'); 601 }); 602 603 } else { 604 jQuery(selecteur+ " " + enfant).css('height', 'auto'); 605 } 606 607 }, 608 609 610 /*--------------------------------------------------------------------- 611 :: 612 :: Ajout & retrait de classes aux éléments drupal 613 :: pour être conforme avec le BOOTSTRAP 614 :: 615 -------------------------------------------------------------------*/ 616 stylesDrupal: function() { 617 618 /*----------------------------------------------------------------- 619 :: Description en tooltip 620 -------------------------------------------------------------------*/ 621 $('form:not(.webform-client-form) .form-item .description:not(.description-processed)').each(function(){ 622 $(this).addClass('description-processed').hide(); 623 var descriptionTexte = $(this).text() ; 624 $(this).siblings('label').append(' <span title="'+descriptionTexte+'" class="tooltip-item text-muted"><i class="fa fa-question-circle"></i></span>'); 625 626 }); 627 628 /*----------------------------------------------------------------- 629 :: Formulaire login 630 -------------------------------------------------------------------*/ 631 $('#user-login #edit-actions').removeClass('form-actions'); 632 633 /*----------------------------------------------------------------- 634 :: STYLES FORMULAIRES DRUPAL 635 -------------------------------------------------------------------*/ 636 $('.form-type-radio:not(.form-item-field-type-und)').addClass('radio'); 637 638 /*----------------------------------------------------------------- 639 :: STYLES FORMULAIRES DRUPAL 640 -------------------------------------------------------------------*/ 641 $('.ssks-form-defaut > div, #user-register-form:not(.disable-form-defaut) > div ').addClass('row row-flex'); 642 $(' #user-register-form:not(.disable-form-defaut)').addClass('ssks-form-defaut'); 643 644 /*Elements en une colonne*/ 645 $('.ssks-form-defaut').find('.form-type-textarea, .form-actions, #edit-actions, .mdp-reset , .form-type-radios , .form-type-checkboxes, .form-item-title , .field-name-body').addClass('col-xs-12'); 646 647 /*Elements en deux colonne*/ 648 $('.ssks-form-defaut').find('.form-type-textfield , .form-type-password , .form-type-select , form-type-file , .form-type-managed-file').addClass('col-xs-12 col-sm-6 '); 649 650 /*Formulaire condensé colonne*/ 651 $('.form-condensed.ssks-form-defaut').find('.form-type-textfield , .form-type-password , .form-type-radios , .form-type-select , form-type-file , .form-type-managed-file , .form-type-checkboxes').addClass('col-lg-4 '); 652 653 /*Exception Objet/sujet du formulaire en 1 colonne */ 654 $('.form-item-contact-objet').removeClass('col-sm-6'); 655 656 657 /*----------------------------------------------------------------- 658 :: Checkbox 659 -------------------------------------------------------------------*/ 660 // $('.form-type-checkbox').addClass('checkbox'); 661 662 // SI PAS DE LABEL, wrap en col-xs-12 et ajoute form-item 663 $('.ssks-form-defaut .form-checkboxes').each(function(){ 664 if( $(this).closest('.form-type-checkboxes').length == 0){ 665 $('.form-checkboxes').addClass('col-xs-12 form-item'); 666 } 667 }); 668 669 670 $('.ssks-form-defaut .form-type-checkbox').each(function(){ 671 if( $(this).closest('.form-checkboxes').length == 0 && $(this).parent('td').length == 0){ 672 $(this).not('.checkbox-processed').addClass('checkbox-processed').wrap('<div class="col-xs-12"/>'); 673 } 674 }); 675 676 677 678 679 }, 680 /*--------------------------------------------------------------------- 681 :: Retour / Scroll en haut 682 ---------------------------------------------------------------------*/ 683 initUpButton: function() { 684 685 var boutonHaut = $('#retour-haut'); 686 687 jQuery(window).scroll(function() { 688 689 if (jQuery(this).scrollTop() != 0) { 690 boutonHaut.addClass('is-visible'); 691 } else { 692 boutonHaut.removeClass('is-visible'); 693 } 694 695 }); 696 boutonHaut.not('.processed').addClass('processed').on('click', function() { 697 jQuery('body,html').animate({ 698 scrollTop: 0 699 }, 500); 700 return false;
701 }); 702 } 703 } 704 705 if (Drupal.ajax) { 706 // Ajout une commande ajax qui peut être déclanchée depuis PHP @see 707 // ajax_command_replace for exemple Cette commande est une copie 708 // modifiée de la commande "insert" du core drupal (misc/ajax.js:525) 709 // La commande de base encapsulait le nouveau contenu dans une div, ici 710 // on insert directement le contenu 711 Drupal.ajax.prototype.commands["ssks_insert"] = function (ajax, response, status) { 712 // Get information from the response. If it is not there, default to 713 // our presets. 714 var wrapper = response.selector ? $(response.selector) : $(ajax.wrapper); 715 var method = response.method || ajax.method; 716 var effect = ajax.getEffect(response); 717 var new_content = $(response.data); 718 719 // If removing content from the wrapper, detach behaviors first. 720 switch (method) { 721 case 'html': 722 case 'replaceWith': 723 case 'replaceAll': 724 case 'empty': 725 case 'remove': 726 var settings = response.settings || ajax.settings || Drupal.settings; 727 Drupal.detachBehaviors(wrapper, settings); 728 } 729 730 // Add the new content to the page. 731 wrapper[method](new_content); 732 733 // Immediately hide the new content if we're using any effects. 734 if (effect.showEffect != 'show') { 735 new_content.hide(); 736 } 737 738 // Determine which effect to use and what content will receive the 739 // effect, then show the new content. 740 if ($('.ajax-new-content', new_content).length > 0) { 741 $('.ajax-new-content', new_content).hide(); 742 new_content.show(); 743 $('.ajax-new-content', new_content)[effect.showEffect](effect.showSpeed); 744 } 745 else if (effect.showEffect != 'show') { 746 new_content[effect.showEffect](effect.showSpeed); 747 } 748 749 // Attach all JavaScript behaviors to the new content, if it was 750 // successfully added to the page, this if statement allows 751 // #ajax['wrapper'] to be optional. 752 if (new_content.parents('html').length > 0) { 753 // Apply any settings from the returned JSON if available. 754 var settings = response.settings || ajax.settings || Drupal.settings; 755 Drupal.attachBehaviors(new_content, settings); 756 } 757 } 758 } 759})(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.