3631 |
idir |
1 |
function WidgetPhoto( proprietes ) {
|
|
|
2 |
if ( this.valOk( proprietes ) ) {
|
|
|
3 |
this.id = proprietes.id;
|
|
|
4 |
this.galerieId = proprietes.galerieId;
|
|
|
5 |
}
|
|
|
6 |
}
|
|
|
7 |
|
|
|
8 |
WidgetPhoto.prototype = new WidgetPhotoCommun();
|
|
|
9 |
|
|
|
10 |
WidgetPhoto.prototype.initTpl = function() {
|
|
|
11 |
$('.grid').masonry({
|
|
|
12 |
itemSelector: '.grid-item',
|
|
|
13 |
columnWidth: '.grid-sizer',
|
|
|
14 |
gutter: 10,
|
|
|
15 |
percentPosition: true
|
|
|
16 |
});
|
3829 |
idir |
17 |
|
3631 |
idir |
18 |
};
|
|
|
19 |
|
|
|
20 |
WidgetPhoto.prototype.initEvts = function() {
|
|
|
21 |
const lthis = this;
|
|
|
22 |
const $thisGalerie = $( '#cel-photo-contenu' + this.id );
|
|
|
23 |
var url = '',
|
|
|
24 |
focus = $( '#print_content' );
|
|
|
25 |
|
|
|
26 |
$thisGalerie.on( 'click', 'a.cel-img, a.cel-img-contact', function( event ) {
|
|
|
27 |
event.preventDefault();
|
|
|
28 |
var lienImage = this.href;
|
|
|
29 |
|
|
|
30 |
if ( !/contact/.test( this.className ) ) {
|
|
|
31 |
url = '?mode=popup&url_image=' + lienImage + '&galerie_id=' + lthis.galerieId;
|
|
|
32 |
url += '&popup_url=' + encodeURIComponent( url );
|
|
|
33 |
} else {
|
|
|
34 |
url = lienImage;
|
|
|
35 |
}
|
|
|
36 |
lthis.chargerContenuModale( url );
|
|
|
37 |
});
|
|
|
38 |
$( '.bouton-plus-filtres', $thisGalerie ).on( 'click', function( event ) {
|
|
|
39 |
event.preventDefault();
|
|
|
40 |
$( '.autres-filtres, .plus, .moins', $thisGalerie ).toggleClass( 'hidden' );
|
|
|
41 |
});
|
|
|
42 |
$( '.bouton-fermer-filtres', $thisGalerie ).on( 'click', function( event ) {
|
|
|
43 |
event.preventDefault();
|
|
|
44 |
$( '.autres-filtres, .bouton-plus-filtres .moins', $thisGalerie ).addClass( 'hidden' );
|
|
|
45 |
$( '.bouton-plus-filtres .plus', $thisGalerie ).removeClass( 'hidden' );
|
|
|
46 |
});
|
3960 |
julien |
47 |
|
|
|
48 |
lthis.rechercher();
|
3961 |
julien |
49 |
lthis.affichageEFlore();
|
3631 |
idir |
50 |
};
|
3960 |
julien |
51 |
|
|
|
52 |
WidgetPhoto.prototype.rechercher = function(){
|
|
|
53 |
const lthis = this;
|
|
|
54 |
$("#bouton-rechercher-1").click(function(event){
|
|
|
55 |
event.preventDefault();
|
|
|
56 |
var rechercheValue = $('#champ-recherche-1').val();
|
|
|
57 |
lthis.lancerLaRecherche(rechercheValue, "recherche");
|
|
|
58 |
})
|
|
|
59 |
|
|
|
60 |
$("#champ-recherche-1").keyup(function(event) {
|
|
|
61 |
if (event.key === "Enter") {
|
|
|
62 |
event.preventDefault();
|
|
|
63 |
var rechercheValue = $('#champ-recherche-1').val();
|
|
|
64 |
lthis.lancerLaRecherche(rechercheValue, "recherche");
|
|
|
65 |
}
|
|
|
66 |
});
|
|
|
67 |
|
|
|
68 |
$(".bloc-filtre input").keyup(function (event){
|
|
|
69 |
if (event.key === "Enter") {
|
|
|
70 |
event.preventDefault();
|
|
|
71 |
var rechercheValue = $(this).val();
|
|
|
72 |
var filterName = $(this).attr('name');
|
|
|
73 |
lthis.lancerLaRecherche(rechercheValue, filterName);
|
|
|
74 |
}
|
|
|
75 |
})
|
|
|
76 |
|
|
|
77 |
$(".bloc-filtre #referentiel").on("change", function (event){
|
|
|
78 |
event.preventDefault();
|
|
|
79 |
var rechercheValue = $(this).val();
|
|
|
80 |
var filterName = $(this).attr('name');
|
|
|
81 |
lthis.lancerLaRecherche(rechercheValue, filterName);
|
|
|
82 |
})
|
|
|
83 |
|
|
|
84 |
$(".bloc-filtre #date_deb").on("change", function (event){
|
|
|
85 |
event.preventDefault();
|
|
|
86 |
var rechercheValue = $(this).val();
|
|
|
87 |
lthis.lancerLaRecherche(rechercheValue, "date_deb");
|
|
|
88 |
})
|
|
|
89 |
|
|
|
90 |
$(".bloc-filtre #date_fin").on("change", function (event){
|
|
|
91 |
event.preventDefault();
|
|
|
92 |
var rechercheValue = $(this).val();
|
|
|
93 |
lthis.lancerLaRecherche(rechercheValue, "date_fin");
|
|
|
94 |
})
|
|
|
95 |
|
|
|
96 |
$(".bloc-filtre input[type='checkbox']").change(function() {
|
|
|
97 |
var filterName = $(this).attr('name');
|
|
|
98 |
var isChecked = $(this).is(':checked');
|
|
|
99 |
if (isChecked) {
|
|
|
100 |
lthis.updateURLWithCheckboxValue(isChecked, filterName);
|
|
|
101 |
} else {
|
|
|
102 |
lthis.removeURLParameter(filterName);
|
|
|
103 |
}
|
|
|
104 |
});
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
WidgetPhoto.prototype.lancerLaRecherche = function(rechercheValue, filterName){
|
|
|
108 |
var url = window.location.href;
|
|
|
109 |
var parameter = filterName + "=" + encodeURIComponent( rechercheValue );
|
|
|
110 |
|
|
|
111 |
// Utiliser une expression régulière pour rechercher le paramètre "recherche=" dans l'URL
|
|
|
112 |
var regex = new RegExp('(\\?|&)+' + filterName + '=([^&]*)');
|
|
|
113 |
|
|
|
114 |
// Vérifier si le paramètre "recherche=" existe dans l'URL initial
|
|
|
115 |
if (regex.test(url)) {
|
|
|
116 |
// Remplacer le paramètre existant par le nouveau paramètre
|
|
|
117 |
url = url.replace(regex, "$1" + parameter);
|
|
|
118 |
} else {
|
|
|
119 |
// Ajouter le nouveau paramètre à la fin de l'URL
|
|
|
120 |
url.indexOf("?") !== -1 ? url += "&" + parameter : url += "?" + parameter;
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
// Recharger la page avec le nouvel URL
|
|
|
124 |
window.location.replace(url);
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
WidgetPhoto.prototype.updateURLWithCheckboxValue = function(isChecked, filterName) {
|
|
|
128 |
var url = window.location.href;
|
|
|
129 |
var parameter = filterName + "=" + (isChecked ? "true" : "false");
|
|
|
130 |
var regex = new RegExp('(\\?|&)+' + filterName + '=(true|false)');
|
|
|
131 |
|
|
|
132 |
if (regex.test(url)) {
|
|
|
133 |
url = url.replace(regex, "$1" + parameter);
|
|
|
134 |
} else {
|
|
|
135 |
url.indexOf("?") !== -1 ? url += "&" + parameter : url += "?" + parameter;
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
// Rediriger vers la nouvelle URL
|
|
|
139 |
window.location.replace(url);
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
WidgetPhoto.prototype.removeURLParameter = function(filterName) {
|
|
|
143 |
var url = window.location.href;
|
|
|
144 |
var regex = new RegExp('(\\?|&)' + filterName + '=(true|false)(\\?|&|$)');
|
|
|
145 |
|
|
|
146 |
url = url.replace(regex, function(match, p1, p2, p3) {
|
|
|
147 |
switch (p1){
|
|
|
148 |
case "?":
|
|
|
149 |
return p3 === '&' ? '?' : '';
|
|
|
150 |
case "&":
|
|
|
151 |
return p3 === '&' ? '&' : '';
|
|
|
152 |
default :
|
|
|
153 |
return match;
|
|
|
154 |
}
|
|
|
155 |
});
|
|
|
156 |
|
|
|
157 |
// Rediriger vers la nouvelle URL
|
|
|
158 |
window.location.replace(url);
|
|
|
159 |
};
|
3961 |
julien |
160 |
|
|
|
161 |
WidgetPhoto.prototype.affichageEFlore = function (){
|
|
|
162 |
const lthis = this;
|
|
|
163 |
let tagToDisplay = 'fleur';
|
|
|
164 |
|
|
|
165 |
// Remove 'active' class from all list items
|
|
|
166 |
$(".icone-organe-list").removeClass("active");
|
|
|
167 |
|
|
|
168 |
// Add 'active' class to the clicked list item
|
|
|
169 |
$("#eflore-fleur").parent(".icone-organe-list").addClass("active");
|
|
|
170 |
|
|
|
171 |
lthis.displayImages(tagToDisplay);
|
|
|
172 |
|
|
|
173 |
$(".lien-images-organes").click(function(event){
|
|
|
174 |
event.preventDefault();
|
|
|
175 |
|
|
|
176 |
// Remove 'active' class from all list items
|
|
|
177 |
$(".icone-organe-list").removeClass("active");
|
|
|
178 |
|
|
|
179 |
// Add 'active' class to the clicked list item
|
|
|
180 |
$(this).parent(".icone-organe-list").addClass("active");
|
|
|
181 |
|
|
|
182 |
// Get the parameters 'value' and 'filterName' from the clicked link
|
|
|
183 |
tagToDisplay = $(this).attr("title");
|
|
|
184 |
|
|
|
185 |
lthis.displayImages(tagToDisplay);
|
|
|
186 |
})
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
WidgetPhoto.prototype.displayImages = function (tagToDisplay){
|
|
|
190 |
$(".cel-photo").hide();
|
|
|
191 |
$("."+tagToDisplay).show();
|
|
|
192 |
$(".non_eflore").show();
|
|
|
193 |
}
|