Chromium Code Reviews| 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(); |
| + } |
| +}); |