Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 3174 Rev 3176
Line 73... Line 73...
73
  $( '#add-fields' ).click( function() {
73
  $( '#add-fields' ).click( function() {
74
    // Affichage du formulaire pour un champ
74
    // Affichage du formulaire pour un champ
75
    displayNewField( fieldIndex );
75
    displayNewField( fieldIndex );
76
    // Affichage du nom du champ
76
    // Affichage du nom du champ
77
    onChangeDisplayFieldLabel( fieldIndex );
77
    onChangeDisplayFieldLabel( fieldIndex );
-
 
78
    // Empêcher de créer plus d'une fois la même clé
-
 
79
    onChangeCheckKeyUnique();
78
    // Affichage des images/nom des documents importés dans les champs ajoutés
80
    // Affichage des images/nom des documents importés dans les champs ajoutés
79
    inputFile();
81
    inputFile();
80
    // Recueil des informations correspondantes au nouveau champ
82
    // Recueil des informations correspondantes au nouveau champ
81
    onChangeFieldTypeCollectDetails( fieldIndex );
83
    onChangeFieldTypeCollectDetails( fieldIndex );
82
    // Suppression d'un champ
84
    // Suppression d'un champ
Line 337... Line 339...
337
 
339
 
338
/*********************************************
340
/*********************************************
339
 *  Validation et envoi des nouveaux champs  *
341
 *  Validation et envoi des nouveaux champs  *
Line -... Line 342...
-
 
342
 *********************************************/
-
 
343
 
-
 
344
// Empêcher de créer plus d'une fois la même clé
-
 
345
function onChangeCheckKeyUnique() {
-
 
346
 if( 1 < $( '.field-key' ).length ) {
-
 
347
    let notUnique = false;
-
 
348
 
-
 
349
    $( '.field-key' ).change( function () {
-
 
350
          // On force le type de thisString en number pour comparer à l'index du for (plus bas)
-
 
351
      let thisIndex = Number( $( this ).attr( 'data-id' ) ),
-
 
352
          thisFieldKey = $( '.field-key[data-id="' + thisIndex + '"]' ),
-
 
353
          count = $( '.field-key' ).length;
-
 
354
 
-
 
355
      for(var index = 0 ; index < count ; index++) {
-
 
356
        let loopFieldKey = $( '.field-key[data-id="' + index + '"]' );
-
 
357
        // Si cet index ne correspond pas à un champ supprimé
-
 
358
        // On compare la valeur avec les autres champs
-
 
359
        if( 0 < loopFieldKey.length && thisIndex !== index && thisFieldKey.val() === loopFieldKey.val()) {
-
 
360
          notUnique = true;
-
 
361
        }
-
 
362
      }
-
 
363
      if( notUnique ) {
-
 
364
        // Le champ est signalé en rouge
-
 
365
        thisFieldKey.addClass( 'invalid' );
-
 
366
        // Un message d'alerte apparait sous le champ
-
 
367
        if( 0 === $( '.invalid-field-key[data-id="' + thisIndex + '"]' ).length ) {
-
 
368
          thisFieldKey.after(
-
 
369
            '<p class="message invalid-field-key" data-id="' + thisIndex + '">' +
-
 
370
              '<i class="fa fa-exclamation-triangle" aria-hidden="true" style="color:#ff5d55"></i>' +
-
 
371
              ' Vous avez déjà utilisé cette clé!' +
-
 
372
            '</p>'
-
 
373
          );
-
 
374
        }
-
 
375
        // Un message d'alerte apparait au dessus des boutons prévisualiser/valider
-
 
376
        if( 0 === $( '.invalid-field-key-bottom' ).length ) {
-
 
377
          $( '#new-fields' ).append(
-
 
378
            '<p class="message invalid-field-key-bottom">' +
-
 
379
              '<i class="fa fa-exclamation-triangle" aria-hidden="true" style="color:#ff5d55"></i>' +
-
 
380
              ' Une clé a été utilisée plusieurs fois' +
-
 
381
            '</p>'
-
 
382
          );
-
 
383
        }
-
 
384
        // Les boutons prévisualiser/valider sont désactivés et signalés en rouge
-
 
385
        $( '#preview-field , #validate-new-fields' ).addClass( 'invalid' ).css( 'pointer-events', 'none' );
-
 
386
      // Si on est ok on retire toutes les alertes
-
 
387
      } else {
-
 
388
        thisFieldKey.removeClass( 'invalid' );
-
 
389
        $( '#preview-field , #validate-new-fields' ).removeClass( 'invalid' );
-
 
390
        $( '.invalid-field-key[data-id="' + thisIndex + '"]' ).hide( 200 , function () {
-
 
391
          $( this ).remove();
-
 
392
        });
-
 
393
        $( '.invalid-field-key-bottom' ).hide( 200 , function () {
-
 
394
          $( this ).remove();
-
 
395
        });
-
 
396
        $( '#preview-field' )[0].style.removeProperty( 'pointer-events' );
-
 
397
        $( '#validate-new-fields' )[0].style.removeProperty( 'pointer-events' )
-
 
398
      }
-
 
399
      // Réinitialisation
-
 
400
      notUnique = false;
-
 
401
    });
-
 
402
  }
340
 *********************************************/
403
}
341
 
404
 
342
//Activation/Désactivation des boutons valider/prévisualiser
405
//Activation/Désactivation des boutons valider/prévisualiser
343
function activatePreviewAndValidateButtons() {
406
function activatePreviewAndValidateButtons() {
344
  var invalidElementInfos = false, // true si aucune option n'a été entrée pour un élément de liste (select, radio, etc.)
407
  var invalidElementInfos = false, // true si aucune option n'a été entrée pour un élément de liste (select, radio, etc.)
Line 463... Line 526...
463
      // Ajout de le nom au tableau de resultats
526
      // Ajout de le nom au tableau de resultats
464
      datasToSubmit[ resultArrayIndex ].name = $( '.field-name' , thisFieldset ).val();
527
      datasToSubmit[ resultArrayIndex ].name = $( '.field-name' , thisFieldset ).val();
465
      // Recueil de l'élément choisi pour le tableau de resultats
528
      // Recueil de l'élément choisi pour le tableau de resultats
466
      datasToSubmit[ resultArrayIndex ].element = $( '.field-element' , thisFieldset ).val();
529
      datasToSubmit[ resultArrayIndex ].element = $( '.field-element' , thisFieldset ).val();
467
      // Ajout de la valeur 'requis' ou non au tableau de resultats
530
      // Ajout de la valeur 'requis' ou non au tableau de resultats
468
      datasToSubmit[ resultArrayIndex ].mandatory = false;
-
 
469
      // Ajout de "champ requis"
-
 
470
      if( $( '.field-is_mandatory' , thisFieldset ).is( ':checked' ) ) {
531
      datasToSubmit[ resultArrayIndex ].mandatory = $( '.field-is_mandatory' , thisFieldset ).is( ':checked' );
471
        datasToSubmit[ resultArrayIndex ].mandatory = true;
-
 
472
      }
-
 
473
      // Ajout de l'unité au tableau de resultats
532
      // Ajout de l'unité au tableau de resultats
474
      if ( $( '.field-unit' , thisFieldset ).val() ) {
-
 
475
        datasToSubmit[ resultArrayIndex ].unit = $( '.field-unit' , thisFieldset ).val();
533
      datasToSubmit[ resultArrayIndex ].unit = $( '.field-unit' , thisFieldset ).val() || null;
476
      }
-
 
477
      // Ajout du tooltip au tableau de resultats
534
      // Ajout du tooltip au tableau de resultats
478
      if ( $( '.field-description' , thisFieldset ).val() ) {
-
 
479
        datasToSubmit[ resultArrayIndex ].description = $( '.field-description' , thisFieldset ).val();
535
      datasToSubmit[ resultArrayIndex ].description = $( '.field-description' , thisFieldset ).val() || null;
480
      }
-
 
481
      // Ajout du nom du document d'aide au tableau de resultats
536
      // Ajout du nom du document d'aide au tableau de resultats
482
      if ( $('.file-return.help-doc-' + index ).text() ) {
-
 
483
        datasToSubmit[ resultArrayIndex ].help = $( '.file-return.help-doc-' + index ).text();
537
      datasToSubmit[ resultArrayIndex ].help = $( '.file-return.help-doc-' + index ).text() || null;
484
      }
-
 
485
      // Collecte les des données dépendantes de l'élément choisi
538
      // Collecte les des données dépendantes de l'élément choisi
486
      // sous forme d'un tableau de resultats
539
      // sous forme d'un tableau de resultats
487
      onSelectCollectDataValuesToSubmit( datasToSubmit[ resultArrayIndex ] , thisFieldset );
540
      onSelectCollectDataValuesToSubmit( datasToSubmit[ resultArrayIndex ] , thisFieldset );
488
      if( $.isEmptyObject(datasToSubmit[ resultArrayIndex ].fieldValues) ){
541
      if( $.isEmptyObject(datasToSubmit[ resultArrayIndex ].fieldValues) ){
489
        delete datasToSubmit[ resultArrayIndex ].fieldValues;
542
        delete datasToSubmit[ resultArrayIndex ].fieldValues;
Line 534... Line 587...
534
        break;
587
        break;
Line 535... Line 588...
535
 
588
 
536
      case 'number':
589
      case 'number':
537
      case 'range':
590
      case 'range':
538
        // Placeholder
-
 
539
        if( $( '.aide-saisie' , thisFieldset ).val() ) {
591
        // Placeholder
540
         datasToSubmitObject.fieldValues.placeholder = $( '.aide-saisie' , thisFieldset ).val();
-
 
541
        }
592
        datasToSubmitObject.fieldValues.placeholder = $( '.aide-saisie' , thisFieldset ).val() || null;
542
        // Valeur par défaut
-
 
543
        if( $( '.default' , thisFieldset ).val() ) {
593
        // Valeur par défaut
544
          datasToSubmitObject.fieldValues.default = $( '.default' , thisFieldset ).val();
-
 
545
        }
594
        datasToSubmitObject.fieldValues.default = $( '.default' , thisFieldset ).val() || null;
546
        // Incrémentation ( attribut step="" )
-
 
547
        if( $( '.step' , thisFieldset ).val() ) {
595
        // Incrémentation ( attribut step="" )
548
          datasToSubmitObject.fieldValues.step = $( '.step' , thisFieldset ).val();
-
 
549
        }
596
         datasToSubmitObject.fieldValues.step = $( '.step' , thisFieldset ).val() || null;
550
        // Min
-
 
551
        if( $( '.min' , thisFieldset ).val() ) {
597
        // Min
552
          datasToSubmitObject.fieldValues.min = $( '.min' , thisFieldset ).val();
-
 
553
        }
598
        datasToSubmitObject.fieldValues.min = $( '.min' , thisFieldset ).val() || null;
554
        // Max
-
 
555
        if( $( '.max' , thisFieldset ).val() ) {
599
        // Max
556
          datasToSubmitObject.fieldValues.max = $( '.max' , thisFieldset ).val();
-
 
557
        }
600
        datasToSubmitObject.fieldValues.max = $( '.max' , thisFieldset ).val() || null;
Line 558... Line 601...
558
        break;
601
        break;
559
 
602
 
560
      case 'date':
-
 
561
        // Min
603
      case 'date':
562
        if( $( '.min' , thisFieldset ).val() ) {
-
 
563
          datasToSubmitObject.fieldValues.min = $( '.min' , thisFieldset ).val();
604
        // Min
564
        }
-
 
565
        // Max
605
        datasToSubmitObject.fieldValues.min = $( '.min' , thisFieldset ).val() || null;
566
        if( $( '.max' , thisFieldset ).val() ) {
-
 
567
         datasToSubmitObject.fieldValues.max = $( '.max' , thisFieldset ).val();
606
        // Max
Line 568... Line 607...
568
        }
607
        datasToSubmitObject.fieldValues.max = $( '.max' , thisFieldset ).val() || null;
569
        break;
608
        break;
570
 
609
 
571
      case 'email':
610
      case 'email':
572
      case 'text':
611
      case 'text':
573
      case 'textarea':
-
 
574
      default:
612
      case 'textarea':
575
        // Placeholder
-
 
576
        if( $( '.aide-saisie' , thisFieldset ).val() ) {
613
      default:
577
          datasToSubmitObject.fieldValues.placeholder = $( '.aide-saisie' , thisFieldset ).val();
614
        // Placeholder
578
        }
615
        datasToSubmitObject.fieldValues.placeholder = $( '.aide-saisie' , thisFieldset ).val() || null;
579
        break;
616
        break;
Line 580... Line 617...
580
    }
617
    }
581
    return datasToSubmitObject;
618
    return datasToSubmitObject;
582
}
619
}
583
 
620
 
584
// Ajout d'une valeur d'un élément liste (select, checkbox etc.)
621
// Ajout d'une valeur d'un élément liste (select, checkbox etc.)
-
 
622
// dans le tableau de resultats
585
// dans le tableau de resultats
623
function onChangeStoreListValueLabel( datasToSubmitObject , thisFieldset ) {
-
 
624
  $( '.list-value' , thisFieldset ).each( function() {
586
function onChangeStoreListValueLabel( datasToSubmitObject , thisFieldset ) {
625
    var selectedFieldElement = $( '.field-element' , thisFieldset ).val();
587
  $( '.list-value' , thisFieldset ).each( function() {
626
 
-
 
627
     if( $( this ).val() ){
588
    var selectedFieldElement = $( '.field-element' , thisFieldset ).val();
628
      // Is-default-value non cochée
-
 
629
      if( !$( '.is-defaut-value[data-list-value-id="' + $( this ).attr( 'data-list-value-id' ) + '"]' , thisFieldset ).attr( 'checked' ) ) {
589
     if( $( this ).val() ){
630
        datasToSubmitObject.fieldValues.listValue.push( $( this ).val() );
-
 
631
      // Is-default-value cochée pour select/radio
590
      if( !$( '.is-defaut-value[data-list-value-id="' + $( this ).attr('data-list-value-id') + '"]' , thisFieldset ).attr( 'checked' ) ) {
632
      } else if( 'select' ===  selectedFieldElement || 'radio' === selectedFieldElement ) {
-
 
633
        // Une seule valeur par defaut, devient la première valeur du tableau + '#'
591
        datasToSubmitObject.fieldValues.listValue.push( $( this ).val() );
634
        datasToSubmitObject.fieldValues.listValue.unshift( $( this ).val() + '#' );
592
      } else if( 'select' ===  selectedFieldElement || 'radio' === selectedFieldElement ) {
635
      // Is-default-value cochée pour checkbox/list-checkbox
593
        datasToSubmitObject.fieldValues.listValue.unshift( $( this ).val() + '#' );
636
      } else {
594
      } else {
637
        // On ajoute simplement la valeur au tableau + '#'
595
        datasToSubmitObject.fieldValues.listValue.push( $( this ).val() + '#' );
638
        datasToSubmitObject.fieldValues.listValue.push( $( this ).val() + '#' );
Line 596... Line 639...
596
      }
639
      }
597
    }
640
    }
598
  });
641
  });
Line 599... Line -...
599
}
-
 
600
 
642
}
601
/************************************************
-
 
602
 *  Fonction d'affichage des champs classiques  *
-
 
603
 ************************************************/
-
 
604
 
-
 
605
// Affichage des infos dès que disponibles
-
 
606
// pour les champs classiques
-
 
607
function renderFields( $source , $taget ) {
-
 
608
 
-
 
609
  if($source.val()) {
-
 
610
    $taget.text( $source.val() );
-
 
611
  }
643
 
612
  $source.change( function () {
644
/************************************************
613
    $taget.text( $( this ).val() );
645
 *  Fonction d'affichage des champs classiques  *
614
  });
646
 ************************************************/
615
}
647
 
616
 
648
// Prévisualisation
617
function DisplayClassicFields() {
649
function DisplayClassicFields() {
618
  // Affichage du titre du widget
650
  // Affichage du titre du widget
619
  renderFields( $('#titre') , $( '.widget-renderer h1' ) );
651
  renderFields( $('#titre') , $( '.widget-renderer h1' ) );
620
  // Affichage du nom du projet
652
  // Affichage du nom du projet
621
  renderFields( $('#projet') , $( '.projet-description' ));
653
  renderFields( $('#projet') , $( '.projet-description' ));
622
  // Affichage de la description
654
  // Affichage de la description
623
  renderFields( $('#description') , $( '.preview-description' ) );
655
  renderFields( $('#description') , $( '.preview-description' ) );
624
  // Affichage du logo s'il existe déjà
-
 
625
  if( $('#logo').val() ) {
656
  // Affichage du logo s'il existe déjà
626
    $( '#preview-logo' ).prop( 'src' , $( '#group-settings-form .logo img' ).prop('src') );
657
  if( $('#logo').val() || $('#logo')[0].defaultValue ) {
627
  }
-
 
628
  // Affichage du logo chargé
658
    $( '#preview-logo img' ).prop( 'src' , $( '#group-settings-form .logo img' ).prop('src') );
-
 
659
  }
-
 
660
  // Affichage du logo chargé
-
 
661
  $( '#logo.input-file' ).change( function( event ) {
629
  $( '#logo.input-file' ).change( function( event ) {
662
    // Si le 'change' était pas une suppression
630
 
663
    if( $.isEmptyObject( event.target.files[0] ) ) {
631
    if( !$.isEmptyObject( event.target.files[0] ) ) {
664
      $( '#preview-logo img' ).prop( 'src' , '' );
632
      $( '#preview-logo img' ).prop( 'src' , URL.createObjectURL( event.target.files[0] ) );
665
    // Si on a chargé un logo ou changé le fichier
633
    } else {
666
    } else {
Line 642... Line 675...
642
      $( '.widget-renderer' )[0].style.removeProperty( 'background' );
675
      $( '.widget-renderer' )[0].style.removeProperty( 'background' );
643
    }
676
    }
644
  });
677
  });
645
}
678
}
Line -... Line 679...
-
 
679
 
-
 
680
// Affichage des infos dès que disponibles
-
 
681
// pour les champs classiques
-
 
682
function renderFields( $source , $taget ) {
-
 
683
  if($source.val()) {
-
 
684
    $taget.text( $source.val() );
-
 
685
  }
-
 
686
  $source.change( function () {
-
 
687
    $taget.text( $( this ).val() );
-
 
688
  });
Line -... Line 689...
-
 
689
}
646
 
690
 
647
 
691
 
648
// /*****************************************************
692
/*****************************************************
Line 649... Line 693...
649
//  *  Fonction d'affichage des champs supplémentaires  *
693
 *  Fonction d'affichage des champs supplémentaires  *
650
//  *****************************************************/
694
 *****************************************************/
651
 
-
 
-
 
695
 
-
 
696
// Construction des éléments à visualiser
652
// Construction des éléments à visualiser
697
function onClickPreviewField( thisFieldset , index ) {
653
function onClickPreviewField( thisFieldset , index ) {
698
  // Récupération des données
654
 
699
      // Tous les champs
655
  var fieldLabel       = $( '.field-name'            , thisFieldset ).val(),
700
  var fieldLabel       = $( '.field-name'            , thisFieldset ).val(),//nom
656
      fieldKey         = $( '.field-key'             , thisFieldset ).val(),
701
      fieldKey         = $( '.field-key'             , thisFieldset ).val(),//clé
657
      fieldElement     = $( '.field-element'         , thisFieldset ).val(),
702
      fieldElement     = $( '.field-element'         , thisFieldset ).val(),//élément
658
      fieldIsMandatory = $( '.field-is_mandatory'    , thisFieldset ).is( ':checked' ),
703
      fieldIsMandatory = $( '.field-is_mandatory'    , thisFieldset ).is( ':checked' ),//champ requis
659
      fieldUnit        = $( '.field-unit'            , thisFieldset ).val(),
704
      fieldUnit        = $( '.field-unit'            , thisFieldset ).val(),//unités
660
      fieldTooltip     = $( '.field-description'     , thisFieldset ).val(),
705
      fieldTooltip     = $( '.field-description'     , thisFieldset ).val(),//info-bulle
661
      fieldHelp        = $( '.file-return.help-doc-' + index ).text(),
706
      fieldHelp        = $( '.file-return.help-doc-' + index ).text(),//nom du fichier d'aide
662
      fieldPlaceholder = $( '.aide-saisie'           , thisFieldset ).val() || '',
707
      fieldPlaceholder = $( '.aide-saisie'           , thisFieldset ).val() || '',//placeholder
663
      fieldDefaultNum  = $( '.default'               , thisFieldset ).val(),
708
      // Champs à valeur numérique ou date
-
 
709
      fieldStep        = $( '.step'                  , thisFieldset ).val(),
-
 
710
      fieldMin         = $( '.min'                   , thisFieldset ).val(),
664
      fieldStep        = $( '.step'                  , thisFieldset ).val(),
711
      fieldMax         = $( '.max'                   , thisFieldset ).val(),
665
      fieldMin         = $( '.min'                   , thisFieldset ).val(),
712
      // Champs "listes"
666
      fieldMax         = $( '.max'                   , thisFieldset ).val(),
-
 
667
      fieldOtherValue  = $( '.option-other-value'    , thisFieldset ).is( ':checked' ),
-
 
668
      fieldOptions     = collectListOptions( thisFieldset );
-
 
669
 
713
      fieldDefaultNum  = $( '.default'               , thisFieldset ).val(),//option pas default
670
 
714
      fieldOtherValue  = $( '.option-other-value'    , thisFieldset ).is( ':checked' ),//option autre
671
 
715
      fieldOptions     = collectListOptions( thisFieldset );//Array: toutes les options
-
 
716
  // Variables d'affichage
672
  var fieldHtmlObject  = {},
717
  var fieldHtml               = '',//variable contenant tout le html à afficher
673
      fieldHtml        = '',
718
      commonFieldsHtml        = {},//Éléments simples ou chaînes communes aux "listes"
674
      constHtml        = {},
719
      listFieldsHtml = {},//chaînes & html pour les listes mais non spécifiques
675
      listHtml         = {},
-
 
676
      count            = fieldOptions.length,
720
      listFieldsHtml          = {},//chaînes & html spécifiques aux listes
677
      fieldHelpClass   = '';
721
      count                   = fieldOptions.length;//nombre d'options, pour les boucles for
-
 
722
  //valeurs initiales des chaînes de caractères
678
 
723
  //Éléments simples ou chaînes communes aux "listes"
-
 
724
  commonFieldsHtml = {
679
  // Pour les éléments simples
725
    dataIdAttr : ' data-id="' + index + '"',
680
  fieldHtmlObject = {
726
    helpButton : '',//bouton aide
-
 
727
    helpClass  : '',//classe de l'élément associé au bouton aide
681
    fieldHelpButton : '',
728
    titleAttr  : '',//info-bulle
-
 
729
    fieldInput : {//attributs de l'élément
682
    fieldTitleAttr : '',
730
      typeAttr        : ' type="' + fieldElement + '"',
683
    fieldLabel     : {
731
      nameAttr        : ' name="' + fieldKey + '"',
684
      labelForAttr         :' for="' + fieldKey + '"',
732
      classAttr       : ' class="' +  fieldKey + '"',
685
      labelClassAttr       :'',
733
      placeholderAttr : '',
686
      labelOtherAttr       : '',
734
      mandatoryAttr   : '',//required
687
      labelContent         : fieldLabel
735
      otherAttr       : ''
688
    },
736
    },
689
    fieldInput     : {
-
 
690
      inputTypeAttr        : ' type="' + fieldElement + '"',
737
    fieldLabel : {//attributs et contenu du label
691
      inputNameAttr        : ' name="' + fieldKey + '"',
-
 
692
      inputDataIdAttr      : ' data-id="' + index + '"',
738
      labelContent    : fieldLabel,//label
693
      inputClassAttr       : ' class="' +  fieldKey + '"',
739
      forAttr         : ' for="' + fieldKey + '"',//attribut for
694
      inputPlaceholderAttr : '',
740
      classAttr       : '',//classe du label
695
      inputOtherAttr       : ''
-
 
696
    }
741
      otherAttr       : ''//tous autres attributs
697
  }
742
    }
698
 
743
  }
699
  // Pour les éléments de listes (select, checkbox, etc.)
744
  // Pour les éléments de listes (select, checkbox, etc.)
700
  constHtml = {
-
 
701
    fieldContainerContent : fieldLabel,
-
 
702
    fieldDataIdAttr       : ' data-id="' + index + '"',
-
 
703
    fieldTitleAttr        : '',
-
 
704
    fieldMandatoryAttr    : '',
-
 
705
    fieldContainerClass   : ''
-
 
706
  };
-
 
707
 
-
 
708
  listHtml = {
745
  listFieldsHtml = {
709
    optionLabel : {},
746
    containerContent : fieldLabel,//les options peuvent avoir chacune un label
710
    optionInput  : {
747
    containerClass   : '',//une classe pour le conteneur
711
      inputTypeAttr    : ' type="'  + fieldElement + '"',
-
 
712
      inputNameAttr    : ' name="'  + fieldKey + '"',
-
 
713
      inputClassAttr   : ' class="' +  fieldKey + '"',
748
    forAttr          : '',//correspond à l'id d'une checkbox/radio/list-checkbox
714
      inputOptionIdAttr : ''
-
 
715
    }
749
    optionIdAttr     : '',//value-id
716
  };
750
    defaultAttr      : ''//default
717
 
751
  };
718
  // Changement d'un élément existant:
752
  // Changement d'un élément existant:
719
  // supprimer le précédent pour ajouter le nouveau
753
  // supprimer le précédent pour ajouter le nouveau
720
  if( 0 < $( '.preview-fields' , thisFieldset ).length ) {
-
 
721
    $( '.preview-fields' , thisFieldset ).remove();
754
  if( 0 < $( '.preview-fields' , thisFieldset ).length ) {
722
  }
755
    $( '.preview-fields' , thisFieldset ).remove();
723
 
756
  }
724
  // Si l'élément est requis
757
  // Élément requis
725
  if( fieldIsMandatory ) {
758
  if( fieldIsMandatory ) {
726
    // Attribut required
759
    // Attribut required pour le listes
727
    fieldHtmlObject.fieldInput.inputOtherAttr += ' required="required"';
760
    commonFieldsHtml.fieldInput.mandatoryAttr = ' required="required"';
728
    // Nom du champ (éléments listes)
761
    // Nom du champ (éléments listes)
729
    constHtml.fieldContainerContent         += ' *';
762
    listFieldsHtml.containerContent         += ' *';
730
    // Nom du champ (éléments simples)
-
 
731
    fieldHtmlObject.fieldLabel.labelContent += ' *';
763
    // Nom du champ (éléments simples)
732
  }
764
    commonFieldsHtml.fieldLabel.labelContent += ' *';
733
 
765
  }
734
  // Si on a une infobulle
766
  // Infobulle
735
  if( '' !== fieldTooltip ) {
-
 
736
    fieldHtmlObject.fieldTitleAttr = ' title="' +  fieldTooltip + '"';
767
  if( '' !== fieldTooltip ) {
737
  }
768
    commonFieldsHtml.titleAttr = ' title="' +  fieldTooltip + '"';
738
 
769
  }
739
  // Si on a un placeholder
-
 
740
  if( '' !== fieldPlaceholder ) {
770
  // Placeholder
741
    fieldHtmlObject.fieldInput.inputPlaceholderAttr = ' placeholder="' +  fieldPlaceholder + '"';
-
 
-
 
771
  if( '' !== fieldPlaceholder ) {
742
    console.log(fieldPlaceholder);
772
    commonFieldsHtml.fieldInput.placeholderAttr = ' placeholder="' +  fieldPlaceholder + '"';
-
 
773
  }
743
  }
774
  // Fichier d'aide
-
 
775
  if( '' !== fieldHelp ) {
744
 
776
    // Bouton 'aide'
745
  if( '' !== fieldHelp ) {
777
    commonFieldsHtml.helpButton = '<div class="button help-button"><i class="fas fa-info-circle"></i></div>';
746
    fieldHtmlObject.fieldHelpButton = '<div class="button help-button"><i class="fas fa-info-circle"></i></div>';
-
 
747
    fieldHelpClass = ' and-help';
778
    // classe 'aide'
748
  }
779
    commonFieldsHtml.helpClass = ' and-help';
749
 
780
  }
750
  // html à ajouter en fonction de l'élément choisi
781
  // html à ajouter en fonction de l'élément choisi
751
  switch( fieldElement ) {
782
  switch( fieldElement ) {
752
    case 'checkbox' :
783
    case 'checkbox' :
753
    case 'radio' :
784
    case 'radio' :
754
      constHtml.fieldContainerClass = ' class="' + fieldElement +'"';
785
      listFieldsHtml.containerClass = ' class="' + fieldElement +'"';
755
      fieldHtml =
786
      fieldHtml =
756
        // Conteneur
787
        // Conteneur
757
        '<div' +
788
        '<div' +
758
          // Class="L'élément choisi"
789
          // Class="L'élément choisi"
759
          constHtml.fieldContainerClass +
790
          listFieldsHtml.containerClass +
760
          // DataId
791
          // DataId
761
          constHtml.fieldDataIdAttr +
792
          commonFieldsHtml.dataIdAttr +
762
          // Required
793
          // Required
763
          constHtml.fieldMandatoryAttr +
794
          commonFieldsHtml.fieldInput.mandatoryAttr +
764
          // Info bulle
795
          // Info bulle
-
 
796
          commonFieldsHtml.titleAttr +
765
          constHtml.fieldTitleAttr +
797
        ' >'+
-
 
798
          // Nom du champ
766
        ' >'+
799
          // Classe 'and-help'
767
          // Nom du champ
800
          '<div class="list-label' + commonFieldsHtml.helpClass + '">' +
-
 
801
            // Label
768
          '<div class="list-label' + fieldHelpClass + '">' +
802
            listFieldsHtml.containerContent +
769
            constHtml.fieldContainerContent +
803
          '</div>' +
770
          '</div>' +
804
          // Bouton 'help'
771
          fieldHtmlObject.fieldHelpButton;
805
          commonFieldsHtml.helpButton;
772
      // On déroule les différentes valeurs
-
 
773
      for ( let i = 0; i < count; i++ ) {
806
      // On déroule les différentes valeurs
774
        let fieldOption = fieldOptions[i];
807
      for( let i = 0; i < count; i++ ) {
775
 
808
        let fieldOption = fieldOptions[i];
776
        listHtml.optionInput.inputDefaultAttr = '';
-
 
-
 
809
        // L'id de input
777
        listHtml.optionInput.inputIdAttr = ' id="' + fieldOption.optionValue + '"';
810
        listFieldsHtml.inputIdAttr = ' id="' + fieldOption.optionValue + '"';
778
        listHtml.optionLabel.labelForAttr = ' for="' + fieldOption.optionValue + '"';
811
        listFieldsHtml.forAttr = ' for="' + fieldOption.optionValue + '"';
779
 
812
        // Default
780
        // Si c'est une/l'option par défaut
813
        listFieldsHtml.defaultAttr = '';//réinitialisation
781
        if( fieldOption.isDefault ) {
-
 
782
          listHtml.optionInput.inputDefaultAttr = ' checked';
814
        if( fieldOption.isDefault ) {//affectation
783
        }
815
          listFieldsHtml.defaultAttr = ' checked';
784
 
816
        }
785
        // L'indice de chaque option
817
        // L'indice de chaque option
786
        // L'option "autre" n'en a pas
818
        // L'option "autre" n'en a pas
Line 787... Line 819...
787
        if( '' !== fieldOption.optionIndex ) {
819
        if( '' !== fieldOption.optionIndex ) {
788
          listHtml.optionInput.inputOptionIdAttr = ' value-id="' + fieldOption.optionIndex + '"';
820
          listFieldsHtml.optionIdAttr = ' value-id="' + fieldOption.optionIndex + '"';
789
        }
821
        }
790
 
822
 
791
        fieldHtml +=
823
        fieldHtml +=
792
          '<label' +
824
          '<label' +
793
            // For
825
            // For
794
            listHtml.optionLabel.labelForAttr +
826
            listFieldsHtml.forAttr +
795
            // value-id
827
            // value-id
796
            listHtml.optionInput.inputOptionIdAttr +
828
            listFieldsHtml.optionIdAttr +
797
            // Class="nom du champ"
829
            // Class="nom du champ"
-
 
830
            commonFieldsHtml.fieldInput.classAttr +
-
 
831
          '>' +
798
            listHtml.optionInput.inputClassAttr +
832
            '<input' +
799
          '>' +
833
              // Type
800
            '<input' +
834
              commonFieldsHtml.fieldInput.typeAttr +
801
              // Type
835
              // Id
802
              listHtml.optionInput.inputTypeAttr +
836
              listFieldsHtml.inputIdAttr +
803
              // DataId
837
              // DataId
804
              constHtml.fieldDataIdAttr +
838
              commonFieldsHtml.dataIdAttr +
805
              // value-id
839
              // value-id
806
              listHtml.optionInput.inputOptionIdAttr +
840
              listFieldsHtml.optionIdAttr +
807
              // Name
841
              // Name
808
              listHtml.optionInput.inputNameAttr +
842
              commonFieldsHtml.fieldInput.nameAttr +
809
              // Value
843
              // Value
810
              ' value="' + fieldOption.optionValue + '"' +
844
              ' value="' + fieldOption.optionValue + '"' +
811
              // Checked
845
              // Checked
812
              listHtml.optionInput.inputDefaultAttr +
846
              listFieldsHtml.defaultAttr +
813
              // Class="nom du champ"
847
              // Class="nom du champ"
814
              listHtml.optionInput.inputClassAttr +
848
              commonFieldsHtml.fieldInput.classAttr +
815
            '>' +
-
 
816
            // Label de l'option
849
            '>' +
817
            fieldOption.optionText +
850
            // Label de l'option
818
          '</label>';
851
            fieldOption.optionText +
819
 
852
          '</label>';
820
        // Si valeur "autre" est cochée
853
        // Si valeur "autre" est cochée
821
        if( fieldOtherValue ) {
854
        if( fieldOtherValue ) {
822
          fieldHtml +=
855
          fieldHtml +=
823
            '<label for="other"' +
856
            '<label for="other"' +
824
              constHtml.fieldDataIdAttr +
857
              commonFieldsHtml.dataIdAttr +
825
            '>' +
858
            '>' +
826
              '<input' +
859
              '<input' +
827
                listHtml.optionInput.inputTypeAttr +
860
                commonFieldsHtml.fieldInput.typeAttr +
828
                ' id="other"' +
861
                ' id="other"' +
829
                listHtml.optionInput.inputNameAttr +
862
                commonFieldsHtml.fieldInput.nameAttr +
830
                ' value="other"' +
863
                ' value="other"' +
831
                listHtml.optionInput.inputClassAttr +
864
                commonFieldsHtml.fieldInput.classAttr +
832
                constHtml.fieldDataIdAttr +
865
                commonFieldsHtml.dataIdAttr +
833
              '>' +
866
              '>' +
834
            'Autre</label>';
867
            'Autre</label>';
835
        }
-
 
836
      }
868
        }
Line 837... Line 869...
837
      // Fin du conteneur
869
      }
838
      fieldHtml += '</div>';
870
      // Fin du conteneur
-
 
871
      fieldHtml += '</div>';
839
 
872
      break;
840
      break;
873
 
841
 
874
    case 'list-checkbox':
842
    case 'list-checkbox':
875
      fieldHtml =
843
      fieldHtml =
876
        // Classe 'and-help'
844
        '<div class="multiselect ' + fieldElement + fieldHelpClass + '"' +
877
        '<div class="multiselect ' + fieldElement + commonFieldsHtml.helpClass + '"' +
845
          // DataId
878
          // DataId
846
          constHtml.fieldDataIdAttr +
879
          commonFieldsHtml.dataIdAttr +
847
        '>' +
880
        '>' +
848
          '<label>' +
881
          '<label>' +
849
            // Nom du champ
882
            // Nom du champ
850
            constHtml.fieldContainerContent +
883
            listFieldsHtml.containerContent +
851
          '</label>' +
-
 
852
          '<div class="selectBox"' +
884
          '</label>' +
853
            // DataId
885
          '<div class="selectBox"' +
854
            constHtml.fieldDataIdAttr +
886
            // DataId
855
          '>' +
887
            commonFieldsHtml.dataIdAttr +
856
 
888
          '>' +
857
            '<select' +
889
            '<select' +
858
              // DataId
890
              // DataId
859
              constHtml.fieldDataIdAttr +
891
              commonFieldsHtml.dataIdAttr +
860
              // Required
892
              // Required
861
              constHtml.fieldMandatoryAttr +
893
              commonFieldsHtml.fieldInput.mandatoryAttr +
862
              // Info bulle
894
              // Info bulle
863
              constHtml.fieldTitleAttr +
895
              commonFieldsHtml.titleAttr +
864
            '>' +
896
            '>' +
865
              // Apparait dans la barre de sélection
897
              // Apparait dans la barre de sélection
866
              '<option>Plusieurs choix possibles</option>' +
898
              '<option>Plusieurs choix possibles</option>' +
867
            '</select>' +
899
            '</select>' +
868
            '<div class="overSelect"></div>' +
900
            '<div class="overSelect"></div>' +
869
          '</div>' +
901
          '</div>' +
870
          '<div class="checkboxes hidden"' +
902
          '<div class="checkboxes hidden"' +
871
            // DataId
903
            // DataId
872
            constHtml.fieldDataIdAttr +
-
 
-
 
904
            commonFieldsHtml.dataIdAttr +
873
          '>';
905
          '>';
-
 
906
      // On déroule les différentes valeurs
874
      // On déroule les différentes valeurs
907
      for( let i = 0; i < count; i++ ) {
-
 
908
        let fieldOption = fieldOptions[i];
875
      for ( let i = 0; i < count; i++ ) {
909
        // Type="checkbox"
-
 
910
        commonFieldsHtml.fieldInput.typeAttr = ' type="checkbox"';
876
        let fieldOption = fieldOptions[i];
911
        // Id
877
 
-
 
878
        listHtml.optionInput.inputTypeAttr = ' type="checkbox"';
912
        listFieldsHtml.inputIdAttr = ' id="' + fieldOption.optionValue.toLowerCase() + '"';
879
        listHtml.optionInput.inputIdAttr = ' id="' + fieldOption.optionValue.toLowerCase() + '"';
913
        // For
880
        listHtml.optionLabel.labelForAttr = ' for="' + fieldOption.optionValue.toLowerCase() + '"';
914
        listFieldsHtml.forAttr = ' for="' + fieldOption.optionValue.toLowerCase() + '"';
881
        listHtml.optionInput.inputDefaultAttr = '';
-
 
-
 
915
        // Default
882
 
916
        listFieldsHtml.defaultAttr = '';//réinitialisation
883
        if( fieldOption.isDefault ) {
917
        if( fieldOption.isDefault ) {
884
          listHtml.optionInput.inputDefaultAttr = ' checked';
918
          listFieldsHtml.defaultAttr = ' checked';//affectation
Line 885... Line 919...
885
        }
919
        }
886
 
-
 
887
        if( '' !== fieldOption.optionIndex ) {
920
        // value-id
-
 
921
        if( '' !== fieldOption.optionIndex ) {
888
          listHtml.optionInput.inputOptionIdAttr = ' value-id="' + fieldOption.optionIndex + '"';
922
          listFieldsHtml.optionIdAttr = ' value-id="' + fieldOption.optionIndex + '"';
889
        }
923
        }
890
 
924
 
891
        fieldHtml +=
925
        fieldHtml +=
892
 
-
 
893
          '<label' +
926
          '<label' +
-
 
927
            // For
-
 
928
            listFieldsHtml.forAttr +
894
            listHtml.optionLabel.labelForAttr +
929
            // value-id
895
            // value-id
930
            listFieldsHtml.optionIdAttr +
896
            listHtml.optionInput.inputOptionIdAttr +
931
          '>' +
897
          '>' +
932
            '<input type="checkbox"' +
898
 
933
              // Id
899
            '<input type="checkbox"' +
934
              listFieldsHtml.inputIdAttr +
900
              // value-id
935
              // value-id
901
              listHtml.optionInput.inputOptionIdAttr +
936
              listFieldsHtml.optionIdAttr +
902
              // Name
937
              // Name
903
              listHtml.optionInput.inputNameAttr +
938
              commonFieldsHtml.fieldInput.nameAttr +
904
              // Value
939
              // Value
905
              ' value="' + fieldOption.optionValue + '"' +
940
              ' value="' + fieldOption.optionValue + '"' +
906
              // Checked
941
              // Checked
907
              listHtml.optionInput.inputDefaultAttr +
942
              listFieldsHtml.defaultAttr +
908
              // Class="nom du champ"
943
              // Class="nom du champ"
909
              listHtml.optionInput.inputClassAttr +
944
              commonFieldsHtml.fieldInput.classAttr +
910
              // DataId
945
              // DataId
911
              constHtml.fieldDataIdAttr +
-
 
912
            '>' +
946
              commonFieldsHtml.dataIdAttr +
913
            // Label de l'option
947
            '>' +
914
            fieldOption.optionText +
948
            // Label de l'option
915
          '</label>';
949
            fieldOption.optionText +
916
      }
950
          '</label>';
917
 
951
      }
918
      // Si valeur "autre" est cochée
952
      // Si valeur "autre" est cochée
919
      if( fieldOtherValue ) {
953
      if( fieldOtherValue ) {
920
        fieldHtml +=
954
        fieldHtml +=
921
          '<label for="other"' +
955
          '<label for="other"' +
922
            // DataId
956
            // DataId
923
            constHtml.fieldDataIdAttr +
957
            commonFieldsHtml.dataIdAttr +
924
          '>' +
958
          '>' +
925
            '<input type="checkbox"' +
959
            '<input type="checkbox"' +
926
              ' id="other"' +
960
              ' id="other"' +
927
              listHtml.optionInput.inputNameAttr +
961
              commonFieldsHtml.fieldInput.nameAttr +
928
              ' value="other"' +
962
              ' value="other"' +
929
              listHtml.optionInput.inputClassAttr +
-
 
930
              // DataId
963
              commonFieldsHtml.fieldInput.classAttr +
931
              constHtml.fieldDataIdAttr +
964
              // DataId
932
            '>' +
965
              commonFieldsHtml.dataIdAttr +
933
          'Autre</label>';
966
            '>' +
-
 
967
          'Autre</label>';
934
      }
968
      }
935
 
-
 
936
      // Fermeture des conteneurs .multiselect .checkboxes
969
      // Fermeture des conteneurs .multiselect .checkboxes
Line 937... Line 970...
937
      fieldHtml +=
970
      fieldHtml +=
938
        '</div>'+
971
        '</div>'+
939
      '</div>' +
972
      '</div>' +
940
      fieldHtmlObject.fieldHelpButton;
973
      // Bouton 'help'
941
 
974
      commonFieldsHtml.helpButton;
942
      break;
975
      break;
943
 
976
 
944
    case 'select':
977
    case 'select':
945
      fieldHtml =
978
      fieldHtml =
946
        '<label' +
979
        '<label' +
947
          ' for="' + fieldKey + '"' +
980
          commonFieldsHtml.fieldLabel.forAttr +
-
 
981
          // Info bulle
948
          // Info bulle
982
          commonFieldsHtml.titleAttr +
-
 
983
        '>' +
949
          constHtml.fieldTitleAttr +
984
          // Nom du champ
950
        '>' +
985
          listFieldsHtml.containerContent +
951
          // Nom du champ
986
        '</label>' +
952
          constHtml.fieldContainerContent +
987
        // Conteneur/Wrapper
953
        '</label>' +
988
        // +Classe 'and-help'
954
        // Conteneur/Wrapper
989
        '<div class="select-wrapper add-field-select ' + fieldElement + commonFieldsHtml.helpClass + '"' +
955
        '<div class="select-wrapper add-field-select ' + fieldElement + fieldHelpClass + '"' +
990
          // DataID
956
          constHtml.fieldDataIdAttr +
991
          commonFieldsHtml.dataIdAttr +
957
        '>' +
992
        '>' +
958
          '<select' +
993
          '<select' +
959
            ' name="' + fieldKey + '"' +
994
            commonFieldsHtml.fieldInput.nameAttr +
960
            ' id="' + fieldKey + '"' +
995
            ' id="' + fieldKey + '"' +
Line 961... Line 996...
961
            //Class
996
            // Class
962
            listHtml.optionInput.inputClassAttr +
997
            commonFieldsHtml.fieldInput.classAttr +
963
            // Required
998
            // Required
964
            constHtml.fieldMandatoryAttr +
-
 
965
            // DataId
999
            commonFieldsHtml.fieldInput.mandatoryAttr +
966
            constHtml.fieldDataIdAttr +
1000
            // DataId
967
          '>';
-
 
968
 
1001
            commonFieldsHtml.dataIdAttr +
969
      // On déroule les différentes valeurs
1002
          '>';
970
      for ( let i = 0; i < count; i++ ) {
1003
 
971
        let fieldOption = fieldOptions[i];
-
 
-
 
1004
      // On déroule les différentes valeurs
972
 
1005
      for( let i = 0; i < count; i++ ) {
973
        listHtml.optionInput.inputDefaultAttr = '';
1006
        let fieldOption = fieldOptions[i];
974
        listHtml.optionInput.inputdisabledAttr = '';
1007
        // Default
Line 975... Line 1008...
975
 
1008
        listFieldsHtml.defaultAttr = '';//réinitialisation
976
        if( fieldOption.isDefault ) {
1009
        if( fieldOption.isDefault ) {//affectation
977
          listHtml.optionInput.inputDefaultAttr = ' selected="selected"';
1010
          listFieldsHtml.defaultAttr = ' selected="selected"';
978
        }
1011
        }
979
 
1012
        // value-id
980
        if( '' !== fieldOption.optionIndex ) {
1013
        if( '' !== fieldOption.optionIndex ) {
981
          listHtml.optionInput.inputOptionIdAttr = ' value-id="' + fieldOption.optionIndex + '"';
1014
          listFieldsHtml.optionIdAttr = ' value-id="' + fieldOption.optionIndex + '"';
982
        }
1015
        }
983
 
1016
 
984
        fieldHtml +=
1017
        fieldHtml +=
985
          '<option' +
1018
          '<option' +
986
            // Value
1019
            // Value
987
            ' value="' + fieldOption.optionValue + '"' +
1020
            ' value="' + fieldOption.optionValue + '"' +
988
            // Value-id
-
 
989
            listHtml.optionInput.inputOptionIdAttr +
1021
            // Value-id
990
            // Selected
1022
            listFieldsHtml.optionIdAttr +
991
            listHtml.optionInput.inputDefaultAttr +
1023
            // Selected
992
          '>' +
1024
            listFieldsHtml.defaultAttr +
993
            // Option
1025
          '>' +
994
            fieldOption.optionText +
1026
            // Option
995
          '</option>';
1027
            fieldOption.optionText +
996
      }
-
 
-
 
1028
          '</option>';
997
 
1029
      }
998
      // Si valeur "autre" est cochée
1030
      // Si valeur "autre" est cochée
999
      if( fieldOtherValue ) {
1031
      if( fieldOtherValue ) {
1000
        fieldHtml +=
1032
        fieldHtml +=
1001
          '<option class="other" value="other"' + constHtml.fieldDataIdAttr + '>' +
-
 
-
 
1033
          '<option class="other" value="other"' + commonFieldsHtml.dataIdAttr + '>' +
1002
            'Autre' +
1034
            'Autre' +
1003
          '</option>';
-
 
1004
      }
1035
          '</option>';
Line 1005... Line 1036...
1005
 
1036
      }
-
 
1037
      // Fermeture des conteneurs
1006
      fieldHtml +=
1038
      fieldHtml +=
1007
          '</select>' +
1039
          '</select>' +
1008
        // Fin du conteneur/wrapper
-
 
-
 
1040
        // Fin du conteneur/wrapper
1009
        '</div>' +
1041
        '</div>' +
1010
 
-
 
-
 
1042
        // Bouton 'help'
1011
        fieldHtmlObject.fieldHelpButton;
1043
        commonFieldsHtml.helpButton;
Line 1012... Line 1044...
1012
 
1044
      break;
-
 
1045
 
1013
      break;
1046
    case 'file' :
1014
 
1047
      // Ouvrir l'attribut class (suppression de '"')
1015
    case 'file' :
1048
      commonFieldsHtml.fieldInput.classAttr = commonFieldsHtml.fieldInput.classAttr.slice(0, -1);
1016
      fieldHtmlObject.fieldInput.inputClassAttr = fieldHtmlObject.fieldInput.inputClassAttr.slice(0, -1);
1049
      commonFieldsHtml.fieldInput.classAttr += ' input-file"';
1017
      fieldHtmlObject.fieldInput.inputClassAttr += ' input-file"';
1050
      // Class du label
1018
 
1051
      commonFieldsHtml.fieldLabel.classAttr = ' class="label-file"';
1019
      fieldHtmlObject.fieldLabel.labelClassAttr = ' class="label-file"';
1052
      // Type de fichiers acceptés
1020
 
1053
      commonFieldsHtml.fieldInput.otherAttr += ' accept="application/pdf, image/*, video/*"';
1021
      fieldHtmlObject.fieldInput.inputOtherAttr += ' accept="application/pdf, image/*, video/*"';
1054
 
1022
 
1055
      fieldHtml =
1023
      fieldHtml =
1056
        // Classe 'and-help'
1024
        '<div class="input-file-container' + fieldHelpClass + '">' +
1057
        '<div class="input-file-container' + commonFieldsHtml.helpClass + '">' +
1025
          '<input' +
1058
          '<input' +
1026
            // Type
1059
            // Type
-
 
1060
            commonFieldsHtml.fieldInput.typeAttr +
-
 
1061
            // Name
1027
            fieldHtmlObject.fieldInput.inputTypeAttr +
1062
            commonFieldsHtml.fieldInput.nameAttr +
1028
            // Name
1063
            // DataId
1029
            fieldHtmlObject.fieldInput.inputNameAttr +
1064
            commonFieldsHtml.dataIdAttr +
1030
            // DataId
-
 
1031
            fieldHtmlObject.fieldInput.inputDataIdAttr +
1065
            // Class
1032
            // Class
1066
            commonFieldsHtml.fieldInput.classAttr +
1033
            fieldHtmlObject.fieldInput.inputClassAttr +
1067
            // Info-bulle
1034
            // Info-bulle
1068
            commonFieldsHtml.titleAttr +
1035
            fieldHtmlObject.fieldTitleAttr +
1069
            // Placeholder
1036
            // Placeholder
1070
            commonFieldsHtml.fieldInput.placeholderAttr +
1037
            fieldHtmlObject.fieldInput.inputPlaceholderAttr +
1071
            // Required
1038
            // Autres attributs
1072
            commonFieldsHtml.fieldInput.mandatoryAttr +
1039
            fieldHtmlObject.fieldInput.inputOtherAttr +
1073
            // Autres attributs
1040
          '>' +
1074
            commonFieldsHtml.fieldInput.otherAttr +
1041
 
1075
          '>' +
1042
          '<label' +
-
 
1043
            // For
1076
          '<label' +
1044
            fieldHtmlObject.fieldLabel.labelForAttr +
-
 
-
 
1077
            // For
1045
            // Class
1078
            commonFieldsHtml.fieldLabel.forAttr +
1046
            fieldHtmlObject.fieldLabel.labelClassAttr +
-
 
-
 
1079
            // Class
1047
            // Info-bulle
1080
            commonFieldsHtml.fieldLabel.classAttr +
1048
            fieldHtmlObject.fieldTitleAttr +
-
 
1049
          '><i class="fas fa-download"></i> ' +
1081
            // Info-bulle
Line 1050... Line 1082...
1050
            // Nom du champ
1082
            commonFieldsHtml.titleAttr +
-
 
1083
          '><i class="fas fa-download"></i> ' +
1051
            fieldHtmlObject.fieldLabel.labelContent +
1084
            // Nom du champ
1052
          '</label>' +
1085
            commonFieldsHtml.fieldLabel.labelContent +
1053
 
1086
          '</label>' +
Line 1054... Line 1087...
1054
        '</div>' +
1087
        '</div>' +
1055
 
1088
        // Bouton supprimer le fichier
1056
        '<div class="remove-file button" name="remove-file" title="Supprimer le fichier"><i class="fas fa-times" aria-hidden="true"></i></div>' +
1089
        '<div class="remove-file button" name="remove-file" title="Supprimer le fichier"><i class="fas fa-times" aria-hidden="true"></i></div>' +
1057
 
1090
        // Bouton 'help'
1058
        fieldHtmlObject.fieldHelpButton;
1091
        commonFieldsHtml.helpButton;
1059
 
1092
      break;
1060
      break;
1093
 
1061
 
1094
    case 'textarea':
1062
    case 'textarea':
1095
      // Classe 'and-help'
1063
      fieldHtmlObject.fieldLabel.labelClassAttr = ' class="' + fieldHelpClass + '"';
1096
      commonFieldsHtml.fieldLabel.classAttr = ' class="' + commonFieldsHtml.helpClass + '"';
1064
      // Autres attributs
1097
      // Autres attributs
1065
      fieldHtmlObject.fieldInput.inputOtherAttr += ' id="' + fieldKey + '"';
1098
      commonFieldsHtml.fieldInput.otherAttr += ' id="' + fieldKey + '"';
1066
 
1099
 
1067
      fieldHtml =
1100
      fieldHtml =
1068
        '<label' +
-
 
-
 
1101
        '<label' +
1069
          // For
1102
          // For
1070
          fieldHtmlObject.fieldLabel.labelForAttr +
-
 
1071
          // Class
1103
          commonFieldsHtml.fieldLabel.forAttr +
1072
          fieldHtmlObject.fieldLabel.labelClassAttr +
1104
          // Class
1073
          // Info-bulle
1105
          commonFieldsHtml.fieldLabel.classAttr +
1074
          fieldHtmlObject.fieldTitleAttr +
1106
          // Info-bulle
1075
          // Autres attributs
1107
          commonFieldsHtml.titleAttr +
1076
          fieldHtmlObject.fieldLabel.labelOtherAttr +
1108
          // Autres attributs
1077
        '>' +
1109
          commonFieldsHtml.fieldLabel.otherAttr +
1078
          // Nom du champ
1110
        '>' +
1079
          fieldHtmlObject.fieldLabel.labelContent +
1111
          // Nom du champ
1080
        '</label>' +
1112
          commonFieldsHtml.fieldLabel.labelContent +
1081
 
1113
        '</label>' +
-
 
1114
        // Bouton 'help'
-
 
1115
        commonFieldsHtml.helpButton +
1082
        fieldHtmlObject.fieldHelpButton +
1116
        '<textarea' +
1083
 
1117
          // Name
1084
        '<textarea' +
1118
          commonFieldsHtml.fieldInput.nameAttr +
1085
          // Name
-
 
1086
          fieldHtmlObject.fieldInput.inputNameAttr +
1119
          // DataId
Line 1087... Line 1120...
1087
          // DataId
1120
          commonFieldsHtml.dataIdAttr +
-
 
1121
          // Class
1088
          fieldHtmlObject.fieldInput.inputDataIdAttr +
1122
          commonFieldsHtml.fieldInput.classAttr +
1089
          // Class
1123
          // Info-bulle
1090
          fieldHtmlObject.fieldInput.inputClassAttr +
1124
          commonFieldsHtml.titleAttr +
1091
          // Info-bulle
1125
          // Info-bulle
1092
          fieldHtmlObject.fieldTitleAttr +
1126
          commonFieldsHtml.fieldInput.placeholderAttr +
1093
          // Info-bulle
1127
          // Required
1094
          fieldHtmlObject.fieldInput.inputPlaceholderAttr +
1128
          commonFieldsHtml.fieldInput.mandatoryAttr +
1095
          // Autres attributs
1129
          // Autres attributs
1096
          fieldHtmlObject.fieldInput.inputOtherAttr +
1130
          commonFieldsHtml.fieldInput.otherAttr +
1097
        '></textarea>';
1131
        '></textarea>';
1098
 
1132
        break;
1099
        break;
1133
 
1100
 
1134
    case 'range':
Line 1101... Line 1135...
1101
    case 'range':
1135
      // Classe 'and-help'
1102
      fieldHtmlObject.fieldLabel.labelClassAttr = ' class="' + fieldHelpClass + '"';
1136
      commonFieldsHtml.fieldLabel.classAttr = ' class="' + commonFieldsHtml.helpClass + '"';
1103
 
1137
      // Step
1104
      if( '' !== fieldStep ) {
1138
      if( '' !== fieldStep ) {
1105
        fieldHtmlObject.fieldInput.inputOtherAttr += ' step="' +  fieldStep + '"';
1139
        commonFieldsHtml.fieldInput.otherAttr += ' step="' +  fieldStep + '"';
1106
      }
1140
      }
1107
 
1141
      // Min
1108
      if( '' !== fieldMin ) {
1142
      if( '' !== fieldMin ) {
1109
        fieldHtmlObject.fieldInput.inputOtherAttr += ' min="' +  fieldMin + '"';
1143
        commonFieldsHtml.fieldInput.otherAttr += ' min="' +  fieldMin + '"';
1110
      }
1144
      }
1111
 
1145
      //Max
1112
      if( '' !== fieldMax ) {
1146
      if( '' !== fieldMax ) {
1113
        fieldHtmlObject.fieldInput.inputOtherAttr += ' max="' +  fieldMax + '"';
1147
        commonFieldsHtml.fieldInput.otherAttr += ' max="' +  fieldMax + '"';
1114
      }
1148
      }
1115
 
1149
 
1116
      fieldHtml =
-
 
-
 
1150
      fieldHtml =
1117
        '<div class="number">' +
1151
        '<div class="number">' +
Line 1118... Line 1152...
1118
          '<label' +
1152
          '<label' +
1119
            // For
1153
            // For
1120
            fieldHtmlObject.fieldLabel.labelForAttr +
1154
            commonFieldsHtml.fieldLabel.forAttr +
1121
            // Class
1155
            // Class
1122
            fieldHtmlObject.fieldLabel.labelClassAttr +
1156
            commonFieldsHtml.fieldLabel.classAttr +
1123
            // Info-bulle
1157
            // Info-bulle
1124
            fieldHtmlObject.fieldTitleAttr +
1158
            commonFieldsHtml.titleAttr +
1125
            // Autres attributs
1159
            // Autres attributs
1126
            fieldHtmlObject.fieldLabel.labelOtherAttr +
1160
            commonFieldsHtml.fieldLabel.otherAttr +
1127
          '>' +
1161
          '>' +
1128
            // Nom du champ
1162
            // Nom du champ
1129
            fieldHtmlObject.fieldLabel.labelContent +
1163
            commonFieldsHtml.fieldLabel.labelContent +
1130
          '</label>' +
1164
          '</label>' +
-
 
1165
          // Bouton 'help'
-
 
1166
          commonFieldsHtml.helpButton +
1131
 
1167
 
1132
          fieldHtmlObject.fieldHelpButton +
1168
          '<input' +
1133
 
1169
            // Type
1134
          '<input' +
-
 
1135
            // Type
1170
            commonFieldsHtml.fieldInput.typeAttr +
1136
            fieldHtmlObject.fieldInput.inputTypeAttr +
-
 
1137
            // Name
1171
            // Name
Line 1138... Line 1172...
1138
            fieldHtmlObject.fieldInput.inputNameAttr +
1172
            commonFieldsHtml.fieldInput.nameAttr +
1139
            // DataId
1173
            // DataId
-
 
1174
            commonFieldsHtml.dataIdAttr +
1140
            fieldHtmlObject.fieldInput.inputDataIdAttr +
1175
            // Class
-
 
1176
            commonFieldsHtml.fieldInput.classAttr +
1141
            // Class
1177
            // Info-bulle
1142
            fieldHtmlObject.fieldInput.inputClassAttr +
1178
            commonFieldsHtml.titleAttr +
1143
            // Info-bulle
1179
            // Info-bulle
1144
            fieldHtmlObject.fieldTitleAttr +
1180
            commonFieldsHtml.fieldInput.placeholderAttr +
1145
            // Info-bulle
1181
            // Required
1146
            fieldHtmlObject.fieldInput.inputPlaceholderAttr +
1182
            commonFieldsHtml.fieldInput.mandatoryAttr +
1147
            // Autres attributs
1183
            // Autres attributs
1148
            fieldHtmlObject.fieldInput.inputOtherAttr +
1184
            commonFieldsHtml.fieldInput.otherAttr +
1149
          '>' +
1185
          '>' +
1150
 
1186
        '</div>';
1151
        '</div>';
1187
        break;
1152
 
1188
 
1153
        break;
1189
    case 'date':
1154
 
-
 
1155
    case 'date':
1190
    case 'number':
1156
    case 'number':
1191
      // Ouvrir l'attribut class (suppression de '"')
1157
      fieldHtmlObject.fieldInput.inputClassAttr = fieldHtmlObject.fieldInput.inputClassAttr.slice(0, -1);
1192
      commonFieldsHtml.fieldInput.classAttr = commonFieldsHtml.fieldInput.classAttr.slice(0, -1);
1158
      fieldHtmlObject.fieldInput.inputClassAttr += fieldHelpClass + '"';
1193
      // Classe 'and-help'
1159
 
1194
      commonFieldsHtml.fieldInput.classAttr += commonFieldsHtml.helpClass + '"';
1160
      if( '' !== fieldStep ) {
1195
      // Step
1161
        fieldHtmlObject.fieldInput.inputOtherAttr += ' step="' +  fieldStep + '"';
1196
      if( '' !== fieldStep ) {
1162
      }
1197
        commonFieldsHtml.fieldInput.otherAttr += ' step="' +  fieldStep + '"';
1163
 
1198
      }
1164
      if( '' !== fieldMin ) {
1199
      // Min
1165
        fieldHtmlObject.fieldInput.inputOtherAttr += ' min="' +  fieldMin + '"';
1200
      if( '' !== fieldMin ) {
1166
      }
1201
        commonFieldsHtml.fieldInput.otherAttr += ' min="' +  fieldMin + '"';
1167
 
1202
      }
1168
      if( '' !== fieldMax ) {
1203
      // Max
1169
        fieldHtmlObject.fieldInput.inputOtherAttr += ' max="' +  fieldMax + '"';
1204
      if( '' !== fieldMax ) {
1170
      }
-
 
1171
 
1205
        commonFieldsHtml.fieldInput.otherAttr += ' max="' +  fieldMax + '"';
1172
      fieldHtml =
1206
      }
1173
        '<div class="number">' +
1207
      fieldHtml =
1174
          '<label' +
1208
        '<div class="number">' +
1175
            // For
1209
          '<label' +
1176
            fieldHtmlObject.fieldLabel.labelForAttr +
1210
            // For
1177
            // Class
1211
            commonFieldsHtml.fieldLabel.forAttr +
1178
            fieldHtmlObject.fieldLabel.labelClassAttr +
1212
            // Class
1179
            // Info-bulle
1213
            commonFieldsHtml.fieldLabel.classAttr +
1180
            fieldHtmlObject.fieldTitleAttr +
1214
            // Info-bulle
1181
            // Autres attributs
1215
            commonFieldsHtml.titleAttr +
1182
            fieldHtmlObject.fieldLabel.labelOtherAttr +
1216
            // Autres attributs
1183
          '>' +
1217
            commonFieldsHtml.fieldLabel.otherAttr +
-
 
1218
          '>' +
-
 
1219
            // Nom du champ
1184
            // Nom du champ
1220
            commonFieldsHtml.fieldLabel.labelContent +
1185
            fieldHtmlObject.fieldLabel.labelContent +
1221
          '</label>' +
1186
          '</label>' +
1222
          '<input' +
1187
 
-
 
-
 
1223
            // Type
1188
          '<input' +
1224
            commonFieldsHtml.fieldInput.typeAttr +
1189
            // Type
-
 
1190
            fieldHtmlObject.fieldInput.inputTypeAttr +
1225
            // Name
1191
            // Name
-
 
1192
            fieldHtmlObject.fieldInput.inputNameAttr +
1226
            commonFieldsHtml.fieldInput.nameAttr +
Line 1193... Line 1227...
1193
            // DataId
1227
            // DataId
1194
            fieldHtmlObject.fieldInput.inputDataIdAttr +
1228
            commonFieldsHtml.dataIdAttr +
1195
            // Class
1229
            // Class
-
 
1230
            commonFieldsHtml.fieldInput.classAttr +
1196
            fieldHtmlObject.fieldInput.inputClassAttr +
1231
            // Info-bulle
-
 
1232
            commonFieldsHtml.titleAttr +
1197
            // Info-bulle
1233
            // Info-bulle
Line 1198... Line 1234...
1198
            fieldHtmlObject.fieldTitleAttr +
1234
            commonFieldsHtml.fieldInput.placeholderAttr +
1199
            // Info-bulle
1235
            // Required
1200
            fieldHtmlObject.fieldInput.inputPlaceholderAttr +
1236
            commonFieldsHtml.fieldInput.mandatoryAttr +
1201
            // Autres attributs
1237
            // Autres attributs
1202
            fieldHtmlObject.fieldInput.inputOtherAttr +
1238
            commonFieldsHtml.fieldInput.otherAttr +
1203
          '>' +
1239
          '>' +
1204
 
1240
          // Bouton 'help'
1205
          fieldHtmlObject.fieldHelpButton +
1241
          commonFieldsHtml.helpButton +
1206
 
1242
        '</div>';
1207
        '</div>';
1243
        break;
1208
 
1244
 
1209
        break;
1245
    case 'text' :
1210
 
1246
    case 'email':
1211
    case 'text' :
1247
    default:
1212
    case 'email':
-
 
1213
    default:
1248
      // Ouvrir l'attribut class (suppression de '"')
1214
      fieldHtmlObject.fieldInput.inputClassAttr = fieldHtmlObject.fieldInput.inputClassAttr.slice(0, -1);
1249
      commonFieldsHtml.fieldInput.classAttr = commonFieldsHtml.fieldInput.classAttr.slice(0, -1);
1215
      fieldHtmlObject.fieldInput.inputClassAttr += fieldHelpClass + '"';
1250
      // Classe 'and-help'
1216
 
1251
      commonFieldsHtml.fieldInput.classAttr += commonFieldsHtml.helpClass + '"';
1217
      fieldHtml =
1252
 
1218
        '<label' +
1253
      fieldHtml =
1219
          // For
1254
        '<label' +
1220
          fieldHtmlObject.fieldLabel.labelForAttr +
1255
          // For
1221
          // Class
1256
          commonFieldsHtml.fieldLabel.forAttr +
1222
          fieldHtmlObject.fieldLabel.labelClassAttr +
1257
          // Class
1223
          // Info-bulle
1258
          commonFieldsHtml.fieldLabel.classAttr +
1224
          fieldHtmlObject.fieldTitleAttr +
1259
          // Info-bulle
1225
          // Autres attributs
1260
          commonFieldsHtml.titleAttr +
-
 
1261
          // Autres attributs
-
 
1262
          commonFieldsHtml.fieldLabel.otherAttr +
1226
          fieldHtmlObject.fieldLabel.labelOtherAttr +
1263
        '>' +
1227
        '>' +
1264
          // Nom du champ
1228
          // Nom du champ
1265
          commonFieldsHtml.fieldLabel.labelContent +
1229
          fieldHtmlObject.fieldLabel.labelContent +
-
 
-
 
1266
        '</label>' +
1230
        '</label>' +
1267
        '<input' +
1231
 
-
 
1232
        '<input' +
1268
          // Type
1233
          // Type
1269
          commonFieldsHtml.fieldInput.typeAttr +
1234
          fieldHtmlObject.fieldInput.inputTypeAttr +
-
 
1235
          // Name
1270
          // Name
1236
          fieldHtmlObject.fieldInput.inputNameAttr +
1271
          commonFieldsHtml.fieldInput.nameAttr +
Line 1237... Line 1272...
1237
          // DataId
1272
          // DataId
1238
          fieldHtmlObject.fieldInput.inputDataIdAttr +
1273
          commonFieldsHtml.dataIdAttr +
1239
          // Class
1274
          // Class
1240
          fieldHtmlObject.fieldInput.inputClassAttr +
1275
          commonFieldsHtml.fieldInput.classAttr +
Line 1241... Line 1276...
1241
          // Info-bulle
1276
          // Info-bulle
1242
          fieldHtmlObject.fieldTitleAttr +
-
 
1243
          // Info-bulle
1277
          commonFieldsHtml.titleAttr +
1244
          fieldHtmlObject.fieldInput.inputPlaceholderAttr +
1278
          // Info-bulle
1245
          // Autres attributs
1279
          commonFieldsHtml.fieldInput.placeholderAttr +
1246
          fieldHtmlObject.fieldInput.inputOtherAttr +
1280
          // Required
1247
        '>' +
1281
          commonFieldsHtml.fieldInput.mandatoryAttr +
1248
 
1282
          // Autres attributs
1249
        fieldHtmlObject.fieldHelpButton;
1283
          commonFieldsHtml.fieldInput.otherAttr +
1250
 
1284
        '>' +
1251
      break;
1285
        // Bouton 'help'
1252
  }
1286
        commonFieldsHtml.helpButton;
1253
 
-
 
1254
  return fieldHtml;
1287
      break;
1255
}
1288
  }
1256
 
1289
  return fieldHtml;
Line 1257... Line 1290...
1257
// Construire un tableau des options pour chaque élément de listes
1290
}
1258
function collectListOptions( thisFieldset ) {
1291
 
-
 
1292
// Construire un tableau des options pour chaque élément de listes
-
 
1293
function collectListOptions( thisFieldset ) {
1259
  var $details = $( '.field-details' , thisFieldset ),
1294
  var $details = $( '.field-details' , thisFieldset ),
1260
      options = [];
1295
      options = [];
1261
 
1296
 
1262
  $details.find( '.new-value' ).each( function() {
1297
  $details.find( '.new-value' ).each( function() {
1263
 
1298
    options.push({
1264
    options.push({
1299
      // Valeur transmise (value)
1265
      // Valeur transmise (value)
1300
      optionValue : $( this ).find('.list-value').val().toLowerCase(),
1266
      optionValue : $( this ).find('.list-value').val().toLowerCase(),
1301
      // Valeur Visible
1267
      // Valeur Visible
-
 
1268
      optionText  : capitalize( $( this ).find('.list-value').val() ),
1302
      optionText  : capitalize( $( this ).find('.list-value').val() ),
1269
      // Booléen "default"
1303
      // Booléen "default"
1270
      isDefault   : $( this ).find( '.is-defaut-value').is( ':checked' ),
1304
      isDefault   : $( this ).find( '.is-defaut-value').is( ':checked' ),
1271
      // Indice de l'option
1305
      // Indice de l'option
1272
      optionIndex : $( this ).attr('data-list-value-id')
1306
      optionIndex : $( this ).attr('data-list-value-id')
Line 1273... Line 1307...
1273
    });
1307
    });
1274
 
1308
  });
1275
  });
1309
  return options;
1276
  return options;
1310
}
-
 
1311
 
1277
}
1312
// Faire apparaitre un champ text "Autre"
1278
 
1313
function onOtherOption( thisFieldset , index ) {
1279
// Faire apparaitre un champ text "Autre"
1314
  // Ce champ (dans la prévisualisation)
1280
function onOtherOption( thisFieldset , index ) {
1315
  var thisPreviewFieldset = $( '.preview-fields[data-id="' + index + '"]'),
1281
  //L'élément choisi
1316
      //L'élément choisi
1282
  var element = $('.field-element' , thisFieldset ).val(),
1317
      element             = $('.field-element' , thisFieldset ).val(),
1283
      // Où insérer le champ "Autre"
1318
      // Où insérer le champ "Autre"
1284
      $element = $( '.' + element , thisFieldset ),
1319
      $element            = $( '.' + element , thisPreviewFieldset ),
1285
      // html du champ "Autre"
-
 
1286
      collectOther =
1320
      // html du champ "Autre"
Line 1287... Line 1321...
1287
        '<label data-id="' + index + '" for="collect-other">Autre option :</label>' +
1321
      collectOther        =
1288
        '<input type="text" name="collect-other" data-id="' + index + '" class="collect-other" >';
1322
        '<label data-id="' + index + '" for="collect-other">Autre option :</label>' +
1289
 
1323
        '<input type="text" name="collect-other" data-id="' + index + '" class="collect-other" >';
1290
  // Pouvoir supprimer le champ "Autre"
1324
  // Pouvoir supprimer le champ "Autre"
1291
  function optionRemove( thisFieldset ) {
1325
  function optionRemove( thisPreviewFieldset ) {
1292
    $( 'label[for="collect-other"]' , thisFieldset ).remove();
1326
    $( 'label[for="collect-other"]' , thisPreviewFieldset ).remove();
1293
    $( 'input.collect-other' , thisFieldset ).remove();
1327
    $( 'input.collect-other' , thisPreviewFieldset ).remove();
1294
  }
1328
  }
1295
 
1329
 
1296
  switch( element ) {
1330
  switch( element ) {
1297
    case 'radio' :
1331
    case 'radio' :
1298
      // Lorsqu'un nouveau bouton est coché
-
 
1299
      $( 'input' , thisFieldset ).on( 'change' , function () {
1332
      // Lorsqu'un nouveau bouton est coché
Line 1300... Line 1333...
1300
        if( 'other' === $( this ).val() ) {
1333
      $( 'input' , thisPreviewFieldset ).on( 'change' , function () {
1301
          // Insertion du champ "Autre" après les boutons
1334
  console.log($( this ));
1302
          $element.after( collectOther );
1335
        if( 'other' === $( this ).val() ) {
1303
        } else {
1336
          // Insertion du champ "Autre" après les boutons
1304
          // Suppression du champ autre
1337
          $element.after( collectOther );
1305
          optionRemove( thisFieldset );
1338
        } else {
1306
        }
1339
          // Suppression du champ autre
1307
      });
1340
          optionRemove( thisPreviewFieldset );
1308
 
1341
        }
1309
      break;
1342
      });
1310
 
1343
      break;
1311
    case 'select' :
1344
 
1312
      // Lorsque l'option "Autre" est selectionnée
-
 
1313
      $( 'select' , thisFieldset ).on( 'change' , function () {
1345
    case 'select' :
Line 1314... Line 1346...
1314
        if( 'other' === $( this).val() ) {
1346
      // Lorsque l'option "Autre" est selectionnée
1315
          // Insertion du champ "Autre" après les boutons
1347
      $( 'select' , thisPreviewFieldset ).on( 'change' , function () {
1316
          $element.after( collectOther );
1348
        if( 'other' === $( this).val() ) {
Line 1367... Line 1399...
1367
      $( '#zone-supp .preview-container' ).append(
1399
      $( '#zone-supp .preview-container' ).append(
1368
        '<div class="preview-fields" data-id="' + index + '">'+
1400
        '<div class="preview-fields" data-id="' + index + '">'+
1369
          onClickPreviewField( thisFieldset , index ) +
1401
          onClickPreviewField( thisFieldset , index ) +
1370
        '</div>'
1402
        '</div>'
1371
      );
1403
      );
1372
 
-
 
1373
      // Ajout/suppression d'un champ texte "Autre"
1404
      // Ajout/suppression d'un champ texte "Autre"
1374
      if( $( '.option-other-value' , thisFieldset ).is( ':checked' ) ) {
1405
      if( $( '.option-other-value' , thisFieldset ).is( ':checked' ) ) {
1375
        onOtherOption( thisFieldset , index);
1406
        onOtherOption( thisFieldset , index);
1376
      }
1407
      }
1377
    }
1408
    }
1378
  }
1409
  }
1379
  // Le titre + message de la section prévisualisation ne sont ajoutés qu'une fois
1410
  // Le titre + message de la section prévisualisation ne sont ajoutés qu'une fois
1380
  firstClick = false;
1411
  firstClick = false;
1381
}
1412
}
Line -... Line 1413...
-
 
1413
 
-
 
1414
// Activation/Desactivation et contenu de la modale Bootstrap
1382
 
1415
// https://getbootstrap.com/docs/3.3/javascript/#modals
1383
function previewFieldHelpModal() {
1416
function previewFieldHelpModal() {
1384
  $( '#zone-supp' ).on( 'click' , '.help-button' , function ( event ) {
1417
  $( '#zone-supp' ).on( 'click' , '.help-button' , function ( event ) {
1385
    var index = $( this ).closest( '.preview-fields' ).attr( 'data-id' ),
1418
    var index = $( this ).closest( '.preview-fields' ).attr( 'data-id' ),
1386
        thisFieldset = $( '.new-field[data-id="' + index + '"]' ),
1419
        thisFieldset = $( '.new-field[data-id="' + index + '"]' ),
1387
        file = $( '.field-help' , thisFieldset )[0].files[0],
1420
        file = $( '.field-help' , thisFieldset )[0].files[0],
1388
        tmppath = URL.createObjectURL( file ),
1421
        tmppath = URL.createObjectURL( file );
1389
        helpModalHtml = '';
-
 
1390
 
1422
    // Titre
1391
    $( '#help-modal-label' ).text( 'Aide pour : ' +  $( '.field-name' , thisFieldset ).val() );
1423
    $( '#help-modal-label' ).text( 'Aide pour : ' +  $( '.field-name' , thisFieldset ).val() );
1392
 
1424
    // Contenu
1393
    if( file.type.match( 'image' ) ) {
1425
    if( file.type.match( 'image' ) ) {
1394
        $( '#print_content' ).append( '<img src="' + tmppath + '" style="max-width:100%">' );
1426
        $( '#print_content' ).append( '<img src="' + tmppath + '" style="max-width:100%">' );
1395
    } else if( file.type.match( 'pdf' ) ) {
1427
    } else if( file.type.match( 'pdf' ) ) {
1396
        $( '#print_content' ).append( '<iframe src="' + tmppath + '" width="100%" height="650" align="middle" scrolling="no" frameborder="0"></iframe>' );
1428
        $( '#print_content' ).append( '<iframe src="' + tmppath + '" width="100%" height="650" align="middle" scrolling="no" frameborder="0"></iframe>' );
1397
    }
-
 
-
 
1429
    }
1398
 
1430
    // Sortie avec la touche escape
-
 
1431
    $( '#help-modal' ).modal( { keyboard : true } );
1399
    $( '#help-modal' ).modal( { keyboard : true } );
1432
    // Affichage
1400
    $( '#help-modal' ).modal( 'show' );
-
 
-
 
1433
    $( '#help-modal' ).modal( 'show' );
-
 
1434
    // Remplacer l'autofocus qui ne fonctionne plus en HTML5
-
 
1435
    // Message dans la doc de bootstrap :
-
 
1436
    // Due to how HTML5 defines its semantics,
-
 
1437
    // the autofocus HTML attribute has no effect in Bootstrap modals.
1401
 
1438
    // To achieve the same effect, use some custom JavaScript
1402
    $( '#help-modal' ).on( 'shown.bs.modal' , function () {
1439
    $( '#help-modal' ).on( 'shown.bs.modal' , function () {
1403
      $( '#myInput' ).trigger( 'focus' );
1440
      $( '#myInput' ).trigger( 'focus' );
1404
    })
-
 
-
 
1441
    })
1405
 
1442
    // Réinitialisation
1406
    $( '#help-modal' ).on( 'hidden.bs.modal' , function () {
1443
    $( '#help-modal' ).on( 'hidden.bs.modal' , function () {
1407
      $( '#help-modal-label' ).text();
1444
      $( '#help-modal-label' ).text();
1408
      $( '#print_content' ).empty();
1445
      $( '#print_content' ).empty();
1409
    })
1446
    })
1410
  });
1447
  });
Line 1411... Line -...
1411
}
-
 
1412
 
1448
}
1413
 
1449
 
1414
 
1450
 
Line 1415... Line 1451...
1415
/***************************
1451
/***************************
1416
 *  Lancement des scripts  *
1452
 *  Lancement des scripts  *
1417
 ***************************/
1453
 ***************************/
Line 1418... Line 1454...
1418
 
1454
 
1419
// Tableau d'envoi des données
-
 
1420
 var datasToSubmit = new Array();
-
 
1421
 var firstClick = true;
-
 
1422
 
1455
// Tableau d'envoi des données
1423
jQuery( document ).ready( function() {
1456
var datasToSubmit = new Array();
1424
  // console.log($(location).attr('search'));
1457
var firstClick = true;
1425
  // console.log($(location).attr('search').search('='));
1458
 
1426
  // console.log($(location).attr('search').charAt(6));
1459
jQuery( document ).ready( function() {
1427
  // Identifiant de champ
1460
  // Identifiant de champ
1428
  var fieldIndex = 0;
-
 
1429
  // Ajout de nouveaux champs
1461
  var fieldIndex = 0;
1430
  onClickAddNewFields( fieldIndex );
1462
  // Ajout de nouveaux champs
1431
  // Activation/Desactivation des boutons valider et prévisualiser
-
 
1432
  activatePreviewAndValidateButtons();
-
 
1433
 
1463
  onClickAddNewFields( fieldIndex );
1434
  // Prévisualisation des champs classiques
1464
  // Activation/Desactivation des boutons valider et prévisualiser
1435
  DisplayClassicFields()
1465
  activatePreviewAndValidateButtons();
1436
 
1466
  // Prévisualisation des champs classiques
1437
 
-
 
-
 
1467
  DisplayClassicFields();
1438
  // Affichage des images ou nom des documents importés
1468
  // Affichage des images ou nom des documents importés
1439
  inputFile();
-
 
1440
  // Affichage des List-checkbox
1469
  inputFile();