Subversion Repositories eFlore/Applications.cel

Rev

Rev 3631 | Rev 3824 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3631 Rev 3823
Line 1... Line 1...
1
function WidgetPhotoPopup( proprietes ) {
1
function WidgetPhotoPopup( proprietes ) {
2
	if( this.valOk( proprietes ) ) {
2
	if( this.valOk( proprietes ) ) {
3
		this.urlWidget    = proprietes.urlWidget;
3
		this.urlWidget                    = proprietes.urlWidget;
4
		this.urls         = proprietes.urls;
4
		this.urls                         = proprietes.urls;
5
		this.infos_images = proprietes.infos_images;
5
		this.infos_images                 = proprietes.infos_images;
6
		this.indexImage   = proprietes.indexImage;
6
		this.indexImage                   = proprietes.indexImage;
7
		this.urlImage     = proprietes.urlImage;
7
		this.urlImage                     = proprietes.urlImage;
8
		this.tailleMax    = proprietes.tailleMax;
8
		this.tailleMax                    = proprietes.tailleMax;
9
		this.popup_url       = proprietes.popup_url;
9
		this.popupUrl                     = proprietes.popupUrl;
-
 
10
		this.urlBaseTelechargement        = proprietes.urlBaseTelechargement;
-
 
11
		this.urlServiceRegenererMiniature = proprietes.urlServiceRegenererMiniature;
10
	}
12
	}
-
 
13
 
-
 
14
	this.mettreAJourInfosImage();
11
}
15
}
Line 12... Line 16...
12
 
16
 
Line 13... Line 17...
13
WidgetPhotoPopup.prototype =  new WidgetPhotoCommun();
17
WidgetPhotoPopup.prototype =  new WidgetPhotoCommun();
14
 
18
 
15
WidgetPhotoPopup.prototype.initTpl = function() {
19
WidgetPhotoPopup.prototype.initTpl = function() {
-
 
20
	this.redimensionnerGalerie();
16
	this.redimensionnerGalerie();
21
	if( this.valOk( this.urlImage, false, 'null' ) ) {
-
 
22
 
17
	if( this.valOk( this.urlImage, false, 'null' ) ) {
23
		this.indexImage = this.urls.indexOf( this.urlImage );
18
		this.indexImage = this.urls.indexOf( this.urlImage );
24
 
-
 
25
		$( '#info-img-galerie' ).find( '.active' ).removeClass( 'active' );
19
		$( '#info-img-galerie' ).find( '.active' ).removeClass( 'active' );
26
		$( '#img-cadre-' + this.indexImage + ',#indicateur-img-' + this.indexImage ).addClass( 'active' );
20
		$( '#img-cadre-' + this.indexImage + ',#indicateur-img-' + this.indexImage ).addClass( 'active' );
27
 
-
 
28
		this.mettreAJourPopup();
21
		this.afficherTitreImage();
29
	}
22
	}
30
 
Line 23... Line 31...
23
	this.redimentionnerModaleCarousel();
31
	this.redimentionnerModaleCarousel();
24
};
32
};
Line 25... Line 33...
25
 
33
 
26
WidgetPhotoPopup.prototype.initEvts = function() {
34
WidgetPhotoPopup.prototype.initEvts = function() {
27
	const lthis = this;
35
	const lthis = this;
28
 
36
 
29
	this.initEvtsDefilerImage();
37
	this.initEvtsDefilerImage();
30
	this.initEvtsContact();
38
	this.initEvtsContact();
31
	$( window ).on( 'resize', lthis.redimentionnerModaleCarousel.bind( lthis ) );
39
	$( window ).on( 'resize', lthis.redimentionnerModaleCarousel.bind( lthis ) );
Line -... Line 40...
-
 
40
	this.initEvtsFonctionsPhoto();
-
 
41
	this.initEvtsRetourGalerieResponsive();
-
 
42
	this.initEvtsTagsPF();
-
 
43
};
-
 
44
 
-
 
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() {
-
 
54
	this.item         = this.infos_images[this.urls[this.indexImage]];
-
 
55
	this.titreImage   = this.item['titre'];
-
 
56
	this.lienEflore   = this.item['lien'];
-
 
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        = 'https://'+this.obs['url_ip'];
32
	this.initEvtsFonstionsPhoto();
62
	this.auteur       = this.item['utilisateur']['nom_utilisateur'];
33
	this.initEvtsRetourGalerieResponsive();
63
	this.urlProfil    = '/profil-par-id/'+this.item['utilisateur']['id_utilisateur'];
Line 34... Line 64...
34
	this.initEvtsTagsPF();
64
	this.date         = this.item['date'];
35
};
65
};
36
 
