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

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

Issue 1963503002: MD WebUI: Add shared cr-toolbar element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove dom-if 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_search_field.js
diff --git a/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.js b/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.js
new file mode 100644
index 0000000000000000000000000000000000000000..eaee8400b753be7ad63f0e8796a30311885d5730
--- /dev/null
+++ b/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.js
@@ -0,0 +1,50 @@
+// 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-search-field',
+
+ behaviors: [CrSearchFieldBehavior],
+
+ properties: {
+ narrow: {
+ type: Boolean,
+ reflectToAttribute: true,
+ },
+ // Prompt text to display in the search field.
+ label: String,
+ // Tooltip to display on the clear search button.
+ clearLabel: String,
+ },
+
+ listeners: {
+ 'tap': 'showSearch_',
+ 'clearSearch.tap': 'hideSearch_',
+ 'searchInput.blur': 'onInputBlur_'
+ },
+
+ /** @private */
+ onInputBlur_: function() {
+ if (!this.hasSearchText_)
dpapad 2016/05/25 01:20:10 The underscore at the end of hasSearchText_ implie
tsergeant 2016/05/25 07:01:30 Done, made public.
+ this.showingSearch = false;
+ },
+
+ /**
+ * @param {Event} e
+ * @private
+ */
+ showSearch_: function(e) {
+ if (e.target != this.$.clearSearch)
+ this.showingSearch = true;
+ },
+
+ /**
+ * @param {Event} e
+ * @private
+ */
+ hideSearch_: function(e) {
+ this.showingSearch = false;
+ e.stopPropagation();
+ }
+});

Powered by Google App Engine
This is Rietveld 408576698