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

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

Issue 682863004: print preview: Fix visual tab order for "Print"/"Cancel" buttons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 6 years, 2 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
Index: ui/webui/resources/js/cr/ui/node_utils.js
diff --git a/ui/webui/resources/js/cr/ui/node_utils.js b/ui/webui/resources/js/cr/ui/node_utils.js
new file mode 100644
index 0000000000000000000000000000000000000000..a380670e4f31d07968325abddf25797016aa8da7
--- /dev/null
+++ b/ui/webui/resources/js/cr/ui/node_utils.js
@@ -0,0 +1,33 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.exportPath('cr.ui');
+
+/**
+ * Reverse the child elements of any found button strips if they haven't already
+ * been reversed. This is necessary because WebKit does not alter the tab order
+ * for elements that are visually reversed using flex-direction: reverse, and
+ * the button order is reversed for views. See http://webk.it/62664 for more
+ * information.
+ * @param {Node=} opt_root Starting point for button strips to reverse.
+ */
+cr.ui.reverseButtonStrips = function(opt_root) {
+ if (!(cr.isWindows || cr.isChromeOS)) {
+ // Only reverse on platforms that need it (differ from the HTML order).
+ return;
+ }
+
+ var root = opt_root || document;
+ var buttonStrips = root.querySelectorAll('.button-strip:not([reversed])');
+ for (var j = 0; j < buttonStrips.length; j++) {
+ var buttonStrip = buttonStrips[j];
+
+ var childNodes = buttonStrip.childNodes;
+ for (var i = childNodes.length - 1; i >= 0; i--) {
+ buttonStrip.appendChild(childNodes[i]);
+ }
+
+ buttonStrip.setAttribute('reversed', '');
+ }
+};
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.html ('k') | ui/webui/resources/js/cr/ui/page_manager/page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698