Sha256: 22165d1f19ff708236ef9133511b7f2dfe71f1e3fd1e115c0c9edd0827e4eb16

Contents?: true

Size: 984 Bytes

Versions: 8

Compression:

Stored size: 984 Bytes

Contents

var hidden_input = $("input[name='<%= j params[:page_part_id] %>[photo_tokens]']");

<% if @photos.present? %>
  var photo_collection = $("<%= j render partial: 'photo_collection', locals: {photos: @photos} %>");
  hidden_input.parents('.horizontal-form-content').find('.photo-collection').html(photo_collection);
  hidden_input.parents('.horizontal-form-content').find('a .placeholder').addClass('pull-right');
  hidden_input.val("<%= @photos.map(&:id).join(',') %>");
<% else %>
  hidden_input.parents('.horizontal-form-content').find('a .placeholder').removeClass('pull-right');
  hidden_input.val("");
<% end %>

$('.sortable-grid').sortable().bind('sortupdate', function(e) {
  position_array = [];
  $(e.target).find('li.image').each(function(index) {
    position_array.push($(this).data('photo-id'));
  });
  $(e.target).parents('.horizontal-form-content').find('.photo-positions').val(position_array.join(","));
});
$('.sortable-grid').trigger('sortupdate');

$.hideModal();

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spina-0.9.0 app/views/spina/admin/photos/insert_photo_collection.js.erb
spina-0.8.3 app/views/spina/admin/photos/insert_photo_collection.js.erb
spina-0.8.2 app/views/spina/admin/photos/insert_photo_collection.js.erb
spina-0.8.1 app/views/spina/admin/photos/insert_photo_collection.js.erb
spina-0.8.0 app/views/spina/admin/photos/insert_photo_collection.js.erb
spina-0.7.3 app/views/spina/admin/photos/insert_photo_collection.js.erb
spina-0.7.2 app/views/spina/admin/photos/insert_photo_collection.js.erb
spina-0.7.0 app/views/spina/admin/photos/insert_photo_collection.js.erb