unified js for dtext previews

This commit is contained in:
albert
2011-10-20 18:50:16 -04:00
parent f630365c3b
commit e8808987d5
21 changed files with 101 additions and 190 deletions

View File

@@ -5,6 +5,8 @@
<%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5"} %>
<%= f.input :is_active %>
<%= f.input :is_banned %>
<%= f.input :notes, :as => :text %>
<%= f.button :submit %>
<%= render "dtext/form", :name => "Notes", :input_id => "artist_notes", :input_name => "artist[notes]", :value => @artist.notes, :preview_id => "dtext-preview" %>
<%= f.button :submit, "Submit" %>
<%= f.button :submit, "Preview", "data-input-id" => "artist_notes", "data-preview-id" => "dtext-preview" %>
<% end %>

View File

@@ -2,7 +2,7 @@
<div class="index">
<h1>Bans</h1>
<table>
<table class="striped">
<thead>
<tr>
<th>User</th>

View File

@@ -3,8 +3,9 @@
<h1>Edit Comment</h1>
<%= simple_form_for(@comment) do |f| %>
<%= f.input :body %>
<%= f.button :submit %>
<%= render "dtext/form", :name => "Body", :input_id => "comment_body", :input_name => "comment[body]", :value => @comment.body, :preview_id => "dtext-preview" %>
<%= f.button :submit, "Submit" %>
<%= f.button :submit, "Preview", "data-input-id" => "comment_body", "data-preview-id" => "dtext-preview" %>
<% end %>
</div>
</div>

View File

@@ -1,11 +1,9 @@
<div class="comment-preview dtext dtext-preview">
</div>
<%= form_tag(comments_path) do %>
<%= form_tag(comments_path, :class => "simple_form") do %>
<%= hidden_field "comment", "post_id", :value => post.id %>
<%= text_area "comment", "body", :size => "60x7" %>
<br>
<%= render "dtext/form", :name => "Response", :input_id => "comment_response_for_#{post.id}", :input_name => "comment[body]", :value => "", :preview_id => "dtext-preview-for-#{post.id}" %>
<%= submit_tag "Post" %>
<%= submit_tag "Preview" %>
<%= link_to "Formatting", wiki_pages_path(:title => "help:dtext") %>
<% end %>
<%= submit_tag "Preview", "data-input-id" => "comment_response_for_#{post.id}", "data-preview-id" => "dtext-preview-for-#{post.id}" %>
<% end %>

View File

@@ -1,10 +1,9 @@
<div id="preview">
</div>
<%= simple_form_for(dmail) do |f| %>
<%= f.input :to_name, :label => "To" %>
<%= f.input :title %>
<%= f.input :body, :input_html => {:size => "50x25"} %>
<%= render "dtext/form", :name => "Body", :input_id => "dmail_body", :input_name => "dmail[body]", :value => dmail.body, :preview_id => "dtext-preview" %>
<%= f.button :submit, "Send" %>
<%= submit_tag "Preview", :id => "preview-button" %>
<%= f.button :submit, "Preview", "data-input-id" => "dmail_body", "data-preview-id" => "dtext-preview" %>
<% end %>

View File

@@ -0,0 +1,16 @@
<!--
- name
- input_id
- input_name
- preview_id
- value
-->
<div class="input text optional">
<label class="text optional" for="<%= input_id %>"><%= name %></label>
<div class="dtext-previewable">
<textarea id="<%= input_id %>" class="text optional" rows="20" name="<%= input_name %>" cols="30"><%= value %></textarea>
<div id="<%= preview_id %>" class="dtext-preview"></div>
</div>
<span class="hint">All text is formatted using <%= link_to "DText", wiki_pages_path(:title => "help:dtext") %></span>
</div>

View File

@@ -22,7 +22,8 @@ Or alias a URL: [url=http://www.google.com]Google[/url]
A [[wiki link]] (underscores are not needed).
A {{post link}}. Alternatively, post #1234 (also works with forum posts, comments and pools).
A {{post link}}. Alternatively, post #1234.
Also works with forum posts, comments and pools.
<%= link_to "Read more", wiki_pages_path(:title => "help:dtext") %>.
</pre>

View File

@@ -8,7 +8,8 @@
<% unless @forum_topic.new_record? %>
<%= hidden_field_tag "forum_topic[original_post_attributes][topic_id]", @forum_topic.id %>
<% end %>
<%= pf.input :body, :input_html => {:id => "forum_post_body"} %>
<%= render "dtext/form", :name => "Body", :input_id => "forum_post_body", :input_name => "forum_topic[original_post_attributes][body]", :value => @forum_topic.original_post.body, :preview_id => "dtext-preview" %>
<% end %>
<% if CurrentUser.is_moderator? %>
@@ -17,18 +18,6 @@
<% end %>
<%= f.button :submit, "Submit" %>
<%= f.button :submit, "Preview" %>
<%= f.button :submit, "Preview", "data-input-id" => "forum_post_body", "data-preview-id" => "dtext-preview" %>
<% end %>
</div>
<div id="form-aside">
<div id="preview">
<div class="content dtext">
</div>
<p><a href="#" name="toggle-preview">Hide</a></p>
</div>
<div id="dtext-help">
<%= render "dtext/help" %>
</div>
</div>

View File

@@ -3,25 +3,15 @@
<%= simple_form_for(@wiki_page) do |f| %>
<%= f.input :title %>
<%= f.input :body %>
<%= render "dtext/form", :name => "Body", :input_id => "wiki_page_body", :input_name => "wiki_page[body]", :value => @wiki_page.body, :preview_id => "dtext-preview" %>
<% if CurrentUser.is_janitor? %>
<%= f.input :is_locked %>
<% end %>
<%= f.button :submit, "Submit" %>
<%= f.button :submit, "Preview" %>
<%= f.button :submit, "Preview", "data-input-id" => "wiki_page_body", "data-preview-id" => "dtext-preview" %>
<% end %>
</div>
<div id="form-aside">
<div id="preview">
<div class="content dtext">
</div>
<p><a href="#" name="toggle-preview">Hide</a></p>
</div>
<div id="dtext-help">
<%= render "dtext/help" %>
</div>
</div>

View File

@@ -3,7 +3,7 @@
<%= render "sidebar" %>
<section id="content">
<h1>Edit Wiki Page: <%= @wiki_page.title %></h1>
<h1>Edit Wiki Page</h1>
<%= render "form" %>
</section>
</div>