Subversion Repositories eFlore/Applications.cel

Rev

Rev 3832 | Rev 3837 | 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;
3833 idir 6
		this.indexPremiereImage           = proprietes.indexImage;
7
		this.indexImage                   = this.indexPremiereImage;
3823 idir 8
		this.urlImage                     = proprietes.urlImage;
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();
22
	if( this.valOk( this.urlImage, false, 'null' ) ) {
3823 idir 23
 
3833 idir 24
		this.indexImage = this.indexPremiereImage + this.urls.indexOf( this.urlImage );
25
	console.log(this.indexImage);
3823 idir 26
 
3631 idir 27
		$( '#info-img-galerie' ).find( '.active' ).removeClass( 'active' );
28
		$( '#img-cadre-' + this.indexImage + ',#indicateur-img-' + this.indexImage ).addClass( 'active' );
3823 idir 29
 
30
		this.mettreAJourPopup();
3631 idir 31
	}
3823 idir 32
 
3631 idir 33
	this.redimentionnerModaleCarousel();
34
};
35
 
36
WidgetPhotoPopup.prototype.initEvts = function() {
37
	const lthis = this;
38
 
39
	this.initEvtsDefilerImage();
40
	this.initEvtsContact();
41
	$( window ).on( 'resize', lthis.redimentionnerModaleCarousel.bind( lthis ) );
3823 idir 42
	this.initEvtsFonctionsPhoto();
3631 idir 43
	this.initEvtsRetourGalerieResponsive();
44
	this.initEvtsTagsPF();
45
};
46
 
3823 idir 47
WidgetPhotoPopup.prototype.mettreAJourPopup = function() {
48
	this.mettreAJourInfosImage();
49
	this.afficherTitreImage();
50
	this.traiterMetas();
51
	this.regenererMiniature();
52
	this.fournirLienIdentiplante();
53
};
54
 
55
WidgetPhotoPopup.prototype.mettreAJourInfosImage = function() {
3826 idir 56
	this.item          = this.infos_images[this.urls[this.indexImage]];
57
	this.titreImage    = this.item['titre'];
3825 idir 58
	this.urlLienEflore = this.item['lien'];
3826 idir 59
	this.idImage       = this.item['id_photo'];
60
	this.urlThisImage  = this.item['url_photo']+'.jpg';
61
	this.obs           = this.item['obs'];
62
	this.nn            = '[nn' + this.obs['nom_sel_nn']+']';
63
	this.urlIP         = this.obs['url_ip'];
64
	this.tagsImage     = this.tagsToArray( this.item['tags_photo'] );
65
	this.tagsObs       = this.tagsToArray( this.obs['tags_obs'] );
66
	this.auteur        = this.item['utilisateur']['nom_utilisateur'];
67
	this.date          = this.item['date'];
3823 idir 68
};
69
 
3825 idir 70
WidgetPhotoPopup.prototype.tagsToArray = function( tags ) {
3832 idir 71
	if(!this.valOk(tags)) {
72
		return [];
73
	}
3825 idir 74
	tags = tags.replace( new RegExp('\\.'), '' ).split( ',' );
75
 
76
	let cleanTags       = [],
77
		nbTags          = tags.length,
78
		tag             = '',
79
		tagsSansEspaces = '',
80
		cleanTagIndex   = 0;
81
 
82
	for(let i = 0; i < nbTags; i++) {
83
		tag = tags[i];
84
		tagsSansEspaces = tag.replace( ' ', '');
85
		if( '' !== tagsSansEspaces ) {
86
			cleanTags.push( tag.trim() );
87
		}
88
	}
89
 
90
	return cleanTags;
91
};
92
 
