Subversion Repositories eFlore/Applications.cel

Rev

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