Subversion Repositories eFlore/Applications.cel

Rev

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