Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: options.js

Issue 29339619: Issue 3909 - Move "Tweaks" below "Filter lists" on options page (Closed)
Patch Set: Created April 8, 2016, 6:57 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « options.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « options.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld