Subversion Repositories eFlore/Applications.cel

Rev

Rev 3832 | Rev 3837 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3832 Rev 3833
1
function WidgetPhotoPopup( proprietes ) {
1
function WidgetPhotoPopup( proprietes ) {
2
	if( this.valOk( proprietes ) ) {
2
	if( this.valOk( proprietes ) ) {
3
		this.urlWidget                    = proprietes.urlWidget;
3
		this.urlWidget                    = proprietes.urlWidget;
4
		this.urls                         = proprietes.urls;
4
		this.urls                         = proprietes.urls;
5
		this.infos_images                 = proprietes.infos_images;
5
		this.infos_images                 = proprietes.infos_images;
6
		this.indexImage                   = proprietes.indexImage;
6
		this.indexPremiereImage           = proprietes.indexImage;
-
 
7
		this.indexImage                   = this.indexPremiereImage;
7
		this.urlImage                     = proprietes.urlImage;
8
		this.urlImage                     = proprietes.urlImage;
8
		this.tailleMax                    = proprietes.tailleMax;
9
		this.tailleMax                    = proprietes.tailleMax;
9
		this.popupUrl                     = proprietes.popupUrl;
10
		this.popupUrl                     = proprietes.popupUrl;
10
		this.urlBaseTelechargement        = proprietes.urlBaseTelechargement;
11
		this.urlBaseTelechargement        = proprietes.urlBaseTelechargement;
11
		this.urlServiceRegenererMiniature = proprietes.urlServiceRegenererMiniature;
12
		this.urlServiceRegenererMiniature = proprietes.urlServiceRegenererMiniature;
12
	}
13
	}
13
 
14
 
14
	this.mettreAJourInfosImage();
15
	this.mettreAJourInfosImage();
15
}
16
}
16
 
17
 
17
WidgetPhotoPopup.prototype = new WidgetPhotoCommun();
18
WidgetPhotoPopup.prototype = new WidgetPhotoCommun();
18
 
19
 
19
WidgetPhotoPopup.prototype.initTpl = function() {
20
WidgetPhotoPopup.prototype.initTpl = function() {
20
	this.redimensionnerGalerie();
21
	this.redimensionnerGalerie();
21
	if( this.valOk( this.urlImage, false, 'null' ) ) {
22
	if( this.valOk( this.urlImage, false, 'null' ) ) {
22
 
23
 
-
 
24
		this.indexImage = this.indexPremiereImage + this.urls.indexOf( this.urlImage );
23
		this.indexImage = this.urls.indexOf( this.urlImage );
25
	console.log(this.indexImage);
24
 
26
 
25
		$( '#info-img-galerie' ).find( '.active' ).removeClass( 'active' );
27
		$( '#info-img-galerie' ).find( '.active' ).removeClass( 'active' );
26
		$( '#img-cadre-' + this.indexImage + ',#indicateur-img-' + this.indexImage ).addClass( 'active' );
28
		$( '#img-cadre-' + this.indexImage + ',#indicateur-img-' + this.indexImage ).addClass( 'active' );
27
 
29
 
28
		this.mettreAJourPopup();
30
		this.mettreAJourPopup();
29
	}
31
	}
30
 
32
 
31
	this.redimentionnerModaleCarousel();
33
	this.redimentionnerModaleCarousel();
32
};
34
};
33
 
35
 
34
WidgetPhotoPopup.prototype.initEvts = function() {
36
WidgetPhotoPopup.prototype.initEvts = function() {
35
	const lthis = this;
37
	const lthis = this;
36
 
38
 
37
	this.initEvtsDefilerImage();
39
	this.initEvtsDefilerImage();
38
	this.initEvtsContact();
40
	this.initEvtsContact();
39
	$( window ).on( 'resize', lthis.redimentionnerModaleCarousel.bind( lthis ) );
41
	$( window ).on( 'resize', lthis.redimentionnerModaleCarousel.bind( lthis ) );
40
	this.initEvtsFonctionsPhoto();
42
	this.initEvtsFonctionsPhoto();
41
	this.initEvtsRetourGalerieResponsive();
43
	this.initEvtsRetourGalerieResponsive();
42
	this.initEvtsTagsPF();
44
	this.initEvtsTagsPF();
43
};
45
};
44
 
46
 
45
WidgetPhotoPopup.prototype.mettreAJourPopup = function() {
47
WidgetPhotoPopup.prototype.mettreAJourPopup = function() {
46
	this.mettreAJourInfosImage();
48
	this.mettreAJourInfosImage();
47
	this.afficherTitreImage();
49
	this.afficherTitreImage();
48
	this.traiterMetas();
50
	this.traiterMetas();
49
	this.regenererMiniature();
51
	this.regenererMiniature();
50
	this.fournirLienIdentiplante();
52
	this.fournirLienIdentiplante();
51
};
53
};
52
 
54
 
53
WidgetPhotoPopup.prototype.mettreAJourInfosImage = function() {
55
WidgetPhotoPopup.prototype.mettreAJourInfosImage = function() {
54
	this.item          = this.infos_images[this.urls[this.indexImage]];
56
	this.item          = this.infos_images[this.urls[this.indexImage]];
55
	this.titreImage    = this.item['titre'];
57
	this.titreImage    = this.item['titre'];
56
	this.urlLienEflore = this.item['lien'];
58
	this.urlLienEflore = this.item['lien'];
57
	this.idImage       = this.item['id_photo'];
59
	this.idImage       = this.item['id_photo'];
58
	this.urlThisImage  = this.item['url_photo']+'.jpg';
60
	this.urlThisImage  = this.item['url_photo']+'.jpg';
59
	this.obs           = this.item['obs'];
61
	this.obs           = this.item['obs'];
60
	this.nn            = '[nn' + this.obs['nom_sel_nn']+']';
62
	this.nn            = '[nn' + this.obs['nom_sel_nn']+']';
61
	this.urlIP         = this.obs['url_ip'];
63
	this.urlIP         = this.obs['url_ip'];
62
	this.tagsImage     = this.tagsToArray( this.item['tags_photo'] );
64
	this.tagsImage     = this.tagsToArray( this.item['tags_photo'] );
63
	this.tagsObs       = this.tagsToArray( this.obs['tags_obs'] );
65
	this.tagsObs       = this.tagsToArray( this.obs['tags_obs'] );
64
	this.auteur        = this.item['utilisateur']['nom_utilisateur'];
66
	this.auteur        = this.item['utilisateur']['nom_utilisateur'];
65
	this.date          = this.item['date'];
67
	this.date          = this.item['date'];
66
};
68
};
67
 
69
 
