- uid = (attachment.persisted? ? attachment.id : Time.now.to_f.to_s.split('.')[1] + Random.rand(10000).to_s) - hidden ||= false %tr.attachment{:style => "#{(attachment.marked_for_destruction? || hidden) ? 'display: none;' : ''}"} %td.attachment-image = effective_asset_image_tag(attachment.asset) %td.attachment-title{:title => effective_asset_title(attachment.asset)} - if attachment_links = link_to attachment.asset.title, attachment.asset.url, :target => '_blank' - else = attachment.asset.title %td.attachment-size = number_to_human_size(attachment.asset.data_size) %td - if attachment_actions.include?('insert') || attachment_actions.include?('attach') - asset = attachment.asset - if asset.image? || asset.icon? %a.btn.btn-primary.attachment-insert{:href => '#', 'data-asset-id' => asset.id, 'data-asset' => effective_asset_image_tag(asset)} Attach - elsif asset.video? %a.btn.btn-primary.attachment-insert{:href => '#', 'data-asset-id' => asset.id, 'data-asset' => effective_asset_video_tag(asset)} Attach - else %a.btn.btn-primary.attachment-insert{:href => '#', 'data-asset-id' => asset.id, 'data-asset' => effective_asset_link_to(asset)} Attach - if attachment_actions.include?('remove') %a.attachment-remove{:href => '#', :title => 'Remove'} %i.glyphicon.glyphicon-remove - if attachment_actions.include?('delete') = link_to effective_assets.effective_asset_path(attachment.asset), :class => 'btn btn-danger attachment-delete', :data => {:method => :delete, :confirm => "Are you sure you want to delete this file? This cannot be undone!"} do %i.glyphicon.glyphicon-trash - if attachment.persisted? = hidden_field_tag(attachable_object_name + "[attachments_attributes][#{uid}][id]", attachment.id) = hidden_field_tag(attachable_object_name + "[attachments_attributes][#{uid}][asset_id]", attachment.asset_id) = hidden_field_tag(attachable_object_name + "[attachments_attributes][#{uid}][box]", attachment.box) = hidden_field_tag(attachable_object_name + "[attachments_attributes][#{uid}][_destroy]", attachment.marked_for_destruction? ? 1 : nil, :class => 'asset-box-remove')