refactored dtext field helper
This commit is contained in:
@@ -6,7 +6,6 @@ div#search {
|
||||
|
||||
div#page {
|
||||
overflow: hidden;
|
||||
width: 85em;
|
||||
margin: 0 30px;
|
||||
|
||||
aside#sidebar {
|
||||
|
||||
@@ -28,7 +28,6 @@ table.striped {
|
||||
font-weight: bold;
|
||||
text-align: left;
|
||||
color: #333;
|
||||
padding: 8px 6px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,22 @@ module ApplicationHelper
|
||||
html.html_safe
|
||||
end
|
||||
|
||||
def dtext_field(object, name, options = {})
|
||||
options[:name] ||= "Body"
|
||||
options[:input_id] ||= "#{object}_#{name}"
|
||||
options[:input_name] ||= "#{object}[#{name}]"
|
||||
options[:value] ||= instance_variable_get("@#{object}").try(name)
|
||||
options[:preview_id] ||= "dtext-preview"
|
||||
|
||||
render "dtext/form", options
|
||||
end
|
||||
|
||||
def dtext_preview_button(object, name, options = {})
|
||||
options[:input_id] ||= "#{object}_#{name}"
|
||||
options[:preview_id] ||= "dtext-preview"
|
||||
submit_tag("Preview", "data-input-id" => options[:input_id], "data-preview-id" => options[:preview_id])
|
||||
end
|
||||
|
||||
protected
|
||||
def nav_link_match(controller, url)
|
||||
url =~ case controller
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
<%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5"} %>
|
||||
<%= f.input :is_active %>
|
||||
<%= f.input :is_banned %>
|
||||
|
||||
<%= render "dtext/form", :name => "Notes", :input_id => "artist_notes", :input_name => "artist[notes]", :value => @artist.notes, :preview_id => "dtext-preview" %>
|
||||
<%= dtext_field "artist", "notes" %>
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<%= f.button :submit, "Preview", "data-input-id" => "artist_notes", "data-preview-id" => "dtext-preview" %>
|
||||
<%= dtext_preview_button "artist", "notes" %>
|
||||
<% end %>
|
||||
@@ -3,9 +3,9 @@
|
||||
<h1>Edit Comment</h1>
|
||||
|
||||
<%= simple_form_for(@comment) do |f| %>
|
||||
<%= render "dtext/form", :name => "Body", :input_id => "comment_body", :input_name => "comment[body]", :value => @comment.body, :preview_id => "dtext-preview" %>
|
||||
<%= dtext_field "comment", "body" %>
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<%= f.button :submit, "Preview", "data-input-id" => "comment_body", "data-preview-id" => "dtext-preview" %>
|
||||
<%= dtext_preview_button "comment", "body" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<%= form_tag(comments_path, :class => "simple_form") do %>
|
||||
<%= hidden_field "comment", "post_id", :value => post.id %>
|
||||
<%= render "dtext/form", :name => "Response", :input_id => "comment_response_for_#{post.id}", :input_name => "comment[body]", :value => "", :preview_id => "dtext-preview-for-#{post.id}" %>
|
||||
<%= dtext_field "comment", "body", :input_id => "comment_response_for_#{post.id}", :preview_id => "dtext-preview-for-#{post.id}" %>
|
||||
<%= submit_tag "Post" %>
|
||||
<%= submit_tag "Preview", "data-input-id" => "comment_response_for_#{post.id}", "data-preview-id" => "dtext-preview-for-#{post.id}" %>
|
||||
<%= dtext_preview_button "comment", "body", :input_id => "comment_response_for_#{post.id}", :preview_id => "dtext-preview-for-#{post.id}" %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<%= simple_form_for(dmail) do |f| %>
|
||||
<%= f.input :to_name, :label => "To" %>
|
||||
<%= f.input :title %>
|
||||
|
||||
<%= render "dtext/form", :name => "Body", :input_id => "dmail_body", :input_name => "dmail[body]", :value => dmail.body, :preview_id => "dtext-preview" %>
|
||||
|
||||
<%= dtext_field "dmail", "body" %>
|
||||
<%= f.button :submit, "Send" %>
|
||||
<%= f.button :submit, "Preview", "data-input-id" => "dmail_body", "data-preview-id" => "dtext-preview" %>
|
||||
<%= dtext_preview_button "dmail", "body" %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,23 +1,9 @@
|
||||
<div id="form-content">
|
||||
<%= error_messages_for("forum_post") %>
|
||||
<%= error_messages_for("forum_post") %>
|
||||
|
||||
<%= simple_form_for(@forum_post) do |f| %>
|
||||
<%= f.input :topic_id, :as => :hidden %>
|
||||
<%= f.input :body %>
|
||||
<%= simple_form_for(@forum_post) do |f| %>
|
||||
<%= f.input :topic_id, :as => :hidden %>
|
||||
<%= dtext_field "forum_post", "body" %>
|
||||
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<%= f.button :submit, "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>
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<%= dtext_preview_button "forum_post", "body" %>
|
||||
<% end %>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<%= hidden_field_tag "forum_topic[original_post_attributes][topic_id]", @forum_topic.id %>
|
||||
<% end %>
|
||||
|
||||
<%= 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" %>
|
||||
<%= dtext_field "forum_post", "body", :input_name => "forum_topic[original_post_attributes][body]", :value => @forum_topic.original_post.body %>
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.is_moderator? %>
|
||||
@@ -18,6 +18,6 @@
|
||||
<% end %>
|
||||
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<%= f.button :submit, "Preview", "data-input-id" => "forum_post_body", "data-preview-id" => "dtext-preview" %>
|
||||
<%= dtext_preview_button "forum_post", "body" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
</div>
|
||||
|
||||
<%= simple_form_for(@user_feedback) do |f| %>
|
||||
<%= f.input :user_name %>
|
||||
<%= f.input :user_name, :label => "User" %>
|
||||
<%= f.input :category, :collection => ["positive", "neutral", "negative"], :include_blank => false %>
|
||||
<%= f.input :body, :input_html => {:size => "50x5"} %>
|
||||
<%= dtext_field "user_feedback", "body" %>
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<%= f.button :submit, "Preview" %>
|
||||
<%= dtext_preview_button "user_feedback", "body" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
<%= simple_form_for(@wiki_page) do |f| %>
|
||||
<%= f.input :title %>
|
||||
|
||||
<%= render "dtext/form", :name => "Body", :input_id => "wiki_page_body", :input_name => "wiki_page[body]", :value => @wiki_page.body, :preview_id => "dtext-preview" %>
|
||||
<%= dtext_field "wiki_page", "body" %>
|
||||
|
||||
<% if CurrentUser.is_janitor? %>
|
||||
<%= f.input :is_locked %>
|
||||
<% end %>
|
||||
|
||||
<%= f.button :submit, "Submit" %>
|
||||
<%= f.button :submit, "Preview", "data-input-id" => "wiki_page_body", "data-preview-id" => "dtext-preview" %>
|
||||
<%= dtext_preview_button "wiki_page", "body" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user