68
WidgetPhotoPopup.prototype.tagsToArray = function( tags ) {
70
WidgetPhotoPopup.prototype.tagsToArray = function( tags ) {
69
	if(!this.valOk(tags)) {
71
	if(!this.valOk(tags)) {
70
		return [];
72
		return [];
71
	}
73
	}
72
	tags = tags.replace( new RegExp('\\.'), '' ).split( ',' );
74
	tags = tags.replace( new RegExp('\\.'), '' ).split( ',' );
73
 
75
 
74
	let cleanTags       = [],
76
	let cleanTags       = [],
75
		nbTags          = tags.length,
77
		nbTags          = tags.length,
76
		tag             = '',
78
		tag             = '',
77
		tagsSansEspaces = '',
79
		tagsSansEspaces = '',
78
		cleanTagIndex   = 0;
80
		cleanTagIndex   = 0;
79
 
81
 
80
	for(let i = 0; i < nbTags; i++) {
82
	for(let i = 0; i < nbTags; i++) {
81
		tag = tags[i];
83
		tag = tags[i];
82
		tagsSansEspaces = tag.replace( ' ', '');
84
		tagsSansEspaces = tag.replace( ' ', '');
83
		if( '' !== tagsSansEspaces ) {
85
		if( '' !== tagsSansEspaces ) {
84
			cleanTags.push( tag.trim() );
86
			cleanTags.push( tag.trim() );
85
		}
87
		}
86
	}
88
	}
87
 
89
 
88
	return cleanTags;
90
	return cleanTags;
89
};
91
};
90
 
92
 
91
WidgetPhotoPopup.prototype.initEvtsDefilerImage = function() {
93
WidgetPhotoPopup.prototype.initEvtsDefilerImage = function() {
92
	const lthis = this;
94
	const lthis = this;
93
 
95
 
94
	$( '#precedent, #suivant' ).on( 'click', function() {
96
	$( '#precedent, #suivant' ).on( 'click', function() {
95
		lthis.defilerImage( this.id );
97
		lthis.defilerImage( this.id );
96
	});
98
	});
97
 
99
 
98
	$( '#print_content:not(saisir-tag)' ).on( 'keydown', function( event ) {
100
	$( '#print_content:not(saisir-tag)' ).on( 'keydown', function( event ) {
99
 
101
 
100
		const determinerSens = function( enventKey, left, right ) {
102
		const determinerSens = function( enventKey, left, right ) {
101
			switch ( enventKey ) {
103
			switch ( enventKey ) {
102
				case left:
104
				case left:
103
					return 'suivant';
105
					return 'suivant';
104
				case right:
106
				case right:
105
					return 'precedent';
107
					return 'precedent';
106
				default:
108
				default:
107
					break;
109
					break;
108
			}
110
			}
109
 
111
 
110
			return;
112
			return;
111
		}
113
		}
112
 
114
 
113
		event = (event || window.event);
115
		event = (event || window.event);
114
		// event.keyCode déprécié, on tente d'abord event.key
116
		// event.keyCode déprécié, on tente d'abord event.key
115
		let sens = ( 'key' in event ) ? determinerSens( event.key, 'ArrowLeft', 'ArrowRight' ) : determinerSens( event.keyCode, 37, 39 );;
117
		let sens = ( 'key' in event ) ? determinerSens( event.key, 'ArrowLeft', 'ArrowRight' ) : determinerSens( event.keyCode, 37, 39 );;
116
 
118
 
117
		if ( lthis.valOk( sens ) ) {
119
		if ( lthis.valOk( sens ) ) {
118
			lthis.defilerImage( sens );
120
			lthis.defilerImage( sens );
119
		}
121
		}
120
	});
122
	});
121
};
123
};
122
 
124
 
123
WidgetPhotoPopup.prototype.initEvtsContact = function() {
125
WidgetPhotoPopup.prototype.initEvtsContact = function() {
124
	const lthis = this;
126
	const lthis = this;
125
 
127
 
126
	$( '#bloc-infos-img' ).on( 'click', '.lien_contact', function( event ) {
128
	$( '#bloc-infos-img' ).on( 'click', '.lien_contact', function( event ) {
127
		event.preventDefault();
129
		event.preventDefault();
128
		lthis.chargerContenuModale( this.href );
130
		lthis.chargerContenuModale( this.href );
129
	});
131
	});
130
};
132
};
131
 
133
 
132
WidgetPhotoPopup.prototype.initEvtsFonctionsPhoto = function() {
134
WidgetPhotoPopup.prototype.initEvtsFonctionsPhoto = function() {
133
	const lthis = this;
135
	const lthis = this;
134
 
136
 
135
	$( '#boutons-footer #bloc-fct a, #retour-metas' ).on( 'click', function( event ){
137
	$( '#boutons-footer #bloc-fct a, #retour-metas' ).on( 'click', function( event ){
136
		event.preventDefault();
138
		event.preventDefault();
137
		var voletAOuvrir = $( this ).data( 'volet' ),
139
		var voletAOuvrir = $( this ).data( 'volet' ),
138
			voletAFermer = $( '.bloc-volet:not(.hidden)' ).data( 'volet' );
140
			voletAFermer = $( '.bloc-volet:not(.hidden)' ).data( 'volet' );
139
 
141
 
140
		lthis.ouvrirVoletFct( voletAOuvrir, voletAFermer );
142
		lthis.ouvrirVoletFct( voletAOuvrir, voletAFermer );
141
		if ( window.matchMedia( '(max-width: 991px)' ).matches ) {
143
		if ( window.matchMedia( '(max-width: 991px)' ).matches ) {
142
			$( '#info-img-galerie' ).addClass( 'hidden' );
144
			$( '#info-img-galerie' ).addClass( 'hidden' );
143
			$( '#volet, #retour-galerie' ).removeClass( 'hidden' );
145
			$( '#volet, #retour-galerie' ).removeClass( 'hidden' );
144
		}
146
		}
145
	});
147
	});
146
};
148
};
147
 
149
 
148
WidgetPhotoPopup.prototype.initEvtsRetourGalerieResponsive = function() {
150
WidgetPhotoPopup.prototype.initEvtsRetourGalerieResponsive = function() {
149
	$( '#retour-galerie' ).on( 'click', function( event ) {
151
	$( '#retour-galerie' ).on( 'click', function( event ) {
150
		event.preventDefault();
152
		event.preventDefault();
151
		$( '#info-img-galerie' ).removeClass( 'hidden' );
153
		$( '#info-img-galerie' ).removeClass( 'hidden' );
152
		$( this ).addClass( 'hidden' );
154
		$( this ).addClass( 'hidden' );
153
		if ( window.matchMedia( '(max-width: 991px)' ).matches ) {
155
		if ( window.matchMedia( '(max-width: 991px)' ).matches ) {
154
			$( '#volet' ).addClass( 'hidden' );
156
			$( '#volet' ).addClass( 'hidden' );
155
			$( '.bouton-fct.actif' ).removeClass( 'actif' );
157
			$( '.bouton-fct.actif' ).removeClass( 'actif' );
156
		}
158
		}
157
	});
159
	});
158
};
160
};
159
 
161
 