66
 
-
 
67
WidgetPhotoPopup.prototype.initEvtsDefilerImage = function() {
37
WidgetPhotoPopup.prototype.initEvtsDefilerImage = function() {
68
	const lthis = this;
38
	const lthis = this;
-
 
Line 39... Line -...
39
 
-
 
40
	$( '#precedent, #suivant' ).on( 'click', function() {
69
 
41
		lthis.defilerImage( this.id );
70
	$( '#precedent, #suivant' ).on( 'click', function() {
42
	});
71
		lthis.defilerImage( this.id );
43
	$( '#print_content:not(saisir-tag)' ).on( 'keydown', function( event ) {
72
	});
44
		var sens = '';
73
 
45
 
74
	$( '#print_content:not(saisir-tag)' ).on( 'keydown', function( event ) {
-
 
75
 
-
 
76
		const determinerSens = function( enventKey, left, right ) {
46
		event = event || window.event;
77
			switch ( enventKey ) {
47
		// event.keyCode déprécié, on tente d'abord event.key
-
 
-
 
78
				case left:
48
		if ( 'key' in event ) {
79
					return 'suivant';
49
			if( event.key === 'ArrowLeft') { // gauche
-
 
50
				sens = 'suivant';
-
 
51
			} else if ( event.key === 'ArrowRight' ) {  // droite
80
				case right:
-
 
81
					return 'precedent'
-
 
82
				default:
-
 
83
					break;
-
 
84
			}
-
 
85
 
52
				sens = 'precedent';
86
			return;
53
			}
87
		}
54
		} else if( event.keyCode == 37 ) { // gauche
88
 
55
			sens = 'suivant';
89
		event = (event || window.event);
56
		} else if( event.keyCode == 39 ) { // droite
90
		// event.keyCode déprécié, on tente d'abord event.key
Line 69... Line 103...
69
		event.preventDefault();
103
		event.preventDefault();
70
		lthis.chargerContenuModale( this.href );
104
		lthis.chargerContenuModale( this.href );
71
	});
105
	});
72
};
106
};
Line 73... Line 107...
73
 
107
 
74
WidgetPhotoPopup.prototype.initEvtsFonstionsPhoto = function() {
108
WidgetPhotoPopup.prototype.initEvtsFonctionsPhoto = function() {
Line 75... Line 109...
75
	const lthis = this;
109
	const lthis = this;
76
 
110
 
77
	$( '#boutons-footer #bloc-fct a, #retour-metas' ).on( 'click', function( event ){
111
	$( '#boutons-footer #bloc-fct a, #retour-metas' ).on( 'click', function( event ){
Line 128... Line 162...
128
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
162
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
129
		$( this ).parent( '.custom-tag' ).remove();
163
		$( this ).parent( '.custom-tag' ).remove();
130
	});
164
	});
Line 131... Line 165...
131
 
165
 
132
	$( '#bloc-tags' ).on( 'keyup', '.custom-tag.actif', function( event ) {
166
	$( '#bloc-tags' ).on( 'keyup', '.custom-tag.actif', function( event ) {
Line 133... Line 167...
133
		var supprimerTag = false;
167
		let supprimerTag = false;
134
 
168
 
135
		event = event || window.event;
169
		event = ( event || window.event );
136
		// event.keyCode déprécié, on tente d'abord event.key
170
		// event.keyCode déprécié, on tente d'abord event.key
137
		if ( 'key' in event ) {
171
		if ( 'key' in event ) {
138
			supprimerTag = ( 'Delete' === event.key || 'Backspace' === event.key );
172
			supprimerTag = ( 'Delete' === event.key || 'Backspace' === event.key );
139
		} else {
173
		} else {
140
			supprimerTag = ( 46 === event.keyCode || 8 === event.keyCode );
174
			supprimerTag = ( 46 === event.keyCode || 8 === event.keyCode );
141
		}
175
		}
142
		if ( supprimerTag ) {
176
		if ( supprimerTag ) {
143
		//			Supprimer un custom-tag
177
			//			Supprimer un custom-tag
144
		//	_OPTIONS
178
			//	_OPTIONS
145
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
179
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
146
		// 	_paramètres
180
			// 	_paramètres
147
		// L'id du tag à la fin de l'url
181
			// L'id du tag à la fin de l'url
148
		//	_DELETE
182
			//	_DELETE
149
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
183
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles/38368
150
		// 	_réponse:
184
			// 	_réponse:
151
		// ""
185
			// ""
152
		// 			Mettre à jour les mots cles
186
			// 			Mettre à jour les mots cles
153
		//	_OPTIONS
187
			//	_OPTIONS
154
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
188
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
155
		//	_GET
189
			//	_GET
156
		// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
190
			// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
157
			$( this ).parent( '.custom-tag' ).remove();
191
			$( this ).parent( '.custom-tag' ).remove();
158
		}
192
		}
Line 159... Line 193...
159
	});
193
	});
160
};
194
};
161
 
195
 
162
WidgetPhotoPopup.prototype.defilerImage = function( sens ) {
196
WidgetPhotoPopup.prototype.defilerImage = function( sens ) {
163
	if ( this.valOk( sens, true, 'suivant' ) ) {
197
	if ( 'suivant' === sens ) {
164
		this.indexImage++ ;
198
		this.indexImage++ ;
165
		if( this.indexImage >= this.urls.length ) {
199
		if( this.indexImage >= this.urls.length ) {
166
			this.indexImage = 0;
200
			this.indexImage = 0;
167
		}
201
		}
168
	} else if ( this.valOk( sens, true, 'precedent' ) ) {
202
	} else if ( 'precedent' === sens ) {
169
		this.indexImage--;
203
		this.indexImage--;
170
		if( this.indexImage <= 0 ) {
204
		if( this.indexImage <= 0 ) {
-
 
205
			this.indexImage = this.urls.length -1;
171
			this.indexImage = this.urls.length -1;
206
		}
172
		}
207
	}
Line 173... Line 208...
173
	}
208
	// @TODO: Modifier l'attr content de 'meta[property=og:image]' et y mettre l'url de l'image
174
	this.afficherTitreImage();
-
 
175
};
-
 
176
 
-
 
177
WidgetPhotoPopup.prototype.afficherTitreImage = function() {
-
 
178
	var item         = this.infos_images[this.urls[this.indexImage]],
209
	this.mettreAJourPopup();
179
		titre        = item['titre'],
210
};
180
		infos        = this.decouperTitre( titre ),
211
 
181
		urlThisImage = $( '#illustration-' + this.indexImage ).attr( 'src' );
212
WidgetPhotoPopup.prototype.afficherTitreImage = function() {
-
 
213
	let lienContact  =
182
		lienContact  =
214
			this.urlWidget +'?mode=contact&nn=' + this.nn +
183
			this.urlWidget +'?mode=contact&nn=' + infos.nn +
215
			'&nom_sci=' + this.obs['nom_sel'] +
184
			'&nom_sci=' + infos.nom_sci +
216
			'&date=' + this.date +
185
			'&date=' + infos.date +
217
			'&localisation=' + this.obs['localisation'] +
186
			'&id_image=' + item['guid'] +
218
			'&id_image=' + this.idImage +
187
			'&auteur=' + infos.auteur;
219
			'&auteur=' + this.auteur;
188
 
220
 
189
	if ( this.valOk( this.popup_url ) ) {
221
	if ( this.valOk( this.popupUrl ) ) {
190
		if (! this.popup_url.match( new RegExp( '/img:000' + item['guid'] ) ) ) {
222
		if (! this.popupUrl.match( new RegExp( 'img:' + this.idImage ) ) ) {
Line 191... Line -...
191
			this.popup_url = this.actualiserPopupUrl( this.popup_url, urlThisImage );
-
 
192
		}
-
 
193
		lienContact += '&popup_url=' + encodeURIComponent( this.popup_url );
-
 
194
	}
-
 
195
 
223
			this.popupUrl = this.actualiserPopupUrl( this.popupUrl, this.urlThisImage );
196
	titre =
-
 
197
		'<a href="' + item['lien'] + '">' + infos.nom_sci + '</a> '+
-
 
198
		' par <a class="lien_contact" href="' + lienContact + '">' + infos.auteur + '</a> '+
-
 
199
		' le ' + infos.date + ' ';
224
		}
200
	$( '#bloc-infos-img' ).html( titre );
225
		lienContact += '&popup_url=' + encodeURIComponent( this.popupUrl );
201
};
226
	}
202
 
227
 
203
WidgetPhotoPopup.prototype.decouperTitre = function( titre ) {
-
 
204
	var tab_titre       = titre.split( '[nn' ),
-
 
205
		nom_sci         = tab_titre[0],
-
 
206
		tab_titre_suite = tab_titre[1].split( ' par ' ),
-
 
207
		nn              = '[nn' + tab_titre_suite[0],
-
 
208
		tab_titre_fin   = tab_titre_suite[1].split( ' le ' ),
-
 
209
		utilisateur     = tab_titre_fin[0],
-
 
210
		date            = tab_titre_fin[1],
-
 
211
		titre_decoupe = {
228
	$( '#bloc-infos-img' ).html(
212
			'nom_sci' : nom_sci,
-
 
213
			'nn'      : nn,
-
 
214
			'date'    : date,
229
		'<a href="' + this.lienEflore + '">' + this.obs['nom_sel'] + '</a> '+
Line 215... Line 230...
215
			'auteur'  : utilisateur
230
		' par '+
216
		};
-
 
217
 
231
		'<a class="lien_contact" href="' + lienContact + '">' + this.auteur + '</a> '+
Line 218... Line 232...
218
	return titre_decoupe;
232
		' le ' + this.date + ' - ' + this.obs['localisation']
219
};
233
	);
220
 
234
};
221
WidgetPhotoPopup.prototype.actualiserPopupUrl = function( queryString, remplacement ) {
235
 
Line 251... Line 265...
251
		$( '#retour-galerie' ).addClass( 'hidden' );
265
		$( '#retour-galerie' ).addClass( 'hidden' );
252
	}
266
	}
