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