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

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

Issue 2842303004: MD Settings: update dialogs to focus without ink when using mouse (Closed)
Patch Set: different approach Created 3 years, 7 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
(Empty)
1 // Copyright 2017 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.define('cr.ui', function() {
6 var hideInk = false;
7
8 document.addEventListener('mousedown', function() {
dpapad 2017/05/02 00:13:22 As discussed in person, can we make this file re-e
Dan Beam 2017/05/02 02:55:11 Done.
9 hideInk = true;
10 }, true);
11 document.addEventListener('touchstart', function() {
dpapad 2017/05/02 00:13:22 Maybe we can use 'pointerdown' instead of mousedow
Dan Beam 2017/05/02 02:55:11 Done.
12 hideInk = true;
13 }, true);
14 document.addEventListener('keydown', function() {
15 hideInk = false;
16 }, true);
17
18 /**
19 * Attempts to track whether focus outlines should be shown, and if they
20 * shouldn't, removes the "ink" (ripple) from a control while focusing it.
21 * This is helpful when a user is clicking/touching, because it's not super
22 * helpful to show focus ripples in that case. This is Polymer-specific.
23 * @param {Element} toFocus
dpapad 2017/05/02 00:13:22 I think focus() only exists on HTMLElemnet, but no
Dan Beam 2017/05/02 02:55:11 Done. (I originally didn't do this intentionally t
24 */
25 function focusWithoutInk(toFocus) {
26 assert('noink' in toFocus);
27 assert(document == toFocus.ownerDocument);
28
29 var origNoInk;
30
31 if (hideInk) {
32 origNoInk = toFocus.noink;
33 toFocus.noink = true;
34 }
35
36 toFocus.focus();
37
38 if (hideInk)
39 toFocus.noink = origNoInk;
40 }
41
42 return {focusWithoutInk: focusWithoutInk};
43 });
OLDNEW
« no previous file with comments | « ui/webui/resources/js/cr/ui/compiled_resources2.gyp ('k') | ui/webui/resources/webui_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698