160
WidgetPhotoPopup.prototype.initEvtsTagsPF = function() {
162
WidgetPhotoPopup.prototype.initEvtsTagsPF = function() {
161
	//recupérer tags en ajax (voir pictoflora, peut-être dans le php?)
163
	//recupérer tags en ajax (voir pictoflora, peut-être dans le php?)
162
	//	_OPTIONS
164
	//	_OPTIONS
163
	// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
165
	// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
164
	//	_GET
166
	//	_GET
165
	// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
167
	// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
166
	this.tagsPfCustom();
168
	this.tagsPfCustom();
167
	$( '#bloc-tags' ).on( 'click', '.tag', function( event ) {
169
	$( '#bloc-tags' ).on( 'click', '.tag', function( event ) {
168
		event.preventDefault();
170
		event.preventDefault();
169
		$( this ).toggleClass( 'actif' );
171
		$( this ).toggleClass( 'actif' );
170
	});
172
	});
171
	$( '#bloc-tags' ).on( 'click', '.custom-tag.actif .fermer', function( event ) {
173
	$( '#bloc-tags' ).on( 'click', '.custom-tag.actif .fermer', function( event ) {
172
		event.preventDefault();
174
		event.preventDefault();
173
		//			Supprimer un custom-tag
175
		//			Supprimer un custom-tag
174
		//	_OPTIONS
176
		//	_OPTIONS
175
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
177
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
176
		// 	_paramètres
178
		// 	_paramètres
177
		// L'id du tag à la fin de l'url
179
		// L'id du tag à la fin de l'url
178
		//	_DELETE
180
		//	_DELETE
179
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
181
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
180
		// 	_réponse:
182
		// 	_réponse:
181
		// ""
183
		// ""
182
		// 			Mettre à jour les mots cles
184
		// 			Mettre à jour les mots cles
183
		//	_OPTIONS
185
		//	_OPTIONS
184
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
186
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
185
		//	_GET
187
		//	_GET
186
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
188
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
187
		$( this ).parent( '.custom-tag' ).remove();
189
		$( this ).parent( '.custom-tag' ).remove();
188
	});
190
	});
189
 
191
 
190
	$( '#bloc-tags' ).on( 'keyup', '.custom-tag.actif', function( event ) {
192
	$( '#bloc-tags' ).on( 'keyup', '.custom-tag.actif', function( event ) {
191
		let supprimerTag = false;
193
		let supprimerTag = false;
192
 
194
 
193
		event = ( event || window.event );
195
		event = ( event || window.event );
194
		// event.keyCode déprécié, on tente d'abord event.key
196
		// event.keyCode déprécié, on tente d'abord event.key
195
		if ( 'key' in event ) {
197
		if ( 'key' in event ) {
196
			supprimerTag = ( 'Delete' === event.key || 'Backspace' === event.key );
198
			supprimerTag = ( 'Delete' === event.key || 'Backspace' === event.key );
197
		} else {
199
		} else {
198
			supprimerTag = ( 46 === event.keyCode || 8 === event.keyCode );
200
			supprimerTag = ( 46 === event.keyCode || 8 === event.keyCode );
199
		}
201
		}
200
		if ( supprimerTag ) {
202
		if ( supprimerTag ) {
201
			//			Supprimer un custom-tag
203
			//			Supprimer un custom-tag
202
			//	_OPTIONS
204
			//	_OPTIONS
203
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
205
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
204
			// 	_paramètres
206
			// 	_paramètres
205
			// L'id du tag à la fin de l'url
207
			// L'id du tag à la fin de l'url
206
			//	_DELETE
208
			//	_DELETE
207
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
209
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
208
			// 	_réponse:
210
			// 	_réponse:
209
			// ""
211
			// ""
210
			// 			Mettre à jour les mots cles
212
			// 			Mettre à jour les mots cles
211
			//	_OPTIONS
213
			//	_OPTIONS
212
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
214
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
213
			//	_GET
215
			//	_GET
214
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
216
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
215
			$( this ).parent( '.custom-tag' ).remove();
217
			$( this ).parent( '.custom-tag' ).remove();
216
		}
218
		}
217
	});
219
	});
218
};
220
};
219
 
221
 
220
WidgetPhotoPopup.prototype.defilerImage = function( sens ) {
222
WidgetPhotoPopup.prototype.defilerImage = function( sens ) {
-
 
223
	let indexDerniereImage = this.indexPremiereImage + this.urls.length;
221
	if ( 'suivant' === sens ) {
224
	if ( 'suivant' === sens ) {
222
		this.indexImage++ ;
225
		this.indexImage++ ;
223
		if( this.indexImage >= this.urls.length ) {
226
		if( this.indexImage >= indexDerniereImage ) {
224
			this.indexImage = 0;
227
			this.indexImage = 0;
225
		}
228
		}
226
	} else if ( 'precedent' === sens ) {
229
	} else if ( 'precedent' === sens ) {
227
		this.indexImage--;
230
		this.indexImage--;
228
		if( this.indexImage <= 0 ) {
231
		if( this.indexImage <= 0 ) {
229
			this.indexImage = this.urls.length -1;
232
			this.indexImage = indexDerniereImage -1;
230
		}
233
		}
231
	}
234
	}
232
	// @TODO: Modifier l'attr content de 'meta[property=og:image]' et y mettre l'url de l'image
235
	// @TODO: Modifier l'attr content de 'meta[property=og:image]' et y mettre l'url de l'image
233
	this.mettreAJourPopup();
236
	this.mettreAJourPopup();
234
};
237
};
235
 
238
 
236
WidgetPhotoPopup.prototype.afficherTitreImage = function() {
239
WidgetPhotoPopup.prototype.afficherTitreImage = function() {
237
	let lienContact  =
240
	let lienContact  =
238
			this.urlWidget +'?mode=contact&nn=' + this.nn +
241
			this.urlWidget +'?mode=contact&nn=' + this.nn +
239
			'&nom_sci=' + this.obs['nom_sel'] +
242
			'&nom_sci=' + this.obs['nom_sel'] +
240
			'&date=' + this.date +
243
			'&date=' + this.date +
241
			'&localisation=' + this.obs['localisation'] +
244
			'&localisation=' + this.obs['localisation'] +
242
			'&id_image=' + this.idImage +
245
			'&id_image=' + this.idImage +
243
			'&auteur=' + this.auteur;
246
			'&auteur=' + this.auteur;
244
 
247
 
245
	if ( this.valOk( this.popupUrl ) ) {
248
	if ( this.valOk( this.popupUrl ) ) {
246
		if (! this.popupUrl.match( new RegExp( 'img:' + this.idImage ) ) ) {
249
		if (! this.popupUrl.match( new RegExp( 'img:' + this.idImage ) ) ) {
247
			this.popupUrl = this.actualiserPopupUrl( this.popupUrl, this.urlThisImage );
250
			this.popupUrl = this.actualiserPopupUrl( this.popupUrl, this.urlThisImage );
248
		}
251
		}
249
		lienContact += '&popup_url=' + encodeURIComponent( this.popupUrl );
252
		lienContact += '&popup_url=' + encodeURIComponent( this.popupUrl );
250
	}
253
	}
251
 
254
 
252
	$( '#bloc-infos-img' ).html(
255
	$( '#bloc-infos-img' ).html(
253
		this.afficherLien( this.urlLienEflore, this.obs['nom_sel'] )+
256
		this.afficherLien( this.urlLienEflore, this.obs['nom_sel'] )+
254
		' par '+
257
		' par '+
255
		'<a class="lien_contact" href="' + lienContact + '">' + this.auteur + '</a> '+
258
		'<a class="lien_contact" href="' + lienContact + '">' + this.auteur + '</a> '+
256
		' le ' + this.date + ' - ' + this.obs['localisation']
259
		' le ' + this.date + ' - ' + this.obs['localisation']
257
	);
260
	);
258
};
261
};
259
 
