bugfix multiple lines

This commit is contained in:
Thomas Blazek
2013-08-22 13:49:11 +02:00
parent 60d86d9cb1
commit cbe536a56b
3 changed files with 80 additions and 79 deletions

View File

@@ -46,7 +46,7 @@ class FotosController < ApplicationController
@foto.gallery_id = (params[:gallery_id]) @foto.gallery_id = (params[:gallery_id])
@gallery = @foto.gallery @gallery = @foto.gallery
respond_to do |format| respond_to do |format|
@foto.title = @foto.datei @foto.title = @foto.datei.filename
if @foto.save if @foto.save
format.html { format.html {
render :json => [@foto.to_jq_upload].to_json, render :json => [@foto.to_jq_upload].to_json,

View File

@@ -8,7 +8,7 @@ class Foto < ActiveRecord::Base
"id" => read_attribute(:id), "id" => read_attribute(:id),
"title" => read_attribute(:title), "title" => read_attribute(:title),
"description" => read_attribute(:desc), "description" => read_attribute(:desc),
"name" => read_attribute(:datei), "name" => read_attribute(:title),
"size" => datei.size, "size" => datei.size,
"url" => datei.url, "url" => datei.url,
"thumbnail_url" => datei.thumb.url, "thumbnail_url" => datei.thumb.url,

View File

@@ -1,43 +1,43 @@
<div class="container"> <div class="container">
<h2>Upload file</h2> <h2>Upload file</h2>
<%= semantic_form_for [@gallery, @foto], :remote=>true, :html => { :multipart => true, :id => "fileupload" } do |f| %> <%= semantic_form_for [@gallery, @foto], :remote=>true, :html => { :multipart => true, :id => "fileupload" } do |f| %>
<!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload --> <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
<div class="row fileupload-buttonbar"> <div class="row fileupload-buttonbar">
<div class="span7"> <div class="span7">
<!-- The fileinput-button span is used to style the file input field as button --> <!-- The fileinput-button span is used to style the file input field as button -->
<span class="btn btn-success fileinput-button"> <span class="btn btn-success fileinput-button">
<i class="icon-plus icon-white"></i> <i class="icon-plus icon-white"></i>
<span>Add files...</span> <span>Add files...</span>
<%= f.file_field :datei, :multiple=>true%> <%= f.file_field :datei, :multiple=>true%>
<%= f.input :gallery %> <%= f.input :gallery %>
</span> </span>
<button type="submit" class="btn btn-primary start"> <button type="submit" class="btn btn-primary start">
<i class="icon-upload icon-white"></i> <i class="icon-upload icon-white"></i>
<span>Start upload</span> <span>Start upload</span>
</button> </button>
<button type="reset" class="btn btn-warning cancel"> <button type="reset" class="btn btn-warning cancel">
<i class="icon-ban-circle icon-white"></i> <i class="icon-ban-circle icon-white"></i>
<span>Cancel upload</span> <span>Cancel upload</span>
</button> </button>
<button type="button" class="btn btn-danger delete"> <button type="button" class="btn btn-danger delete">
<i class="icon-trash icon-white"></i> <i class="icon-trash icon-white"></i>
<span>Delete</span> <span>Delete</span>
</button> </button>
<input type="checkbox" class="toggle"> <input type="checkbox" class="toggle">
</div> </div>
<div class="span5"> <div class="span5">
<!-- The global progress bar --> <!-- The global progress bar -->
<div class="progress progress-success progress-striped active fade"> <div class="progress progress-success progress-striped active fade">
<div class="bar" style="width:0%;"></div> <div class="bar" style="width:0%;"></div>
</div>
</div> </div>
</div> </div>
<!-- The loading indicator is shown during image processing --> </div>
<div class="fileupload-loading"></div> <!-- The loading indicator is shown during image processing -->
<br> <div class="fileupload-loading"></div>
<!-- The table listing the files available for upload/download --> <br>
<table class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody> <!-- The table listing the files available for upload/download -->
</table> <table class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody>
</table>
<% end %> <% end %>
</div> </div>
@@ -86,53 +86,54 @@
<!-- The template to display files available for download --> <!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl"> <script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %} {% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-download fade"> <tr class="template-download fade">
{% if (file.error) { %} {% if (file.error) { %}
<td></td> <td></td>
<td class="name"><span>{%=file.name%}</span></td> <td class="name"><span>{%=file.name%}</span></td>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td> <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
<td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td> <td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
{% } else { %} {% } else { %}
<td class="preview">{% if (file.thumbnail_url) { %} <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> <a href="{%=file.url%}" title="{%=file.name%}" rel="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
{% } %}</td> {% } %}</td>
<td class="name"> <td class="name">
<a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a> <a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a>
</td> </td>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td> <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
<td colspan="2"></td> <td colspan="2"></td>
{% } %}
<td class="delete">
<button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
<i class="icon-trash icon-white"></i>
<span>{%=locale.fileupload.destroy%}</span>
</button>
<input type="checkbox" name="delete" value="1">
</td>
</tr>
{% } %} {% } %}
<td class="delete">
<button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
<i class="icon-trash icon-white"></i>
<span>{%=locale.fileupload.destroy%}</span>
</button>
<input type="checkbox" name="delete" value="1">
</td>
</tr>
{% } %}
</script> </script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(function () { $(function () {
// Initialize the jQuery File Upload widget: // Initialize the jQuery File Upload widget:
$('#fileupload').fileupload(); $('#fileupload').fileupload();
// //
// Load existing files: // Load existing files:
$.getJSON($('#fileupload').prop('action'), function (files) { $.getJSON($('#fileupload').prop('action'), function (files) {
var fu = $('#fileupload').data('blueimpFileupload'), var fu = $('#fileupload').data('blueimpFileupload'),
template; template;
fu._adjustMaxNumberOfFiles(-files.length); fu._adjustMaxNumberOfFiles(-files.length);
console.log(files); console.log(files);
template = fu._renderDownload(files) // no Download on Upload form
.appendTo($('#fileupload .files')); //template = fu._renderDownload(files)
// Force reflow: //.appendTo($('#fileupload .files'));
fu._reflow = fu._transition && template.length && // Force reflow:
template[0].offsetWidth; fu._reflow = fu._transition && template.length &&
template.addClass('in'); template[0].offsetWidth;
$('#loading').remove(); template.addClass('in');
}); $('#loading').remove();
$('#foto_datei').attr('name', 'foto[datei]'); });
$('#foto_datei').attr('name', 'foto[datei]');
$('#foto_datei').fileupload(); $('#foto_datei').fileupload();
}); });