Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 3247 Rev 3260
Line 42... Line 42...
42
      $( '.selectBox select.focus' ).each( function() {
42
      $( '.selectBox select.focus' ).each( function() {
43
        $( this ).removeClass( 'focus' );
43
        $( this ).removeClass( 'focus' );
44
      });
44
      });
45
    }
45
    }
46
  });
46
  });
47
 
-
 
48
  $( '#zone-appli' ).on( 'click' , '.selectBox' , function() {
47
  $( '#zone-appli' ).on( 'click' , '.selectBox' , function() {
49
    // afficher/cacher le volet des checkboxes et focus
48
    // afficher/cacher le volet des checkboxes et focus
50
    $( this ).next().toggleClass( 'hidden' );
49
    $( this ).next().toggleClass( 'hidden' );
51
    $( this ).find( 'select' ).toggleClass( 'focus' );
50
    $( this ).find( 'select' ).toggleClass( 'focus' );
Line 52... Line 51...
52
 
51
 
53
    // Cacher le volet des autres checkboxes et retirer leur focus
52
    // Cacher le volet des autres checkboxes et retirer leur focus
54
    var $checkboxes = $( this ).next(),
53
    var $checkboxes = $( this ).next(),
-
 
54
        count = $( '.checkboxes' ).length;
55
        count = $( '.checkboxes' ).length;
55
 
56
    for ( var i = 0; i < count; i++ ) {
56
    for ( var i = 0; i < count; i++ ) {
57
      if ( $( '.checkboxes' )[i] !== $checkboxes[0] && !$checkboxes.hasClass( 'hidden' ) ) {
57
      if ( $( '.checkboxes' )[i] !== $checkboxes[0] && !$checkboxes.hasClass( 'hidden' ) ) {
58
        var $otherListCheckboxes = $( '.checkboxes' )[i];
58
        var $otherListCheckboxes = $( '.checkboxes' )[i];
59
        if ( !$otherListCheckboxes.classList.contains( 'hidden' ) ) {
59
        if ( !$otherListCheckboxes.classList.contains( 'hidden' ) ) {
Line 62... Line 62...
62
        if( $otherListCheckboxes.previousElementSibling.firstElementChild.classList.contains( 'focus' ) ) {
62
        if( $otherListCheckboxes.previousElementSibling.firstElementChild.classList.contains( 'focus' ) ) {
63
          $otherListCheckboxes.previousElementSibling.firstElementChild.classList.remove( 'focus' );
63
          $otherListCheckboxes.previousElementSibling.firstElementChild.classList.remove( 'focus' );
64
        }
64
        }
65
      }
65
      }
66
    }
66
    }
67
 
-
 
68
  });
67
  });
69
}
68
}
Line 70... Line 69...
70
 
69
 
71
// Style et affichage des input type="range"
70
// Style et affichage des input type="range"
72
function inputRangeDisplayNumber() {
71
function inputRangeDisplayNumber() {
73
  $( 'input[type="range"]' ).each( function() {
-
 
74
 
72
  $( 'input[type="range"]' ).each( function() {
75
    $( this ).siblings( '.range-live-value' ).text( $( this ).val() );
73
    $( this ).siblings( '.range-live-value' ).text( $( this ).val() );
76
  });
74
  });
77
  $( '#zone-supp' ).on( 'input' , 'input[type="range"]' , function () {
75
  $( '#zone-supp' ).on( 'input' , 'input[type="range"]' , function () {
78
    $( this ).siblings( '.range-live-value' ).text( $( this ).val() );
76
    $( this ).siblings( '.range-live-value' ).text( $( this ).val() );
-
 
77
  });
-
 
78
  $( '#ajouter-obs' ).on( 'click', function() {
-
 
79
    $( '.range-live-value' ).each( function() {
-
 
80
      var $this = $( this );
-
 
81
      $this.text( '' );
-
 
82
    });
79
  });
83
  });
Line 80... Line 84...
80
}
84
}
81
 
85
 