262
 
260
WidgetPhotoPopup.prototype.actualiserPopupUrl = function( queryString, remplacement ) {
263
WidgetPhotoPopup.prototype.actualiserPopupUrl = function( queryString, remplacement ) {
261
	let queryStringParsee = queryString.substring(1).split('&');
264
	let queryStringParsee = queryString.substring(1).split('&');
262
 
265
 
263
	$.each( queryStringParsee,  function( i, param ) {
266
	$.each( queryStringParsee,  function( i, param ) {
264
		if( /url_image/.test( param ) ) {
267
		if( /url_image/.test( param ) ) {
265
			queryString = queryString.replace( param, 'url_image=' + remplacement );
268
			queryString = queryString.replace( param, 'url_image=' + remplacement );
266
			return false;
269
			return false;
267
		}
270
		}
268
	});
271
	});
269
	return queryString;
272
	return queryString;
270
};
273
};
271
 
274
 
272
WidgetPhotoPopup.prototype.redimentionnerModaleCarousel = function() {
275
WidgetPhotoPopup.prototype.redimentionnerModaleCarousel = function() {
273
	this.redimensionnerGalerie();
276
	this.redimensionnerGalerie();
274
	if ( window.matchMedia( '(max-width: 991px)' ).matches ) {
277
	if ( window.matchMedia( '(max-width: 991px)' ).matches ) {
275
		$( '#volet, #retour-galerie' ).addClass( 'hidden' );
278
		$( '#volet, #retour-galerie' ).addClass( 'hidden' );
276
		$( '#info-img-galerie' ).removeClass( 'hidden' );
279
		$( '#info-img-galerie' ).removeClass( 'hidden' );
277
		$( '.bouton-fct.actif' ).removeClass( 'actif' );
280
		$( '.bouton-fct.actif' ).removeClass( 'actif' );
278
		$( '.nettoyage-volet.haut' ).text( $( '#bloc-infos-img' ).text() );
281
		$( '.nettoyage-volet.haut' ).text( $( '#bloc-infos-img' ).text() );
279
		$( '#boutons-footer, #info-img-galerie' ).removeClass( 'col-lg-8' );
282
		$( '#boutons-footer, #info-img-galerie' ).removeClass( 'col-lg-8' );
280
		$( '#bloc-infos-img, #volet' ).removeClass( 'col-lg-4' );
283
		$( '#bloc-infos-img, #volet' ).removeClass( 'col-lg-4' );
281
	} else {
284
	} else {
282
		$( '#volet, #info-img-galerie' ).removeClass( 'hidden' );
285
		$( '#volet, #info-img-galerie' ).removeClass( 'hidden' );
283
		if ( this.valOk( $( '.bloc-volet:not(.hidden)' ) ) ) {
286
		if ( this.valOk( $( '.bloc-volet:not(.hidden)' ) ) ) {
284
			$( '.bouton-fct.' + $( '.bloc-volet:not(.hidden)' ).data( 'volet' ) ).addClass( 'actif' );
287
			$( '.bouton-fct.' + $( '.bloc-volet:not(.hidden)' ).data( 'volet' ) ).addClass( 'actif' );
285
		}
288
		}
286
		$( '.nettoyage-volet.bas' ).text( $( '#bloc-infos-img' ).text() );
289
		$( '.nettoyage-volet.bas' ).text( $( '#bloc-infos-img' ).text() );
287
		$( '#boutons-footer, #info-img-galerie' ).addClass( 'col-lg-8' );
290
		$( '#boutons-footer, #info-img-galerie' ).addClass( 'col-lg-8' );
288
		$( '#bloc-infos-img, #volet' ).addClass( 'col-lg-4' );
291
		$( '#bloc-infos-img, #volet' ).addClass( 'col-lg-4' );
289
		$( '#retour-galerie' ).addClass( 'hidden' );
292
		$( '#retour-galerie' ).addClass( 'hidden' );
290
	}
293
	}
291
};
294
};
292
 
295
 
293
WidgetPhotoPopup.prototype.redimensionnerGalerie = function() {
296
WidgetPhotoPopup.prototype.redimensionnerGalerie = function() {
294
	var maxSize = ( $( window ).width() / $( window ).height() ) < 1 ? $( window ).width() : $( window ).height();
297
	var maxSize = ( $( window ).width() / $( window ).height() ) < 1 ? $( window ).width() : $( window ).height();
295
 
298
 
296
	maxSize -= 30;
299
	maxSize -= 30;
297
	$( '.carousel-item img' ).each( function( index, image ) {
300
	$( '.carousel-item img' ).each( function( index, image ) {
298
		var proportion  = image.dataset.width / image.dataset.height,
301
		var proportion  = image.dataset.width / image.dataset.height,
299
			cssResize   = {};
302
			cssResize   = {};
300
 
303
 
301
		if ( proportion >= 1 ) {
304
		if ( proportion >= 1 ) {
302
			cssResize['width'] = maxSize;
305
			cssResize['width'] = maxSize;
303
		}
306
		}
304
		if ( proportion <= 1) {
307
		if ( proportion <= 1) {
305
			cssResize['height'] = maxSize;
308
			cssResize['height'] = maxSize;
306
		}
309
		}
307
		$( image ).css( cssResize );
310
		$( image ).css( cssResize );
308
	});
311
	});
309
};
312
};
310
 
313
 
311
WidgetPhotoPopup.prototype.ouvrirVoletFct = function( voletAOuvrir, voletAFermer ) {
314
WidgetPhotoPopup.prototype.ouvrirVoletFct = function( voletAOuvrir, voletAFermer ) {
312
	if( voletAOuvrir !== voletAFermer ) {
315
	if( voletAOuvrir !== voletAFermer ) {
313
		$( '#boutons-footer  .' + voletAFermer ).removeClass( 'actif' );
316
		$( '#boutons-footer  .' + voletAFermer ).removeClass( 'actif' );
314
		$( '#boutons-footer  .' + voletAOuvrir ).addClass( 'actif' );
317
		$( '#boutons-footer  .' + voletAOuvrir ).addClass( 'actif' );
315
		$( '#bloc-' + voletAFermer ).addClass( 'hidden' );
318
		$( '#bloc-' + voletAFermer ).addClass( 'hidden' );
316
		$( '#bloc-' + voletAOuvrir ).removeClass( 'hidden' );
319
		$( '#bloc-' + voletAOuvrir ).removeClass( 'hidden' );
317
		$( '#volet' ).scrollTop(0);
320
		$( '#volet' ).scrollTop(0);
318
		$( '#retour-metas' ).removeClass( 'hidden', 'meta' === voletAOuvrir );
321
		$( '#retour-metas' ).removeClass( 'hidden', 'meta' === voletAOuvrir );
319
	}
322
	}
320
};
323
};
321
 
