@@ -5,42 +5,42 var observingContextMenuClick; | |||
|
5 | 5 | |
|
6 | 6 | ContextMenu = Class.create(); |
|
7 | 7 | ContextMenu.prototype = { |
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
8 | initialize: function (url) { | |
|
9 | this.url = url; | |
|
10 | this.createMenu(); | |
|
11 | 11 | |
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 | } | |
|
17 | ||
|
18 |
|
|
|
19 |
|
|
|
20 | }, | |
|
12 | if (!observingContextMenuClick) { | |
|
13 | Event.observe(document, 'click', this.Click.bindAsEventListener(this)); | |
|
14 | Event.observe(document, 'contextmenu', this.RightClick.bindAsEventListener(this)); | |
|
15 | observingContextMenuClick = true; | |
|
16 | } | |
|
17 | ||
|
18 | this.unselectAll(); | |
|
19 | this.lastSelected = null; | |
|
20 | }, | |
|
21 | 21 | |
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 | } | |
|
34 |
|
|
|
35 | }, | |
|
22 | RightClick: function(e) { | |
|
23 | this.hideMenu(); | |
|
24 | // do not show the context menu on links | |
|
25 | if (Event.element(e).tagName == 'A') { return; } | |
|
26 | var tr = Event.findElement(e, 'tr'); | |
|
27 | if (tr == document || tr == undefined || !tr.hasClassName('hascontextmenu')) { return; } | |
|
28 | Event.stop(e); | |
|
29 | if (!this.isSelected(tr)) { | |
|
30 | this.unselectAll(); | |
|
31 | this.addSelection(tr); | |
|
32 | this.lastSelected = tr; | |
|
33 | } | |
|
34 | this.showMenu(e); | |
|
35 | }, | |
|
36 | 36 | |
|
37 | 37 | Click: function(e) { |
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 | } | |
|
42 |
|
|
|
43 |
|
|
|
38 | if (Event.element(e).tagName == 'A' && Event.element(e).hasClassName('submenu')) { | |
|
39 | Event.stop(e) | |
|
40 | return; | |
|
41 | } | |
|
42 | this.hideMenu(); | |
|
43 | if (Event.element(e).tagName == 'A' || Event.element(e).tagName == 'IMG') { return; } | |
|
44 | 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')) { |
@@ -114,7 +114,7 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 | 120 | new Ajax.Updater({success:'context-menu'}, this.url, |
@@ -123,34 +123,34 ContextMenu.prototype = { | |||
|
123 | 123 | evalScripts:true, |
|
124 | 124 | parameters:Form.serialize(Event.findElement(e, 'form')), |
|
125 | 125 | onComplete:function(request){ |
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
|
131 | ||
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 | ||
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 | } | |
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|
148 | } | |
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
|
153 | ||
|
126 | dims = $('context-menu').getDimensions(); | |
|
127 | menu_width = dims.width; | |
|
128 | menu_height = dims.height; | |
|
129 | max_width = mouse_x + 2*menu_width; | |
|
130 | max_height = mouse_y + menu_height; | |
|
131 | ||
|
132 | var ws = window_size(); | |
|
133 | window_width = ws.width; | |
|
134 | window_height = ws.height; | |
|
135 | ||
|
136 | /* display the menu above and/or to the left of the click if needed */ | |
|
137 | if (max_width > window_width) { | |
|
138 | render_x -= menu_width; | |
|
139 | $('context-menu').addClassName('reverse-x'); | |
|
140 | } else { | |
|
141 | $('context-menu').removeClassName('reverse-x'); | |
|
142 | } | |
|
143 | if (max_height > window_height) { | |
|
144 | render_y -= menu_height; | |
|
145 | $('context-menu').addClassName('reverse-y'); | |
|
146 | } else { | |
|
147 | $('context-menu').removeClassName('reverse-y'); | |
|
148 | } | |
|
149 | if (render_x <= 0) render_x = 1; | |
|
150 | if (render_y <= 0) render_y = 1; | |
|
151 | $('context-menu').style['left'] = (render_x + 'px'); | |
|
152 | $('context-menu').style['top'] = (render_y + 'px'); | |
|
153 | ||
|
154 | 154 | Effect.Appear('context-menu', {duration: 0.20}); |
|
155 | 155 | if (window.parseStylesheets) { window.parseStylesheets(); } // IE |
|
156 | 156 | }}) |
@@ -187,8 +187,8 ContextMenu.prototype = { | |||
|
187 | 187 | }, |
|
188 | 188 | |
|
189 | 189 | checkSelectionBox: function(tr, checked) { |
|
190 |
|
|
|
191 |
|
|
|
190 | var inputs = Element.getElementsBySelector(tr, 'input'); | |
|
191 | if (inputs.length > 0) { inputs[0].checked = checked; } | |
|
192 | 192 | }, |
|
193 | 193 | |
|
194 | 194 | isSelected: function(tr) { |
@@ -205,32 +205,32 ContextMenu.prototype = { | |||
|
205 | 205 | } |
|
206 | 206 | |
|
207 | 207 | function toggleIssuesSelection(el) { |
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 | } | |
|
219 | } | |
|
208 | var boxes = el.getElementsBySelector('input[type=checkbox]'); | |
|
209 | var all_checked = true; | |
|
210 | for (i = 0; i < boxes.length; i++) { if (boxes[i].checked == false) { all_checked = false; } } | |
|
211 | for (i = 0; i < boxes.length; i++) { | |
|
212 | if (all_checked) { | |
|
213 | boxes[i].checked = false; | |
|
214 | boxes[i].up('tr').removeClassName('context-menu-selection'); | |
|
215 | } else if (boxes[i].checked == false) { | |
|
216 | boxes[i].checked = true; | |
|
217 | boxes[i].up('tr').addClassName('context-menu-selection'); | |
|
218 | } | |
|
219 | } | |
|
220 | 220 | } |
|
221 | 221 | |
|
222 | 222 | function window_size() { |
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
|
223 | var w; | |
|
224 | var h; | |
|
225 | if (window.innerWidth) { | |
|
226 | w = window.innerWidth; | |
|
227 | h = window.innerHeight; | |
|
228 | } else if (document.documentElement) { | |
|
229 | w = document.documentElement.clientWidth; | |
|
230 | h = document.documentElement.clientHeight; | |
|
231 | } else { | |
|
232 | w = document.body.clientWidth; | |
|
233 | h = document.body.clientHeight; | |
|
234 | } | |
|
235 | return {width: w, height: h}; | |
|
236 | 236 | } |
General Comments 0
You need to be logged in to leave comments.
Login now