Sha256: 132401d254178e66996148741f772e09efe28834d3c10b0cd5268b216995a79f

Contents?: true

Size: 1.56 KB

Versions: 4

Compression:

Stored size: 1.56 KB

Contents

$(document).ready(function() {

  if ($('input#preferences_use_s3[type="checkbox"]:checked').length > 0)
    $('#s3_settings').show();

  // Toggle display of S3 settings based on value of use_s3 checkbox
  $('input#preferences_use_s3[type="checkbox"]').click(function() {
    $('#s3_settings').toggle();
  });

  $('.destroy_style').live("click", function() {
   $(this).parent().remove();
  });

  $('.destroy_header').live("click", function() {
    $(this).parent().remove();
  });

  // Handle adding new styles
  var styles_hash_index = 1;
  $('.add_style').click(function() {
    $('#styles_list').append(generate_html_for_hash("new_attachment_styles", styles_hash_index));
  });

  // Handle adding new headers
  var headers_hash_index = 1;
  $('.add_header').click(function() {
    $('#headers_list').append(generate_html_for_hash("new_s3_headers", headers_hash_index));
  });

  // Generates html for new paperclip styles form fields
  generate_html_for_hash = function(hash_name, index) {
    var html = '<li>';
    html += '<label for="' + hash_name + '_' + index + '_name">';
    html += 'Name</label>';
    html += '<input id="' + hash_name + '_' + index + '_name" name="' + hash_name + '[' + index + '][name]" type="text">';
    html += '<label for="' + hash_name + '_' + index + '_value">';
    html += 'Value</label>';
    html += '<input id="' + hash_name + '_' + index + '_value" name="' + hash_name + '[' + index + '][value]" type="text">';
    html += '<a href="#" alt="Destroy" class="destroy_style">&nbsp;x</a>';
    html += '</li>';

    index += 1;
    return html;
  };



});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spree_core-1.1.1 app/assets/javascripts/admin/image_settings.js
spree_core-1.1.0 app/assets/javascripts/admin/image_settings.js
spree_core-1.1.0.rc2 app/assets/javascripts/admin/image_settings.js
spree_core-1.1.0.rc1 app/assets/javascripts/admin/image_settings.js