324
 
322
WidgetPhotoPopup.prototype.tagsPfCustom = function() {
325
WidgetPhotoPopup.prototype.tagsPfCustom = function() {
323
	const lthis = this;
326
	const lthis = this;
324
 
327
 
325
	$( '#saisir-tag' ).on( 'blur keyup', function( event ) {
328
	$( '#saisir-tag' ).on( 'blur keyup', function( event ) {
326
		event = ( event || window.event );
329
		event = ( event || window.event );
327
 
330
 
328
		var ajouterTag = ( 'blur' === event.type );
331
		var ajouterTag = ( 'blur' === event.type );
329
 
332
 
330
		// event.keyCode déprécié, on tente d'abord event.key
333
		// event.keyCode déprécié, on tente d'abord event.key
331
		if ( 'key' in event  ) {
334
		if ( 'key' in event  ) {
332
			if ( 'Enter' === event.key ) {
335
			if ( 'Enter' === event.key ) {
333
				ajouterTag = true;
336
				ajouterTag = true;
334
			}
337
			}
335
		} else if ( 13 === event.keyCode ) {
338
		} else if ( 13 === event.keyCode ) {
336
			ajouterTag = true;
339
			ajouterTag = true;
337
		}
340
		}
338
		if	( ajouterTag ) {
341
		if	( ajouterTag ) {
339
			var nouveauTag     = $( this ).val(),
342
			var nouveauTag     = $( this ).val(),
340
				nouveauTagAttr = lthis.chaineValableAttributsHtml( nouveauTag.toLowerCase() );
343
				nouveauTagAttr = lthis.chaineValableAttributsHtml( nouveauTag.toLowerCase() );
341
 
344
 
342
			if( lthis.valOk( nouveauTagAttr ) && !lthis.valOk( $( '#' + nouveauTagAttr + '.tag' ) ) ) {
345
			if( lthis.valOk( nouveauTagAttr ) && !lthis.valOk( $( '#' + nouveauTagAttr + '.tag' ) ) ) {
343
				// 			Envoyer tags en ajax :
346
				// 			Envoyer tags en ajax :
344
				// 	_OPTIONS
347
				// 	_OPTIONS
345
				// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/
348
				// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/
346
				//  _paramètres :
349
				//  _paramètres :
347
				//rien
350
				//rien
348
				// 	_PUT
351
				// 	_PUT
349
				// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/
352
				// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/
350
				// 	_paramètres :
353
				// 	_paramètres :
351
				// image=197938&mot_cle=motcleperso&auteur.id=44084
354
				// image=197938&mot_cle=motcleperso&auteur.id=44084
352
				// 			Mettre à jour les mots cles
355
				// 			Mettre à jour les mots cles
353
				//	_OPTIONS
356
				//	_OPTIONS
354
				// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
357
				// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
355
				//	_GET
358
				//	_GET
356
				// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
359
				// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
357
				$( '#tags-pf-supp' ).append(
360
				$( '#tags-pf-supp' ).append(
358
					'<a id="' + nouveauTagAttr + '" class="btn tag custom-tag actif">' +
361
					'<a id="' + nouveauTagAttr + '" class="btn tag custom-tag actif">' +
359
						nouveauTag + '&nbsp;<i class="fas fa-times-circle fermer"></i>' +
362
						nouveauTag + '&nbsp;<i class="fas fa-times-circle fermer"></i>' +
360
					'</a>'
363
					'</a>'
361
				);
364
				);
362
				$( '#form-tags-auteur' )[0].reset();
365
				$( '#form-tags-auteur' )[0].reset();
363
				$( this ).val( '' );
366
				$( this ).val( '' );
364
			}
367
			}
365
		}
368
		}
366
	});
369
	});
367
};
370
};
368
 
371
 
369
WidgetPhotoPopup.prototype.traiterMetas = function() {
372
WidgetPhotoPopup.prototype.traiterMetas = function() {
370
	this.afficherMetas();
373
	this.afficherMetas();
371
	this.afficherPopupLocalisation();
374
	this.afficherPopupLocalisation();
372
	this.afficherMetasPlus();
375
	this.afficherMetasPlus();
373
	this.fournirLienTelechargement();
376
	this.fournirLienTelechargement();
374
};
377
};
375
 
378
 
376
WidgetPhotoPopup.prototype.afficherMetas = function() {
379
WidgetPhotoPopup.prototype.afficherMetas = function() {
377
	const lthis         = this;
380
	const lthis         = this;
378
	const META_CONTENUS = {
381
	const META_CONTENUS = {
379
		'nom' : this.afficherLien( this.urlLienEflore, this.obs['nom_sel'] ),
382
		'nom' : this.afficherLien( this.urlLienEflore, this.obs['nom_sel'] ),
380
		'localisation' : this.obs['localisation'],
383
		'localisation' : this.obs['localisation'],
381
		'auteur' : this.auteur,
384
		'auteur' : this.auteur,
382
		'date-obs' : this.date,
385
		'date-obs' : this.date,
383
		'commentaire' : this.obs['commentaire'],
386
		'commentaire' : this.obs['commentaire'],
384
		'certitude' : this.obs['certitude'],
387
		'certitude' : this.obs['certitude'],
385
		'fiabilite' : this.obs['fiabilite'],
388
		'fiabilite' : this.obs['fiabilite'],
386
		'num-photo' : this.idImage,
389
		'num-photo' : this.idImage,
387
		'titre-original' : this.item['nom_original'],
390
		'titre-original' : this.item['nom_original'],
388
		'date-photo' : this.formaterDate( this.item['date_photo'] ),
391
		'date-photo' : this.formaterDate( this.item['date_photo'] ),
389
		'attribution-copy' : this.item['attribution'],
392
		'attribution-copy' : this.item['attribution'],
390
		'url-copy' : this.urlThisImage
393
		'url-copy' : this.urlThisImage
391
	};
394
	};
392
 
395
 
393
	$.each( META_CONTENUS, function( attrId, contenu ) {
396
	$.each( META_CONTENUS, function( attrId, contenu ) {
394
		let $metaContainer = $( '#bloc-meta #'+attrId );
397
		let $metaContainer = $( '#bloc-meta #'+attrId );
395
 
398
 
396
		if ( lthis.valOk( contenu ) ) {
399
		if ( lthis.valOk( contenu ) ) {
397
			switch( attrId ) {
400
			switch( attrId ) {
398
				case 'attribution-copy' :
401
				case 'attribution-copy' :
399
				case 'url-copy' :
402
				case 'url-copy' :
400
					$metaContainer.val( contenu );
403
					$metaContainer.val( contenu );
401
					lthis.copieAutoChamp( $metaContainer );
404
					lthis.copieAutoChamp( $metaContainer );
402
					break;
405
					break;
403
				case 'nom' :
406
				case 'nom' :
404
					$( '.contenu', $metaContainer ).html( contenu );
407
					$( '.contenu', $metaContainer ).html( contenu );
405
					$( '.bouton', $metaContainer ).attr( 'href', lthis.urlLienEflore );
408
					$( '.bouton', $metaContainer ).attr( 'href', lthis.urlLienEflore );
406
					break;
409
					break;
407
				case 'auteur' :
410
				case 'auteur' :
408
					$( '.bouton', $metaContainer ).attr( 'href', lthis.item['urlProfil'] );
411
					$( '.bouton', $metaContainer ).attr( 'href', lthis.item['urlProfil'] );
409
				default:
412
				default:
410
					$( '.contenu', $metaContainer ).text( contenu );
413
					$( '.contenu', $metaContainer ).text( contenu );
411
					break;
414
					break;
412
			}
415
			}
413
		}
416
		}
414
	});
417
	});
415
};
418
};
416
 
