Subversion Repositories eFlore/Applications.cel

Rev

Rev 3288 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3288 Rev 3331
Line 156... Line 156...
156
// Faire apparaitre un champ text "Autre"
156
// Faire apparaitre un champ text "Autre"
157
function onOtherOption() {
157
function onOtherOption() {
158
  const PREFIX = 'collect-other-';
158
  const PREFIX = 'collect-other-';
Line 159... Line 159...
159
 
159
 
160
  // Ajouter un champ texte pour "Autre"
160
  // Ajouter un champ texte pour "Autre"
161
  function optionAdd( otherId, $target, element, dataName ) {
161
  function optionAdd( otherId, $target, element, dataName, dataLabel ) {
162
    $target.after(
162
    $target.after(
163
      '<div class="control-group">'+
163
      '<div class="control-group">'+
164
        '<label'+
164
        '<label'+
165
          ' for="' + otherId + '"'+
165
          ' for="' + otherId + '"'+
166
          ' class="' + otherId + '"'+
166
          ' class="' + otherId + '"'+
167
        '>'+
167
        '>'+
168
          'Autre option :'+
168
          'Autre option "' + dataLabel.toLowerCase() + '" :'+
169
        '</label>'+
169
        '</label>'+
170
        '<input'+
170
        '<input'+
171
          ' type="text"'+
171
          ' type="text"'+
172
          ' id="' + otherId + '"'+
172
          ' id="' + otherId + '"'+
Line 183... Line 183...
183
  // Supprimer un champ texte pour "Autre"
183
  // Supprimer un champ texte pour "Autre"
184
  function optionRemove( otherId ) {
184
  function optionRemove( otherId ) {
185
    $( '.' + otherId + ', #' + otherId ).remove();
185
    $( '.' + otherId + ', #' + otherId ).remove();
186
  }
186
  }
Line 187... Line 187...
187
 
187
 
188
  $( '#form-supp .other' ).each( function() {
188
  $( '#formulaire .other' ).each( function() {
189
    if( $( this ).hasClass( 'is-select' ) ) {
189
    if( $( this ).hasClass( 'is-select' ) ) {
190
      var dataName = $( this ).data( 'name' ),
190
      var dataName  = $( this ).data( 'name' ),
-
 
191
          otherId   = PREFIX + dataName,
Line 191... Line 192...
191
          otherId  = PREFIX + dataName;
192
          dataLabel = $( '.select' ).data( 'label' );
192
 
193
 
193
      // Insertion du champ "Autre" après les boutons
194
      // Insertion du champ "Autre" après les boutons
194
      optionAdd( otherId, $( this ).parent( '.add-field-select' ), 'select', dataName );
195
      optionAdd( otherId, $( this ).parent( '.add-field-select' ), 'select', dataName, dataLabel );
195
    } else if ( $( this ).is( ':checked' ) ) {
196
    } else if ( $( this ).is( ':checked' ) ) {
196
      var dataName = $( this ).data( 'name' ),
197
      var dataName  = $( this ).data( 'name' ),
-
 
198
          otherId   = PREFIX + dataName,
197
          otherId  = PREFIX + dataName,
199
          element   = $( this ).data( 'element' ),
198
          element = $( this ).data( 'element' );
200
          dataLabel = $( this ).data( 'label' );
199
      // Insertion du champ "Autre" après les boutons
201
      // Insertion du champ "Autre" après les boutons
200
      optionAdd( otherId, $( this ).parent( 'label' ), element, dataName );
202
      optionAdd( otherId, $( this ).parent( 'label' ), element, dataName, dataLabel );
Line 201... Line 203...
201
    }
203
    }
202
  });
204
  });
203
 
205
 
-
 
206
  $( '#formulaire .select' ).change( function () {
Line 204... Line 207...
204
  $( '#form-supp .select' ).change( function () {
207
    var dataName  = $( this ).data( 'name' ),
205
    var dataName = $( this ).data( 'name' ),
208
        otherId   = PREFIX + dataName,
206
        otherId  = PREFIX + dataName;
209
        dataLabel = $( this ).data( 'label' );
207
 
210
 
208
    if( 'other' === $( this ).val() ) {
211
    if( 'other' === $( this ).val() ) {
209
        // Insertion du champ "Autre" après les boutons
212
        // Insertion du champ "Autre" après les boutons
210
        optionAdd( otherId, $( this ).parent( '.add-field-select' ), 'select', dataName );
213
        optionAdd( otherId, $( this ).parent( '.add-field-select' ), 'select', dataName, dataLabel );
211
      } else {
214
      } else {
212
        // Suppression du champ autre
215
        // Suppression du champ autre
Line 213... Line 216...
213
        optionRemove( otherId );
216
        optionRemove( otherId );
214
        $( this ).find( '.other' ).val( 'other' );
217
        $( this ).find( '.other' ).val( 'other' );
215
      }
218
      }
-
 
219
  });
Line 216... Line 220...
216
  });
220
 
217
 
221
  $( '#formulaire input[type=radio]' ).change( function () {
218
  $( '#form-supp input[type=radio]' ).change( function () {
222
    var dataName  = $( this ).data( 'name' ),
219
    var dataName = $( this ).data( 'name' ),
223
        otherId   = PREFIX + dataName,
220
        otherId  = PREFIX + dataName;
224
        dataLabel = $( this ).data( 'label' );
221
 
225
 
222
    if( 'other' === $( this ).val() ) {
226
    if( 'other' === $( this ).val() ) {
223
      // Insertion du champ "Autre" après les boutons
227
      // Insertion du champ "Autre" après les boutons
224
      optionAdd( otherId, $( this ).parent( 'label' ), 'radio', dataName );
228
      optionAdd( otherId, $( this ).parent( 'label' ), 'radio', dataName, dataLabel );
Line 225... Line 229...
225
    } else {
229
    } else {
226
      // Suppression du champ autre
230
      // Suppression du champ autre
227
      optionRemove( otherId );
231
      optionRemove( otherId );
228
      $( this ).closest( '.radio' ).find( '.other' ).val( 'other' );
232
      $( this ).closest( '.radio' ).find( '.other' ).val( 'other' );
-
 
233
    }
Line 229... Line 234...
229
    }
234
  });
230
  });
235
 
231
 
236
  $( '#formulaire .list-checkbox .other, #formulaire .checkbox .other' ).click( function () {
232
  $( '#form-supp .list-checkbox .other, #form-supp .checkbox .other' ).click( function () {
237
    var dataName  = $( this ).data( 'name' ),
233
    var dataName = $( this ).data( 'name' ),
238
        otherId   = PREFIX + dataName,
234
        otherId  = PREFIX + dataName,
239
        element   = $( this ).data( 'element' ),
235
        element = $( this ).data( 'element' );
240
        dataLabel = $( this ).data( 'label' );
236
 
241
 
237
    if( $( this ).is( ':checked' ) ) {
242
    if( $( this ).is( ':checked' ) ) {
238
        // Insertion du champ "Autre" après les boutons
243
        // Insertion du champ "Autre" après les boutons
Line 239... Line 244...
239
        optionAdd( otherId, $( this ).parent( 'label' ), element, dataName );
244
        optionAdd( otherId, $( this ).parent( 'label' ), element, dataName, dataLabel );
240
      } else {
245
      } else {
241
        // Suppression du champ autre
246
        // Suppression du champ autre
242
        optionRemove( otherId );
247
        optionRemove( otherId );
Line 243... Line 248...
243
        $( this ).val( 'other' );
248
        $( this ).val( 'other' );
244
      }
249
      }