Subversion Repositories eFlore/Applications.cel

Rev

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