Subversion Repositories eFlore/Applications.cel

Rev

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