253
};
267
};
Line 254... Line 268...
254
 
268
 
255
WidgetPhotoPopup.prototype.redimensionnerGalerie = function() {
-
 
256
	const lthis = this;
269
WidgetPhotoPopup.prototype.redimensionnerGalerie = function() {
Line 257... Line 270...
257
	var maxSize = ( $( window ).width() / $( window ).height() ) < 1 ? $( window ).width() : $( window ).height();
270
	var maxSize = ( $( window ).width() / $( window ).height() ) < 1 ? $( window ).width() : $( window ).height();
258
 
271
 
259
	maxSize -= 30;
272
	maxSize -= 30;
Line 276... Line 289...
276
		$( '#boutons-footer  .' + voletAFermer ).removeClass( 'actif' );
289
		$( '#boutons-footer  .' + voletAFermer ).removeClass( 'actif' );
277
		$( '#boutons-footer  .' + voletAOuvrir ).addClass( 'actif' );
290
		$( '#boutons-footer  .' + voletAOuvrir ).addClass( 'actif' );
278
		$( '#bloc-' + voletAFermer ).addClass( 'hidden' );
291
		$( '#bloc-' + voletAFermer ).addClass( 'hidden' );
279
		$( '#bloc-' + voletAOuvrir ).removeClass( 'hidden' );
292
		$( '#bloc-' + voletAOuvrir ).removeClass( 'hidden' );
280
		$( '#volet' ).scrollTop(0);
293
		$( '#volet' ).scrollTop(0);
281
		if( 'meta' !== voletAOuvrir ) {
-
 
282
			$( '#retour-metas' ).removeClass( 'hidden' );
294
		$( '#retour-metas' ).removeClass( 'hidden', 'meta' === voletAOuvrir );
283
		} else {
-
 
284
			$( '#retour-metas' ).addClass( 'hidden' );
-
 
285
		}
-
 
286
	}
295
	}
