Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 Polymer({ | |
| 6 is: 'cr-toolbar', | |
| 7 | |
| 8 behaviors: [CrSearchFieldBehavior], | |
| 9 | |
| 10 properties: { | |
| 11 // Name to display in the toolbar, in titlecase. | |
| 12 pageName: String, | |
| 13 | |
| 14 lowerPageName_: { | |
| 15 type: String, | |
| 16 computed: 'computeLowerPageName_(pageName)' | |
| 17 } | |
| 18 }, | |
| 19 | |
| 20 attached: function() { | |
| 21 document.addEventListener('click', this.onDocumentClick_.bind(this)); | |
| 22 }, | |
| 23 | |
| 24 detached: function() { | |
| 25 document.removeEventListener('click', this.onDocumentClick_.bind(this)); | |
| 26 }, | |
| 27 | |
| 28 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
| |
| 29 // body is active when the user has just clicked off into empty space. | |
| 30 if (document.activeElement == document.body && !this.hasSearchText_) | |
| 31 this.showingSearch_ = false; | |
| 32 }, | |
| 33 | |
| 34 showSearch_: function(e) { | |
| 35 if (e.target != this.$['clear-search']) | |
| 36 this.showingSearch_ = true; | |
| 37 }, | |
| 38 | |
| 39 computeLowerPageName_: function(name) { | |
| 40 return name.toLowerCase(); | |
| 41 } | |
| 42 }); | |
| OLD | NEW |