Sha256: bfd52ffbc0a0788db5f612d6b16943b1bb31008b1ce17178dda6a6872fb47a33

Contents?: true

Size: 1015 Bytes

Versions: 9

Compression:

Stored size: 1015 Bytes

Contents

// An all-purpose value-grabber. This method has been extracted from a couple
// of different places in the codebase, and could do with a haircut.
slices.getValue = function(inp) {
  inp = $(inp);

  // If the input has a computed value assigned, return it.
  if (inp.data('computed-value')) {
    return inp.data('computed-value');

  // If the input is a special array type, return concatenated value.
  } else if (inp.data('type') === 'array') {
    return inp.val().split('||');

  // If the input is a checkbox, return true/false for checked/unchecked.
  } else if (inp.is(':checkbox')) {
    return inp.is(':checked');

  // If field contains a set of radio buttons, find checked and return value.
  } else if (inp.is(':has(:radio)')) {
    return inp.find(':checked').val();

  // Otherwise, this is simple input and we just take its value normally.
  } else {
    return inp.val();
  }
}

// Returns the value for a particular id.
slices.getValueForId = function(id) {
  return slices.getValue('#' + id);
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
slices-2.0.2 app/assets/javascripts/slices/app/helpers/get_value.js
slices-2.0.1 app/assets/javascripts/slices/app/helpers/get_value.js
slices-2.0.0 app/assets/javascripts/slices/app/helpers/get_value.js
slices-1.0.5 app/assets/javascripts/slices/app/helpers/get_value.js
slices-1.0.4 app/assets/javascripts/slices/app/helpers/get_value.js
slices-1.0.3 app/assets/javascripts/slices/app/helpers/get_value.js
slices-1.0.2 app/assets/javascripts/slices/app/helpers/get_value.js
slices-1.0.1 app/assets/javascripts/slices/app/helpers/get_value.js
slices-1.0.0 app/assets/javascripts/slices/app/helpers/get_value.js