-/* redMine - project management software
- Copyright (C) 2006-2008 Jean-Philippe Lang */
+/* Redmine - project management software
+ Copyright (C) 2006-2012 Jean-Philippe Lang */
var observingContextMenuClick;
Event.observe(document, 'contextmenu', this.RightClick.bindAsEventListener(this));
observingContextMenuClick = true;
}
-
+
this.unselectAll();
this.lastSelected = null;
},
-
+
RightClick: function(e) {
this.hideMenu();
// do not show the context menu on links
}
this.hideMenu();
if (Event.element(e).tagName == 'A' || Event.element(e).tagName == 'IMG') { return; }
- if (Event.isLeftClick(e) || (navigator.appVersion.match(/\bMSIE\b/))) {
+ if (Event.isLeftClick(e) || (navigator.appVersion.match(/\bMSIE\b/))) {
var tr = Event.findElement(e, 'tr');
if (tr!=null && tr!=document && tr.hasClassName('hascontextmenu')) {
// a row was clicked, check if the click was on checkbox
}
}
},
-
+
createMenu: function() {
if (!$('context-menu')) {
var menu = document.createElement("div");
document.getElementById("content").appendChild(menu);
}
},
-
+
showMenu: function(e) {
var mouse_x = Event.pointerX(e);
var mouse_y = Event.pointerY(e);
var max_height;
$('context-menu').style['left'] = (render_x + 'px');
- $('context-menu').style['top'] = (render_y + 'px');
+ $('context-menu').style['top'] = (render_y + 'px');
Element.update('context-menu', '');
- new Ajax.Updater({success:'context-menu'}, this.url,
+ new Ajax.Updater({success:'context-menu'}, this.url,
{asynchronous:true,
method: 'get',
evalScripts:true,
menu_height = dims.height;
max_width = mouse_x + 2*menu_width;
max_height = mouse_y + menu_height;
-
+
var ws = window_size();
window_width = ws.width;
window_height = ws.height;
-
+
/* display the menu above and/or to the left of the click if needed */
if (max_width > window_width) {
render_x -= menu_width;
if (render_y <= 0) render_y = 1;
$('context-menu').style['left'] = (render_x + 'px');
$('context-menu').style['top'] = (render_y + 'px');
-
+
Effect.Appear('context-menu', {duration: 0.20});
if (window.parseStylesheets) { window.parseStylesheets(); } // IE
}})
},
-
+
hideMenu: function() {
Element.hide('context-menu');
},
-
+
addSelection: function(tr) {
tr.addClassName('context-menu-selection');
this.checkSelectionBox(tr, true);
this.clearDocumentSelection();
},
-
+
toggleSelection: function(tr) {
if (this.isSelected(tr)) {
this.removeSelection(tr);
this.addSelection(tr);
}
},
-
+
removeSelection: function(tr) {
tr.removeClassName('context-menu-selection');
this.checkSelectionBox(tr, false);
},
-
+
unselectAll: function() {
var rows = $$('.hascontextmenu');
for (i=0; i<rows.length; i++) {
this.removeSelection(rows[i]);
}
},
-
+
checkSelectionBox: function(tr, checked) {
var inputs = Element.getElementsBySelector(tr, 'input');
if (inputs.length > 0) { inputs[0].checked = checked; }
},
-
+
isSelected: function(tr) {
return Element.hasClassName(tr, 'context-menu-selection');
},
-
+
clearDocumentSelection: function() {
if (document.selection) {
document.selection.clear(); // IE