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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/cr/ui/focus_without_ink.js
diff --git a/ui/webui/resources/js/cr/ui/focus_without_ink.js b/ui/webui/resources/js/cr/ui/focus_without_ink.js
new file mode 100644
index 0000000000000000000000000000000000000000..f3e51462e192044b7374d46a6876cd1f3accc250
--- /dev/null
+++ b/ui/webui/resources/js/cr/ui/focus_without_ink.js
@@ -0,0 +1,43 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('cr.ui', function() {
+ var hideInk = false;
+
+ 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.
+ hideInk = true;
+ }, true);
+ 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.
+ hideInk = true;
+ }, true);
+ document.addEventListener('keydown', function() {
+ hideInk = false;
+ }, true);
+
+ /**
+ * Attempts to track whether focus outlines should be shown, and if they
+ * shouldn't, removes the "ink" (ripple) from a control while focusing it.
+ * This is helpful when a user is clicking/touching, because it's not super
+ * helpful to show focus ripples in that case. This is Polymer-specific.
+ * @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
+ */
+ function focusWithoutInk(toFocus) {
+ assert('noink' in toFocus);
+ assert(document == toFocus.ownerDocument);
+
+ var origNoInk;
+
+ if (hideInk) {
+ origNoInk = toFocus.noink;
+ toFocus.noink = true;
+ }
+
+ toFocus.focus();
+
+ if (hideInk)
+ toFocus.noink = origNoInk;
+ }
+
+ return {focusWithoutInk: focusWithoutInk};
+});
« 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