419
 
417
WidgetPhotoPopup.prototype.copieAutoChamp = function( $champACopier ) {
420
WidgetPhotoPopup.prototype.copieAutoChamp = function( $champACopier ) {
418
	$champACopier.on( 'click', function() {
421
	$champACopier.on( 'click', function() {
419
 
422
 
420
		$( this ).select();
423
		$( this ).select();
421
		document.execCommand( 'copy' );
424
		document.execCommand( 'copy' );
422
 
425
 
423
		$( this ).after(
426
		$( this ).after(
424
			'<p class="copy-message alert-success" style="width: 100%; height:' + $( this ).outerHeight() + 'px; margin: 0; display:flex;">'+
427
			'<p class="copy-message alert-success" style="width: 100%; height:' + $( this ).outerHeight() + 'px; margin: 0; display:flex;">'+
425
				'<span style="margin:auto; font-size:1rem;">Copié dans le presse papier</span>'+
428
				'<span style="margin:auto; font-size:1rem;">Copié dans le presse papier</span>'+
426
			'</p>'
429
			'</p>'
427
		).addClass( 'hidden' );
430
		).addClass( 'hidden' );
428
 
431
 
429
		setTimeout( function() {
432
		setTimeout( function() {
430
			$( '.copy-message' ).remove();
433
			$( '.copy-message' ).remove();
431
			$champACopier.removeClass( 'hidden' );
434
			$champACopier.removeClass( 'hidden' );
432
		}, 1000 );
435
		}, 1000 );
433
	});
436
	});
434
};
437
};
435
 
438
 
436
WidgetPhotoPopup.prototype.afficherMetasPlus = function() {
439
WidgetPhotoPopup.prototype.afficherMetasPlus = function() {
437
	const lthis         = this;
440
	const lthis         = this;
438
	const META_LABELS  = {
441
	const META_LABELS  = {
439
		'id_obs' : 'observation n°',
442
		'id_obs' : 'observation n°',
440
		'projet' : 'projet',
443
		'projet' : 'projet',
441
		'nom_referentiel' : 'réferentiel',
444
		'nom_referentiel' : 'réferentiel',
442
		'date_obs' : 'date d´observation',
445
		'date_obs' : 'date d´observation',
443
		'nom_sel': 'nom scientifique',
446
		'nom_sel': 'nom scientifique',
444
		'nom_sel_nn' : 'nom scientifique n°',
447
		'nom_sel_nn' : 'nom scientifique n°',
445
		'nom_ret' : 'nom retenu',
448
		'nom_ret' : 'nom retenu',
446
		'nom_ret_nn' : 'nom retenu n°',
449
		'nom_ret_nn' : 'nom retenu n°',
447
		'famille' : 'famille',
450
		'famille' : 'famille',
448
		'tags_obs' : 'tags de l´observation',
451
		'tags_obs' : 'tags de l´observation',
449
		'lieudit' : 'lieu dit',
452
		'lieudit' : 'lieu dit',
450
		'station' : 'station',
453
		'station' : 'station',
451
		'milieu' : 'milieu',
454
		'milieu' : 'milieu',
452
		'latitude' : 'latitude',
455
		'latitude' : 'latitude',
453
		'longitude' : 'longitude',
456
		'longitude' : 'longitude',
454
		'altitude' : 'altitude',
457
		'altitude' : 'altitude',
455
		'localisation_precision': 'précision de la localisation',
458
		'localisation_precision': 'précision de la localisation',
456
		'code_insee' : 'code insee de la commune',
459
		'code_insee' : 'code insee de la commune',
457
		'dept' : 'département',
460
		'dept' : 'département',
458
		'pays' : 'pays',
461
		'pays' : 'pays',
459
		'est_ip_valide' : 'validée sur identiplante',
462
		'est_ip_valide' : 'validée sur identiplante',
460
		'score_ip' : 'score identiplante',
463
		'score_ip' : 'score identiplante',
461
		'url_ip' : 'url identiplante',
464
		'url_ip' : 'url identiplante',
462
		'abondance' : 'abondance',
465
		'abondance' : 'abondance',
463
		'phenologie' : 'phénologie',
466
		'phenologie' : 'phénologie',
464
		'spontaneite' : 'spontaneite',
467
		'spontaneite' : 'spontaneite',
465
		'type_donnees' : 'type de donnees',
468
		'type_donnees' : 'type de donnees',
466
		'biblio' : 'bibliographie',
469
		'biblio' : 'bibliographie',
467
		'source' : 'source',
470
		'source' : 'source',
468
		'herbier' : 'herbier',
471
		'herbier' : 'herbier',
469
		'observateur' : 'observateur',
472
		'observateur' : 'observateur',
470
		'observateur_structure' : 'structure'
473
		'observateur_structure' : 'structure'
471
	};
474
	};
472
 
475
 
473
	const $contenuPlusMeta  = $( '#contenu-meta-plus' );
476
	const $contenuPlusMeta  = $( '#contenu-meta-plus' );
474
	let degres = $contenuPlusMeta.is( ':visible' ) ? '180' : '0';
477
	let degres = $contenuPlusMeta.is( ':visible' ) ? '180' : '0';
475
 
478
 
476
	this.rotationFleche( degres );
479
	this.rotationFleche( degres );
477
	$contenuPlusMeta.empty();
480
	$contenuPlusMeta.empty();
478
 
481
 
479
	$.each( META_LABELS, function( cle, label ) {
482
	$.each( META_LABELS, function( cle, label ) {
480
		let idAttr = cle.replace( '_', '-' ),
483
		let idAttr = cle.replace( '_', '-' ),
481
			contenu = lthis.obs[cle];
484
			contenu = lthis.obs[cle];
482
 
485
 
483
		switch( cle ) {
486
		switch( cle ) {
484
			case 'nom_sel':
487
			case 'nom_sel':
485
				contenu = lthis.afficherLien( lthis.urlLienEflore, contenu );
488
				contenu = lthis.afficherLien( lthis.urlLienEflore, contenu );
486
				break;
489
				break;
487
 
490
 
488
			case 'nom_ret':
491
			case 'nom_ret':
489
				let urlEfloreNomRetenu = lthis.urlLienEflore.replace( lthis.obs['nom_sel_nn'], lthis.obs['nom_ret_nn'] );
492
				let urlEfloreNomRetenu = lthis.urlLienEflore.replace( lthis.obs['nom_sel_nn'], lthis.obs['nom_ret_nn'] );
490
 
493
 
491
				contenu = lthis.afficherLien( urlEfloreNomRetenu, contenu );
494
				contenu = lthis.afficherLien( urlEfloreNomRetenu, contenu );
492
				break;
495
				break;
493
 
496
 
494
			case 'url_ip':
497
			case 'url_ip':
495
				contenu = lthis.afficherLien( contenu, contenu );
498
				contenu = lthis.afficherLien( contenu, contenu );
496
				break;
499
				break;
497
 
500
 
498
			case 'est_ip_valide':
501
			case 'est_ip_valide':
499
			case 'herbier':
502
			case 'herbier':
500
				if( '0' === contenu ) {
503
				if( '0' === contenu ) {
501
					contenu = 'non';
504
					contenu = 'non';
502
				}
505
				}
503
				break;
506
				break;
504
 
507
 
505
			case 'date_obs':
508
			case 'date_obs':
506
				contenu = lthis.formaterDate( contenu );
509
				contenu = lthis.formaterDate( contenu );
507
				break;
510
				break;
508
 
511
 
509
			case 'tags_obs':
512
			case 'tags_obs':
510
				let tagsObsLength = lthis.tagsObs.length;
513
				let tagsObsLength = lthis.tagsObs.length;
511
				contenu = lthis.tagsObs.join( '<br>' );
514
				contenu = lthis.tagsObs.join( '<br>' );
512
				break;
515
				break;
513
 
516
 
514
			default:
517
			default:
515
				break;
518
				break;
516
		}
519
		}
517
 
520
 
518
		if ( lthis.valOk( contenu ) ) {
521
		if ( lthis.valOk( contenu ) ) {
519
			$contenuPlusMeta.append(
522
			$contenuPlusMeta.append(
520
				'<li id="' + idAttr + '-meta-plus" class="row">'+
523
				'<li id="' + idAttr + '-meta-plus" class="row">'+
521
					'<div class="col-5 label">' + label.charAt( 0 ).toUpperCase() + label.slice( 1 ) + '</div>'+
524
					'<div class="col-5 label">' + label.charAt( 0 ).toUpperCase() + label.slice( 1 ) + '</div>'+
522
					'<div class="col-7 contenu">' + contenu + '</div>'+
525
					'<div class="col-7 contenu">' + contenu + '</div>'+
523
				'</li>'
526
				'</li>'
524
			);
527
			);
525
		}
528
		}
526
	});
529
	});
527
 
530
 
528
	if( !$contenuPlusMeta.hasClass( 'actif' ) ) {
531
	if( !$contenuPlusMeta.hasClass( 'actif' ) ) {
529
		$contenuPlusMeta.hide();
532
		$contenuPlusMeta.hide();
530
	}
533
	}
531
 
534
 
532
	let estVisible = false;
535
	let estVisible = false;
533
 
536
 
534
	$( '#plus-meta' ).off( 'click' ).on( 'click', function( event ) {
537
	$( '#plus-meta' ).off( 'click' ).on( 'click', function( event ) {
535
		event.preventDefault();
538
		event.preventDefault();
536
		$contenuPlusMeta.toggle( 200, function() {
539
		$contenuPlusMeta.toggle( 200, function() {
537
			estVisible = $contenuPlusMeta.is( ':visible' );
540
			estVisible = $contenuPlusMeta.is( ':visible' );
538
			degres     = estVisible ? '180' : '0';
541
			degres     = estVisible ? '180' : '0';
539
			$( this ).toggleClass( 'actif', estVisible );
542
			$( this ).toggleClass( 'actif', estVisible );
540
			lthis.rotationFleche( degres );
543
			lthis.rotationFleche( degres );
541
		});
544
		});
542
	});
545
	});
543
};
546
};
544
 
