From 30734ba8e8f040f3cff158351733c6228bd2db18 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 7 Apr 2007 18:56:12 +0000 Subject: [PATCH] Added toggle_link helper. git-svn-id: http://redmine.rubyforge.org/svn/trunk@432 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 7 +++++++ app/views/news/show.rhtml | 9 ++++----- app/views/projects/calendar.rhtml | 2 +- app/views/projects/gantt.rhtml | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 14934a3e4..44674bd75 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -54,6 +54,13 @@ module ApplicationHelper link_to "#{issue.tracker.name} ##{issue.id}", :controller => "issues", :action => "show", :id => issue end + def toggle_link(name, id, options={}) + onclick = "Element.toggle('#{id}'); " + onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ") + onclick << "return false;" + link_to(name, "#", :onclick => onclick) + end + def image_to_function(name, function, html_options = {}) html_options.symbolize_keys! tag(:input, html_options.merge({ diff --git a/app/views/news/show.rhtml b/app/views/news/show.rhtml index 92e664452..d1c144323 100644 --- a/app/views/news/show.rhtml +++ b/app/views/news/show.rhtml @@ -24,10 +24,9 @@ <% if authorize_for 'news', 'add_comment' %> -<% form_tag({:action => 'add_comment', :id => @news}) do %> -<%= error_messages_for 'comment' %> -


-<%= text_area 'comment', 'comment', :cols => 60, :rows => 6 %>

-<%= submit_tag l(:button_add) %> +

<%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comment" %>

+<% form_tag({:action => 'add_comment', :id => @news}, :id => "add_comment_form", :style => "display:none;") do %> +<%= text_area 'comment', 'comment', :cols => 60, :rows => 6 %> +

<%= submit_tag l(:button_add) %>

<% end %> <% end %> \ No newline at end of file diff --git a/app/views/projects/calendar.rhtml b/app/views/projects/calendar.rhtml index b6ed913f2..4f4b5ab71 100644 --- a/app/views/projects/calendar.rhtml +++ b/app/views/projects/calendar.rhtml @@ -15,7 +15,7 @@ <%= submit_tag l(:button_submit), :class => "button-small" %> - <%= l(:label_options) %> + <%= toggle_link l(:label_options), "trackerselect" %>