From 8df3db566a3a937b45ebf11adb90d265e6f5e2d4 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 17 Nov 2019 20:45:02 +0100 Subject: initial checking of customized version 1.0rc9 --- js/index.js | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 js/index.js (limited to 'js/index.js') diff --git a/js/index.js b/js/index.js new file mode 100644 index 0000000..ae0586b --- /dev/null +++ b/js/index.js @@ -0,0 +1,91 @@ +Event.observe(window,'load',tasklistInit); +Event.observe(window,'load',searchInit); + +function tasklistInit() { + Caret.init(); +} +function searchInit() { + if (navigator.appVersion.match(/\bMSIE 6\.0\b/) && $('searchthisproject') && $('reset')) { + Event.observe('searchthisproject','click',function() {$('reset').remove();}); + } +} +var Caret = { + init: function () { + var task = sessionStorage.getItem('current_task') || 'top'; + if (task == 'bottom' || task == 'top') { + var tab = $('tasklist_table'); + var rows = tab ? tab.getElementsByTagName('tbody')[0].getElementsByTagName('tr') : []; + Caret.currentRow = (task == 'top' || rows.length == 0) ? rows[0] : rows[rows.length-1]; + } + else { + Caret.currentRow = $('task'+task); + } + if (Caret.currentRow) { + Element.addClassName(Caret.currentRow,'current_row'); + Event.observe(document,'keydown',Caret.keypress); + } + }, + keypress: function (e) { + var src = Event.element(e); + if (/input|select|textarea/.test(src.nodeName.toLowerCase())) { + // don't do anything if key is pressed in input, select or textarea + return; + } + if ((useAltForKeyboardNavigation && !e.altKey) || + (!useAltForKeyboardNavigation && e.altKey) || + e.ctrlKey || e.shiftKey) { + return; + } + switch (e.keyCode) { + case 74: // user pressed "j" move down + Element.removeClassName(Caret.currentRow,'current_row'); + Caret.nextRow(); + Element.addClassName(Caret.currentRow,'current_row'); + Event.stop(e); + break; + case 75: // user pressed "k" move up + Element.removeClassName(Caret.currentRow,'current_row'); + Caret.previousRow(); + Element.addClassName(Caret.currentRow,'current_row'); + Event.stop(e); + break; + case 79: // user pressed "o" open task + window.location = Caret.currentRow.getElementsByTagName('a')[0].href; // FIXME ambiguous in future: if first a is not a link to the task, e.g. a column with link to task opener + Event.stop(e); + break; + } + }, + nextRow: function () { + var row = Caret.currentRow; + while ((row = row.nextSibling)) { + if ('tr' == row.nodeName.toLowerCase()) { + Caret.currentRow = row; + return; + } + } + // we've reached the bottom of the list + if ($('next')) { + //Cookie.setVar('current_task','top'); // doesn't work well on multitab multiproject usage + sessionStorage.setItem('current_task','top'); + window.location = $('next').href; + return; + } + }, + previousRow: function () { + var row = Caret.currentRow; + while ((row = row.previousSibling)) { + if ('tr' == row.nodeName.toLowerCase()) { + Caret.currentRow = row; + return; + } + } + // we've reached the top of the list + if ($('previous')) { + //Cookie.setVar('current_task','bottom'); // doesn't work well on multitab multiproject usage + sessionStorage.setItem('current_task','bottom'); + window.location = $('previous').href; + return; + } + + } +}; -- cgit v1.2.3-54-g00ecf