Commit 87a14099 authored by jplang's avatar jplang

Don't use a global variable for storing context menu URL.

git-svn-id: https://svn.redmine.org/redmine/trunk@15936 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent adf89df9
......@@ -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)
......
......@@ -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
......
<%= 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 %>">
......
<% 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>
......
......@@ -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, {
......
......@@ -69,4 +69,4 @@
:title => l(:label_changes_details)) %>
<% end %>
<%= context_menu issues_context_menu_path %>
<%= context_menu %>
......@@ -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 %>
......@@ -16,6 +16,6 @@
<%= render_blocks(@blocks['right'], @user) %>
</div>
<%= context_menu issues_context_menu_path %>
<%= context_menu %>
<% html_title(l(:label_my_page)) -%>
<%= 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 %>
......@@ -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 %>
......@@ -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>
......
......@@ -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);
});
......@@ -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'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment