summaryrefslogtreecommitdiff
path: root/program/js/list.js
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-05-09 13:35:15 +0200
committerThomas Bruederli <thomas@roundcube.net>2014-05-09 13:35:15 +0200
commit93cd38af7dc7a361af488478c31e946a0c5ea10c (patch)
tree2db0c926c3559bafe476ec91e4574ff6bfcbbb50 /program/js/list.js
parent6789bf1f4dfd32cd54a0fbe520ff3e1a6f6afb8a (diff)
Avoid scrolling when list gets back focus (on invisible focus element)
Diffstat (limited to 'program/js/list.js')
-rw-r--r--program/js/list.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/program/js/list.js b/program/js/list.js
index 6a0c5b3b6..fa37353e8 100644
--- a/program/js/list.js
+++ b/program/js/list.js
@@ -115,7 +115,7 @@ init: function()
// this helps to maintain the natural tab order when moving focus with keyboard
this.focus_elem = $('<a>')
.attr('tabindex', '0')
- .attr('style', 'display:block; width:1px; height:1px; line-height:1px; overflow:hidden; position:absolute; top:-1000px')
+ .attr('style', 'display:block; width:1px; height:1px; line-height:1px; overflow:hidden; position:fixed; top:-1000px')
.html('Select List')
.insertAfter(this.list)
.on('focus', function(e){ me.focus(e); })
@@ -186,9 +186,9 @@ init_header: function()
if (this.fixed_header) { // copy (modified) fixed header back to the actual table
$(this.list.tHead).replaceWith($(this.fixed_header).find('thead').clone());
- $(this.list.tHead).find('tr td').attr('style', '').find('a.sortcol').attr('tabindex', '-1'); // remove fixed widths
+ $(this.list.tHead).find('tr td').attr('style', '').find('a').attr('tabindex', '-1'); // remove fixed widths
}
- else if (!bw.touch && this.list.className.indexOf('fixedheader') >= 0 && 0) {
+ else if (!bw.touch && this.list.className.indexOf('fixedheader') >= 0) {
this.init_fixed_header();
}
@@ -408,7 +408,7 @@ focus: function(e)
// Un-focus already focused elements (#1487123, #1487316, #1488600, #1488620)
if (this.focus_elem) {
// We now fix this by explicitly assigning focus to a dedicated link element
- this.focus_elem.focus();
+ this.focus_noscroll(this.focus_elem);
}
else {
// It looks that window.focus() does the job for all browsers, but not Firefox (#1489058)
@@ -441,6 +441,16 @@ blur: function(e)
$(this.list).removeClass('focus');
},
+/**
+ * Focus the given element without scrolling the list container
+ */
+focus_noscroll: function(elem)
+{
+ var y = this.frame.scrollTop || this.frame.scrollY;
+ elem.focus();
+ this.frame.scrollTop = y;
+},
+
/**
* Set/unset the given column as hidden