Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 3270 Rev 3271
Line 32... Line 32...
32
	this.serviceNomCommuneUrlAlt = null;
32
	this.serviceNomCommuneUrlAlt = null;
33
	this.chargementIconeUrl = null;
33
	this.chargementIconeUrl = null;
34
	this.chargementImageIconeUrl = null;
34
	this.chargementImageIconeUrl = null;
35
	this.calendrierIconeUrl = null;
35
	this.calendrierIconeUrl = null;
36
	this.pasDePhotoIconeUrl = null;
36
	this.pasDePhotoIconeUrl = null;
-
 
37
	this.observer = null;
Line 37... Line 38...
37
 
38
 
38
	// système de traduction minimaliste
39
	// système de traduction minimaliste
39
	this.msgs = {
40
	this.msgs = {
40
		fr: {
41
		fr: {
Line 786... Line 787...
786
	$( '#taxon' ).on( 'change', function() {
787
	$( '#taxon' ).on( 'change', function() {
787
		var images = valeurOk( $( '#miniatures .miniature' ) );
788
		var images = valeurOk( $( '#miniatures .miniature' ) );
788
		lthis.validerTaxonImage( valeurOk( $( this ).val() ), images );
789
		lthis.validerTaxonImage( valeurOk( $( this ).val() ), images );
789
	});
790
	});
Line -... Line 791...
-
 
791
 
790
 
792
	// MutationObserver sur les miniatures pour validation
Line 791... Line 793...
791
	this.surPresenceAbsenceMiniature();
793
	this.surPresenceAbsenceMiniature();
792
 
794
 
793
	$( '#form-observation' ).validate({
795
	$( '#form-observation' ).validate({
Line 820... Line 822...
820
	});
822
	});
821
};
823
};
Line 822... Line 824...
822
 
824
 
823
WidgetSaisie.prototype.validerTaxonImage = function( taxon = false, images = false ) {
825
WidgetSaisie.prototype.validerTaxonImage = function( taxon = false, images = false ) {
824
	var taxonOuImage = ( images || taxon );
-
 
825
	console.log();
826
	var taxonOuImage = ( images || taxon );
826
	if ( images || taxon ) {
827
	if ( images || taxon ) {
827
		this.masquerPanneau( '#dialogue-taxon-or-image' );
828
		this.masquerPanneau( '#dialogue-taxon-or-image' );
828
		$( '#bloc-taxon' ).removeClass( 'error' )
829
		$( '#bloc-taxon' ).removeClass( 'error' )
829
			.find( 'span.error' ).hide();
830
			.find( 'span.error' ).hide();
Line 839... Line 840...
839
	return ( images || taxon );
840
	return ( images || taxon );
840
};
841
};
Line 841... Line 842...
841
 
842
 
842
WidgetSaisie.prototype.surPresenceAbsenceMiniature = function() {
843
WidgetSaisie.prototype.surPresenceAbsenceMiniature = function() {
-
 
844
	var lthis = this;
843
	var lthis = this;
845
 
844
	// Selectionne le noeud dont les mutations seront observées
846
	// Selectionne le noeud dont les mutations seront observées
845
	var targetNode = document.getElementById( 'miniatures' );
847
	var targetNode = document.getElementById( 'miniatures' );
846
	// Fonction callback à éxécuter quand une mutation est observée
848
	// Fonction callback à éxécuter quand une mutation est observée
847
	var callback = function( mutationsList ) {
849
	var callback = function( mutationsList ) {
Line 850... Line 852...
850
	        images = ( 0 < mutation.target.childElementCount );
852
	        images = ( 0 < mutation.target.childElementCount );
851
		 	lthis.validerTaxonImage( taxon, images );
853
		 	lthis.validerTaxonImage( taxon, images );
852
	    }
854
	    }
853
	};
855
	};
854
	// Créé une instance de l'observateur lié à la fonction de callback
856
	// Créé une instance de l'observateur lié à la fonction de callback
855
	var observer = new MutationObserver( callback );
857
	this.observer = new MutationObserver( callback );
856
	// Commence à observer le noeud cible pour les mutations précédemment configurées
858
	// Commence à observer le noeud cible pour les mutations précédemment configurées
857
	observer.observe( targetNode, { childList: true } );
859
	this.observer.observe( targetNode, { childList: true } );
858
};
860
};
Line 859... Line 861...
859
 
861
 
860
WidgetSaisie.prototype.validerFormulaire = function() {
862
WidgetSaisie.prototype.validerFormulaire = function() {
861
	var observateur  = $( '#form-observateur' ).valid();
863
	var observateur  = $( '#form-observateur' ).valid();
862
	var obs          = $( '#form-observation' ).valid();
864
	var obs          = $( '#form-observation' ).valid();
863
	var images       = valeurOk( $( '#miniatures .miniature' ) );
865
	var images       = valeurOk( $( '#miniatures .miniature' ) );
864
	var taxon        = valeurOk( $( '#taxon' ).val() );
866
	var taxon        = valeurOk( $( '#taxon' ).val() );
865
	// validation et panneau taxon/images
867
	// validation et panneau taxon/images
866
 	var taxonOuImage = this.validerTaxonImage( taxon, images );
868
 	var taxonOuImage = this.validerTaxonImage( taxon, images );
867
 	console.log(taxonOuImage);
869
 	// console.log(taxonOuImage);
868
	var chpsSupp     = new Boolean();
870
	var chpsSupp     = new Boolean();
869
	if ( valeurOk( $( '#form-supp' ) ) ) {
871
	if ( valeurOk( $( '#form-supp' ) ) ) {
870
		chpsSupp = ( function () {
872
		chpsSupp = ( function () {
871
			var otherFlag = $( '#form-supp' ).valid();
873
			var otherFlag = $( '#form-supp' ).valid();
Line 968... Line 970...
968
		this.stockerObsData();
970
		this.stockerObsData();
969
		this.supprimerMiniatures();
971
		this.supprimerMiniatures();
970
		if( !this.especeImposee ) {
972
		if( !this.especeImposee ) {
971
			$( '#taxon' ).val( '' );
973
			$( '#taxon' ).val( '' );
972
			$( '#taxon' ).data( 'numNomSel', '' )
974
			$( '#taxon' ).data( 'numNomSel', '' )
973
			.data( 'nomRet','' )
975
				.data( 'nomRet','' )
974
			.data( 'numNomRet', '' )
976
				.data( 'numNomRet', '' )
975
			.data( 'nt', '' )
977
				.data( 'nt', '' )
976
			.data( 'famille', '' );
978
				.data( 'famille', '' );
977
			if( this.isTaxonListe ) {
979
			if( this.isTaxonListe ) {
978
				$( '#taxon-liste' ).find( 'option' ).each( function() {
980
				$( '#taxon-liste' ).find( 'option' ).each( function() {
979
					if ( $( this ).hasClass( 'choisir' ) ) {
981
					if ( $( this ).hasClass( 'choisir' ) ) {
980
						$( this ).attr( 'selected', true );
982
						$( this ).attr( 'selected', true );
981
					} else {
983
					} else {
Line 1263... Line 1265...
1263
 
1265
 
1264
/**
1266
/**
1265
 * Efface toutes les miniatures (formulaire)
1267
 * Efface toutes les miniatures (formulaire)
1266
 */
1268
 */
-
 
1269
WidgetSaisie.prototype.supprimerMiniatures = function() {
-
 
1270
	// Déconnection MutationObserver miniatures
-
 
1271
	// Sinon on a une erreur avant la création d'une nouvelle obs
1267
WidgetSaisie.prototype.supprimerMiniatures = function() {
1272
	this.observer.disconnect();
-
 
1273
	$( '#miniatures' ).empty();
-
 
1274
	// la validation miniatures reprend à 0 pour une nouvelle obs
1268
	$( '#miniatures' ).empty();
1275
	this.surPresenceAbsenceMiniature();
1269
	$( '#miniature-msg' ).empty();
1276
	$( '#miniature-msg' ).empty();
Line 1270... Line 1277...
1270
};
1277
};
1271
 
1278
 
1272
WidgetSaisie.prototype.surChangementNbreObs = function() {
1279
WidgetSaisie.prototype.surChangementNbreObs = function() {
1273
	if ( 0 === this.obsNbre ) {
-
 
1274
		$( '#transmettre-obs' ).attr( 'disabled', 'disabled' );
1280
	if ( 0 === this.obsNbre ) {
1275
		$( '#ajouter-obs' ).attr( 'disabled', 'disabled' );
1281
		$( '#transmettre-obs' ).attr( 'disabled', 'disabled' );
1276
	} else if ( 0 < this.obsNbre && this.obsNbre < this.obsMaxNbre ) {
1282
	} else if ( 0 < this.obsNbre && this.obsNbre < this.obsMaxNbre ) {
1277
		$( '#transmettre-obs' ).removeAttr( 'disabled' );
1283
		$( '#transmettre-obs' ).removeAttr( 'disabled' );
1278
		$( '#ajouter-obs' ).removeAttr( 'disabled' );
1284
		$( '#ajouter-obs' ).removeAttr( 'disabled' );