OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 cr.exportPath('cr.ui'); |
| 6 |
| 7 /** |
| 8 * Reverse the child elements of any found button strips if they haven't already |
| 9 * been reversed. This is necessary because WebKit does not alter the tab order |
| 10 * for elements that are visually reversed using flex-direction: reverse, and |
| 11 * the button order is reversed for views. See http://webk.it/62664 for more |
| 12 * information. |
| 13 * @param {Node=} opt_root Starting point for button strips to reverse. |
| 14 */ |
| 15 cr.ui.reverseButtonStrips = function(opt_root) { |
| 16 if (!(cr.isWindows || cr.isChromeOS)) { |
| 17 // Only reverse on platforms that need it (differ from the HTML order). |
| 18 return; |
| 19 } |
| 20 |
| 21 var root = opt_root || document; |
| 22 var buttonStrips = root.querySelectorAll('.button-strip:not([reversed])'); |
| 23 for (var j = 0; j < buttonStrips.length; j++) { |
| 24 var buttonStrip = buttonStrips[j]; |
| 25 |
| 26 var childNodes = buttonStrip.childNodes; |
| 27 for (var i = childNodes.length - 1; i >= 0; i--) { |
| 28 buttonStrip.appendChild(childNodes[i]); |
| 29 } |
| 30 |
| 31 buttonStrip.setAttribute('reversed', ''); |
| 32 } |
| 33 }; |
OLD | NEW |