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

Unified Diff: ui/webui/resources/js/cr/ui/search_field.js

Issue 1308893009: [MD Extensions] Move search field out of downloads, use it in extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/js/cr/ui/search_field.js
diff --git a/ui/webui/resources/js/cr/ui/search_field.js b/ui/webui/resources/js/cr/ui/search_field.js
new file mode 100644
index 0000000000000000000000000000000000000000..646080b2df04c4483e34684b9e256addcf9029fe
--- /dev/null
+++ b/ui/webui/resources/js/cr/ui/search_field.js
@@ -0,0 +1,61 @@
+// Copyright 2015 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 SearchField = Polymer({
+ is: 'search-field',
+
+ properties: {
+ showingSearch_: {
+ type: Boolean,
+ value: false,
+ },
+ },
+
+ setDelegate: function(delegate) {
+ this.delegate_ = delegate;
+ },
+
+ getValue: function() {
+ return this.$['search-input'].value;
+ },
+
+ /** @private */
+ onSearchTermSearch_: function() {
+ if (this.delegate_)
+ this.delegate_.onSearchTermSearch(this.$['search-input'].value);
+ },
+
+ /** @private */
+ onSearchTermKeydown_: function(e) {
+ assert(this.showingSearch_);
+ if (e.keyIdentifier == 'U+001B') // Escape.
+ this.toggleShowingSearch_();
+ },
+
+ /** @private */
+ toggleShowingSearch_: function() {
+ this.showingSearch_ = !this.showingSearch_;
+
+ if (this.showingSearch_) {
+ this.$['search-input'].focus();
+ } else {
+ this.$['search-input'].value = '';
+ this.onSearchTermSearch_();
+ }
+ },
+ });
+
+ /** @interface */
+ SearchField.Delegate = function() {};
+
+ SearchField.Delegate.prototype = {
+ /**
+ * @param {string} value
+ */
+ onSearchTermSearch: assertNotReached,
+ };
+
+ return {SearchField: SearchField};
+});

Powered by Google App Engine
This is Rietveld 408576698