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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698