Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 3824 Rev 3825
Line 12... Line 12...
12
	}
12
	}
Line 13... Line 13...
13
 
13
 
14
	this.mettreAJourInfosImage();
14
	this.mettreAJourInfosImage();
Line 15... Line 15...
15
}
15
}
Line 16... Line 16...
16
 
16
 
17
WidgetPhotoPopup.prototype =  new WidgetPhotoCommun();
17
WidgetPhotoPopup.prototype = new WidgetPhotoCommun();
18
 
18
 
Line 51... Line 51...
51
};
51
};
Line 52... Line 52...
52
 
52
 
53
WidgetPhotoPopup.prototype.mettreAJourInfosImage = function() {
53
WidgetPhotoPopup.prototype.mettreAJourInfosImage = function() {
54
	this.item         = this.infos_images[this.urls[this.indexImage]];
54
	this.item         = this.infos_images[this.urls[this.indexImage]];
55
	this.titreImage   = this.item['titre'];
55
	this.titreImage   = this.item['titre'];
56
	this.lienEflore   = this.item['lien'];
56
	this.urlLienEflore = this.item['lien'];
57
	this.idImage      = this.item['id_photo'];
57
	this.idImage      = this.item['id_photo'];
58
	this.urlThisImage = this.item['url_photo']+'.jpg';
58
	this.urlThisImage = this.item['url_photo']+'.jpg';
59
	this.obs          = this.item['obs'];
59
	this.obs          = this.item['obs'];
60
	this.nn           = '[nn' + this.obs['nom_sel_nn']+']';
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'] );
61
	this.urlIP        = this.obs['url_ip'];
63
	this.tagsObs      = this.tagsToArray( this.obs['tags_obs'] );
62
	this.auteur       = this.item['utilisateur']['nom_utilisateur'];
64
	this.auteur       = this.item['utilisateur']['nom_utilisateur'];
63
	this.urlProfil    = '/profil-par-id/'+this.item['utilisateur']['id_utilisateur'];
65
	this.urlProfil    = '/profil-par-id/'+this.item['utilisateur']['id_utilisateur'];
64
	this.date         = this.item['date'];
66
	this.date         = this.item['date'];
Line -... Line 67...
-
 
67
};
-
 
68
 
-
 
69
WidgetPhotoPopup.prototype.tagsToArray = function( tags ) {
-
 
70
	tags = tags.replace( new RegExp('\\.'), '' ).split( ',' );
-
 
71
 
-
 
72
	let cleanTags       = [],
-
 
73
		nbTags          = tags.length,
-
 
74
		tag             = '',
-
 
75
		tagsSansEspaces = '',
-
 
76
		cleanTagIndex   = 0;
-
 
77
 
-
 
78
	for(let i = 0; i < nbTags; i++) {
-
 
79
		tag = tags[i];
-
 
80
		tagsSansEspaces = tag.replace( ' ', '');
-
 
81
		if( '' !== tagsSansEspaces ) {
-
 
82
			cleanTags.push( tag.trim() );
-
 
83
		}
-
 
84
	}
-
 
85
 
-
 
86
	return cleanTags;
65
};
87
};
66
 
88
 
Line 67... Line 89...
67
WidgetPhotoPopup.prototype.initEvtsDefilerImage = function() {
89
WidgetPhotoPopup.prototype.initEvtsDefilerImage = function() {
68
	const lthis = this;
90
	const lthis = this;
Line 76... Line 98...
76
		const determinerSens = function( enventKey, left, right ) {
98
		const determinerSens = function( enventKey, left, right ) {
77
			switch ( enventKey ) {
99
			switch ( enventKey ) {
78
				case left:
100
				case left:
79
					return 'suivant';
101
					return 'suivant';
80
				case right:
102
				case right:
81
					return 'precedent'
103
					return 'precedent';
82
				default:
104
				default:
83
					break;
105
					break;
84
			}
106
			}
Line 85... Line 107...
85
 
107
 
Line 224... Line 246...
224
		}
246
		}
225
		lienContact += '&popup_url=' + encodeURIComponent( this.popupUrl );
247
		lienContact += '&popup_url=' + encodeURIComponent( this.popupUrl );
226
	}
248
	}
Line 227... Line 249...
227
 
249
 
228
	$( '#bloc-infos-img' ).html(
250
	$( '#bloc-infos-img' ).html(
229
		'<a href="' + this.lienEflore + '">' + this.obs['nom_sel'] + '</a> '+
251
		this.afficherLien( this.urlLienEflore, this.obs['nom_sel'] )+
230
		' par '+
252
		' par '+
231
		'<a class="lien_contact" href="' + lienContact + '">' + this.auteur + '</a> '+
253
		'<a class="lien_contact" href="' + lienContact + '">' + this.auteur + '</a> '+
232
		' le ' + this.date + ' - ' + this.obs['localisation']
254
		' le ' + this.date + ' - ' + this.obs['localisation']
233
	);
255
	);
