@@ -1,5 +1,5 | |||||
1 |
/* |
|
1 | /* Redmine - project management software | |
2 |
Copyright (C) 2006-20 |
|
2 | Copyright (C) 2006-2012 Jean-Philippe Lang */ | |
3 |
|
3 | |||
4 | var observingContextMenuClick; |
|
4 | var observingContextMenuClick; | |
5 |
|
5 | |||
@@ -14,11 +14,11 ContextMenu.prototype = { | |||||
14 | Event.observe(document, 'contextmenu', this.RightClick.bindAsEventListener(this)); |
|
14 | Event.observe(document, 'contextmenu', this.RightClick.bindAsEventListener(this)); | |
15 | observingContextMenuClick = true; |
|
15 | observingContextMenuClick = true; | |
16 | } |
|
16 | } | |
17 |
|
17 | |||
18 | this.unselectAll(); |
|
18 | this.unselectAll(); | |
19 | this.lastSelected = null; |
|
19 | this.lastSelected = null; | |
20 | }, |
|
20 | }, | |
21 |
|
21 | |||
22 | RightClick: function(e) { |
|
22 | RightClick: function(e) { | |
23 | this.hideMenu(); |
|
23 | this.hideMenu(); | |
24 | // do not show the context menu on links |
|
24 | // do not show the context menu on links | |
@@ -41,7 +41,7 ContextMenu.prototype = { | |||||
41 | } |
|
41 | } | |
42 | this.hideMenu(); |
|
42 | this.hideMenu(); | |
43 | if (Event.element(e).tagName == 'A' || Event.element(e).tagName == 'IMG') { return; } |
|
43 | if (Event.element(e).tagName == 'A' || Event.element(e).tagName == 'IMG') { return; } | |
44 |
if (Event.isLeftClick(e) || (navigator.appVersion.match(/\bMSIE\b/))) { |
|
44 | if (Event.isLeftClick(e) || (navigator.appVersion.match(/\bMSIE\b/))) { | |
45 | var tr = Event.findElement(e, 'tr'); |
|
45 | var tr = Event.findElement(e, 'tr'); | |
46 | if (tr!=null && tr!=document && tr.hasClassName('hascontextmenu')) { |
|
46 | if (tr!=null && tr!=document && tr.hasClassName('hascontextmenu')) { | |
47 | // a row was clicked, check if the click was on checkbox |
|
47 | // a row was clicked, check if the click was on checkbox | |
@@ -90,7 +90,7 ContextMenu.prototype = { | |||||
90 | } |
|
90 | } | |
91 | } |
|
91 | } | |
92 | }, |
|
92 | }, | |
93 |
|
93 | |||
94 | createMenu: function() { |
|
94 | createMenu: function() { | |
95 | if (!$('context-menu')) { |
|
95 | if (!$('context-menu')) { | |
96 | var menu = document.createElement("div"); |
|
96 | var menu = document.createElement("div"); | |
@@ -99,7 +99,7 ContextMenu.prototype = { | |||||
99 | document.getElementById("content").appendChild(menu); |
|
99 | document.getElementById("content").appendChild(menu); | |
100 | } |
|
100 | } | |
101 | }, |
|
101 | }, | |
102 |
|
102 | |||
103 | showMenu: function(e) { |
|
103 | showMenu: function(e) { | |
104 | var mouse_x = Event.pointerX(e); |
|
104 | var mouse_x = Event.pointerX(e); | |
105 | var mouse_y = Event.pointerY(e); |
|
105 | var mouse_y = Event.pointerY(e); | |
@@ -114,10 +114,10 ContextMenu.prototype = { | |||||
114 | var max_height; |
|
114 | var max_height; | |
115 |
|
115 | |||
116 | $('context-menu').style['left'] = (render_x + 'px'); |
|
116 | $('context-menu').style['left'] = (render_x + 'px'); | |
117 |
$('context-menu').style['top'] = (render_y + 'px'); |
|
117 | $('context-menu').style['top'] = (render_y + 'px'); | |
118 | Element.update('context-menu', ''); |
|
118 | Element.update('context-menu', ''); | |
119 |
|
119 | |||
120 |
new Ajax.Updater({success:'context-menu'}, this.url, |
|
120 | new Ajax.Updater({success:'context-menu'}, this.url, | |
121 | {asynchronous:true, |
|
121 | {asynchronous:true, | |
122 | method: 'get', |
|
122 | method: 'get', | |
123 | evalScripts:true, |
|
123 | evalScripts:true, | |
@@ -128,11 +128,11 ContextMenu.prototype = { | |||||
128 | menu_height = dims.height; |
|
128 | menu_height = dims.height; | |
129 | max_width = mouse_x + 2*menu_width; |
|
129 | max_width = mouse_x + 2*menu_width; | |
130 | max_height = mouse_y + menu_height; |
|
130 | max_height = mouse_y + menu_height; | |
131 |
|
131 | |||
132 | var ws = window_size(); |
|
132 | var ws = window_size(); | |
133 | window_width = ws.width; |
|
133 | window_width = ws.width; | |
134 | window_height = ws.height; |
|
134 | window_height = ws.height; | |
135 |
|
135 | |||
136 | /* display the menu above and/or to the left of the click if needed */ |
|
136 | /* display the menu above and/or to the left of the click if needed */ | |
137 | if (max_width > window_width) { |
|
137 | if (max_width > window_width) { | |
138 | render_x -= menu_width; |
|
138 | render_x -= menu_width; | |
@@ -150,22 +150,22 ContextMenu.prototype = { | |||||
150 | if (render_y <= 0) render_y = 1; |
|
150 | if (render_y <= 0) render_y = 1; | |
151 | $('context-menu').style['left'] = (render_x + 'px'); |
|
151 | $('context-menu').style['left'] = (render_x + 'px'); | |
152 | $('context-menu').style['top'] = (render_y + 'px'); |
|
152 | $('context-menu').style['top'] = (render_y + 'px'); | |
153 |
|
153 | |||
154 | Effect.Appear('context-menu', {duration: 0.20}); |
|
154 | Effect.Appear('context-menu', {duration: 0.20}); | |
155 | if (window.parseStylesheets) { window.parseStylesheets(); } // IE |
|
155 | if (window.parseStylesheets) { window.parseStylesheets(); } // IE | |
156 | }}) |
|
156 | }}) | |
157 | }, |
|
157 | }, | |
158 |
|
158 | |||
159 | hideMenu: function() { |
|
159 | hideMenu: function() { | |
160 | Element.hide('context-menu'); |
|
160 | Element.hide('context-menu'); | |
161 | }, |
|
161 | }, | |
162 |
|
162 | |||
163 | addSelection: function(tr) { |
|
163 | addSelection: function(tr) { | |
164 | tr.addClassName('context-menu-selection'); |
|
164 | tr.addClassName('context-menu-selection'); | |
165 | this.checkSelectionBox(tr, true); |
|
165 | this.checkSelectionBox(tr, true); | |
166 | this.clearDocumentSelection(); |
|
166 | this.clearDocumentSelection(); | |
167 | }, |
|
167 | }, | |
168 |
|
168 | |||
169 | toggleSelection: function(tr) { |
|
169 | toggleSelection: function(tr) { | |
170 | if (this.isSelected(tr)) { |
|
170 | if (this.isSelected(tr)) { | |
171 | this.removeSelection(tr); |
|
171 | this.removeSelection(tr); | |
@@ -173,28 +173,28 ContextMenu.prototype = { | |||||
173 | this.addSelection(tr); |
|
173 | this.addSelection(tr); | |
174 | } |
|
174 | } | |
175 | }, |
|
175 | }, | |
176 |
|
176 | |||
177 | removeSelection: function(tr) { |
|
177 | removeSelection: function(tr) { | |
178 | tr.removeClassName('context-menu-selection'); |
|
178 | tr.removeClassName('context-menu-selection'); | |
179 | this.checkSelectionBox(tr, false); |
|
179 | this.checkSelectionBox(tr, false); | |
180 | }, |
|
180 | }, | |
181 |
|
181 | |||
182 | unselectAll: function() { |
|
182 | unselectAll: function() { | |
183 | var rows = $$('.hascontextmenu'); |
|
183 | var rows = $$('.hascontextmenu'); | |
184 | for (i=0; i<rows.length; i++) { |
|
184 | for (i=0; i<rows.length; i++) { | |
185 | this.removeSelection(rows[i]); |
|
185 | this.removeSelection(rows[i]); | |
186 | } |
|
186 | } | |
187 | }, |
|
187 | }, | |
188 |
|
188 | |||
189 | checkSelectionBox: function(tr, checked) { |
|
189 | checkSelectionBox: function(tr, checked) { | |
190 | var inputs = Element.getElementsBySelector(tr, 'input'); |
|
190 | var inputs = Element.getElementsBySelector(tr, 'input'); | |
191 | if (inputs.length > 0) { inputs[0].checked = checked; } |
|
191 | if (inputs.length > 0) { inputs[0].checked = checked; } | |
192 | }, |
|
192 | }, | |
193 |
|
193 | |||
194 | isSelected: function(tr) { |
|
194 | isSelected: function(tr) { | |
195 | return Element.hasClassName(tr, 'context-menu-selection'); |
|
195 | return Element.hasClassName(tr, 'context-menu-selection'); | |
196 | }, |
|
196 | }, | |
197 |
|
197 | |||
198 | clearDocumentSelection: function() { |
|
198 | clearDocumentSelection: function() { | |
199 | if (document.selection) { |
|
199 | if (document.selection) { | |
200 | document.selection.clear(); // IE |
|
200 | document.selection.clear(); // IE |
General Comments 0
You need to be logged in to leave comments.
Login now