287
};
296
};
Line 288... Line 297...
288
 
297
 
289
WidgetPhotoPopup.prototype.tagsPfCustom = function() {
298
WidgetPhotoPopup.prototype.tagsPfCustom = function() {
Line 290... Line 299...
290
	const lthis = this;
299
	const lthis = this;
291
 
300
 
Line 292... Line 301...
292
	$( '#saisir-tag' ).on( 'blur keyup', function( event ) {
301
	$( '#saisir-tag' ).on( 'blur keyup', function( event ) {
Line 293... Line 302...
293
		event = event || window.event;
302
		event = ( event || window.event );
294
 
303
 
Line 320... Line 329...
320
				//	_OPTIONS
329
				//	_OPTIONS
321
				// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
330
				// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
322
				//	_GET
331
				//	_GET
323
				// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
332
				// https://api-test.tela-botanica.org/service:del:0.1/mots-cles?image=197938
324
				$( '#tags-pf-supp' ).append(
333
				$( '#tags-pf-supp' ).append(
325
					'<a id="' + nouveauTagAttr + '" class="btn tag custom-tag">' +
334
					'<a id="' + nouveauTagAttr + '" class="btn tag custom-tag actif">' +
326
						nouveauTag + '&nbsp;<i class="fas fa-times-circle fermer"></i>' +
335
						nouveauTag + '&nbsp;<i class="fas fa-times-circle fermer"></i>' +
327
					'</a>'
336
					'</a>'
328
				);
337
				);
329
				$( '#form-tags-auteur' )[0].reset();
338
				$( '#form-tags-auteur' )[0].reset();
330
				$( this ).val( '' );
339
				$( this ).val( '' );
331
			}
340
			}
332
		}
341
		}
333
	});
