Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: ui/webui/resources/js/cr/ui/tabs.js

Issue 15389003: Loosen a bit the HTML hierarchy required for Tabs to work, Improved UX of the dev tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Introduce RTL, changed non-selected tab color, applied feedback from dbeam. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/apps_debugger/main.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/cr/ui/tabs.js
diff --git a/ui/webui/resources/js/cr/ui/tabs.js b/ui/webui/resources/js/cr/ui/tabs.js
index 6afa5663133d325dc80161f6fa9b98cb5314e712..5d03de1c2b04690bb4ff6cc8f83811b3ca03d14e 100644
--- a/ui/webui/resources/js/cr/ui/tabs.js
+++ b/ui/webui/resources/js/cr/ui/tabs.js
@@ -10,7 +10,9 @@ cr.define('cr.ui', function() {
* @return {TabBox} The tab box if found.
*/
function getTabBox(el) {
- return el.parentElement && el.parentElement.parentElement;
+ return findAncestor(el, function(node) {
+ return node.tagName == 'TABBOX';
+ });
}
/**
@@ -39,12 +41,13 @@ cr.define('cr.ui', function() {
TABPANEL: TabPanel
};
- var child;
- for (var i = 0; child = this.children[i]; i++) {
- var constr = map[child.tagName];
- if (constr)
+ Object.keys(map).forEach(function(tagName) {
+ var children = this.getElementsByTagName(tagName);
+ var constr = map[tagName];
+ for (var i = 0; child = children[i]; i++) {
cr.ui.decorate(child, constr);
- }
+ }
+ }.bind(this));
}
/**
@@ -53,10 +56,18 @@ cr.define('cr.ui', function() {
* @this {TabBox}
*/
function selectedIndexSetHook(selectedIndex) {
- var child, tabChild;
- for (var i = 0; child = this.children[i]; i++) {
- for (var j = 0; tabChild = child.children[j]; j++) {
- tabChild.selected = j == selectedIndex;
+ var child, tabChild, element;
+ element = this.querySelector('tabs');
+ if (element) {
+ for (var i = 0; child = element.children[i]; i++) {
+ child.selected = i == selectedIndex;
+ }
+ }
+
+ element = this.querySelector('tabpanels');
+ if (element) {
+ for (var i = 0; child = element.children[i]; i++) {
+ child.selected = i == selectedIndex;
}
}
}
@@ -113,7 +124,7 @@ cr.define('cr.ui', function() {
decorate: function() {
decorateChildren.call(this);
- // Make the Tabs element fousable.
+ // Make the Tabs element focusable.
this.tabIndex = 0;
this.addEventListener('keydown', this.handleKeyDown_.bind(this));
@@ -149,8 +160,9 @@ cr.define('cr.ui', function() {
delta *= -1;
var count = this.children.length;
- var index = this.parentElement.selectedIndex;
- this.parentElement.selectedIndex = (index + delta + count) % count;
+ var tabbox = getTabBox(this);
+ var index = tabbox.selectedIndex;
+ tabbox.selectedIndex = (index + delta + count) % count;
// Show focus outline since we used the keyboard.
this.focusOutlineManager_.visible = true;
« no previous file with comments | « chrome/browser/resources/apps_debugger/main.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698