- uid = (attachment.persisted? ? attachment.id : Time.now.to_f.to_s.split('.')[1] + Random.rand(10000).to_s) - limit ||= 99999999 - attachment_counter ||= 0 - hidden ||= (attachment_counter >= limit) %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, nil, public: true).gsub("'", '"').html_safe} Attach - elsif asset.video? %a.btn.btn-primary.attachment-insert{:href => '#', 'data-asset-id' => asset.id, 'data-asset' => effective_asset_video_tag(asset, nil, public: true).gsub("'", '"').html_safe} Attach - else %a.btn.btn-primary.attachment-insert{:href => '#', 'data-asset-id' => asset.id, 'data-asset' => effective_asset_link_to(asset, nil, public: true).gsub("'", '"').html_safe} 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') = hidden_field_tag("#{attachable_object_name}[attachments_attributes][#{uid}][position]", 1)