| Line 569... |
Line 569... |
| 569 |
$( this ).valid();
|
569 |
$( this ).valid();
|
| 570 |
});
|
570 |
});
|
| 571 |
$( 'input[type=date]' ).on( 'input', function() {
|
571 |
$( 'input[type=date]' ).on( 'input', function() {
|
| 572 |
$( this ).valid();
|
572 |
$( this ).valid();
|
| 573 |
});
|
573 |
});
|
| 574 |
// Validation Taxon si pas de miniature
|
574 |
// Validation taxon
|
| 575 |
$( '#taxon' ).on( 'change', function() {
|
575 |
// et gestion des messages d'erreur taxon et images en fonction de la certitude
|
| 576 |
const images = valOk( $( '#miniatures .miniature' ) );
|
576 |
$( '#taxon, #certitude' ).on( 'change', function() {
|
| 577 |
|
- |
|
| 578 |
lthis.validerTaxonImage( valOk( $( this ).val() ), images );
|
577 |
lthis.validerTaxonRequis( valOk( $( '#taxon' ).val() ) );
|
| 579 |
});
|
578 |
});
|
| 580 |
// Validation miniatures avec MutationObserver
|
579 |
// Validation miniatures avec MutationObserver
|
| 581 |
this.surPresenceAbsenceMiniature();
|
580 |
this.surPresenceAbsenceMiniature();
|
| 582 |
$( '#form-observation' ).validate({
|
581 |
$( '#form-observation' ).validate({
|
| 583 |
rules : {
|
582 |
rules : {
|
| Line 613... |
Line 612... |
| 613 |
$( '#connexion,#inscription,#bouton-anonyme' ).on( 'click', function( event ) {
|
612 |
$( '#connexion,#inscription,#bouton-anonyme' ).on( 'click', function( event ) {
|
| 614 |
$( '.nav.control-group' ).removeClass( 'error' );
|
613 |
$( '.nav.control-group' ).removeClass( 'error' );
|
| 615 |
});
|
614 |
});
|
| 616 |
};
|
615 |
};
|
| Line 617... |
Line -... |
| 617 |
|
- |
|
| 618 |
WidgetSaisie.prototype.validerTaxonImage = function( taxon = false, images = false ) {
|
- |
|
| Line -... |
Line 616... |
| - |
|
616 |
|
| - |
|
617 |
|
| - |
|
618 |
WidgetSaisie.prototype.validerCertitudeTaxonImage = function( hasTaxon = false, hasImages = false ) {
|
| - |
|
619 |
if( 'certain' === $( '#certitude' ).val() ) {
|
| - |
|
620 |
return this.validerTaxonRequis( hasTaxon );
|
| - |
|
621 |
} else {
|
| - |
|
622 |
return this.validerImageRequise( hasImages );
|
| - |
|
623 |
}
|
| - |
|
624 |
};
|
| - |
|
625 |
|
| - |
|
626 |
WidgetSaisie.prototype.validerTaxonRequis = function( hasTaxon = false ) {
|
| - |
|
627 |
const taxonEstRequis = 'certain' === $( '#certitude' ).val();
|
| - |
|
628 |
|
| - |
|
629 |
$( '#photos-conteneur').removeClass( 'error' )
|
| 619 |
const taxonOuImage = images || taxon;
|
630 |
.find( 'span.error' ).hide();
|
| - |
|
631 |
|
| - |
|
632 |
if ( !hasTaxon && taxonEstRequis ) {
|
| - |
|
633 |
this.afficherPanneau( '#dialogue-taxon-or-image' );
|
| - |
|
634 |
$( '#bloc-taxon' ).addClass( 'error' )
|
| 620 |
|
635 |
.find( 'span.error' ).show();
|
| 621 |
if ( taxonOuImage ) {
|
636 |
} else {
|
| 622 |
this.masquerPanneau( '#dialogue-taxon-or-image' );
|
637 |
this.masquerPanneau( '#dialogue-taxon-or-image' );
|
| - |
|
638 |
$( '#bloc-taxon' ).removeClass( 'error' )
|
| - |
|
639 |
.find( 'span.error' ).hide();
|
| - |
|
640 |
}
|
| - |
|
641 |
|
| - |
|
642 |
if ( taxonEstRequis ) {
|
| - |
|
643 |
return hasTaxon;
|
| - |
|
644 |
}
|
| - |
|
645 |
};
|
| - |
|
646 |
|
| - |
|
647 |
WidgetSaisie.prototype.validerImageRequise = function( hasImages = false ) {
|
| - |
|
648 |
$( '#bloc-taxon' ).removeClass( 'error' )
|
| - |
|
649 |
.find( 'span.error' ).hide();
|
| - |
|
650 |
|
| 623 |
$( '#bloc-taxon' ).removeClass( 'error' )
|
651 |
if ( hasImages ) {
|
| 624 |
.find( 'span.error' ).hide();
|
652 |
this.masquerPanneau( '#dialogue-taxon-or-image' );
|
| 625 |
$( '#fichier' ).parent( 'label.label-file' ).removeClass( 'error' );
|
653 |
$( '#fichier' ).parent( 'label.label-file' ).removeClass( 'error' );
|
| 626 |
$( '#photos-conteneur').removeClass( 'error' ).find( 'span.error' ).hide();
|
654 |
$( '#photos-conteneur').removeClass( 'error' ).find( 'span.error' ).hide();
|
| 627 |
} else {
|
- |
|
| 628 |
this.afficherPanneau( '#dialogue-taxon-or-image' );
|
- |
|
| 629 |
$( '#bloc-taxon' ).addClass( 'error' )
|
655 |
} else {
|
| 630 |
.find( 'span.error' ).show();
|
656 |
this.afficherPanneau( '#dialogue-taxon-or-image' );
|
| 631 |
$( '#fichier' ).parent( 'label.label-file' ).addClass( 'error' );
|
657 |
$( '#fichier' ).parent( 'label.label-file' ).addClass( 'error' );
|
| 632 |
$( '#photos-conteneur').addClass( 'error' ).find( 'span.error' ).show();
|
658 |
$( '#photos-conteneur').addClass( 'error' ).find( 'span.error' ).show();
|
| 633 |
}
|
659 |
}
|
| Line 634... |
Line 660... |
| 634 |
return taxonOuImage;
|
660 |
return hasImages;
|
| 635 |
};
|
661 |
};
|
| 636 |
|
662 |
|
| 637 |
WidgetSaisie.prototype.surPresenceAbsenceMiniature = function() {
|
663 |
WidgetSaisie.prototype.surPresenceAbsenceMiniature = function() {
|
| 638 |
const lthis = this;
|
664 |
const lthis = this;
|
| 639 |
// voir : https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/disconnect
|
665 |
// voir : https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/disconnect
|
| 640 |
// Selectionne le noeud dont les mutations seront observées
|
666 |
// Selectionne le noeud dont les mutations seront observées
|
| 641 |
const targetNode = document.getElementById( 'miniatures' );
|
- |
|
| 642 |
// Fonction callback à éxécuter quand une mutation est observée
|
- |
|
| 643 |
const callback = mutationsList => {
|
667 |
const targetNode = document.getElementById( 'miniatures' );
|
| - |
|
668 |
// Fonction callback à éxécuter quand une mutation est observée
|
| 644 |
let taxon;
|
669 |
const callback = mutationsList => {
|
| 645 |
|
670 |
for( let mutation of mutationsList ) {
|
| 646 |
for( let mutation of mutationsList ) {
|
671 |
lthis.validerCertitudeTaxonImage(
|
| 647 |
taxon = valOk( $( '#taxon' ).val() );
|
672 |
valOk( $( '#taxon' ).val() ),
|
| 648 |
images = ( 0 < mutation.target.childElementCount );
|
673 |
0 < mutation.target.childElementCount
|
| 649 |
lthis.validerTaxonImage( taxon, images );
|
674 |
);
|
| 650 |
}
|
675 |
}
|
| 651 |
};
|
676 |
};
|
| Line 657... |
Line 682... |
| 657 |
|
682 |
|
| 658 |
WidgetSaisie.prototype.validerForm = function() {
|
683 |
WidgetSaisie.prototype.validerForm = function() {
|
| 659 |
const observateur = ( $( '#form-observateur' ).valid() && $( '#courriel' ).valid() && $( '#courriel_confirmation' ).valid() ),
|
684 |
const observateur = ( $( '#form-observateur' ).valid() && $( '#courriel' ).valid() && $( '#courriel_confirmation' ).valid() ),
|
| 660 |
obs = $( '#form-observation' ).valid(),
|
685 |
obs = $( '#form-observation' ).valid(),
|
| 661 |
geoloc = ( valOk( $( '#latitude' ).val() ) && valOk( $( '#longitude' ).val() ) ) ,
|
- |
|
| 662 |
images = valOk( $( '#miniatures .miniature' ) ),
|
- |
|
| 663 |
taxon = valOk( $( '#taxon' ).val() ),
|
686 |
geoloc = ( valOk( $( '#latitude' ).val() ) && valOk( $( '#longitude' ).val() ) ) ,
|
| 664 |
// validation et panneau taxon/images
|
687 |
// validation et panneau taxon/images
|
| - |
|
688 |
certitudeTaxonImage = this.validerCertitudeTaxonImage(
|
| - |
|
689 |
valOk( $( '#taxon' ).val() ),
|
| - |
|
690 |
valOk( $( '#miniatures .miniature' ) )
|
| 665 |
taxonOuImage = this.validerTaxonImage( taxon, images );
|
691 |
);
|
| Line 666... |
Line 692... |
| 666 |
let chpsSupp = true;
|
692 |
let chpsSupp = true;
|
| 667 |
|
693 |
|
| 668 |
if ( valOk( $( '#form-supp' ) ) ) {
|
694 |
if ( valOk( $( '#form-supp' ) ) ) {
|
| Line 696... |
Line 722... |
| 696 |
$( '.nav.control-group' ).removeClass( 'error' );
|
722 |
$( '.nav.control-group' ).removeClass( 'error' );
|
| 697 |
} else {
|
723 |
} else {
|
| 698 |
this.afficherPanneau( '#dialogue-utilisateur-non-identifie' );
|
724 |
this.afficherPanneau( '#dialogue-utilisateur-non-identifie' );
|
| 699 |
$( '.nav.control-group' ).addClass( 'error' );
|
725 |
$( '.nav.control-group' ).addClass( 'error' );
|
| 700 |
}
|
726 |
}
|
| 701 |
return ( observateur && obs && geoloc && taxonOuImage && chpsSupp );
|
727 |
return ( observateur && obs && geoloc && certitudeTaxonImage && chpsSupp );
|
| 702 |
};
|
728 |
};
|
| Line 703... |
Line 729... |
| 703 |
|
729 |
|
| 704 |
// Referentiel ****************************************************************/
|
730 |
// Referentiel ****************************************************************/
|
| 705 |
// N'est pas utilisé en cas de taxon-liste
|
731 |
// N'est pas utilisé en cas de taxon-liste
|