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:
Toshi MARUYAMA 2012-02-16 01:35:23 +00:00
parent a6bad4a47d
commit fc7b71b334
1 changed files with 88 additions and 88 deletions

View File

@ -5,42 +5,42 @@ var observingContextMenuClick;
ContextMenu = Class.create();
ContextMenu.prototype = {
initialize: function (url) {
this.url = url;
this.createMenu();
initialize: function (url) {
this.url = url;
this.createMenu();
if (!observingContextMenuClick) {
Event.observe(document, 'click', this.Click.bindAsEventListener(this));
Event.observe(document, 'contextmenu', this.RightClick.bindAsEventListener(this));
observingContextMenuClick = true;
}
if (!observingContextMenuClick) {
Event.observe(document, 'click', this.Click.bindAsEventListener(this));
Event.observe(document, 'contextmenu', this.RightClick.bindAsEventListener(this));
observingContextMenuClick = true;
}
this.unselectAll();
this.lastSelected = null;
},
this.unselectAll();
this.lastSelected = null;
},
RightClick: function(e) {
this.hideMenu();
// do not show the context menu on links
if (Event.element(e).tagName == 'A') { return; }
var tr = Event.findElement(e, 'tr');
if (tr == document || tr == undefined || !tr.hasClassName('hascontextmenu')) { return; }
Event.stop(e);
if (!this.isSelected(tr)) {
this.unselectAll();
this.addSelection(tr);
this.lastSelected = tr;
}
this.showMenu(e);
},
RightClick: function(e) {
this.hideMenu();
// do not show the context menu on links
if (Event.element(e).tagName == 'A') { return; }
var tr = Event.findElement(e, 'tr');
if (tr == document || tr == undefined || !tr.hasClassName('hascontextmenu')) { return; }
Event.stop(e);
if (!this.isSelected(tr)) {
this.unselectAll();
this.addSelection(tr);
this.lastSelected = tr;
}
this.showMenu(e);
},
Click: function(e) {
if (Event.element(e).tagName == 'A' && Event.element(e).hasClassName('submenu')) {
Event.stop(e)
return;
}
this.hideMenu();
if (Event.element(e).tagName == 'A' || Event.element(e).tagName == 'IMG') { return; }
if (Event.element(e).tagName == 'A' && Event.element(e).hasClassName('submenu')) {
Event.stop(e)
return;
}
this.hideMenu();
if (Event.element(e).tagName == 'A' || Event.element(e).tagName == 'IMG') { return; }
if (Event.isLeftClick(e) || (navigator.appVersion.match(/\bMSIE\b/))) {
var tr = Event.findElement(e, 'tr');
if (tr!=null && tr!=document && tr.hasClassName('hascontextmenu')) {
@ -123,33 +123,33 @@ ContextMenu.prototype = {
evalScripts:true,
parameters:Form.serialize(Event.findElement(e, 'form')),
onComplete:function(request){
dims = $('context-menu').getDimensions();
menu_width = dims.width;
menu_height = dims.height;
max_width = mouse_x + 2*menu_width;
max_height = mouse_y + menu_height;
dims = $('context-menu').getDimensions();
menu_width = dims.width;
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;
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;
$('context-menu').addClassName('reverse-x');
} else {
$('context-menu').removeClassName('reverse-x');
}
if (max_height > window_height) {
render_y -= menu_height;
$('context-menu').addClassName('reverse-y');
} else {
$('context-menu').removeClassName('reverse-y');
}
if (render_x <= 0) render_x = 1;
if (render_y <= 0) render_y = 1;
$('context-menu').style['left'] = (render_x + 'px');
$('context-menu').style['top'] = (render_y + 'px');
/* display the menu above and/or to the left of the click if needed */
if (max_width > window_width) {
render_x -= menu_width;
$('context-menu').addClassName('reverse-x');
} else {
$('context-menu').removeClassName('reverse-x');
}
if (max_height > window_height) {
render_y -= menu_height;
$('context-menu').addClassName('reverse-y');
} else {
$('context-menu').removeClassName('reverse-y');
}
if (render_x <= 0) render_x = 1;
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
@ -187,8 +187,8 @@ ContextMenu.prototype = {
},
checkSelectionBox: function(tr, checked) {
var inputs = Element.getElementsBySelector(tr, 'input');
if (inputs.length > 0) { inputs[0].checked = checked; }
var inputs = Element.getElementsBySelector(tr, 'input');
if (inputs.length > 0) { inputs[0].checked = checked; }
},
isSelected: function(tr) {
@ -205,32 +205,32 @@ ContextMenu.prototype = {
}
function toggleIssuesSelection(el) {
var boxes = el.getElementsBySelector('input[type=checkbox]');
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 (all_checked) {
boxes[i].checked = false;
boxes[i].up('tr').removeClassName('context-menu-selection');
} else if (boxes[i].checked == false) {
boxes[i].checked = true;
boxes[i].up('tr').addClassName('context-menu-selection');
}
}
var boxes = el.getElementsBySelector('input[type=checkbox]');
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 (all_checked) {
boxes[i].checked = false;
boxes[i].up('tr').removeClassName('context-menu-selection');
} else if (boxes[i].checked == false) {
boxes[i].checked = true;
boxes[i].up('tr').addClassName('context-menu-selection');
}
}
}
function window_size() {
var w;
var h;
if (window.innerWidth) {
w = window.innerWidth;
h = window.innerHeight;
} else if (document.documentElement) {
w = document.documentElement.clientWidth;
h = document.documentElement.clientHeight;
} else {
w = document.body.clientWidth;
h = document.body.clientHeight;
}
return {width: w, height: h};
var w;
var h;
if (window.innerWidth) {
w = window.innerWidth;
h = window.innerHeight;
} else if (document.documentElement) {
w = document.documentElement.clientWidth;
h = document.documentElement.clientHeight;
} else {
w = document.body.clientWidth;
h = document.body.clientHeight;
}
return {width: w, height: h};
}