Rev 3961 | Blame | Compare with Previous | Last modification | View Log | RSS feed
function WidgetPhoto( proprietes ) {if ( this.valOk( proprietes ) ) {this.id = proprietes.id;this.galerieId = proprietes.galerieId;}}WidgetPhoto.prototype = new WidgetPhotoCommun();WidgetPhoto.prototype.initTpl = function() {$('.grid').masonry({itemSelector: '.grid-item',columnWidth: '.grid-sizer',gutter: 10,percentPosition: true});};WidgetPhoto.prototype.initEvts = function() {const lthis = this;const $thisGalerie = $( '#cel-photo-contenu' + this.id );var url = '',focus = $( '#print_content' );$thisGalerie.on( 'click', 'a.cel-img', function( event ) {event.preventDefault();var lienImage = this.href;if ( !/contact/.test( this.className ) ) {url = '?mode=popup&url_image=' + lienImage + '&galerie_id=' + lthis.galerieId;url += '&popup_url=' + encodeURIComponent( url );} else {url = lienImage;}lthis.chargerContenuModale( url );});$( '.bouton-plus-filtres', $thisGalerie ).on( 'click', function( event ) {event.preventDefault();$( '.autres-filtres, .plus, .moins', $thisGalerie ).toggleClass( 'hidden' );});$( '.bouton-fermer-filtres', $thisGalerie ).on( 'click', function( event ) {event.preventDefault();$( '.autres-filtres, .bouton-plus-filtres .moins', $thisGalerie ).addClass( 'hidden' );$( '.bouton-plus-filtres .plus', $thisGalerie ).removeClass( 'hidden' );});lthis.rechercher();lthis.affichageEFlore();};WidgetPhoto.prototype.rechercher = function(){const lthis = this;$("#bouton-rechercher-1").click(function(event){event.preventDefault();var rechercheValue = $('#champ-recherche-1').val();lthis.lancerLaRecherche(rechercheValue, "recherche");})$("#champ-recherche-1").keyup(function(event) {if (event.key === "Enter") {event.preventDefault();var rechercheValue = $('#champ-recherche-1').val();lthis.lancerLaRecherche(rechercheValue, "recherche");}});$(".bloc-filtre input").keyup(function (event){if (event.key === "Enter") {event.preventDefault();var rechercheValue = $(this).val();var filterName = $(this).attr('name');lthis.lancerLaRecherche(rechercheValue, filterName);}})$(".bloc-filtre #referentiel").on("change", function (event){event.preventDefault();var rechercheValue = $(this).val();var filterName = $(this).attr('name');lthis.lancerLaRecherche(rechercheValue, filterName);})$(".bloc-filtre #date_deb").on("change", function (event){event.preventDefault();var rechercheValue = $(this).val();lthis.lancerLaRecherche(rechercheValue, "date_deb");})$(".bloc-filtre #date_fin").on("change", function (event){event.preventDefault();var rechercheValue = $(this).val();lthis.lancerLaRecherche(rechercheValue, "date_fin");})$(".bloc-filtre input[type='checkbox']").change(function() {var filterName = $(this).attr('name');var isChecked = $(this).is(':checked');if (isChecked) {lthis.updateURLWithCheckboxValue(isChecked, filterName);} else {lthis.removeURLParameter(filterName);}});}WidgetPhoto.prototype.lancerLaRecherche = function(rechercheValue, filterName){var url = window.location.href;var parameter = filterName + "=" + encodeURIComponent( rechercheValue );// Utiliser une expression régulière pour rechercher le paramètre "recherche=" dans l'URLvar regex = new RegExp('(\\?|&)+' + filterName + '=([^&]*)');// Vérifier si le paramètre "recherche=" existe dans l'URL initialif (regex.test(url)) {// Remplacer le paramètre existant par le nouveau paramètreurl = url.replace(regex, "$1" + parameter);} else {// Ajouter le nouveau paramètre à la fin de l'URLurl.indexOf("?") !== -1 ? url += "&" + parameter : url += "?" + parameter;}// Recharger la page avec le nouvel URLwindow.location.replace(url);}WidgetPhoto.prototype.updateURLWithCheckboxValue = function(isChecked, filterName) {var url = window.location.href;var parameter = filterName + "=" + (isChecked ? "true" : "false");var regex = new RegExp('(\\?|&)+' + filterName + '=(true|false)');if (regex.test(url)) {url = url.replace(regex, "$1" + parameter);} else {url.indexOf("?") !== -1 ? url += "&" + parameter : url += "?" + parameter;}// Rediriger vers la nouvelle URLwindow.location.replace(url);}WidgetPhoto.prototype.removeURLParameter = function(filterName) {var url = window.location.href;var regex = new RegExp('(\\?|&)' + filterName + '=(true|false)(\\?|&|$)');url = url.replace(regex, function(match, p1, p2, p3) {switch (p1){case "?":return p3 === '&' ? '?' : '';case "&":return p3 === '&' ? '&' : '';default :return match;}});// Rediriger vers la nouvelle URLwindow.location.replace(url);};WidgetPhoto.prototype.affichageEFlore = function (){const lthis = this;let tagToDisplay = 'fleur';// Remove 'active' class from all list items$(".icone-organe-list").removeClass("active");// Add 'active' class to the clicked list item$("#eflore-fleur").parent(".icone-organe-list").addClass("active");lthis.displayImages(tagToDisplay);$(".lien-images-organes").click(function(event){event.preventDefault();// Remove 'active' class from all list items$(".icone-organe-list").removeClass("active");// Add 'active' class to the clicked list item$(this).parent(".icone-organe-list").addClass("active");// Get the parameters 'value' and 'filterName' from the clicked linktagToDisplay = $(this).attr("title");lthis.displayImages(tagToDisplay);})}WidgetPhoto.prototype.displayImages = function (tagToDisplay){$(".cel-photo").hide();$("."+tagToDisplay).show();$(".non_eflore").show();}