Files
osem/app/views/proposal/_form.html.haml

122 lines
4.8 KiB
Plaintext

.row
.col-md-12
.tabbable
%ul.nav.nav-tabs
%li.active
= link_to "Proposal", "#proposal-content", "data-toggle"=>"tab"
%li
= link_to "Attachments", "#attachment-content", "data-toggle"=>"tab"
.tab-content
#proposal-content.tab-pane.active
= render 'proposal/proposal_form'
#attachment-content.tab-pane
= form_for EventAttachment.new, :url => conference_proposal_event_attachment_index_path(@conference.short_title, @event), :html => { :multipart => true, :id => "fileupload" } do |f|
%table.table.table-striped
%thead
%th
%th
%b Filename
%th
%b Title
%th
%b Size
%th
%b Public
%th
%th
%tbody.files
.row-fluid.fileupload-buttonbar
.btn.btn-success.fileinput-button
%span.glyphicon.glyphicon-icon-plus.icon-white
Add files...
= f.file_field :attachment
= f.hidden_field :event_id, :value => @event.id
:javascript
$(document).ready( function() {
$('#fileupload').fileupload();
$('#fileupload').bind('fileuploadsubmit', function (e, data) {
var inputs = data.context.find(':input');
if (inputs.filter('[required][value=""]').first().focus().length) {
return false;
}
data.formData = inputs.serializeArray();
});
$.getJSON($('#fileupload').prop('action'), function (files) {
var fu = $('#fileupload').data('fileupload'),
template;
fu._adjustMaxNumberOfFiles(-files.length);
template = fu._renderDownload(files)
.appendTo($('#fileupload .files'));
fu._reflow = fu._transition && template.length &&
template[0].offsetWidth;
template.addClass('in');
$('#loading').remove();
});
} );
:plain
<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-upload fade">
<td class="preview"><span class="fade"></span></td>
<td class="name"><span>{%=file.name%}</span>
<div class="progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div>
</td>
<td class="name"><input type="text" name="title[]" value="{%=file.name%}"/></td>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
<td class="name"><input checked type="checkbox" name="public">Public</input></td>
{% if (file.error) { %}
<td class="error"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
{% } else if (o.files.valid && !i) { %}
<td class="start">{% if (!o.options.autoUpload) { %}
<button class="btn btn-primary">
<span class="glyphicon glyphicon-upload"></span>
<span>{%=locale.fileupload.start%}</span>
</button>
{% } %}</td>
{% } else { %}
<td></td>
{% } %}
<td class="cancel">{% if (!i) { %}
<button class="btn btn-warning">
<span class="glyphicon glyphicon-circle"></span>
<span>{%=locale.fileupload.cancel%}</span>
</button>
{% } %}</td>
</tr>
{% } %}
</script>
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-download fade">
{% if (file.error) { %}
<td>{%=file.title%}</td>
<td class="name">{%=file.name%}</td>
<td class="size">{%=o.formatFileSize(file.size)%}</td>
<td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
{% } else { %}
<td class="preview">{% if (file.thumbnail_url) { %}
<a href="{%=file.url%}" title="{%=file.name%}" rel="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
{% } %}</td>
<td class="name">
<a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a>
</td>
<td>{%=file.title%}</td>
<td class="size">{%=o.formatFileSize(file.size)%}</td>
<td>{%=file.public%}</td>
{% } %}
<td class="delete" colspan="2">
<button class="btn btn-danger pull-right" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
<span class="glyphicon glyphicon-trash"></i>
<span>{%=locale.fileupload.destroy%}</span>
</button>
</td>
</tr>
{% } %}
</script>