replace tabs to spaces and fix indents public/javascripts/context_menu.js
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8889 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
a6bad4a47d
commit
fc7b71b334
|
@ -5,42 +5,42 @@ var observingContextMenuClick;
|
||||||
|
|
||||||
ContextMenu = Class.create();
|
ContextMenu = Class.create();
|
||||||
ContextMenu.prototype = {
|
ContextMenu.prototype = {
|
||||||
initialize: function (url) {
|
initialize: function (url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.createMenu();
|
this.createMenu();
|
||||||
|
|
||||||
if (!observingContextMenuClick) {
|
if (!observingContextMenuClick) {
|
||||||
Event.observe(document, 'click', this.Click.bindAsEventListener(this));
|
Event.observe(document, 'click', this.Click.bindAsEventListener(this));
|
||||||
Event.observe(document, 'contextmenu', this.RightClick.bindAsEventListener(this));
|
Event.observe(document, 'contextmenu', this.RightClick.bindAsEventListener(this));
|
||||||
observingContextMenuClick = true;
|
observingContextMenuClick = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.unselectAll();
|
this.unselectAll();
|
||||||
this.lastSelected = null;
|
this.lastSelected = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
RightClick: function(e) {
|
RightClick: function(e) {
|
||||||
this.hideMenu();
|
this.hideMenu();
|
||||||
// do not show the context menu on links
|
// do not show the context menu on links
|
||||||
if (Event.element(e).tagName == 'A') { return; }
|
if (Event.element(e).tagName == 'A') { return; }
|
||||||
var tr = Event.findElement(e, 'tr');
|
var tr = Event.findElement(e, 'tr');
|
||||||
if (tr == document || tr == undefined || !tr.hasClassName('hascontextmenu')) { return; }
|
if (tr == document || tr == undefined || !tr.hasClassName('hascontextmenu')) { return; }
|
||||||
Event.stop(e);
|
Event.stop(e);
|
||||||
if (!this.isSelected(tr)) {
|
if (!this.isSelected(tr)) {
|
||||||
this.unselectAll();
|
this.unselectAll();
|
||||||
this.addSelection(tr);
|
this.addSelection(tr);
|
||||||
this.lastSelected = tr;
|
this.lastSelected = tr;
|
||||||
}
|
}
|
||||||
this.showMenu(e);
|
this.showMenu(e);
|
||||||
},
|
},
|
||||||
|
|
||||||
Click: function(e) {
|
Click: function(e) {
|
||||||
if (Event.element(e).tagName == 'A' && Event.element(e).hasClassName('submenu')) {
|
if (Event.element(e).tagName == 'A' && Event.element(e).hasClassName('submenu')) {
|
||||||
Event.stop(e)
|
Event.stop(e)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.hideMenu();
|
this.hideMenu();
|
||||||
if (Event.element(e).tagName == 'A' || Event.element(e).tagName == 'IMG') { return; }
|
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');
|
var tr = Event.findElement(e, 'tr');
|
||||||
if (tr!=null && tr!=document && tr.hasClassName('hascontextmenu')) {
|
if (tr!=null && tr!=document && tr.hasClassName('hascontextmenu')) {
|
||||||
|
@ -123,33 +123,33 @@ ContextMenu.prototype = {
|
||||||
evalScripts:true,
|
evalScripts:true,
|
||||||
parameters:Form.serialize(Event.findElement(e, 'form')),
|
parameters:Form.serialize(Event.findElement(e, 'form')),
|
||||||
onComplete:function(request){
|
onComplete:function(request){
|
||||||
dims = $('context-menu').getDimensions();
|
dims = $('context-menu').getDimensions();
|
||||||
menu_width = dims.width;
|
menu_width = dims.width;
|
||||||
menu_height = dims.height;
|
menu_height = dims.height;
|
||||||
max_width = mouse_x + 2*menu_width;
|
max_width = mouse_x + 2*menu_width;
|
||||||
max_height = mouse_y + menu_height;
|
max_height = mouse_y + menu_height;
|
||||||
|
|
||||||
var ws = window_size();
|
var ws = window_size();
|
||||||
window_width = ws.width;
|
window_width = ws.width;
|
||||||
window_height = ws.height;
|
window_height = ws.height;
|
||||||
|
|
||||||
/* display the menu above and/or to the left of the click if needed */
|
/* display the menu above and/or to the left of the click if needed */
|
||||||
if (max_width > window_width) {
|
if (max_width > window_width) {
|
||||||
render_x -= menu_width;
|
render_x -= menu_width;
|
||||||
$('context-menu').addClassName('reverse-x');
|
$('context-menu').addClassName('reverse-x');
|
||||||
} else {
|
} else {
|
||||||
$('context-menu').removeClassName('reverse-x');
|
$('context-menu').removeClassName('reverse-x');
|
||||||
}
|
}
|
||||||
if (max_height > window_height) {
|
if (max_height > window_height) {
|
||||||
render_y -= menu_height;
|
render_y -= menu_height;
|
||||||
$('context-menu').addClassName('reverse-y');
|
$('context-menu').addClassName('reverse-y');
|
||||||
} else {
|
} else {
|
||||||
$('context-menu').removeClassName('reverse-y');
|
$('context-menu').removeClassName('reverse-y');
|
||||||
}
|
}
|
||||||
if (render_x <= 0) render_x = 1;
|
if (render_x <= 0) render_x = 1;
|
||||||
if (render_y <= 0) render_y = 1;
|
if (render_y <= 0) render_y = 1;
|
||||||
$('context-menu').style['left'] = (render_x + 'px');
|
$('context-menu').style['left'] = (render_x + 'px');
|
||||||
$('context-menu').style['top'] = (render_y + 'px');
|
$('context-menu').style['top'] = (render_y + 'px');
|
||||||
|
|
||||||
Effect.Appear('context-menu', {duration: 0.20});
|
Effect.Appear('context-menu', {duration: 0.20});
|
||||||
if (window.parseStylesheets) { window.parseStylesheets(); } // IE
|
if (window.parseStylesheets) { window.parseStylesheets(); } // IE
|
||||||
|
@ -187,8 +187,8 @@ ContextMenu.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
checkSelectionBox: function(tr, checked) {
|
checkSelectionBox: function(tr, checked) {
|
||||||
var inputs = Element.getElementsBySelector(tr, 'input');
|
var inputs = Element.getElementsBySelector(tr, 'input');
|
||||||
if (inputs.length > 0) { inputs[0].checked = checked; }
|
if (inputs.length > 0) { inputs[0].checked = checked; }
|
||||||
},
|
},
|
||||||
|
|
||||||
isSelected: function(tr) {
|
isSelected: function(tr) {
|
||||||
|
@ -205,32 +205,32 @@ ContextMenu.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleIssuesSelection(el) {
|
function toggleIssuesSelection(el) {
|
||||||
var boxes = el.getElementsBySelector('input[type=checkbox]');
|
var boxes = el.getElementsBySelector('input[type=checkbox]');
|
||||||
var all_checked = true;
|
var all_checked = true;
|
||||||
for (i = 0; i < boxes.length; i++) { if (boxes[i].checked == false) { all_checked = false; } }
|
for (i = 0; i < boxes.length; i++) { if (boxes[i].checked == false) { all_checked = false; } }
|
||||||
for (i = 0; i < boxes.length; i++) {
|
for (i = 0; i < boxes.length; i++) {
|
||||||
if (all_checked) {
|
if (all_checked) {
|
||||||
boxes[i].checked = false;
|
boxes[i].checked = false;
|
||||||
boxes[i].up('tr').removeClassName('context-menu-selection');
|
boxes[i].up('tr').removeClassName('context-menu-selection');
|
||||||
} else if (boxes[i].checked == false) {
|
} else if (boxes[i].checked == false) {
|
||||||
boxes[i].checked = true;
|
boxes[i].checked = true;
|
||||||
boxes[i].up('tr').addClassName('context-menu-selection');
|
boxes[i].up('tr').addClassName('context-menu-selection');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function window_size() {
|
function window_size() {
|
||||||
var w;
|
var w;
|
||||||
var h;
|
var h;
|
||||||
if (window.innerWidth) {
|
if (window.innerWidth) {
|
||||||
w = window.innerWidth;
|
w = window.innerWidth;
|
||||||
h = window.innerHeight;
|
h = window.innerHeight;
|
||||||
} else if (document.documentElement) {
|
} else if (document.documentElement) {
|
||||||
w = document.documentElement.clientWidth;
|
w = document.documentElement.clientWidth;
|
||||||
h = document.documentElement.clientHeight;
|
h = document.documentElement.clientHeight;
|
||||||
} else {
|
} else {
|
||||||
w = document.body.clientWidth;
|
w = document.body.clientWidth;
|
||||||
h = document.body.clientHeight;
|
h = document.body.clientHeight;
|
||||||
}
|
}
|
||||||
return {width: w, height: h};
|
return {width: w, height: h};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue