| | |
| | | // 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') |
| | | .html('Select List') |
| | | .attr('style', 'display:block; width:1px; height:1px; line-height:1px; overflow:hidden; position:fixed; top:-1000px') |
| | | .html($(this.list).attr('summary') || 'Select List') |
| | | .insertAfter(this.list) |
| | | .on('focus', function(e){ me.focus(e); }) |
| | | .on('blur', function(e){ me.blur(e); }); |
| | |
| | | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | if (!this.fixed_header) { |
| | | this.fixed_header = $('<table>') |
| | | .attr('class', this.list.className + ' fixedcopy') |
| | | .attr('role', 'presentation') |
| | | .css({ position:'fixed' }) |
| | | .append(clone) |
| | | .append('<tbody></tbody>'); |
| | |
| | | if (this.focused) |
| | | return; |
| | | |
| | | var n, id; |
| | | this.focused = true; |
| | | |
| | | for (n in this.selection) { |
| | | id = this.selection[n]; |
| | | if (this.rows[id] && this.rows[id].obj) { |
| | | $(this.rows[id].obj).addClass('selected').removeClass('unfocused'); |
| | | } |
| | | } |
| | | |
| | | if (e) |
| | | rcube_event.cancel(e); |
| | | |
| | | // Un-focus already focused elements (#1487123, #1487316, #1488600, #1488620) |
| | | // It looks that window.focus() does the job for all browsers, but not Firefox (#1489058) |
| | | // We now fix this by explicitly assigning focus to a dedicated link element |
| | | this.focus_elem.focus(); |
| | | if (this.focus_elem) { |
| | | // We now fix this by explicitly assigning focus to a dedicated link element |
| | | this.focus_noscroll(this.focus_elem); |
| | | } |
| | | else { |
| | | // It looks that window.focus() does the job for all browsers, but not Firefox (#1489058) |
| | | $('iframe,:focus:not(body)').blur(); |
| | | window.focus(); |
| | | } |
| | | |
| | | $(this.list).addClass('focus'); |
| | | |
| | |
| | | */ |
| | | blur: function(e) |
| | | { |
| | | var n, id; |
| | | this.focused = false; |
| | | for (n in this.selection) { |
| | | id = this.selection[n]; |
| | | if (this.rows[id] && this.rows[id].obj) { |
| | | $(this.rows[id].obj).removeClass('selected focused').addClass('unfocused'); |
| | | } |
| | | } |
| | | |
| | | $(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; |
| | | }, |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | this.rows[id].clicked = now; |
| | | this.focus(); |
| | | |
| | | return false; |
| | | }, |
| | | |
| | |
| | | this.highlight_row(n, true, true); |
| | | } |
| | | else { |
| | | $(this.rows[n].obj).removeClass('selected').removeClass('unfocused'); |
| | | $(this.rows[n].obj).removeClass('selected').removeAttr('aria-selected'); |
| | | } |
| | | } |
| | | |
| | |
| | | else { |
| | | for (n in this.selection) |
| | | if (this.rows[this.selection[n]]) { |
| | | $(this.rows[this.selection[n]].obj).removeClass('selected').removeClass('unfocused'); |
| | | $(this.rows[this.selection[n]].obj).removeClass('selected').removeAttr('aria-selected'); |
| | | } |
| | | |
| | | this.selection = []; |
| | |
| | | if (this.selection.length > 1 || !this.in_selection(id)) { |
| | | this.clear_selection(null, true); |
| | | this.selection[0] = id; |
| | | $(this.rows[id].obj).addClass('selected'); |
| | | $(this.rows[id].obj).addClass('selected').attr('aria-selected', 'true'); |
| | | } |
| | | } |
| | | else { |
| | | if (!this.in_selection(id)) { // select row |
| | | this.selection.push(id); |
| | | $(this.rows[id].obj).addClass('selected'); |
| | | $(this.rows[id].obj).addClass('selected').attr('aria-selected', 'true'); |
| | | if (!norecur && !this.rows[id].expanded) |
| | | this.highlight_children(id, true); |
| | | } |
| | |
| | | a_post = this.selection.slice(p+1, this.selection.length); |
| | | |
| | | this.selection = a_pre.concat(a_post); |
| | | $(this.rows[id].obj).removeClass('selected').removeClass('unfocused'); |
| | | $(this.rows[id].obj).removeClass('selected').removeAttr('aria-selected'); |
| | | if (!norecur && !this.rows[id].expanded) |
| | | this.highlight_children(id, false); |
| | | } |