3631 idir 93
WidgetPhotoPopup.prototype.initEvtsDefilerImage = function() {
94
	const lthis = this;
95
 
96
	$( '#precedent, #suivant' ).on( 'click', function() {
97
		lthis.defilerImage( this.id );
98
	});
3823 idir 99
 
3631 idir 100
	$( '#print_content:not(saisir-tag)' ).on( 'keydown', function( event ) {
101
 
3823 idir 102
		const determinerSens = function( enventKey, left, right ) {
103
			switch ( enventKey ) {
104
				case left:
105
					return 'suivant';
106
				case right:
3825 idir 107
					return 'precedent';
3823 idir 108
				default:
109
					break;
3631 idir 110
			}
3823 idir 111
 
112
			return;
3631 idir 113
		}
3823 idir 114
 
115
		event = (event || window.event);
116
		// event.keyCode déprécié, on tente d'abord event.key
117
		let sens = ( 'key' in event ) ? determinerSens( event.key, 'ArrowLeft', 'ArrowRight' ) : determinerSens( event.keyCode, 37, 39 );;
118
 
3631 idir 119
		if ( lthis.valOk( sens ) ) {
120
			lthis.defilerImage( sens );
121
		}
122
	});
123
};
124
 
125
WidgetPhotoPopup.prototype.initEvtsContact = function() {
126
	const lthis = this;
127
 
128
	$( '#bloc-infos-img' ).on( 'click', '.lien_contact', function( event ) {
129
		event.preventDefault();
130
		lthis.chargerContenuModale( this.href );
131
	});
132
};
133
 
3823 idir 134
WidgetPhotoPopup.prototype.initEvtsFonctionsPhoto = function() {
3631 idir 135
	const lthis = this;
136
 
137
	$( '#boutons-footer #bloc-fct a, #retour-metas' ).on( 'click', function( event ){
138
		event.preventDefault();
139
		var voletAOuvrir = $( this ).data( 'volet' ),
140
			voletAFermer = $( '.bloc-volet:not(.hidden)' ).data( 'volet' );
141
 
142
		lthis.ouvrirVoletFct( voletAOuvrir, voletAFermer );
143
		if ( window.matchMedia( '(max-width: 991px)' ).matches ) {
144
			$( '#info-img-galerie' ).addClass( 'hidden' );
145
			$( '#volet, #retour-galerie' ).removeClass( 'hidden' );
146
		}
147
	});
148
};
149
 
150
WidgetPhotoPopup.prototype.initEvtsRetourGalerieResponsive = function() {
151
	$( '#retour-galerie' ).on( 'click', function( event ) {
152
		event.preventDefault();
153
		$( '#info-img-galerie' ).removeClass( 'hidden' );
154
		$( this ).addClass( 'hidden' );
155
		if ( window.matchMedia( '(max-width: 991px)' ).matches ) {
156
			$( '#volet' ).addClass( 'hidden' );
157
			$( '.bouton-fct.actif' ).removeClass( 'actif' );
158
		}
159
	});
160
};
161
 
162
WidgetPhotoPopup.prototype.initEvtsTagsPF = function() {
163
	//recupérer tags en ajax (voir pictoflora, peut-être dans le php?)
164
	//	_OPTIONS
165
	// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
166
	//	_GET
167
	// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
168
	this.tagsPfCustom();
169
	$( '#bloc-tags' ).on( 'click', '.tag', function( event ) {
170
		event.preventDefault();
171
		$( this ).toggleClass( 'actif' );
172
	});
173
	$( '#bloc-tags' ).on( 'click', '.custom-tag.actif .fermer', function( event ) {
174
		event.preventDefault();
175
		//			Supprimer un custom-tag
176
		//	_OPTIONS
177
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
178
		// 	_paramètres
179
		// L'id du tag à la fin de l'url
180
		//	_DELETE
181
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
182
		// 	_réponse:
183
		// ""
184
		// 			Mettre à jour les mots cles
185
		//	_OPTIONS
186
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
187
		//	_GET
188
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
189
		$( this ).parent( '.custom-tag' ).remove();
190
	});
191
 
192
	$( '#bloc-tags' ).on( 'keyup', '.custom-tag.actif', function( event ) {
3823 idir 193
		let supprimerTag = false;
3631 idir 194
 
3823 idir 195
		event = ( event || window.event );
3631 idir 196
		// event.keyCode déprécié, on tente d'abord event.key
197
		if ( 'key' in event ) {
198
			supprimerTag = ( 'Delete' === event.key || 'Backspace' === event.key );
199
		} else {
200
			supprimerTag = ( 46 === event.keyCode || 8 === event.keyCode );
201
		}
202
		if ( supprimerTag ) {
3823 idir 203
			//			Supprimer un custom-tag
204
			//	_OPTIONS
205
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
206
			// 	_paramètres
207
			// L'id du tag à la fin de l'url
208
			//	_DELETE
209
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
210
			// 	_réponse:
211
			// ""
212
			// 			Mettre à jour les mots cles
213
			//	_OPTIONS
214
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
215
			//	_GET
216
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
3631 idir 217
			$( this ).parent( '.custom-tag' ).remove();
218
		}
219
	});
220
};
221
 
