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

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

Issue 604373006: Compile chrome://settings, part 9: yet another final battle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@K_blockers_from_bookmarks
Patch Set: dbeam@'s review 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 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 <include src="assert.js"> 5 <include src="assert.js">
6 6
7 /** 7 /**
8 * Alias for document.getElementById. 8 * Alias for document.getElementById.
9 * @param {string} id The ID of the element to find. 9 * @param {string} id The ID of the element to find.
10 * @return {HTMLElement} The found element or null if not found. 10 * @return {HTMLElement} The found element or null if not found.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 */ 247 */
248 function isRTL() { 248 function isRTL() {
249 return document.documentElement.dir == 'rtl'; 249 return document.documentElement.dir == 'rtl';
250 } 250 }
251 251
252 /** 252 /**
253 * Get an element that's known to exist by its ID. We use this instead of just 253 * Get an element that's known to exist by its ID. We use this instead of just
254 * calling getElementById and not checking the result because this lets us 254 * calling getElementById and not checking the result because this lets us
255 * satisfy the JSCompiler type system. 255 * satisfy the JSCompiler type system.
256 * @param {string} id The identifier name. 256 * @param {string} id The identifier name.
257 * @return {!Element} the Element. 257 * @return {!HTMLElement} the Element.
258 */ 258 */
259 function getRequiredElement(id) { 259 function getRequiredElement(id) {
260 var element = $(id); 260 var element = $(id);
Dan Beam 2014/10/02 02:56:35 ^ remove
Vitaly Pavlenko 2014/10/02 18:18:22 Done.
261 assert(element, 'Missing required element: ' + id); 261 return assertInstanceof($(id), HTMLElement,
262 return /** @type {!Element} */(element); 262 'Missing required element: ' + id);
263 } 263 }
264 264
265 // Handle click on a link. If the link points to a chrome: or file: url, then 265 // Handle click on a link. If the link points to a chrome: or file: url, then
266 // call into the browser to do the navigation. 266 // call into the browser to do the navigation.
267 document.addEventListener('click', function(e) { 267 document.addEventListener('click', function(e) {
268 if (e.defaultPrevented) 268 if (e.defaultPrevented)
269 return; 269 return;
270 270
271 var el = e.target; 271 var el = e.target;
272 if (el.nodeType == Node.ELEMENT_NODE && 272 if (el.nodeType == Node.ELEMENT_NODE &&
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 * @param {number} maxLength The maximum length allowed for the string. 432 * @param {number} maxLength The maximum length allowed for the string.
433 * @return {string} The original string if its length does not exceed 433 * @return {string} The original string if its length does not exceed
434 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...' 434 * |maxLength|. Otherwise the first |maxLength| - 1 characters with '...'
435 * appended. 435 * appended.
436 */ 436 */
437 function elide(original, maxLength) { 437 function elide(original, maxLength) {
438 if (original.length <= maxLength) 438 if (original.length <= maxLength)
439 return original; 439 return original;
440 return original.substring(0, maxLength - 1) + '\u2026'; 440 return original.substring(0, maxLength - 1) + '\u2026';
441 } 441 }
OLDNEW
« ui/webui/resources/js/cr/ui/bubble.js ('K') | « ui/webui/resources/js/cr/ui/touch_handler.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698