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

Unified Diff: ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar.js

Issue 1963503002: MD WebUI: Add shared cr-toolbar element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
Index: ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar.js
diff --git a/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar.js b/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar.js
new file mode 100644
index 0000000000000000000000000000000000000000..02b350a7ce6e4c9de57f5f1b83009daa9eb8d9ac
--- /dev/null
+++ b/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar.js
@@ -0,0 +1,42 @@
+// Copyright 2016 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.
+
+Polymer({
+ is: 'cr-toolbar',
+
+ behaviors: [CrSearchFieldBehavior],
+
+ properties: {
+ // Name to display in the toolbar, in titlecase.
+ pageName: String,
+
+ lowerPageName_: {
+ type: String,
+ computed: 'computeLowerPageName_(pageName)'
+ }
+ },
+
+ attached: function() {
+ document.addEventListener('click', this.onDocumentClick_.bind(this));
+ },
+
+ detached: function() {
+ document.removeEventListener('click', this.onDocumentClick_.bind(this));
+ },
+
+ onDocumentClick_: function(e) {
calamity 2016/05/16 04:27:34 Hmmmmm. This is cool but makes me a bit nervous. d
tsergeant 2016/05/17 03:24:39 Hmmm, sure. onBlur is way less annoying when you a
+ // body is active when the user has just clicked off into empty space.
+ if (document.activeElement == document.body && !this.hasSearchText_)
+ this.showingSearch_ = false;
+ },
+
+ showSearch_: function(e) {
+ if (e.target != this.$['clear-search'])
+ this.showingSearch_ = true;
+ },
+
+ computeLowerPageName_: function(name) {
+ return name.toLowerCase();
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698