Subversion Repositories eFlore/Applications.cel

Rev

Rev 3838 | Rev 3948 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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