summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-10-29 14:06:15 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-10-29 14:06:15 +0000
commit18073c971e69fcfbfcafc8f2ec81768ea18220f8 (patch)
tree84b3ae221e6cbaae1d3253d397490f41a8b1a840
parent7cce582c14a0022032cb33c60ad46715ec83af81 (diff)
downloadredmine-18073c971e69fcfbfcafc8f2ec81768ea18220f8.tar.gz
redmine-18073c971e69fcfbfcafc8f2ec81768ea18220f8.zip
Don't use a global variable for storing context menu URL.
git-svn-id: http://svn.redmine.org/redmine/trunk@15936 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/application_helper.rb4
-rw-r--r--app/helpers/issues_helper.rb4
-rw-r--r--app/views/issues/_list.html.erb2
-rw-r--r--app/views/issues/_list_simple.html.erb2
-rw-r--r--app/views/issues/_relations.html.erb4
-rw-r--r--app/views/issues/index.html.erb2
-rw-r--r--app/views/issues/show.html.erb4
-rw-r--r--app/views/my/page.html.erb2
-rw-r--r--app/views/timelog/_list.html.erb4
-rw-r--r--app/views/versions/index.html.erb4
-rw-r--r--app/views/versions/show.html.erb4
-rw-r--r--public/javascripts/context_menu.js10
-rw-r--r--test/functional/versions_controller_test.rb2
13 files changed, 26 insertions, 22 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index c54858b6d..e1505f824 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1165,7 +1165,7 @@ module ApplicationHelper
end
end
- def context_menu(url)
+ def context_menu
unless @context_menu_included
content_for :header_tags do
javascript_include_tag('context_menu') +
@@ -1178,7 +1178,7 @@ module ApplicationHelper
end
@context_menu_included = true
end
- javascript_tag "contextMenuInit('#{ url_for(url) }')"
+ nil
end
def calendar_for(field_id)
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index 08611c91e..72f33da1d 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -90,7 +90,7 @@ module IssuesHelper
end
def render_descendants_tree(issue)
- s = '<form><table class="list issues">'
+ s = '<table class="list issues">'
issue_list(issue.descendants.visible.preload(:status, :priority, :tracker, :assigned_to).sort_by(&:lft)) do |child, level|
css = "issue issue-#{child.id} hascontextmenu #{child.css_classes}"
css << " idnt idnt-#{level}" if level > 0
@@ -102,7 +102,7 @@ module IssuesHelper
content_tag('td', child.disabled_core_fields.include?('done_ratio') ? '' : progress_bar(child.done_ratio), :class=> 'done_ratio'),
:class => css)
end
- s << '</table></form>'
+ s << '</table>'
s.html_safe
end
diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb
index 2376a845b..851fca1a3 100644
--- a/app/views/issues/_list.html.erb
+++ b/app/views/issues/_list.html.erb
@@ -1,4 +1,4 @@
-<%= form_tag({}) do -%>
+<%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do -%>
<%= hidden_field_tag 'back_url', url_for(:params => request.query_parameters), :id => nil %>
<div class="autoscroll">
<table class="list issues <%= sort_css_classes %>">
diff --git a/app/views/issues/_list_simple.html.erb b/app/views/issues/_list_simple.html.erb
index 8ce273db6..0d2850cd0 100644
--- a/app/views/issues/_list_simple.html.erb
+++ b/app/views/issues/_list_simple.html.erb
@@ -1,5 +1,5 @@
<% if issues && issues.any? %>
-<%= form_tag({}) do %>
+<%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do %>
<table class="list list-simple issues">
<thead><tr>
<th class="id">#</th>
diff --git a/app/views/issues/_relations.html.erb b/app/views/issues/_relations.html.erb
index dcf079564..cab1d0c1a 100644
--- a/app/views/issues/_relations.html.erb
+++ b/app/views/issues/_relations.html.erb
@@ -7,7 +7,7 @@
<p><strong><%=l(:label_related_issues)%></strong></p>
<% if @relations.present? %>
-<form>
+<%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do %>
<table class="list issues">
<% @relations.each do |relation| %>
<% other_issue = relation.other_issue(@issue) -%>
@@ -30,7 +30,7 @@
</tr>
<% end %>
</table>
-</form>
+<% end %>
<% end %>
<%= form_for @relation, {
diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb
index d0fd943f0..a9f321c3d 100644
--- a/app/views/issues/index.html.erb
+++ b/app/views/issues/index.html.erb
@@ -69,4 +69,4 @@
:title => l(:label_changes_details)) %>
<% end %>
-<%= context_menu issues_context_menu_path %>
+<%= context_menu %>
diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb
index f8849052d..b9e5111fa 100644
--- a/app/views/issues/show.html.erb
+++ b/app/views/issues/show.html.erb
@@ -96,7 +96,9 @@ end %>
<%= link_to_new_subtask(@issue) if User.current.allowed_to?(:manage_subtasks, @project) %>
</div>
<p><strong><%=l(:label_subtask_plural)%></strong></p>
+<%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do %>
<%= render_descendants_tree(@issue) unless @issue.leaf? %>
+<% end %>
</div>
<% end %>
@@ -157,4 +159,4 @@ end %>
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %>
<% end %>
-<%= context_menu issues_context_menu_path %>
+<%= context_menu %>
diff --git a/app/views/my/page.html.erb b/app/views/my/page.html.erb
index a9a02becb..d5b8e3e30 100644
--- a/app/views/my/page.html.erb
+++ b/app/views/my/page.html.erb
@@ -16,6 +16,6 @@
<%= render_blocks(@blocks['right'], @user) %>
</div>
-<%= context_menu issues_context_menu_path %>
+<%= context_menu %>
<% html_title(l(:label_my_page)) -%>
diff --git a/app/views/timelog/_list.html.erb b/app/views/timelog/_list.html.erb
index be02adb5c..3721df274 100644
--- a/app/views/timelog/_list.html.erb
+++ b/app/views/timelog/_list.html.erb
@@ -1,4 +1,4 @@
-<%= form_tag({}) do -%>
+<%= form_tag({}, :data => {:cm_url => time_entries_context_menu_path}) do -%>
<%= hidden_field_tag 'back_url', url_for(:params => request.query_parameters), :id => nil %>
<div class="autoscroll">
<table class="list time-entries">
@@ -60,4 +60,4 @@
</div>
<% end -%>
-<%= context_menu time_entries_context_menu_path %>
+<%= context_menu %>
diff --git a/app/views/versions/index.html.erb b/app/views/versions/index.html.erb
index 0f1d0b842..ab6182033 100644
--- a/app/views/versions/index.html.erb
+++ b/app/views/versions/index.html.erb
@@ -23,7 +23,7 @@
<%= render(:partial => "wiki/content",
:locals => {:content => version.wiki_page.content}) if version.wiki_page %>
<% if (issues = @issues_by_version[version]) && issues.size > 0 %>
- <%= form_tag({}) do -%>
+ <%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do -%>
<table class="list related-issues">
<caption><%= l(:label_related_issues) %></caption>
<% issues.each do |issue| -%>
@@ -99,4 +99,4 @@
<% html_title(l(:label_roadmap)) %>
-<%= context_menu issues_context_menu_path %>
+<%= context_menu %>
diff --git a/app/views/versions/show.html.erb b/app/views/versions/show.html.erb
index f018c2d8e..638a17af7 100644
--- a/app/views/versions/show.html.erb
+++ b/app/views/versions/show.html.erb
@@ -36,7 +36,7 @@
</div>
<% if @issues.present? %>
-<%= form_tag({}) do -%>
+<%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do -%>
<table class="list related-issues">
<caption><%= l(:label_related_issues) %></caption>
<%- @issues.each do |issue| -%>
@@ -47,7 +47,7 @@
<% end %>
</table>
<% end %>
-<%= context_menu issues_context_menu_path %>
+<%= context_menu %>
<% end %>
</div>
diff --git a/public/javascripts/context_menu.js b/public/javascripts/context_menu.js
index ca2a9bec9..6fd509ea6 100644
--- a/public/javascripts/context_menu.js
+++ b/public/javascripts/context_menu.js
@@ -2,7 +2,6 @@
Copyright (C) 2006-2016 Jean-Philippe Lang */
var contextMenuObserving;
-var contextMenuUrl;
function contextMenuRightClick(event) {
var target = $(event.target);
@@ -98,13 +97,16 @@ function contextMenuShow(event) {
var window_height;
var max_width;
var max_height;
+ var url;
$('#context-menu').css('left', (render_x + 'px'));
$('#context-menu').css('top', (render_y + 'px'));
$('#context-menu').html('');
+ url = $(event.target).parents('form').first().data('cm-url');
+
$.ajax({
- url: contextMenuUrl,
+ url: url,
data: $(event.target).parents('form').first().serialize(),
success: function(data, textStatus, jqXHR) {
$('#context-menu').html(data);
@@ -208,8 +210,7 @@ function contextMenuClearDocumentSelection() {
}
}
-function contextMenuInit(url) {
- contextMenuUrl = url;
+function contextMenuInit() {
contextMenuCreate();
contextMenuUnselectAll();
@@ -243,5 +244,6 @@ function window_size() {
}
$(document).ready(function(){
+ contextMenuInit();
$('input[type=checkbox].toggle-selection').on('change', toggleIssuesSelection);
});
diff --git a/test/functional/versions_controller_test.rb b/test/functional/versions_controller_test.rb
index d794cf3e4..c2f054eee 100644
--- a/test/functional/versions_controller_test.rb
+++ b/test/functional/versions_controller_test.rb
@@ -36,7 +36,7 @@ class VersionsControllerTest < Redmine::ControllerTest
assert_select 'h3', :text => Version.find(1).name, :count => 0
# Context menu on issues
- assert_select "script", :text => Regexp.new(Regexp.escape("contextMenuInit('/issues/context_menu')"))
+ assert_select "form[data-cm-url=?]", '/issues/context_menu'
assert_select "div#sidebar" do
# Links to versions anchors
assert_select 'a[href=?]', '#2.0'