547
 
545
WidgetPhotoPopup.prototype.rotationFleche = function( degres ) {
548
WidgetPhotoPopup.prototype.rotationFleche = function( degres ) {
546
	$( '#plus-meta i' ).css({
549
	$( '#plus-meta i' ).css({
547
		'-webkit-transform' : 'rotate('+ degres +'deg)',
550
		'-webkit-transform' : 'rotate('+ degres +'deg)',
548
		'-moz-transform' : 'rotate('+ degres +'deg)',
551
		'-moz-transform' : 'rotate('+ degres +'deg)',
549
		'-ms-transform' : 'rotate('+ degres +'deg)',
552
		'-ms-transform' : 'rotate('+ degres +'deg)',
550
		'transform' : 'rotate('+ degres +'deg)'
553
		'transform' : 'rotate('+ degres +'deg)'
551
	});
554
	});
552
};
555
};
553
 
556
 
554
WidgetPhotoPopup.prototype.fournirLienTelechargement = function() {
557
WidgetPhotoPopup.prototype.fournirLienTelechargement = function() {
555
	const lthis = this;
558
	const lthis = this;
556
 
559
 
557
	$( '#formats' ).on( 'change', function() {
560
	$( '#formats' ).on( 'change', function() {
558
		let format             = ( $( this ).val() || 'O' ),
561
		let format             = ( $( this ).val() || 'O' ),
559
			lienTelechargement = lthis.urlBaseTelechargement + lthis.idImage + '?methode=telecharger&format=' + format;
562
			lienTelechargement = lthis.urlBaseTelechargement + lthis.idImage + '?methode=telecharger&format=' + format;
560
 
563
 
561
		$( '#telecharger' ).attr( 'href', lienTelechargement );
564
		$( '#telecharger' ).attr( 'href', lienTelechargement );
562
	});
565
	});
563
 
566
 
564
	$( '#formats' ).trigger( 'change' );
567
	$( '#formats' ).trigger( 'change' );
565
};
568
};
566
 
569
 
567
 
570
 
