From 076d4027377ef2ec2bfd19e1e49fa629433a66b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 16 Oct 2015 03:16:24 +0200 Subject: [PATCH] Fix toolbar and menu of Tab - Make menu workable with mouse - Fix toggle action, relate and print - Add missing role for accessibility --- src/tab.js | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/src/tab.js b/src/tab.js index 3f0e36fa7f..878dc2ca63 100644 --- a/src/tab.js +++ b/src/tab.js @@ -31,11 +31,16 @@ if (!func) { return; } - var item = jQuery('
  • ').append( - jQuery('').append(jQuery('', { - 'class': 'glyphicon ' + icon, - 'aria-hidden': 'true' - })).append(' ' + name)); + var item = jQuery('
  • ', { + 'role': 'presentation' + }).append(jQuery('', { + 'role': 'menuitem', + 'href': '#', + 'tabindex': -1 + }).append(jQuery('', { + 'class': 'glyphicon ' + icon, + 'aria-hidden': 'true' + })).append(' ' + name)); menu.append(item); item.click(function() { this[func](); @@ -83,8 +88,9 @@ var add_button = function(tool) { this.buttons[tool[0]] = jQuery('', { - href: '#', - id: tool[0] + 'role': 'menuitem', + 'href': '#', + 'id': tool[0] }) .append(jQuery('', { 'class': 'glyphicon ' + tool[1], @@ -94,8 +100,9 @@ 'class': 'hidden-sm' }).append(' ' + tool[2])) .click(this[tool[4]].bind(this)) - .appendTo(jQuery('
  • ') - .appendTo(toolbar.find('.navbar-collapse > ul'))); + .appendTo(jQuery('
  • ', { + 'role': 'presentation' + }).appendTo(toolbar.find('.navbar-collapse > ul'))); // TODO tooltip }; this.toolbar_def.forEach(add_button.bind(this)); @@ -675,13 +682,22 @@ this.info_bar.message(); }, action: function() { - this.buttons.action.click(); + window.setTimeout(function() { + this.buttons.action.find('ul.dropdown-menu') + .dropdown('toggle'); + }.bind(this)); }, relate: function() { - this.buttons.relate.click(); + window.setTimeout(function() { + this.buttons.relate.find('ul.dropdown-menu') + .dropdown('toggle'); + }.bind(this)); }, print: function() { - this.buttons.print.click(); + window.setTimeout(function() { + this.buttons.print.find('ul.dropdown-menu') + .dropdown('toggle'); + }.bind(this)); } });