222
WidgetPhotoPopup.prototype.defilerImage = function( sens ) {
3833 idir 223
	let indexDerniereImage = this.indexPremiereImage + this.urls.length;
3823 idir 224
	if ( 'suivant' === sens ) {
3631 idir 225
		this.indexImage++ ;
3833 idir 226
		if( this.indexImage >= indexDerniereImage ) {
3631 idir 227
			this.indexImage = 0;
228
		}
3823 idir 229
	} else if ( 'precedent' === sens ) {
3631 idir 230
		this.indexImage--;
231
		if( this.indexImage <= 0 ) {
3833 idir 232
			this.indexImage = indexDerniereImage -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 ) {
3823 idir 421
	$champACopier.on( 'click', function() {
422
 
423
		$( this ).select();
424
		document.execCommand( 'copy' );
425
 
426
		$( this ).after(
427
			'<p class="copy-message alert-success" style="width: 100%; height:' + $( this ).outerHeight() + 'px; margin: 0; display:flex;">'+
428
				'<span style="margin:auto; font-size:1rem;">Copié dans le presse papier</span>'+
429
			'</p>'
430
		).addClass( 'hidden' );
431
 
432
		setTimeout( function() {
433
			$( '.copy-message' ).remove();
434
			$champACopier.removeClass( 'hidden' );
435
		}, 1000 );
436
	});
437
};
438
 
439
WidgetPhotoPopup.prototype.afficherMetasPlus = function() {
440
	const lthis         = this;
441
	const META_LABELS  = {
442
		'id_obs' : 'observation n°',
443
		'projet' : 'projet',
3825 idir 444
		'nom_referentiel' : 'réferentiel',
3823 idir 445
		'date_obs' : 'date d´observation',
446
		'nom_sel': 'nom scientifique',
447
		'nom_sel_nn' : 'nom scientifique n°',
448
		'nom_ret' : 'nom retenu',
449
		'nom_ret_nn' : 'nom retenu n°',
450
		'famille' : 'famille',
451
		'tags_obs' : 'tags de l´observation',
452
		'lieudit' : 'lieu dit',
453
		'station' : 'station',
454
		'milieu' : 'milieu',
455
		'latitude' : 'latitude',
456
		'longitude' : 'longitude',
457
		'altitude' : 'altitude',
458
		'localisation_precision': 'précision de la localisation',
459
		'code_insee' : 'code insee de la commune',
460
		'dept' : 'département',
461
		'pays' : 'pays',
462
		'est_ip_valide' : 'validée sur identiplante',
463
		'score_ip' : 'score identiplante',
464
		'url_ip' : 'url identiplante',
465
		'abondance' : 'abondance',
466
		'phenologie' : 'phénologie',
467
		'spontaneite' : 'spontaneite',
468
		'type_donnees' : 'type de donnees',
469
		'biblio' : 'bibliographie',
470
		'source' : 'source',
471
		'herbier' : 'herbier',
472
		'observateur' : 'observateur',
473
		'observateur_structure' : 'structure'
474
	};
3825 idir 475
 
3823 idir 476
	const $contenuPlusMeta  = $( '#contenu-meta-plus' );
3825 idir 477
	let degres = $contenuPlusMeta.is( ':visible' ) ? '180' : '0';
3823 idir 478
 
479
	this.rotationFleche( degres );
3825 idir 480
	$contenuPlusMeta.empty();
3823 idir 481
 
482
	$.each( META_LABELS, function( cle, label ) {
483
		let idAttr = cle.replace( '_', '-' ),
484
			contenu = lthis.obs[cle];
485
 
3825 idir 486
		switch( cle ) {
487
			case 'nom_sel':
488
				contenu = lthis.afficherLien( lthis.urlLienEflore, contenu );
489
				break;
490
 
491
			case 'nom_ret':
492
				let urlEfloreNomRetenu = lthis.urlLienEflore.replace( lthis.obs['nom_sel_nn'], lthis.obs['nom_ret_nn'] );
493
 
494
				contenu = lthis.afficherLien( urlEfloreNomRetenu, contenu );
495
				break;
496
 
497
			case 'url_ip':
498
				contenu = lthis.afficherLien( contenu, contenu );
499
				break;
500
 
501
			case 'est_ip_valide':
502
			case 'herbier':
503
				if( '0' === contenu ) {
504
					contenu = 'non';
505
				}
506
				break;
507
 
508
			case 'date_obs':
509
				contenu = lthis.formaterDate( contenu );
510
				break;
511
 
512
			case 'tags_obs':
513
				let tagsObsLength = lthis.tagsObs.length;
514
				contenu = lthis.tagsObs.join( '<br>' );
515
				break;
516
 
517
			default:
518
				break;
3823 idir 519
		}
520
 
521
		if ( lthis.valOk( contenu ) ) {
522
			$contenuPlusMeta.append(
523
				'<li id="' + idAttr + '-meta-plus" class="row">'+
524
					'<div class="col-5 label">' + label.charAt( 0 ).toUpperCase() + label.slice( 1 ) + '</div>'+
3829 idir 525
					'<div class="col-7 contenu">' + contenu + '</div>'+
3823 idir 526
				'</li>'
527
			);
528
		}
529
	});
530
 
3825 idir 531
	if( !$contenuPlusMeta.hasClass( 'actif' ) ) {
532
		$contenuPlusMeta.hide();
533
	}
534
 
535
	let estVisible = false;
536
 
3823 idir 537
	$( '#plus-meta' ).off( 'click' ).on( 'click', function( event ) {
538
		event.preventDefault();
539
		$contenuPlusMeta.toggle( 200, function() {
3825 idir 540
			estVisible = $contenuPlusMeta.is( ':visible' );
541
			degres     = estVisible ? '180' : '0';
542
			$( this ).toggleClass( 'actif', estVisible );
3823 idir 543
			lthis.rotationFleche( degres );
544
		});
545
	});
546
};
547
 
548
WidgetPhotoPopup.prototype.rotationFleche = function( degres ) {
549
	$( '#plus-meta i' ).css({
550
		'-webkit-transform' : 'rotate('+ degres +'deg)',
551
		'-moz-transform' : 'rotate('+ degres +'deg)',
552
		'-ms-transform' : 'rotate('+ degres +'deg)',
553
		'transform' : 'rotate('+ degres +'deg)'
554
	});
555
};
556
 
557
WidgetPhotoPopup.prototype.fournirLienTelechargement = function() {
558
	const lthis = this;
559
 
560
	$( '#formats' ).on( 'change', function() {
561
		let format             = ( $( this ).val() || 'O' ),
562
			lienTelechargement = lthis.urlBaseTelechargement + lthis.idImage + '?methode=telecharger&format=' + format;
563
 
564
		$( '#telecharger' ).attr( 'href', lienTelechargement );
565
	});
566
 
567
	$( '#formats' ).trigger( 'change' );
568
};
569
 
570
 
571
WidgetPhotoPopup.prototype.afficherPopupLocalisation = function() {
572
	const lthis = this;
573
 
574
	$( '#localisation a.bouton' ).on( 'click', function( event ){
575
		event.preventDefault();
576
 
577
		$( this ).after(
578
			'<div id="localisation-map-container">'+
579
				'<button id="map-close" type="button" class="bouton btn btn-sm btn-outline-secondary" aria-label="Close">'+
580
					'<span aria-hidden="true">×</span>'+
581
				'</button>'+
582
				'<div id="localisation-map"></div>'+
583
			'</div>'
584
		);
585
 
586
		let lat = lthis.obs['latitude'],
587
			lng = lthis.obs['longitude'],
588
			map = L.map( 'localisation-map', {
589
				zoomControl: true,
590
				dragging: false,
591
				scrollWheelZoom: 'center'
592
			} ).setView( [lat, lng], 12 );
593
 
594
		map.markers = [];
595
 
596
		L.tileLayer(
597
			'https://osm.tela-botanica.org/tuiles/osmfr/{z}/{x}/{y}.png',
598
			{
599
				attribution: 'Data © <a href="http://osm.org/copyright">OpenStreetMap</a>',
600
				maxZoom: 18
601
			}
602
		).addTo( map );
603
 
604
		map.addLayer( new L.FeatureGroup() );
605
 
606
		let marker = new L.Marker(
607
			{
608
				'lat': lat,
609
				'lng': lng
610
			},
611
			{
612
				draggable: false,
613
			}
614
		);
615
 
616
 
617
		map.addLayer( marker );
618
		map.markers.push( marker );
619
 
620
		$( '#map-close' ).on( 'click', function( event ){
621
			$( '#localisation-map-container' ).remove();
622
		});
623
	});
624
 
625
	$( '#fenetre-modal' ).on( 'click', function( event ) {
626
		if(
627
			!$( event.target ).closest( '#localisation-map-container' ).length
628
			&& !$( event.target ).closest( '#obs-localisation' ).length
629
		) {
630
			$( '#localisation-map-container' ).remove();
631
		}
632
	});
633
};
634
 
635
 
636
WidgetPhotoPopup.prototype.regenererMiniature = function() {
637
	const lthis = this;
638
	$( '#regenerer-miniature' ).off( 'click' ).on( 'click', function( event ) {
639
		event.preventDefault();
640
 
641
		let url = lthis.urlServiceRegenererMiniature + lthis.idImage;
642
 
3829 idir 643
		$.get( url, function( data ) {
644
				console.log( data );
645
			}
646
		).fail( function() {
647
			console.log( 'La régénérétion d´image ne s´est pas faite' );
3823 idir 648
		});
649
	});
650
};
651
 
652
WidgetPhotoPopup.prototype.formaterDate = function( sqlDate ) {
653
	dateFormatee = sqlDate
654
		.substring( 0, 10 )
655
		.split( '-' )
656
		.reverse()
657
		.join('/');
658
 
659
	return dateFormatee;
660
};
661
 
3825 idir 662
WidgetPhotoPopup.prototype.afficherLien = function( url, nom ) {
663
	if( !/https?:\/\//.test( url ) ) {
664
		url = 'https://' + url;
665
	}
666
	return '<a href="' + url + '" target="_blank">' + nom + '</a> ';
667
};
668
 
3823 idir 669
WidgetPhotoPopup.prototype.fournirLienIdentiplante = function() {
670
	const lthis = this;
671
	$( '.signaler-erreur-obs' ).each( function() {
672
		$( this ).attr( 'href', lthis.urlIP );
673
	});
674
};
675
 
676
// WidgetPhotoPopup.prototype.afficherTags = function() {
677
// 	const lthis = this;
678
// 	const TAGS_BASE = [
679
// 		'port',
680
// 		'fleur',
681
// 		'fruit',
682
// 		'feuille',
683
// 		'ecorce',
684
// 		'rameau',
685
// 		'planche',
686
// 		'insecte'
687
// 	];
688
 
689
 
690
// };