342
	});
334
};
343
};
-
 
344
 
-
 
345
WidgetPhotoPopup.prototype.traiterMetas = function() {
-
 
346
	this.afficherMetas();
-
 
347
	this.afficherPopupLocalisation();
-
 
348
	this.afficherMetasPlus();
-
 
349
	this.fournirLienTelechargement();
-
 
350
};
-
 
351
 
-
 
352
WidgetPhotoPopup.prototype.afficherMetas = function() {
-
 
353
	const lthis         = this;
-
 
354
	const META_CONTENUS = {
-
 
355
		'nom' : '<a href="' + this.lienEflore + '" target="_blank">' + this.obs['nom_sel'] + '</a> ',
-
 
356
		'localisation' : this.obs['localisation'],
-
 
357
		'auteur' : this.auteur,
-
 
358
		'date-obs' : this.date,
-
 
359
		'commentaire' : this.obs['commentaire'],
-
 
360
		'certitude' : this.obs['certitude'],
-
 
361
		'fiabilite' : this.obs['fiabilite'],
-
 
362
		'num-photo' : this.idImage,
-
 
363
		'titre-original' : this.item['nom_original'],
-
 
364
		'date-photo' : this.formaterDate( this.item['date_photo'] ),
-
 
365
		'attribution-copy' : this.item['attribution'],
-
 
366
		'url-copy' : this.urlThisImage
-
 
367
	};
-
 
368
 
-
 
369
	$.each( META_CONTENUS, function( attrId, contenu ) {
-
 
370
		let $metaContainer = $( '#bloc-meta #'+attrId );
-
 
371
 
-
 
372
		if ( lthis.valOk( contenu ) ) {
-
 
373
			switch( attrId ) {
-
 
374
				case 'attribution-copy' :
-
 
375
				case 'url-copy' :
-
 
376
					$metaContainer.val( contenu );
-
 
377
					lthis.copieAutoChamp( $metaContainer );
-
 
378
					break;
-
 
379
				case 'nom' :
-
 
380
					$( '.contenu', $metaContainer ).html( contenu );
-
 
381
					$( '.bouton', $metaContainer ).attr( 'href', lthis.lienEflore );
-
 
382
					break;
-
 
383
				case 'auteur' :
-
 
384
					$( '.bouton', $metaContainer ).attr( 'href', lthis.urlProfil );
-
 
385
				default:
-
 
386
					$( '.contenu', $metaContainer ).text( contenu );
-
 
387
					break;
-
 
388
			}
-
 
389
		}
-
 
390
	});
-
 
391
};
-
 
