diff --git a/app/assets/javascripts/design_temp.js b/app/assets/javascripts/design_temp.js
index 4c65a4c9..812c2a18 100644
--- a/app/assets/javascripts/design_temp.js
+++ b/app/assets/javascripts/design_temp.js
@@ -11,9 +11,9 @@ $(".r_snapshot").hover(
$('input.multi_files').change(function(){
$(this).prev("ul").append("
"+$(this).val()+"");
new_node =$(this).clone();
- new_node.css("display","none");
- $(this).parent().append(new_node);
- $(this).val("");
+ $(this).css("display","none");
+ new_node.val("");
+ $(this).after(new_node)
});
$('a.remove_mark').live("click",function(){
diff --git a/app/views/admin/designs/_design_file.html.erb b/app/views/admin/designs/_design_file.html.erb
new file mode 100644
index 00000000..610ba099
--- /dev/null
+++ b/app/views/admin/designs/_design_file.html.erb
@@ -0,0 +1,16 @@
+<% fieldname_p = fieldname.pluralize %>
+<%= f.label "fieldname", t('admin.'+fieldname) %>
+
+ <% object.send(fieldname_p).each do |t| %>
+ - <%= t.file_filename %>
+ <%=fields_for "design["+(fieldname_p)+"][]",t,:index=>nil do |f| %>
+ <%= f.hidden_field :id %>
+ <%= f.hidden_field :to_destroy %>
+ <%end%>
+ Del
+
+ <% end %>
+
+<%= fields_for "design["+(fieldname_p)+"][]", object, :index => nil do |f| %>
+ <%= f.file_field :file ,{:class=>"multi_files",:rtype=>rtype}%>
+<% end %>
diff --git a/app/views/admin/designs/_form.html.erb b/app/views/admin/designs/_form.html.erb
index a65ce80b..9d65cf2e 100644
--- a/app/views/admin/designs/_form.html.erb
+++ b/app/views/admin/designs/_form.html.erb
@@ -25,49 +25,13 @@
- <%= f.label "stylesheet", t('admin.stylesheet') %>
-
- <% @design.stylesheets.each do |t| %>
- - <%= t.file_filename %>
- <%= fields_for "design[stylesheets][]", t, :index => nil do |f| %>
- <%= f.hidden_field :id %>
- <%= f.hidden_field :to_destroy %>
- <%end%>
- Del
- <% end %>
-
- <%= fields_for "design[stylesheets][]", @design, :index => nil do |f| %>
- <%= f.file_field :file ,{:class=>"multi_files",:rtype=>"stylesheets"}%>
- <% end %>
+<%= render :partial => 'design_file' ,:locals => { :fieldname=>"stylesheet",:object=>@design ,:f=>f,:rtype=>'stylesheets' } %>
- <%= f.label "javascript", t('admin.javascript') %>
-
- <% @design.javascripts.each do |t| %>
- - <%= t.file_filename %>
- <%=fields_for "design[javascripts][]",t,:index=>nil do |f| %>
- <%= f.hidden_field :id %>
- <%= f.hidden_field :to_destroy %>
- <%end%>
- Del
- <% end %>
-
- <%= fields_for "design[javascripts][]", @design, :index => nil do |f| %>
- <%= f.file_field :file,{:class=>"multi_files",:rtype=>"javascripts"} %>
-<% end %>
+<%= render :partial => 'design_file' ,:locals => { :fieldname=>"javascript",:object=>@design ,:f=>f,:rtype=>'javascripts' } %>
- <%= f.label "image", t('admin.image') %>
-
- <% @design.images.each do |t| %>
- - <%= t.file_filename %>
- Del
-
- <% end %>
-
- <%= fields_for "design[images][]", @design, :index => nil do |f| %>
- <%= f.file_field :file ,{:class=>"multi_files",:rtype=>"images"}%>
- <% end %>
+<%= render :partial => 'design_file' ,:locals => { :fieldname=>"image",:object=>@design ,:f=>f,:rtype=>'' } %>