##// END OF EJS Templates
remove trailing white space from test/fixtures/workflows.yml...
remove trailing white space from test/fixtures/workflows.yml git-svn-id: http://svn.redmine.org/redmine/trunk@16339 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r15554:18073c971e69
r15957:7816a4025a03 master
Show More
context_menu.js
249 lines | 6.9 KiB | application/javascript | JavascriptLexer
Jean-Philippe Lang
[js-cleanup] add short copyright notices to javascripts and remove superfluous newline (#20240)....
r14029 /* Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 Copyright (C) 2006-2016 Jean-Philippe Lang */
Jean-Philippe Lang
[js-cleanup] add short copyright notices to javascripts and remove superfluous newline (#20240)....
r14029
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 var contextMenuObserving;
function contextMenuRightClick(event) {
var target = $(event.target);
if (target.is('a')) {return;}
var tr = target.parents('tr').first();
if (!tr.hasClass('hascontextmenu')) {return;}
event.preventDefault();
if (!contextMenuIsSelected(tr)) {
contextMenuUnselectAll();
contextMenuAddSelection(tr);
contextMenuSetLastSelected(tr);
Toshi MARUYAMA
replace tabs to spaces and fix indents public/javascripts/context_menu.js...
r8769 }
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 contextMenuShow(event);
}
Toshi MARUYAMA
remove trailing white-spaces from public/javascripts/context_menu.js...
r8770
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 function contextMenuClick(event) {
var target = $(event.target);
var lastSelected;
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 if (target.is('a') && target.hasClass('submenu')) {
event.preventDefault();
return;
}
contextMenuHide();
if (target.is('a') || target.is('img')) { return; }
Jean-Philippe Lang
Fixed context menu for IE 7/8 (#12298)....
r10609 if (event.which == 1 || (navigator.appVersion.match(/\bMSIE\b/))) {
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 var tr = target.parents('tr').first();
if (tr.length && tr.hasClass('hascontextmenu')) {
// a row was clicked, check if the click was on checkbox
if (target.is('input')) {
// a checkbox may be clicked
Toshi MARUYAMA
Backport r13313 from rails-4.1 to trunk....
r13045 if (target.prop('checked')) {
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 tr.addClass('context-menu-selection');
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116 } else {
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 tr.removeClass('context-menu-selection');
}
} else {
if (event.ctrlKey || event.metaKey) {
contextMenuToggleSelection(tr);
} else if (event.shiftKey) {
lastSelected = contextMenuLastSelected();
if (lastSelected.length) {
var toggling = false;
$('.hascontextmenu').each(function(){
if (toggling || $(this).is(tr)) {
contextMenuAddSelection($(this));
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116 }
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 if ($(this).is(tr) || $(this).is(lastSelected)) {
toggling = !toggling;
}
});
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116 } else {
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 contextMenuAddSelection(tr);
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116 }
Jean-Philippe Lang
Unselect issues when clicking outside of the list....
r3430 } else {
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 contextMenuUnselectAll();
contextMenuAddSelection(tr);
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116 }
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 contextMenuSetLastSelected(tr);
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116 }
} else {
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 // click is outside the rows
if (target.is('a') && (target.hasClass('disabled') || target.hasClass('submenu'))) {
event.preventDefault();
Jean-Philippe Lang
Allow addition of watchers via bulk edit context menu (#5754)....
r14929 } else if (target.is('.toggle-selection') || target.is('.ui-dialog *') || $('#ajax-modal').is(':visible')) {
Jean-Philippe Lang
Replaces the link with a checkbox to select/unselect all items in the list....
r14347 // nop
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 } else {
contextMenuUnselectAll();
}
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116 }
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 }
}
Toshi MARUYAMA
remove trailing white-spaces from public/javascripts/context_menu.js...
r8770
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 function contextMenuCreate() {
if ($('#context-menu').length < 1) {
var menu = document.createElement("div");
menu.setAttribute("id", "context-menu");
menu.setAttribute("style", "display:none;");
document.getElementById("content").appendChild(menu);
}
}
function contextMenuShow(event) {
var mouse_x = event.pageX;
Jean-Philippe Lang
Issue percentage selector extends screen border (#22059)....
r14967 var mouse_y = event.pageY;
var mouse_y_c = event.clientY;
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 var render_x = mouse_x;
var render_y = mouse_y;
var dims;
var menu_width;
var menu_height;
var window_width;
var window_height;
var max_width;
var max_height;
Jean-Philippe Lang
Don't use a global variable for storing context menu URL....
r15554 var url;
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885
$('#context-menu').css('left', (render_x + 'px'));
$('#context-menu').css('top', (render_y + 'px'));
$('#context-menu').html('');
Jean-Philippe Lang
Don't use a global variable for storing context menu URL....
r15554 url = $(event.target).parents('form').first().data('cm-url');
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 $.ajax({
Jean-Philippe Lang
Don't use a global variable for storing context menu URL....
r15554 url: url,
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 data: $(event.target).parents('form').first().serialize(),
success: function(data, textStatus, jqXHR) {
$('#context-menu').html(data);
menu_width = $('#context-menu').width();
menu_height = $('#context-menu').height();
max_width = mouse_x + 2*menu_width;
Jean-Philippe Lang
Issue percentage selector extends screen border (#22059)....
r14967 max_height = mouse_y_c + menu_height;
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885
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').addClass('reverse-x');
} else {
$('#context-menu').removeClass('reverse-x');
}
Jean-Philippe Lang
Issue percentage selector extends screen border (#22059)....
r14967
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 if (max_height > window_height) {
render_y -= menu_height;
$('#context-menu').addClass('reverse-y');
Jean-Philippe Lang
Issue percentage selector extends screen border (#22059)....
r14967 // adding class for submenu
if (mouse_y_c < 325) {
$('#context-menu .folder').addClass('down');
}
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 } else {
Jean-Philippe Lang
Issue percentage selector extends screen border (#22059)....
r14967 // adding class for submenu
if (window_height - mouse_y_c < 345) {
$('#context-menu .folder').addClass('up');
}
$('#context-menu').removeClass('reverse-y');
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 }
Jean-Philippe Lang
Issue percentage selector extends screen border (#22059)....
r14967
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 if (render_x <= 0) render_x = 1;
if (render_y <= 0) render_y = 1;
$('#context-menu').css('left', (render_x + 'px'));
$('#context-menu').css('top', (render_y + 'px'));
$('#context-menu').show();
//if (window.parseStylesheets) { window.parseStylesheets(); } // IE
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116 }
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 });
}
Toshi MARUYAMA
remove trailing white-spaces from public/javascripts/context_menu.js...
r8770
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 function contextMenuSetLastSelected(tr) {
$('.cm-last').removeClass('cm-last');
tr.addClass('cm-last');
}
Toshi MARUYAMA
remove trailing white-spaces from public/javascripts/context_menu.js...
r8770
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 function contextMenuLastSelected() {
return $('.cm-last').first();
}
Toshi MARUYAMA
remove trailing white-spaces from public/javascripts/context_menu.js...
r8770
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 function contextMenuUnselectAll() {
Jean-Philippe Lang
Replaces the link with a checkbox to select/unselect all items in the list....
r14347 $('input[type=checkbox].toggle-selection').prop('checked', false);
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 $('.hascontextmenu').each(function(){
contextMenuRemoveSelection($(this));
});
$('.cm-last').removeClass('cm-last');
}
function contextMenuHide() {
$('#context-menu').hide();
}
function contextMenuToggleSelection(tr) {
if (contextMenuIsSelected(tr)) {
contextMenuRemoveSelection(tr);
} else {
contextMenuAddSelection(tr);
}
}
function contextMenuAddSelection(tr) {
tr.addClass('context-menu-selection');
contextMenuCheckSelectionBox(tr, true);
contextMenuClearDocumentSelection();
}
function contextMenuRemoveSelection(tr) {
tr.removeClass('context-menu-selection');
contextMenuCheckSelectionBox(tr, false);
}
function contextMenuIsSelected(tr) {
return tr.hasClass('context-menu-selection');
}
function contextMenuCheckSelectionBox(tr, checked) {
Toshi MARUYAMA
Backport r13313 from rails-4.1 to trunk....
r13045 tr.find('input[type=checkbox]').prop('checked', checked);
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 }
function contextMenuClearDocumentSelection() {
// TODO
if (document.selection) {
Jean-Philippe Lang
Fixed: Lost text after selection in issue list with IE (#12650)....
r11520 document.selection.empty(); // IE
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 } else {
window.getSelection().removeAllRanges();
}
}
Jean-Philippe Lang
Don't use a global variable for storing context menu URL....
r15554 function contextMenuInit() {
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 contextMenuCreate();
contextMenuUnselectAll();
if (!contextMenuObserving) {
$(document).click(contextMenuClick);
$(document).contextmenu(contextMenuRightClick);
contextMenuObserving = true;
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116 }
}
Jean-Philippe Lang
Added AJAX based context menu on the project issue list that provide shortcuts for editing, re-assigning, changing the status or the priority, moving or deleting an issue....
r859
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116 function toggleIssuesSelection(el) {
Jean-Philippe Lang
Replaces the link with a checkbox to select/unselect all items in the list....
r14347 var checked = $(this).prop('checked');
var boxes = $(this).parents('table').find('input[name=ids\\[\\]]');
boxes.prop('checked', checked).parents('tr').toggleClass('context-menu-selection', checked);
Jean-Philippe Lang
Added AJAX based context menu on the project issue list that provide shortcuts for editing, re-assigning, changing the status or the priority, moving or deleting an issue....
r859 }
Jean-Philippe Lang
Display the context menu above and/or to the left of the click if needed (patch by Mike Duchene, closes #960)....
r1308
function window_size() {
Toshi MARUYAMA
replace tabs to spaces and fix indents public/javascripts/context_menu.js...
r8769 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};
Jean-Philippe Lang
Display the context menu above and/or to the left of the click if needed (patch by Mike Duchene, closes #960)....
r1308 }
Jean-Philippe Lang
Replaces the link with a checkbox to select/unselect all items in the list....
r14347
$(document).ready(function(){
Jean-Philippe Lang
Don't use a global variable for storing context menu URL....
r15554 contextMenuInit();
Jean-Philippe Lang
Replaces the link with a checkbox to select/unselect all items in the list....
r14347 $('input[type=checkbox].toggle-selection').on('change', toggleIssuesSelection);
});