ADD: Dateieinbindung in TinyMCE für Attachments

This commit is contained in:
HausdorffHimself
2013-08-24 04:07:33 +02:00
parent adbbce5fc8
commit 94614b1d5b
11 changed files with 79 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
<%= semantic_form_for @attachment do |f| %>
<%= semantic_form_for [@thema,@attachment] do |f| %>
<%= f.inputs do %>
<%= f.input :name %>
<%= f.input :datei, :as => :file %>
<% end %>
<%= f.actions do %>

View File

@@ -2,5 +2,5 @@
<%= render 'form' %>
<%= link_to 'Show', @attachment %> |
<%= link_to 'Back', attachments_path %>
<%= link_to 'Back', thema_attachments_path(@attachment.thema,@attachment) %>

View File

@@ -2,4 +2,4 @@
<%= render 'form' %>
<%= link_to 'Back', attachments_path %>
<%= link_to 'Back', @thema %>

View File

@@ -8,7 +8,31 @@
<% end %>
<%= tinymce %>
<h2>Attachments:</h2>
<% @thema.attachments.each do |attachment| %>
<ul>
<li>
<%= link_to attachment.name, edit_thema_attachment_path(@thema,attachment) %>
<button type="button" onclick="insertAttachment(<%="\"" + attachment.datei.url + "\""%>,<%="\""+attachment.name+"\""%>)">Insert Me!</button>
</li>
</ul>
<% end %>
<%= f.actions do %>
<%= f.action :submit, :as => :input %>
<% end %>
<% end %>
<!--
<script>
function insertAttachment(url) {
tinymce.activeEditor.setContent(tinymce.activeEditor.getContent({format : 'raw'}) + "Test");
//editor.setContent(editor.getContent + "<img src=\"" + url + "\">")
}
</script>
-->

View File

@@ -20,6 +20,16 @@
</p>
<% end %>
<%= link_to 'Neue Frage', new_frage_path %> <br/>
<br/>
<%= link_to 'Neue Frage', new_frage_path %>
<h2>Attachments:</h2>
<% @thema.attachments.each do |attachment| %>
<ul>
<li>
<%= link_to attachment.name, edit_thema_attachment_path(@thema,attachment) %> | <%= link_to 'Destroy',[@thema,attachment], method: :delete, data: { confirm: 'Are you sure?' } %>
</li>
</ul>
<% end %>
<%= link_to 'Neues Attachment', new_thema_attachment_path(@thema) %>
<br/>