82
// Activation/Desactivation et contenu de la modale Bootstrap
86
// Activation/Desactivation et contenu de la modale Bootstrap
Line 86... Line 90...
86
    var thisFieldKey = $( this ).data( 'key' ),
90
    var thisFieldKey = $( this ).data( 'key' ),
87
        fileMimeType = $( this ).data( 'mime-type' );
91
        fileMimeType = $( this ).data( 'mime-type' );
Line 88... Line 92...
88
 
92
 
89
    // Titre
93
    // Titre
90
    $( '#help-modal-label' ).text( 'Aide pour : ' +  $( this ).data( 'name' ) );
-
 
91
 
94
    $( '#help-modal-label' ).text( 'Aide pour : ' +  $( this ).data( 'name' ) );
92
    if( fileMimeType.match( 'image' ) ) {
95
    if( fileMimeType.match( 'image' ) ) {
93
      var extention = fileMimeType.replace( /(?:imag)?e\/?/g , '' );
96
      var extention = fileMimeType.replace( /(?:imag)?e\/?/g , '' );
94
      // var extention = 'jpg';
97
      // var extention = 'jpg';
95
      $( '#print_content' ).append( '<img src="' + CHEMIN_FICHIERS + thisFieldKey + '.' + extention + '" style="max-width:100%" alt="' + thisFieldKey + '" />' );
98
      $( '#print_content' ).append( '<img src="' + CHEMIN_FICHIERS + thisFieldKey + '.' + extention + '" style="max-width:100%" alt="' + thisFieldKey + '" />' );
96
    }
-
 
97
 
99
    }
98
    // Sortie avec la touche escape
100
    // Sortie avec la touche escape
99
    $( '#help-modal' ).modal( { keyboard : true } );
101
    $( '#help-modal' ).modal( { keyboard : true } );
100
    // Affichage
102
    // Affichage
101
    $( '#help-modal' ).modal({ show: true });
103
    $( '#help-modal' ).modal({ show: true });