392
 
-
 
393
WidgetPhotoPopup.prototype.copieAutoChamp = function($champACopier) {
-
 
394
	$champACopier.on( 'click', function() {
-
 
395
 
-
 
396
		$( this ).select();
-
 
397
		document.execCommand( 'copy' );
-
 
398
 
-
 
399
		$( this ).after(
-
 
400
			'<p class="copy-message alert-success" style="width: 100%; height:' + $( this ).outerHeight() + 'px; margin: 0; display:flex;">'+
-
 
401
				'<span style="margin:auto; font-size:1rem;">Copié dans le presse papier</span>'+
-
 
402
			'</p>'
-
 
403
		).addClass( 'hidden' );
-
 
404
 
-
 
405
		setTimeout( function() {
-
 
406
			$( '.copy-message' ).remove();
-
 
407
			$champACopier.removeClass( 'hidden' );
-
 
408
		}, 1000 );
-
 
409
	});
-
 
410
};
-
 
411
 
-
 
412
WidgetPhotoPopup.prototype.afficherMetasPlus = function() {
-
 
413
	const lthis         = this;
-
 
414
	const META_LABELS  = {
-
 
415
		'id_obs' : 'observation n°',
-
 
416
		'projet' : 'projet',
-
 
417
		'date_obs' : 'date d´observation',
-
 
418
		'nom_sel': 'nom scientifique',
-
 
419
		'nom_sel_nn' : 'nom scientifique n°',
-
 
420
		'nom_ret' : 'nom retenu',
-
 
421
		'nom_ret_nn' : 'nom retenu n°',
-
 
422
		'famille' : 'famille',
-
 
423
		'nom_referentiel' : 'réferentiel',
-
 
424
		'commentaire' : 'commentaire',
-
 
425
		'certitude' : 'certitude',
-
 
426
		'fiabilite' : 'fiabilite',
-
 
427
		'tags_obs' : 'tags de l´observation',
-
 
428
		'localisation' : 'localisation',
-
 
429
		'lieudit' : 'lieu dit',
-
 
430
		'station' : 'station',
-
 
431
		'milieu' : 'milieu',
-
 
432
		'latitude' : 'latitude',
-
 
433
		'longitude' : 'longitude',
-
 
434
		'altitude' : 'altitude',
-
 
435
		'localisation_precision': 'précision de la localisation',
-
 
436
		'code_insee' : 'code insee de la commune',
-
 
437
		'dept' : 'département',
-
 
438
		'pays' : 'pays',
-
 
439
		'est_ip_valide' : 'validée sur identiplante',
-
 
440
		'score_ip' : 'score identiplante',
-
 
441
		'url_ip' : 'url identiplante',
-
 
442
		'abondance' : 'abondance',
-
 
443
		'phenologie' : 'phénologie',
-
 
444
		'spontaneite' : 'spontaneite',
-
 
445
		'type_donnees' : 'type de donnees',
-
 
446
		'biblio' : 'bibliographie',
-
 
447
		'source' : 'source',
-
 
448
		'herbier' : 'herbier',
-
 
449
		'observateur' : 'observateur',
-
 
450
		'observateur_structure' : 'structure'
-
 
451
	};
-
 
452
	const $contenuPlusMeta  = $( '#contenu-meta-plus' );
-
 
453
	let degres = '0';
-
 
454
 
-
 
455
	this.rotationFleche( degres );
-
 
456
 
-
 
457
	$.each( META_LABELS, function( cle, label ) {
-
 
458
		let idAttr = cle.replace( '_', '-' ),
-
 
459
			contenu = lthis.obs[cle];
-
 
460
 
-
 
461
		if ( 0 <= $.inArray( cle, ['est_ip_valide', 'herbier'] ) && '0' === contenu ) {
-
 
462
			contenu = 'non';
-
 
463
		} else if ( 'date_obs' === cle ) {
-
 
464
			contenu = lthis.formaterDate(contenu);
-
 
465
		}
-
 
466
 
-
 
467
		if ( lthis.valOk( contenu ) ) {
-
 
468
			$contenuPlusMeta.append(
-
 
469
				'<li id="' + idAttr + '-meta-plus" class="row">'+
-
 
470
					'<div class="col-5 label">' + label.charAt( 0 ).toUpperCase() + label.slice( 1 ) + '</div>'+
-
 
471
					'<div class="col-5 contenu">' + contenu + '</div>'+
-
 
472
				'</li>'
-
 
473
			);
-
 
474
		}
-
 
475
	});
-
 
476
 
-
 
477
	$contenuPlusMeta.hide();
-
 
478
	$( '#plus-meta' ).off( 'click' ).on( 'click', function( event ) {
-
 
479
		event.preventDefault();
-
 
480
 
-
 
481
		$contenuPlusMeta.toggle( 200, function() {
-
 
482
			degres = $contenuPlusMeta.is( ':visible' ) ? '180' : '0';
-
 
483
			lthis.rotationFleche( degres );
-
 
484
		});
-
 
485
	});
-
 
486
};
-
 
