summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-07-18 17:47:19 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-07-18 17:47:19 +0000
commitff68fff80ed1cc9f95587581be9eb641d7a776e5 (patch)
tree8401052d01792a36dbe5486379e084a574a33c48 /app
parentbb2af97dcf4ba9372ce78ba8163cc3dc2794a7bb (diff)
downloadredmine-ff68fff80ed1cc9f95587581be9eb641d7a776e5.tar.gz
redmine-ff68fff80ed1cc9f95587581be9eb641d7a776e5.zip
Adds a helper for preview links.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10031 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/application_helper.rb8
-rw-r--r--app/views/boards/show.html.erb8
-rw-r--r--app/views/issues/_edit.html.erb8
-rw-r--r--app/views/issues/new.html.erb8
-rw-r--r--app/views/journals/_notes_form.html.erb11
-rw-r--r--app/views/messages/edit.html.erb9
-rw-r--r--app/views/messages/new.html.erb8
-rw-r--r--app/views/messages/show.html.erb8
-rw-r--r--app/views/news/edit.html.erb7
-rw-r--r--app/views/news/index.html.erb7
-rw-r--r--app/views/news/new.html.erb7
-rw-r--r--app/views/news/show.html.erb7
-rw-r--r--app/views/wiki/edit.html.erb9
13 files changed, 22 insertions, 83 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index d118e04d6..a9dcf25b9 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -995,6 +995,14 @@ module ApplicationHelper
link_to l(:button_delete), url, options
end
+ def preview_link(url, form, target='preview', options={})
+ content_tag 'a', l(:label_preview), {
+ :href => "#",
+ :onclick => %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;|,
+ :accesskey => accesskey(:preview)
+ }.merge(options)
+ end
+
def back_url_hidden_field_tag
back_url = params[:back_url] || request.env['HTTP_REFERER']
back_url = CGI.unescape(back_url.to_s)
diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb
index 523dfea45..3d31014d7 100644
--- a/app/views/boards/show.html.erb
+++ b/app/views/boards/show.html.erb
@@ -14,13 +14,7 @@
<%= form_for @message, :url => {:controller => 'messages', :action => 'new', :board_id => @board}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'messages/form', :locals => {:f => f} %>
<p><%= submit_tag l(:button_create) %>
- <%= link_to_remote l(:label_preview),
- { :url => { :controller => 'messages', :action => 'preview', :board_id => @board },
- :method => 'post',
- :update => 'preview',
- :with => "Form.serialize('message-form')",
- :complete => "Element.scrollTo('preview')"
- }, :accesskey => accesskey(:preview) %> |
+ <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %> |
<%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-message")' %></p>
<% end %>
<div id="preview" class="wiki"></div>
diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb
index b5ddfac38..5b5f53ab6 100644
--- a/app/views/issues/_edit.html.erb
+++ b/app/views/issues/_edit.html.erb
@@ -38,13 +38,7 @@
<%= f.hidden_field :lock_version %>
<%= hidden_field_tag 'last_journal_id', params[:last_journal_id] || @issue.last_journal_id %>
<%= submit_tag l(:button_submit) %>
- <%= link_to_remote l(:label_preview),
- { :url => preview_edit_issue_path(:project_id => @project, :id => @issue),
- :method => 'post',
- :update => 'preview',
- :with => 'Form.serialize("issue-form")',
- :complete => "Element.scrollTo('preview')"
- }, :accesskey => accesskey(:preview) %>
+ <%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue), 'issue-form' %>
<% end %>
<div id="preview" class="wiki"></div>
diff --git a/app/views/issues/new.html.erb b/app/views/issues/new.html.erb
index 4e8449570..fe07dbdd6 100644
--- a/app/views/issues/new.html.erb
+++ b/app/views/issues/new.html.erb
@@ -36,13 +36,7 @@
<%= submit_tag l(:button_create) %>
<%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
- <%= link_to_remote l(:label_preview),
- { :url => preview_new_issue_path(:project_id => @project),
- :method => 'post',
- :update => 'preview',
- :with => "Form.serialize('issue-form')",
- :complete => "Element.scrollTo('preview')"
- }, :accesskey => accesskey(:preview) %>
+ <%= preview_link preview_new_issue_path(:project_id => @project), 'issue-form' %>
<%= javascript_tag "Form.Element.focus('issue_subject');" %>
<% end %>
diff --git a/app/views/journals/_notes_form.html.erb b/app/views/journals/_notes_form.html.erb
index f451dbbeb..f039b478c 100644
--- a/app/views/journals/_notes_form.html.erb
+++ b/app/views/journals/_notes_form.html.erb
@@ -6,14 +6,9 @@
:rows => (@journal.notes.blank? ? 10 : [[10, @journal.notes.length / 50].max, 100].min) %>
<%= call_hook(:view_journals_notes_form_after_notes, { :journal => @journal}) %>
<p><%= submit_tag l(:button_save) %>
- <%= link_to_remote l(:label_preview),
- { :url => preview_edit_issue_path(:project_id => @project, :id => @journal.issue),
- :method => 'post',
- :update => "journal_#{@journal.id}_preview",
- :with => "Form.serialize('journal-#{@journal.id}-form')",
- :complete => "Element.scrollTo('journal_#{@journal.id}_preview')"
- }, :accesskey => accesskey(:preview) %>
- |
+ <%= preview_link preview_edit_issue_path(:project_id => @project, :id => @journal.issue),
+ "journal-#{@journal.id}-form",
+ "journal_#{@journal.id}_preview" %> |
<%= link_to l(:button_cancel), '#', :onclick => "Element.remove('journal-#{@journal.id}-form'); " +
"Element.show('journal-#{@journal.id}-notes'); return false;" %></p>
diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb
index 362f1b6b9..e08d7a297 100644
--- a/app/views/messages/edit.html.erb
+++ b/app/views/messages/edit.html.erb
@@ -12,14 +12,7 @@
<%= render :partial => 'form',
:locals => {:f => f, :replying => !@message.parent.nil?} %>
<%= submit_tag l(:button_save) %>
- <%= link_to_remote l(:label_preview),
- { :url => { :controller => 'messages',
- :action => 'preview', :board_id => @board, :id => @message },
- :method => 'post',
- :update => 'preview',
- :with => "Form.serialize('message-form')",
- :complete => "Element.scrollTo('preview')"
- }, :accesskey => accesskey(:preview) %>
+ <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board, :id => @message}, 'message-form') %>
<% end %>
<div id="preview" class="wiki"></div>
diff --git a/app/views/messages/new.html.erb b/app/views/messages/new.html.erb
index f1dddb6f5..fbdac695f 100644
--- a/app/views/messages/new.html.erb
+++ b/app/views/messages/new.html.erb
@@ -3,13 +3,7 @@
<%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= submit_tag l(:button_create) %>
- <%= link_to_remote l(:label_preview),
- { :url => { :controller => 'messages', :action => 'preview', :board_id => @board },
- :method => 'post',
- :update => 'preview',
- :with => "Form.serialize('message-form')",
- :complete => "Element.scrollTo('preview')"
- }, :accesskey => accesskey(:preview) %>
+ <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
<% end %>
<div id="preview" class="wiki"></div>
diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb
index 639dc2e7c..831d3ec14 100644
--- a/app/views/messages/show.html.erb
+++ b/app/views/messages/show.html.erb
@@ -75,13 +75,7 @@
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
<%= submit_tag l(:button_submit) %>
- <%= link_to_remote l(:label_preview),
- { :url => { :controller => 'messages', :action => 'preview', :board_id => @board },
- :method => 'post',
- :update => 'preview',
- :with => "Form.serialize('message-form')",
- :complete => "Element.scrollTo('preview')"
- }, :accesskey => accesskey(:preview) %>
+ <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
<% end %>
<div id="preview" class="wiki"></div>
</div>
diff --git a/app/views/news/edit.html.erb b/app/views/news/edit.html.erb
index 5dd43c3ce..499451bb7 100644
--- a/app/views/news/edit.html.erb
+++ b/app/views/news/edit.html.erb
@@ -3,12 +3,7 @@
<%= labelled_form_for @news, :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
-<%= link_to_remote l(:label_preview),
- { :url => preview_news_path(:project_id => @project),
- :method => 'get',
- :update => 'preview',
- :with => "Form.serialize('news-form')"
- }, :accesskey => accesskey(:preview) %>
+<%= preview_link preview_news_path(:project_id => @project), 'news-form' %>
<% end %>
<div id="preview" class="wiki"></div>
diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb
index b354adcb8..e62cce498 100644
--- a/app/views/news/index.html.erb
+++ b/app/views/news/index.html.erb
@@ -11,12 +11,7 @@
:html => { :id => 'news-form', :multipart => true } do |f| %>
<%= render :partial => 'news/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
-<%= link_to_remote l(:label_preview),
- { :url => preview_news_path(:project_id => @project),
- :method => 'get',
- :update => 'preview',
- :with => "Form.serialize('news-form')"
- }, :accesskey => accesskey(:preview) %> |
+<%= preview_link preview_news_path(:project_id => @project), 'news-form' %> |
<%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-news")' %>
<% end if @project %>
<div id="preview" class="wiki"></div>
diff --git a/app/views/news/new.html.erb b/app/views/news/new.html.erb
index 95a902432..f96dd5c52 100644
--- a/app/views/news/new.html.erb
+++ b/app/views/news/new.html.erb
@@ -4,11 +4,6 @@
:html => { :id => 'news-form', :multipart => true } do |f| %>
<%= render :partial => 'news/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
- <%= link_to_remote l(:label_preview),
- { :url => preview_news_path(:project_id => @project),
- :method => 'get',
- :update => 'preview',
- :with => "Form.serialize('news-form')"
- }, :accesskey => accesskey(:preview) %>
+ <%= preview_link preview_news_path(:project_id => @project), 'news-form' %>
<% end %>
<div id="preview" class="wiki"></div>
diff --git a/app/views/news/show.html.erb b/app/views/news/show.html.erb
index fba61835d..51a896e12 100644
--- a/app/views/news/show.html.erb
+++ b/app/views/news/show.html.erb
@@ -16,12 +16,7 @@
:html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
-<%= link_to_remote l(:label_preview),
- { :url => preview_news_path(:project_id => @project),
- :method => 'get',
- :update => 'preview',
- :with => "Form.serialize('news-form')"
- }, :accesskey => accesskey(:preview) %> |
+<%= preview_link preview_news_path(:project_id => @project), 'news-form' %> |
<%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("edit-news"); return false;' %>
<% end %>
<div id="preview" class="wiki"></div>
diff --git a/app/views/wiki/edit.html.erb b/app/views/wiki/edit.html.erb
index 0d4da7e79..db9d1c2ef 100644
--- a/app/views/wiki/edit.html.erb
+++ b/app/views/wiki/edit.html.erb
@@ -33,14 +33,7 @@
</div>
<p><%= submit_tag l(:button_save) %>
- <%= link_to_remote l(:label_preview),
- { :url => { :controller => 'wiki', :action => 'preview',
- :project_id => @project, :id => @page.title },
- :method => :post,
- :update => 'preview',
- :with => "Form.serialize('wiki_form')",
- :complete => "Element.scrollTo('preview')"
- }, :accesskey => accesskey(:preview) %></p>
+ <%= preview_link({:controller => 'wiki', :action => 'preview', :project_id => @project, :id => @page.title }, 'wiki_form') %></p>
<%= wikitoolbar_for 'content_text' %>
<% end %>