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

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

Issue 2300753004: MD Settings menu should be visible (Closed)
Patch Set: cleanup Created 4 years, 3 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. Found elements must be HTMLElements. 8 * Alias for document.getElementById. Found elements must be HTMLElements.
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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 386
387 /** 387 /**
388 * Quote a string so it can be used in a regular expression. 388 * Quote a string so it can be used in a regular expression.
389 * @param {string} str The source string. 389 * @param {string} str The source string.
390 * @return {string} The escaped string. 390 * @return {string} The escaped string.
391 */ 391 */
392 function quoteString(str) { 392 function quoteString(str) {
393 return str.replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, '\\$1'); 393 return str.replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, '\\$1');
394 } 394 }
395 395
396 /**
397 * Runs |callback| first time the |eventName| event is fired on |target|, then
398 * removes the listener.
399 * @param {!EventTarget} target
400 * @param {string} eventName
Dan Beam 2016/09/01 01:33:13 nit: maybe support multiple events? ... Callback
michaelpg 2016/09/01 02:20:26 Done. I had briefly considered this but thought it
401 * @param {function(!Event)} callback Called at most once. The
402 * optional return value is passed on by the listener.
403 */
404 function listenOnce(target, eventName, callback) {
405 target.addEventListener(eventName, function runOnce(event) {
michaelpg 2016/09/01 01:00:27 dbeam: your example returned a Promise, but this w
406 target.removeEventListener(eventName, runOnce, false);
michaelpg 2016/09/01 01:00:27 apparently closure requires this 3rd argument for
407 return callback(event);
408 }, false);
Dan Beam 2016/09/01 01:33:13 we'll probably need some type @param {boolean=} op
michaelpg 2016/09/01 02:20:27 Acknowledged (does anyone actually use that? I've
409 }
410
396 // <if expr="is_ios"> 411 // <if expr="is_ios">
397 // Polyfill 'key' in KeyboardEvent for iOS. 412 // Polyfill 'key' in KeyboardEvent for iOS.
398 // This function is not intended to be complete but should 413 // This function is not intended to be complete but should
399 // be sufficient enough to have iOS work correctly while 414 // be sufficient enough to have iOS work correctly while
400 // it does not support key yet. 415 // it does not support key yet.
401 if (!('key' in KeyboardEvent.prototype)) { 416 if (!('key' in KeyboardEvent.prototype)) {
402 Object.defineProperty(KeyboardEvent.prototype, 'key', { 417 Object.defineProperty(KeyboardEvent.prototype, 'key', {
403 /** @this {KeyboardEvent} */ 418 /** @this {KeyboardEvent} */
404 get: function () { 419 get: function () {
405 // 0-9 420 // 0-9
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 case 0xdb: return '['; 467 case 0xdb: return '[';
453 case 0xdd: return ']'; 468 case 0xdd: return ']';
454 } 469 }
455 return 'Unidentified'; 470 return 'Unidentified';
456 } 471 }
457 }); 472 });
458 } else { 473 } else {
459 window.console.log("KeyboardEvent.Key polyfill not required"); 474 window.console.log("KeyboardEvent.Key polyfill not required");
460 } 475 }
461 // </if> /* is_ios */ 476 // </if> /* is_ios */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698