Subversion Repositories eFlore/Applications.cel

Rev

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