Line 350... Line 372...
350
};
372
};
Line 351... Line 373...
351
 
373
 
352
WidgetPhotoPopup.prototype.afficherMetas = function() {
374
WidgetPhotoPopup.prototype.afficherMetas = function() {
353
	const lthis         = this;
375
	const lthis         = this;
354
	const META_CONTENUS = {
376
	const META_CONTENUS = {
355
		'nom' : '<a href="' + this.lienEflore + '" target="_blank">' + this.obs['nom_sel'] + '</a> ',
377
		'nom' : this.afficherLien( this.urlLienEflore, this.obs['nom_sel'] ),
356
		'localisation' : this.obs['localisation'],
378
		'localisation' : this.obs['localisation'],
357
		'auteur' : this.auteur,
379
		'auteur' : this.auteur,
358
		'date-obs' : this.date,
380
		'date-obs' : this.date,
359
		'commentaire' : this.obs['commentaire'],
381
		'commentaire' : this.obs['commentaire'],
Line 376... Line 398...
376
					$metaContainer.val( contenu );
398
					$metaContainer.val( contenu );
377
					lthis.copieAutoChamp( $metaContainer );
399
					lthis.copieAutoChamp( $metaContainer );
378
					break;
400
					break;
379
				case 'nom' :
401
				case 'nom' :
380
					$( '.contenu', $metaContainer ).html( contenu );
402
					$( '.contenu', $metaContainer ).html( contenu );
381
					$( '.bouton', $metaContainer ).attr( 'href', lthis.lienEflore );
403
					$( '.bouton', $metaContainer ).attr( 'href', lthis.urlLienEflore );
382
					break;
404
					break;
383
				case 'auteur' :
405
				case 'auteur' :
384
					$( '.bouton', $metaContainer ).attr( 'href', lthis.urlProfil );
406
					$( '.bouton', $metaContainer ).attr( 'href', lthis.urlProfil );
385
				default:
407
				default:
386
					$( '.contenu', $metaContainer ).text( contenu );
408
					$( '.contenu', $metaContainer ).text( contenu );
Line 412... Line 434...
412
WidgetPhotoPopup.prototype.afficherMetasPlus = function() {
434
WidgetPhotoPopup.prototype.afficherMetasPlus = function() {
413
	const lthis         = this;
435
	const lthis         = this;
414
	const META_LABELS  = {
436
	const META_LABELS  = {
415
		'id_obs' : 'observation n°',
437
		'id_obs' : 'observation n°',
416
		'projet' : 'projet',
438
		'projet' : 'projet',
-
 
439
		'nom_referentiel' : 'réferentiel',
417
		'date_obs' : 'date d´observation',
440
		'date_obs' : 'date d´observation',
418
		'nom_sel': 'nom scientifique',
441
		'nom_sel': 'nom scientifique',
419
		'nom_sel_nn' : 'nom scientifique n°',
442
		'nom_sel_nn' : 'nom scientifique n°',
420
		'nom_ret' : 'nom retenu',
443
		'nom_ret' : 'nom retenu',
421
		'nom_ret_nn' : 'nom retenu n°',
444
		'nom_ret_nn' : 'nom retenu n°',
422
		'famille' : 'famille',
445
		'famille' : 'famille',
423
		'nom_referentiel' : 'réferentiel',
-
 
424
		'commentaire' : 'commentaire',
-
 
425
		'certitude' : 'certitude',
-
 
426
		'fiabilite' : 'fiabilite',
-
 
427
		'tags_obs' : 'tags de l´observation',
446
		'tags_obs' : 'tags de l´observation',
428
		'localisation' : 'localisation',
-
 
429
		'lieudit' : 'lieu dit',
447
		'lieudit' : 'lieu dit',
430
		'station' : 'station',
448
		'station' : 'station',
431
		'milieu' : 'milieu',
449
		'milieu' : 'milieu',
432
		'latitude' : 'latitude',
450
		'latitude' : 'latitude',
433
		'longitude' : 'longitude',
451
		'longitude' : 'longitude',
Line 447... Line 465...
447
		'source' : 'source',
465
		'source' : 'source',
448
		'herbier' : 'herbier',
466
		'herbier' : 'herbier',
449
		'observateur' : 'observateur',
467
		'observateur' : 'observateur',
450
		'observateur_structure' : 'structure'
468
		'observateur_structure' : 'structure'
451
	};
469
	};
-
 
470
 
452
	const $contenuPlusMeta  = $( '#contenu-meta-plus' );
471
	const $contenuPlusMeta  = $( '#contenu-meta-plus' );
453
	let degres = '0';
472
	let degres = $contenuPlusMeta.is( ':visible' ) ? '180' : '0';
Line 454... Line 473...
454
 
473
 
-
 
474
	this.rotationFleche( degres );
Line 455... Line 475...
455
	this.rotationFleche( degres );
475
	$contenuPlusMeta.empty();
456
 
476
 
457
	$.each( META_LABELS, function( cle, label ) {
477
	$.each( META_LABELS, function( cle, label ) {
Line -... Line 478...
-
 
478
		let idAttr = cle.replace( '_', '-' ),
-
 
479
			contenu = lthis.obs[cle];
458
		let idAttr = cle.replace( '_', '-' ),
480
 
-
 
481
		switch( cle ) {
-
 
482
			case 'nom_sel':
-
 
483
				contenu = lthis.afficherLien( lthis.urlLienEflore, contenu );
-
 
484
				break;
-
 
485
 
-
 
486
			case 'nom_ret':
-
 
487
				let urlEfloreNomRetenu = lthis.urlLienEflore.replace( lthis.obs['nom_sel_nn'], lthis.obs['nom_ret_nn'] );
-
 
488
 
-
 
489
				contenu = lthis.afficherLien( urlEfloreNomRetenu, contenu );
-
 
490
				break;
-
 
491
 
-
 
492
			case 'url_ip':
-
 
493
				contenu = lthis.afficherLien( contenu, contenu );
-
 
494
				break;
-
 
495
 
459
			contenu = lthis.obs[cle];
496
			case 'est_ip_valide':
-
 
497
			case 'herbier':
-
 
498
				if( '0' === contenu ) {
-
 
499
					contenu = 'non';
460
 
500
				}
461
		if ( 0 <= $.inArray( cle, ['est_ip_valide', 'herbier'] ) && '0' === contenu ) {
501
				break;
-
 
502
 
-
 
503
			case 'date_obs':
-
 
504
				contenu = lthis.formaterDate( contenu );
-
 
505
				console.log(contenu);
-
 
506
				break;
-
 
507
 
-
 
508
			case 'tags_obs':
-
 
509
				let tagsObsLength = lthis.tagsObs.length;
-
 
510
				contenu = lthis.tagsObs.join( '<br>' );
-
 
511
				break;
462
			contenu = 'non';
512
 
Line 463... Line 513...
463
		} else if ( 'date_obs' === cle ) {
513
			default:
464
			contenu = lthis.formaterDate(contenu);
514
				break;
465
		}
515
		}
Line 472... Line 522...
472
				'</li>'
522
				'</li>'
473
			);
523
			);
474
		}
524
		}
475
	});
525
	});
Line -... Line 526...
-
 
526
 
476
 
527
	if( !$contenuPlusMeta.hasClass( 'actif' ) ) {
-
 
528
		$contenuPlusMeta.hide();
-
 
529
	}
-
 
530
 
-
 
531
	let estVisible = false;
477
	$contenuPlusMeta.hide();
532
 
478
	$( '#plus-meta' ).off( 'click' ).on( 'click', function( event ) {
533
	$( '#plus-meta' ).off( 'click' ).on( 'click', function( event ) {
479
		event.preventDefault();
-
 
480
 
534
		event.preventDefault();
481
		$contenuPlusMeta.toggle( 200, function() {
535
		$contenuPlusMeta.toggle( 200, function() {
-
 
536
			estVisible = $contenuPlusMeta.is( ':visible' );
-
 
537
			degres     = estVisible ? '180' : '0';
482
			degres = $contenuPlusMeta.is( ':visible' ) ? '180' : '0';
538
			$( this ).toggleClass( 'actif', estVisible );
483
			lthis.rotationFleche( degres );
539
			lthis.rotationFleche( degres );
484
		});
540
		});
485
	});
541
	});
Line 594... Line 650...
594
		.join('/');
650
		.join('/');
Line 595... Line 651...
595
 
651
 
596
	return dateFormatee;
652
	return dateFormatee;
Line -... Line 653...
-
 
653
};
-
 
654
 
-
 
655
WidgetPhotoPopup.prototype.afficherLien = function( url, nom ) {
-
 
656
	if( !/https?:\/\//.test( url ) ) {
-
 
657
		url = 'https://' + url;
-
 
658
	}
-
 
659
	return '<a href="' + url + '" target="_blank">' + nom + '</a> ';
597
};
660
};
598
 
661
 
599
WidgetPhotoPopup.prototype.fournirLienIdentiplante = function() {
662
WidgetPhotoPopup.prototype.fournirLienIdentiplante = function() {
600
	const lthis = this;
663
	const lthis = this;
601
	$( '.signaler-erreur-obs' ).each( function() {
664
	$( '.signaler-erreur-obs' ).each( function() {