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

Side by Side Diff: ui/webui/resources/js/cr/ui.js

Issue 2597013002: Run clang-format on ui/webui/resources (Closed)
Patch Set: remove cr_shared_menu.js Created 3 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('cr.ui', function() { 5 cr.define('cr.ui', function() {
6 6
7 /** 7 /**
8 * Decorates elements as an instance of a class. 8 * Decorates elements as an instance of a class.
9 * @param {string|!Element} source The way to find the element(s) to decorate. 9 * @param {string|!Element} source The way to find the element(s) to decorate.
10 * If this is a string then {@code querySeletorAll} is used to find the 10 * If this is a string then {@code querySeletorAll} is used to find the
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 var win = doc.defaultView; 116 var win = doc.defaultView;
117 var computedStyle = win.getComputedStyle(el); 117 var computedStyle = win.getComputedStyle(el);
118 var parentComputedStyle = win.getComputedStyle(parentEl); 118 var parentComputedStyle = win.getComputedStyle(parentEl);
119 var rtl = computedStyle.direction == 'rtl'; 119 var rtl = computedStyle.direction == 'rtl';
120 120
121 // To get the max width we get the width of the treeItem minus the position 121 // To get the max width we get the width of the treeItem minus the position
122 // of the input. 122 // of the input.
123 var inputRect = el.getBoundingClientRect(); // box-sizing 123 var inputRect = el.getBoundingClientRect(); // box-sizing
124 var parentRect = parentEl.getBoundingClientRect(); 124 var parentRect = parentEl.getBoundingClientRect();
125 var startPos = rtl ? parentRect.right - inputRect.right : 125 var startPos = rtl ? parentRect.right - inputRect.right :
126 inputRect.left - parentRect.left; 126 inputRect.left - parentRect.left;
127 127
128 // Add up border and padding of the input. 128 // Add up border and padding of the input.
129 var inner = parseInt(computedStyle.borderLeftWidth, 10) + 129 var inner = parseInt(computedStyle.borderLeftWidth, 10) +
130 parseInt(computedStyle.paddingLeft, 10) + 130 parseInt(computedStyle.paddingLeft, 10) +
131 parseInt(computedStyle.paddingRight, 10) + 131 parseInt(computedStyle.paddingRight, 10) +
132 parseInt(computedStyle.borderRightWidth, 10); 132 parseInt(computedStyle.borderRightWidth, 10);
133 133
134 // We also need to subtract the padding of parent to prevent it to overflow. 134 // We also need to subtract the padding of parent to prevent it to overflow.
135 var parentPadding = rtl ? parseInt(parentComputedStyle.paddingLeft, 10) : 135 var parentPadding = rtl ? parseInt(parentComputedStyle.paddingLeft, 10) :
136 parseInt(parentComputedStyle.paddingRight, 10); 136 parseInt(parentComputedStyle.paddingRight, 10);
137 137
138 var max = parentEl.clientWidth - startPos - inner - parentPadding; 138 var max = parentEl.clientWidth - startPos - inner - parentPadding;
139 if (opt_scale) 139 if (opt_scale)
140 max *= opt_scale; 140 max *= opt_scale;
141 141
142 function limit() { 142 function limit() {
143 if (el.scrollWidth > max) { 143 if (el.scrollWidth > max) {
144 el.style.width = max + 'px'; 144 el.style.width = max + 'px';
145 } else { 145 } else {
146 el.style.width = 0; 146 el.style.width = 0;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 203 }
204 204
205 return { 205 return {
206 decorate: decorate, 206 decorate: decorate,
207 define: define, 207 define: define,
208 limitInputWidth: limitInputWidth, 208 limitInputWidth: limitInputWidth,
209 toCssPx: toCssPx, 209 toCssPx: toCssPx,
210 swallowDoubleClick: swallowDoubleClick 210 swallowDoubleClick: swallowDoubleClick
211 }; 211 };
212 }); 212 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698