568
WidgetPhotoPopup.prototype.afficherPopupLocalisation = function() {
571
WidgetPhotoPopup.prototype.afficherPopupLocalisation = function() {
569
	const lthis = this;
572
	const lthis = this;
570
 
573
 
571
	$( '#localisation a.bouton' ).on( 'click', function( event ){
574
	$( '#localisation a.bouton' ).on( 'click', function( event ){
572
		event.preventDefault();
575
		event.preventDefault();
573
 
576
 
574
		$( this ).after(
577
		$( this ).after(
575
			'<div id="localisation-map-container">'+
578
			'<div id="localisation-map-container">'+
576
				'<button id="map-close" type="button" class="bouton btn btn-sm btn-outline-secondary" aria-label="Close">'+
579
				'<button id="map-close" type="button" class="bouton btn btn-sm btn-outline-secondary" aria-label="Close">'+
577
					'<span aria-hidden="true">×</span>'+
580
					'<span aria-hidden="true">×</span>'+
578
				'</button>'+
581
				'</button>'+
579
				'<div id="localisation-map"></div>'+
582
				'<div id="localisation-map"></div>'+
580
			'</div>'
583
			'</div>'
581
		);
584
		);
582
 
585
 
583
		let lat = lthis.obs['latitude'],
586
		let lat = lthis.obs['latitude'],
584
			lng = lthis.obs['longitude'],
587
			lng = lthis.obs['longitude'],
585
			map = L.map( 'localisation-map', {
588
			map = L.map( 'localisation-map', {
586
				zoomControl: true,
589
				zoomControl: true,
587
				dragging: false,
590
				dragging: false,
588
				scrollWheelZoom: 'center'
591
				scrollWheelZoom: 'center'
589
			} ).setView( [lat, lng], 12 );
592
			} ).setView( [lat, lng], 12 );
590
 
593
 
591
		map.markers = [];
594
		map.markers = [];
592
 
595
 
593
		L.tileLayer(
596
		L.tileLayer(
594
			'https://osm.tela-botanica.org/tuiles/osmfr/{z}/{x}/{y}.png',
597
			'https://osm.tela-botanica.org/tuiles/osmfr/{z}/{x}/{y}.png',
595
			{
598
			{
596
				attribution: 'Data © <a href="http://osm.org/copyright">OpenStreetMap</a>',
599
				attribution: 'Data © <a href="http://osm.org/copyright">OpenStreetMap</a>',
597
				maxZoom: 18
600
				maxZoom: 18
598
			}
601
			}
599
		).addTo( map );
602
		).addTo( map );
600
 
603
 
601
		map.addLayer( new L.FeatureGroup() );
604
		map.addLayer( new L.FeatureGroup() );
602
 
605
 
603
		let marker = new L.Marker(
606
		let marker = new L.Marker(
604
			{
607
			{
605
				'lat': lat,
608
				'lat': lat,
606
				'lng': lng
609
				'lng': lng
607
			},
610
			},
608
			{
611
			{
609
				draggable: false,
612
				draggable: false,
610
			}
613
			}
611
		);
614
		);
612
 
615
 
613
 
616
 
614
		map.addLayer( marker );
617
		map.addLayer( marker );
615
		map.markers.push( marker );
618
		map.markers.push( marker );
616
 
619
 
617
		$( '#map-close' ).on( 'click', function( event ){
620
		$( '#map-close' ).on( 'click', function( event ){
618
			$( '#localisation-map-container' ).remove();
621
			$( '#localisation-map-container' ).remove();
619
		});
622
		});
620
	});
623
	});
621
 
624
 
622
	$( '#fenetre-modal' ).on( 'click', function( event ) {
625
	$( '#fenetre-modal' ).on( 'click', function( event ) {
623
		if(
626
		if(
624
			!$( event.target ).closest( '#localisation-map-container' ).length
627
			!$( event.target ).closest( '#localisation-map-container' ).length
625
			&& !$( event.target ).closest( '#obs-localisation' ).length
628
			&& !$( event.target ).closest( '#obs-localisation' ).length
626
		) {
629
		) {
627
			$( '#localisation-map-container' ).remove();
630
			$( '#localisation-map-container' ).remove();
628
		}
631
		}
629
	});
632
	});
630
};
633
};
631
 
634
 
632
 
635
 
633
WidgetPhotoPopup.prototype.regenererMiniature = function() {
636
WidgetPhotoPopup.prototype.regenererMiniature = function() {
634
	const lthis = this;
637
	const lthis = this;
635
	$( '#regenerer-miniature' ).off( 'click' ).on( 'click', function( event ) {
638
	$( '#regenerer-miniature' ).off( 'click' ).on( 'click', function( event ) {
636
		event.preventDefault();
639
		event.preventDefault();
637
 
640
 
638
		let url = lthis.urlServiceRegenererMiniature + lthis.idImage;
641
		let url = lthis.urlServiceRegenererMiniature + lthis.idImage;
639
 
642
 
640
		$.get( url, function( data ) {
643
		$.get( url, function( data ) {
641
				console.log( data );
644
				console.log( data );
642
			}
645
			}
643
		).fail( function() {
646
		).fail( function() {
644
			console.log( 'La régénérétion d´image ne s´est pas faite' );
647
			console.log( 'La régénérétion d´image ne s´est pas faite' );
645
		});
648
		});
646
	});
649
	});
647
};
650
};
648
 
651
 
649
WidgetPhotoPopup.prototype.formaterDate = function( sqlDate ) {
652
WidgetPhotoPopup.prototype.formaterDate = function( sqlDate ) {
650
	dateFormatee = sqlDate
653
	dateFormatee = sqlDate
651
		.substring( 0, 10 )
654
		.substring( 0, 10 )
652
		.split( '-' )
655
		.split( '-' )
653
		.reverse()
656
		.reverse()
654
		.join('/');
657
		.join('/');
655
 
658
 
656
	return dateFormatee;
659
	return dateFormatee;
657
};
660
};
658
 
661
 
659
WidgetPhotoPopup.prototype.afficherLien = function( url, nom ) {
662
WidgetPhotoPopup.prototype.afficherLien = function( url, nom ) {
660
	if( !/https?:\/\//.test( url ) ) {
663
	if( !/https?:\/\//.test( url ) ) {
661
		url = 'https://' + url;
664
		url = 'https://' + url;
662
	}
665
	}
663
	return '<a href="' + url + '" target="_blank">' + nom + '</a> ';
666
	return '<a href="' + url + '" target="_blank">' + nom + '</a> ';
664
};
667
};
665
 
668
 
666
WidgetPhotoPopup.prototype.fournirLienIdentiplante = function() {
669
WidgetPhotoPopup.prototype.fournirLienIdentiplante = function() {
667
	const lthis = this;
670
	const lthis = this;
668
	$( '.signaler-erreur-obs' ).each( function() {
671
	$( '.signaler-erreur-obs' ).each( function() {
669
		$( this ).attr( 'href', lthis.urlIP );
672
		$( this ).attr( 'href', lthis.urlIP );
670
	});
673
	});
671
};
674
};
672
 
675
 
673
// WidgetPhotoPopup.prototype.afficherTags = function() {
676
// WidgetPhotoPopup.prototype.afficherTags = function() {
674
// 	const lthis = this;
677
// 	const lthis = this;
675
// 	const TAGS_BASE = [
678
// 	const TAGS_BASE = [
676
// 		'port',
679
// 		'port',
677
// 		'fleur',
680
// 		'fleur',
678
// 		'fruit',
681
// 		'fruit',
679
// 		'feuille',
682
// 		'feuille',
680
// 		'ecorce',
683
// 		'ecorce',
681
// 		'rameau',
684
// 		'rameau',
682
// 		'planche',
685
// 		'planche',
683
// 		'insecte'
686
// 		'insecte'
684
// 	];
687
// 	];
685
 
688
 
686
	
689
	
687
// };
690
// };