487
 
-
 
488
WidgetPhotoPopup.prototype.rotationFleche = function( degres ) {
-
 
489
	$( '#plus-meta i' ).css({
-
 
490
		'-webkit-transform' : 'rotate('+ degres +'deg)',
-
 
491
		'-moz-transform' : 'rotate('+ degres +'deg)',
-
 
492
		'-ms-transform' : 'rotate('+ degres +'deg)',
-
 
493
		'transform' : 'rotate('+ degres +'deg)'
-
 
494
	});
-
 
495
};
-
 
496
 
-
 
497
WidgetPhotoPopup.prototype.fournirLienTelechargement = function() {
-
 
498
	const lthis = this;
-
 
499
 
-
 
500
	$( '#formats' ).on( 'change', function() {
-
 
501
		let format             = ( $( this ).val() || 'O' ),
-
 
502
			lienTelechargement = lthis.urlBaseTelechargement + lthis.idImage + '?methode=telecharger&format=' + format;
-
 
503
 
-
 
504
		$( '#telecharger' ).attr( 'href', lienTelechargement );
-
 
505
	});
-
 
506
 
-
 
507
	$( '#formats' ).trigger( 'change' );
-
 
508
};
-
 
509
 
-
 
510
 
-
 
511
WidgetPhotoPopup.prototype.afficherPopupLocalisation = function() {
-
 
512
	const lthis = this;
-
 
513
 
-
 
514
	$( '#localisation a.bouton' ).on( 'click', function( event ){
-
 
515
		event.preventDefault();
-
 
516
 
-
 
517
		$( this ).after(
-
 
518
			'<div id="localisation-map-container">'+
-
 
519
				'<button id="map-close" type="button" class="bouton btn btn-sm btn-outline-secondary" aria-label="Close">'+
-
 
520
					'<span aria-hidden="true">×</span>'+
-
 
521
				'</button>'+
-
 
522
				'<div id="localisation-map"></div>'+
-
 
523
			'</div>'
-
 
524
		);
-
 
525
 
-
 
526
		let lat = lthis.obs['latitude'],
-
 
527
			lng = lthis.obs['longitude'],
-
 
528
			map = L.map( 'localisation-map', {
-
 
529
				zoomControl: true,
-
 
530
				dragging: false,
-
 
531
				scrollWheelZoom: 'center'
-
 
532
			} ).setView( [lat, lng], 12 );
-
 
533
 
-
 
534
		map.markers = [];
-
 
535
 
-
 
536
		L.tileLayer(
-
 
537
			'https://osm.tela-botanica.org/tuiles/osmfr/{z}/{x}/{y}.png',
-
 
538
			{
-
 
539
				attribution: 'Data © <a href="http://osm.org/copyright">OpenStreetMap</a>',
-
 
540
				maxZoom: 18
-
 
541
			}
-
 
542
		).addTo( map );
-
 
543
 
-
 
544
		map.addLayer( new L.FeatureGroup() );
-
 
545
 
-
 
546
		let marker = new L.Marker(
-
 
547
			{
-
 
548
				'lat': lat,
-
 
549
				'lng': lng
-
 
550
			},
-
 
551
			{
-
 
552
				draggable: false,
-
 
553
			}
-
 
554
		);
-
 
555
 
-
 
556
 
-
 
557
		map.addLayer( marker );
-
 
558
		map.markers.push( marker );
-
 
559
 
-
 
560
		$( '#map-close' ).on( 'click', function( event ){
-
 
561
			$( '#localisation-map-container' ).remove();
-
 
562
		});
-
 
563
	});
-
 
564
 
-
 
565
	$( '#fenetre-modal' ).on( 'click', function( event ) {
-
 
566
		if(
-
 
567
			!$( event.target ).closest( '#localisation-map-container' ).length
-
 
568
			&& !$( event.target ).closest( '#obs-localisation' ).length
-
 
569
		) {
-
 
570
			$( '#localisation-map-container' ).remove();
-
 
571
		}
-
 
572
	});
-
 
573
};
-
 
