Index: options.js |
=================================================================== |
--- a/options.js |
+++ b/options.js |
@@ -1114,7 +1114,28 @@ |
openDialog("predefined"); |
break; |
case "focusSection": |
- document.body.setAttribute("data-tab", message.args[0]); |
+ var tabs = document.querySelectorAll("nav [id^=tab-]"); |
Thomas Greiner
2016/04/11 18:34:40
Instead of manually checking the contents of each
|
+ for (var i = 0; i < tabs.length; i++) |
+ { |
+ var tab = tabs[i]; |
+ var section = document.querySelector( |
+ "#content-" + tab.id.substr(4) + |
+ " [data-section='" + message.args[0] + "']" |
+ ); |
+ |
+ if (section) |
+ { |
+ // Switch to the corresponding tab and scroll to the section. |
+ tab.click(); |
Thomas Greiner
2016/04/11 18:34:40
This is a hack. The tab switching functionality is
|
+ section.scrollIntoView(); |
+ |
+ // Focus the first UI element inside the section. |
+ var walker = document.createTreeWalker(section, NodeFilter.SHOW_ELEMENT); |
+ do |
+ walker.currentNode.focus(); |
Thomas Greiner
2016/04/11 18:34:40
How do you know that the element is focusable? You
|
+ while (walker.currentNode != document.activeElement && walker.nextNode()) |
+ } |
+ } |
break; |
} |
break; |