Line 121... Line 123...
121
  $( '#info-button' ).click( function ( event ) {
123
  $( '#info-button' ).click( function ( event ) {
122
    var fileMimeType = $( this ).data( 'mime-info' );
124
    var fileMimeType = $( this ).data( 'mime-info' );
Line 123... Line 125...
123
 
125
 
124
    // Titre
126
    // Titre
125
    $( '#help-modal-label' ).text( 'Aide du projet : ' +  $( '#titre-projet' ).text() );
-
 
126
 
127
    $( '#help-modal-label' ).text( 'Aide du projet : ' +  $( '#titre-projet' ).text() );
127
    if( fileMimeType.match( 'image' ) ) {
-
 
128
 
128
    if( fileMimeType.match( 'image' ) ) {
129
      var extention = fileMimeType.replace( /(?:imag)?e\/?/g , '' );
-
 
130
 
129
      var extention = fileMimeType.replace( /(?:imag)?e\/?/g , '' );
131
      $( '#print_content' ).append( '<img src="' + CHEMIN_FICHIERS + 'info.' + extention + '" style="max-width:100%" alt="info projet" />' );
130
      $( '#print_content' ).append( '<img src="' + CHEMIN_FICHIERS + 'info.' + extention + '" style="max-width:100%" alt="info projet" />' );
132
    }
-
 
133
 
131
    }
134
    // Sortie avec la touche escape
132
    // Sortie avec la touche escape
135
    $( '#help-modal' ).modal( { keyboard : true } );
133
    $( '#help-modal' ).modal( { keyboard : true } );
136
    // Affichage
134
    // Affichage
137
    $( '#help-modal' ).modal({ show: true });
135
    $( '#help-modal' ).modal({ show: true });
Line 153... Line 151...
153
}
151
}
Line 154... Line 152...
154
 
152
 
155
 
153
 
156
// Faire apparaitre un champ text "Autre"
-
 
157
function onOtherOption() {
154
// Faire apparaitre un champ text "Autre"
Line 158... Line 155...
158
 
155
function onOtherOption() {
159
  const PREFIX = 'collect-other-';
156
  const PREFIX = 'collect-other-';
160
 
157
 
-
 
158
  // Ajouter un champ texte pour "Autre"
-
 
159
  function optionAdd( otherId, $target, element, dataName ) {
-
 
160
    $target.after(
161
  // Ajouter un champ texte pour "Autre"
161
      '<div class="control-group">'+
-
 
162
        '<label'+
-
 
163
          ' for="' + otherId + '"'+
-
 
164
          ' class="' + otherId + '"'+
-
 
165
        '>'+
-
 
166
          'Autre option :'+
-
 
167
        '</label>'+
-
 
168
        '<input'+
-
 
169
          ' type="text"'+
-
 
170
          ' id="' + otherId + '"'+
162
  function optionAdd( otherId, $target, element ) {
171
          ' name="' + otherId + '"'+
-
 
172
          ' class="collect-other form-control"'+
-
 
173
          ' data-name="' + dataName + '"'+
163
    $target.after(
174
          ' data-element="' + element + '"'+
-
 
175
        '>'+
164
      '<label for="' + otherId + '" class="' + otherId + '">Autre option :</label>' +
176
      '</div>'
Line 165... Line 177...
165
      '<input type="text" id="' + otherId + '" name="' + otherId + '" class="collect-other" data-element="' + element + '">'
177
    );
166
    );
178
    $( '#' + otherId ).focus();
167
  }
179
  }
168
 
180
 
Line 169... Line 181...
169
  // Supprimer un champ texte pour "Autre"
181
  // Supprimer un champ texte pour "Autre"
170
  function optionRemove( otherId, $this ) {
182
  function optionRemove( otherId ) {
171
    $( '.' + otherId + ', #' + otherId ).remove();
183
    $( '.' + otherId + ', #' + otherId ).remove();
-
 
184
  }
-
 
185
 
172
  }
186
  $( '#form-supp .other' ).each( function() {
173
 
187
    if( $( this ).hasClass( 'is-select' ) ) {
174
  $( '#form-supp .other' ).each( function() {
188
      var dataName = $( this ).data( 'name' ),
175
    if( $( this ).hasClass( 'is-select' ) ) {
189
          otherId  = PREFIX + dataName;
-
 
190
 
176
      var otherId = PREFIX + $( this ).parent( 'select' ).attr( 'name' );
191
      // Insertion du champ "Autre" après les boutons
177
      // Insertion du champ "Autre" après les boutons
192
      optionAdd( otherId, $( this ).parent( '.add-field-select' ), 'select', dataName );
178
      optionAdd( otherId, $( this ).parent( '.select' ) , 'select' );
193
    } else if ( $( this ).is( ':checked' ) ) {
179
    } else if ( $( this ).is( ':checked' ) ) {
194
      var dataName = $( this ).data( 'name' ),
180
      var otherId = PREFIX + $( this ).attr( 'name' ),
195
          otherId  = PREFIX + dataName,
Line 181... Line 196...
181
          element = $( this ).attr( 'data-element' );
196
          element = $( this ).data( 'element' );
182
      // Insertion du champ "Autre" après les boutons
197
      // Insertion du champ "Autre" après les boutons
-
 
198
      optionAdd( otherId, $( this ).parent( 'label' ), element, dataName );
Line 183... Line 199...
183
      optionAdd( otherId, $( this ).parent( 'label' ) , element );
199
    }
184
    }
200
  });
185
  });
201
 
186
 
202
  $( '#form-supp .select' ).change( function () {
187
  $( '#form-supp select' ).change( function () {
203
    var dataName = $( this ).data( 'name' ),
188
    var otherId = PREFIX + $( this ).attr( 'name' );
204
        otherId  = PREFIX + dataName;
189
 
205
 
190
    if( 'other' === $( this ).val() ) {
206
    if( 'other' === $( this ).val() ) {
191
        // Insertion du champ "Autre" après les boutons
207
        // Insertion du champ "Autre" après les boutons
Line 192... Line 208...
192
        optionAdd( otherId, $( this ).parent( '.select' ), 'select' );
208
        optionAdd( otherId, $( this ).parent( '.add-field-select' ), 'select', dataName );
193
      } else {
209
      } else {
-
 
210
        // Suppression du champ autre
Line 194... Line 211...
194
        // Suppression du champ autre
211
        optionRemove( otherId );
195
        optionRemove( otherId, $( this ) );
212
        $( this ).find( '.other' ).val( 'other' );
196
        $( this ).find( '.other' ).val( 'other' );
213
      }
197
      }
214
  });
198
  });
215
 
199
 
216
  $( '#form-supp input[type=radio]' ).change( function () {
200
  $( '#form-supp input[type=radio]' ).change( function () {
217
    var dataName = $( this ).data( 'name' ),
201
    var otherId = PREFIX + $( this ).attr( 'name' );
218
        otherId  = PREFIX + dataName;
202
 
219
 
Line 203... Line 220...
203
    if( 'other' === $( this ).val() ) {
220
    if( 'other' === $( this ).val() ) {
204
        // Insertion du champ "Autre" après les boutons
221
      // Insertion du champ "Autre" après les boutons
205
        optionAdd( otherId, $( this ).parent( 'label' ), 'radio' );
222
      optionAdd( otherId, $( this ).parent( 'label' ), 'radio', dataName );
206
    } else {
223
    } else {
-
 
224
      // Suppression du champ autre
207
      // Suppression du champ autre
225
      optionRemove( otherId );
208
      optionRemove( otherId, $( this ) );
226
      $( this ).closest( '.radio' ).find( '.other' ).val( 'other' );
209
      $( this ).closest( 'div.control-group.radio' ).find( '.other' ).val( 'other' );
227
    }
210
    }
228
  });
211
  });
229
 
212
 
230
  $( '#form-supp .list-checkbox .other, #form-supp .checkbox .other' ).click( function () {
213
  $( '#form-supp .list-checkbox .other, #form-supp .checkbox .other' ).click( function () {
231
    var dataName = $( this ).data( 'name' ),
214
    var otherId = PREFIX + $( this ).attr( 'name' ),
232
        otherId  = PREFIX + dataName,
215
        element = $( this ).attr( 'data-element' );
233
        element = $( this ).data( 'element' );
216
    // console.log(element);
234
 
Line 217... Line 235...
217
    if( $( this ).is( ':checked' ) ) {
235
    if( $( this ).is( ':checked' ) ) {
218
        // Insertion du champ "Autre" après les boutons
236
        // Insertion du champ "Autre" après les boutons
219
        optionAdd( otherId, $( this ).parent( 'label' ), element );
237
        optionAdd( otherId, $( this ).parent( 'label' ), element, dataName );
220
      } else {
238
      } else {
-
 
239
        // Suppression du champ autre
221
        // Suppression du champ autre
240
        optionRemove( otherId );
222
        optionRemove( otherId, $( this ) );
241
        $( this ).val( 'other' );
223
        $( this ).val( 'other' );
242
      }
224
      }
243
  });
225
  });
244
}
226
}
245
 
-
 
246
function collectOtherOption() {
-
 
247
  $( '#form-supp' ).on( 'change', '.collect-other', function () {
227
 
248
    var otherIdSuffix = $( this ).data( 'name' ).replace( '[]', '' );
228
function collectOtherOption() {
249
    var element = $( this ).data( 'element' );
229
  $( '#form-supp' ).on( 'change', '.collect-other', function () {
250
 
-
 
251
    if ( '' === $( this ).val() ){
230
    var otherIdSuffix = $( this ).attr( 'name' ).replace( 'collect-other-', '' ),
252
      if ( 'select' === element ) {
231
        element = $( this ).attr( 'data-element' );
253
        $( '#' + otherIdSuffix ).find( '.other' ).prop( 'selected', false ).val( 'other' );
232
    if ( '' === $( this ).val() ){
254
      } else {
233
      if ( 'select' === element ) {
255
        $( '#other-' + otherIdSuffix ).prop( 'checked', false ).val( 'other' );
234
        $( '#' + otherIdSuffix ).find( '.other' ).prop( 'selected', false );
256
      }
235
      } else {
257
      $( 'label.collect-other-' + otherIdSuffix ).remove();
236
        $( '#other-' + otherIdSuffix ).prop( 'checked', false );
-
 
237
      }
258
      $( this ).remove();
238
    } else {
259
    } else {
239
      if ( 'select' === element ) {
260
      if ( 'select' === element ) {
240
        $( '#' +  otherIdSuffix ).find( '.other' ).val( $( this ).val() );
-
 
241
        $( '#' +  otherIdSuffix + ' option').not( '.other' ).prop( 'selected', false );
261
        $( '#' +  otherIdSuffix ).find( '.other' ).val( $( this ).val() );
242
        $( '#' +  otherIdSuffix ).find( '.other' ).prop( 'selected', true );
262
        $( '#' +  otherIdSuffix ).val( $( this ).val() );
243
      } else {
263
        $( '#' +  otherIdSuffix + ' option').not( '.other' ).prop( 'selected', false );
Line 244... Line 264...
244
        if ( 'radio' === element ) {
264
        $( '#' +  otherIdSuffix ).find( '.other' ).prop( 'selected', true );
245
          $( 'input[name=' + otherIdSuffix + ']' ).not( '#other-' + otherIdSuffix ).prop( 'checked', false );
265
      } else {
246
        }
266
        if ( 'radio' === element ) {
247
        // console.log( otherIdSuffix );
267
          $( 'input[name=' + otherIdSuffix + ']' ).not( '#other-' + otherIdSuffix ).prop( 'checked', false );
Line 248... Line 268...
248
        $( '#other-' + otherIdSuffix ).val( $( this ).val() );
268
        }
249
        $( '#other-' + otherIdSuffix ).prop( 'checked', true );
-
 
250
      }
-
 
251
 
-
 
252
    }
-
 
253
  });
-
 
254
}
-
 
255
 
-
 
256
/***************************
-
 
257
 *  Lancement des scripts  *
-
 
258
 ***************************/
-
 
259
const CHEMIN_FICHIERS = $( '#zone-appli' ).data('url-fichiers');
269
        $( '#other-' + otherIdSuffix ).val( $( this ).val() );
260
 
270
        $( '#other-' + otherIdSuffix ).prop( 'checked', true );
261
jQuery( document ).ready( function() {
-
 
262
  if( 0 < $( '#form-supp' ) ) {
271
      }
263
    $( '#form-supp' )[0].reset();
272
    }
264
  }
273
  });
265
 
274
}
266
    // console.log( $('#taxon').val() !== '' );
275
 
267
    // $('#ajouter-obs').click( function() {
276
/***************************
268
    //   // console.log( $('#taxon').val() !== '' );
-
 
269
    // });
277
 *  Lancement des scripts  *
270
    //pattern="(^(((0[1-9]|1[0-9]|2[0-8])[\/](0[1-9]|1[012]))|((29|30|31)[\/](0[13578]|1[02]))|((29|30)[\/](0[4,6,9]|11)))[\/](19|[2-9][0-9])\d\d$)|(^29[\/]02[\/](19|[2-9][0-9])(00|04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96)$)"
278
 ***************************/
271
 
-
 
272
  // Volet de profil/déconnexion
279
const CHEMIN_FICHIERS = $( '#zone-appli' ).data('url-fichiers');
273
  connexionDprodownMenu();
280
 
274
 
-
 
275
  // Modale "aide" du projet
281
jQuery( document ).ready( function() {
276
  projetHelpModale();
282
  // Volet de profil/déconnexion
277
  // Affichage input file
283
  connexionDprodownMenu();
278
  inputFile();
284
  // Modale "aide" du projet
279
  // Affichage des List-checkbox
285
  projetHelpModale();