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

Side by Side Diff: ui/login/bubble.js

Issue 2104103002: Convert Event#keyIdentifier (deprecated) to Event#key (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 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 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 /** 5 /**
6 * @fileoverview Bubble implementation. 6 * @fileoverview Bubble implementation.
7 */ 7 */
8 8
9 // TODO(xiyuan): Move this into shared. 9 // TODO(xiyuan): Move this into shared.
10 cr.define('cr.ui', function() { 10 cr.define('cr.ui', function() {
11 /** 11 /**
12 * Creates a bubble div. 12 * Creates a bubble div.
13 * @constructor 13 * @constructor
14 * @extends {HTMLDivElement} 14 * @extends {HTMLDivElement}
15 */ 15 */
16 var Bubble = cr.ui.define('div'); 16 var Bubble = cr.ui.define('div');
17 17
18 /** 18 /**
19 * Bubble key codes. 19 * Bubble key codes.
20 * @enum {number} 20 * @enum {number}
21 */ 21 */
22 var KeyCodes = { 22 var KeyCodes = {
Dan Beam 2016/06/29 23:34:17 nit: KeyCodes => Keys
dtapuska 2016/06/30 14:16:50 Done.
23 TAB: 'U+0009', 23 TAB: 'Tab',
24 ENTER: 'Enter', 24 ENTER: 'Enter',
25 ESC: 'U+001B', 25 ESC: 'Escape',
26 SPACE: 'U+0020' 26 SPACE: ' '
27 }; 27 };
28 28
29 /** 29 /**
30 * Bubble attachment side. 30 * Bubble attachment side.
31 * @enum {string} 31 * @enum {string}
32 */ 32 */
33 Bubble.Attachment = { 33 Bubble.Attachment = {
34 RIGHT: 'bubble-right', 34 RIGHT: 'bubble-right',
35 LEFT: 'bubble-left', 35 LEFT: 'bubble-left',
36 TOP: 'bubble-top', 36 TOP: 'bubble-top',
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 handleDocKeyDown_: function(e) { 320 handleDocKeyDown_: function(e) {
321 if (this.hidden) 321 if (this.hidden)
322 return; 322 return;
323 323
324 if (this.hideOnKeyPress_) { 324 if (this.hideOnKeyPress_) {
325 this.hide(); 325 this.hide();
326 return; 326 return;
327 } 327 }
328 // Artificial tab-cycle. 328 // Artificial tab-cycle.
329 329
330 if (e.keyIdentifier == KeyCodes.TAB && e.shiftKey == true && 330 if (e.key == KeyCodes.TAB && e.shiftKey == true &&
331 e.target == this.firstBubbleElement_) { 331 e.target == this.firstBubbleElement_) {
332 this.lastBubbleElement_.focus(); 332 this.lastBubbleElement_.focus();
333 e.preventDefault(); 333 e.preventDefault();
334 } 334 }
335 if (e.keyIdentifier == KeyCodes.TAB && e.shiftKey == false && 335 if (e.key == KeyCodes.TAB && e.shiftKey == false &&
336 e.target == this.lastBubbleElement_) { 336 e.target == this.lastBubbleElement_) {
337 this.firstBubbleElement_.focus(); 337 this.firstBubbleElement_.focus();
338 e.preventDefault(); 338 e.preventDefault();
339 } 339 }
340 // Close bubble on ESC or on hitting spacebar or Enter at close-button. 340 // Close bubble on ESC or on hitting spacebar or Enter at close-button.
341 if (e.keyIdentifier == KeyCodes.ESC || 341 if (e.key == KeyCodes.ESC ||
342 ((e.keyIdentifier == KeyCodes.ENTER || 342 ((e.key == KeyCodes.ENTER ||
343 e.keyIdentifier == KeyCodes.SPACE) && 343 e.key == KeyCodes.SPACE) &&
344 e.target && e.target.classList.contains('close-button'))) 344 e.target && e.target.classList.contains('close-button')))
345 this.hide(); 345 this.hide();
346 }, 346 },
347 347
348 /** 348 /**
349 * Handler of window blur event. 349 * Handler of window blur event.
350 * @private 350 * @private
351 */ 351 */
352 handleWindowBlur_: function(e) { 352 handleWindowBlur_: function(e) {
353 if (!this.hidden) 353 if (!this.hidden)
354 this.hide(); 354 this.hide();
355 } 355 }
356 }; 356 };
357 357
358 return { 358 return {
359 Bubble: Bubble 359 Bubble: Bubble
360 }; 360 };
361 }); 361 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698