Subversion Repositories eFlore/Applications.cel

Rev

Rev 3631 | Rev 3824 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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