574
 
-
 
575
 
-
 
576
WidgetPhotoPopup.prototype.regenererMiniature = function() {
-
 
577
	const lthis = this;
-
 
578
	$( '#regenerer-miniature' ).off( 'click' ).on( 'click', function( event ) {
-
 
579
		event.preventDefault();
-
 
580
 
-
 
581
		let url = lthis.urlServiceRegenererMiniature + lthis.idImage;
-
 
582
 
-
 
583
		$.get( url ).fail( function() {
-
 
584
			console.log( 'a foiré :(' );
-
 
585
		});
-
 
586
	});
-
 
587
};
-
 
588
 
-
 
589
WidgetPhotoPopup.prototype.formaterDate = function( sqlDate ) {
-
 
590
	dateFormatee = sqlDate
-
 
591
		.substring( 0, 10 )
-
 
592
		.split( '-' )
-
 
593
		.reverse()
-
 
594
		.join('/');
-
 
595
 
-
 
596
	return dateFormatee;
-
 
597
};
-
 
598
 
-
 
599
WidgetPhotoPopup.prototype.fournirLienIdentiplante = function() {
-
 
600
	const lthis = this;
-
 
601
	$( '.signaler-erreur-obs' ).each( function() {
-
 
602
		$( this ).attr( 'href', lthis.urlIP );
-
 
603
	});
-
 
604
};
-
 
605
 
-
 
606
// WidgetPhotoPopup.prototype.afficherTags = function() {
-
 
607
// 	const lthis = this;
-
 
608
// 	const TAGS_BASE = [
-
 
609
// 		'port',
-
 
610
// 		'fleur',
-
 
611
// 		'fruit',
-
 
612
// 		'feuille',
-
 
613
// 		'ecorce',
-
 
614
// 		'rameau',
-
 
615
// 		'planche',
-
 
616
// 		'insecte'
-
 
617
// 	];
-
 
618
 
-
 
619
	
-
 
620
// };
335
621