aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2013-01-16 17:27:05 +0100
committerJochen Topf <jochen@topf.org>2013-01-16 17:27:05 +0100
commite18f146bf041d565ff9b40dad7f55cf69a9a025d (patch)
tree258b772f67f0389838b19c4a20031a55dae8d6d7
parent8a3beaa29c1e16a4f230a414734de33d402c1c51 (diff)
downloadtaginfo-e18f146bf041d565ff9b40dad7f55cf69a9a025d.tar
taginfo-e18f146bf041d565ff9b40dad7f55cf69a9a025d.tar.gz
Add keyboard navigation in tables
-rw-r--r--web/public/js/taginfo.js61
1 files changed, 58 insertions, 3 deletions
diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js
index f9bcb06..19952af 100644
--- a/web/public/js/taginfo.js
+++ b/web/public/js/taginfo.js
@@ -412,6 +412,12 @@ function create_flexigrid(domid, options) {
return false;
}
});
+ jQuery('div.bDiv:visible').bind('click', function(event) {
+ var row = jQuery(event.target).parents('tr');
+ console.log("click", row);
+ jQuery('div.bDiv:visible tr').removeClass('trOver');
+ jQuery(row).addClass('trOver');
+ });
} else {
// grid does exist, make sure it has the right size
resize_grid(domid);
@@ -440,6 +446,46 @@ function d3_colors() {
/* ============================ */
+function table_up() {
+ var current = jQuery('.trOver:visible');
+ if (current.size() > 0) {
+ var prev = jQuery('div.bDiv:visible tr.trOver').removeClass('trOver').prev();
+ if (prev.size() > 0) {
+ prev.addClass('trOver');
+ } else {
+ jQuery('div.pPrev:visible').click();
+ }
+ } else {
+ jQuery('div.bDiv:visible tr:last').addClass('trOver');
+ }
+}
+
+function table_down() {
+ var current = jQuery('.trOver:visible');
+ if (current.size() > 0) {
+ var next = jQuery('div.bDiv:visible tr.trOver').removeClass('trOver').next();
+ if (next.size() > 0) {
+ next.addClass('trOver');
+ } else {
+ jQuery('div.pNext:visible').click();
+ }
+ } else {
+ jQuery('div.bDiv:visible tr:first').addClass('trOver');
+ }
+}
+
+function table_right() {
+ var current = jQuery('.trOver');
+ if (current.size() > 0) {
+ var link = current.find("a");
+ if (link.size() > 0) {
+ window.location = link.attr('href');
+ }
+ }
+}
+
+/* ============================ */
+
jQuery(document).ready(function() {
jQuery('#javascriptmsg').remove();
@@ -506,9 +552,6 @@ jQuery(document).ready(function() {
case 84: // t
window.location = '/tags';
break;
- case 8: // backspace
- up();
- break;
case 36: // home
jQuery('div.pFirst:visible').click();
break;
@@ -521,6 +564,18 @@ jQuery(document).ready(function() {
case 35: // end
jQuery('div.pLast:visible').click();
break;
+ case 37: // arrow left
+ up();
+ break;
+ case 38: // arrow up
+ table_up();
+ break;
+ case 39: // arrow right
+ table_right();
+ break;
+ case 40: // arrow down
+ table_down();
+ break;
}
}
}