OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 Polymer({ | 5 Polymer({ |
6 is: 'cr-toolbar', | 6 is: 'cr-toolbar', |
7 | 7 |
8 properties: { | 8 properties: { |
9 // Name to display in the toolbar, in titlecase. | 9 // Name to display in the toolbar, in titlecase. |
10 pageName: String, | 10 pageName: String, |
11 | 11 |
12 // Prompt text to display in the search field. | 12 // Prompt text to display in the search field. |
13 searchPrompt: String, | 13 searchPrompt: String, |
14 | 14 |
15 // Tooltip to display on the clear search button. | 15 // Tooltip to display on the clear search button. |
16 clearLabel: String, | 16 clearLabel: String, |
17 | 17 |
18 // Tooltip to display on the menu button. | 18 // Tooltip to display on the menu button. |
19 menuLabel: String, | 19 menuLabel: String, |
20 | 20 |
21 // Promotional toolstip string, shown in narrow mode if showMenuPromo is | |
22 // true. | |
23 menuPromo: String, | |
24 | |
21 // Value is proxied through to cr-toolbar-search-field. When true, | 25 // Value is proxied through to cr-toolbar-search-field. When true, |
22 // the search field will show a processing spinner. | 26 // the search field will show a processing spinner. |
23 spinnerActive: Boolean, | 27 spinnerActive: Boolean, |
24 | 28 |
25 // Controls whether the menu button is shown at the start of the menu. | 29 // Controls whether the menu button is shown at the start of the menu. |
26 showMenu: { | 30 showMenu: Boolean, |
27 type: Boolean, | 31 |
28 value: false | 32 // Whether to show menu promo tooltip. |
29 }, | 33 showMenuPromo: Boolean, |
30 | 34 |
31 /** @private */ | 35 /** @private */ |
32 narrow_: { | 36 narrow_: { |
33 type: Boolean, | 37 type: Boolean, |
34 reflectToAttribute: true | 38 reflectToAttribute: true |
35 }, | 39 }, |
36 | 40 |
37 /** @private */ | 41 /** @private */ |
38 showingSearch_: { | 42 showingSearch_: { |
39 type: Boolean, | 43 type: Boolean, |
40 reflectToAttribute: true, | 44 reflectToAttribute: true, |
41 }, | 45 }, |
46 | |
47 /** @private */ | |
48 showingMenuPromo_: { | |
49 type: Boolean, | |
50 computed: 'computeShowingMenuPromo_(showMenuPromo, narrow_)', | |
tsergeant
2016/08/25 04:51:00
I think you want to tie this to showMenu_ rather t
Dan Beam
2016/09/09 03:12:08
well, it's already in a <template is="dom-if" if="
| |
51 observer: 'showingMenuPromoChanged_', | |
52 }, | |
42 }, | 53 }, |
43 | 54 |
44 /** @return {!CrToolbarSearchFieldElement} */ | 55 /** @return {!CrToolbarSearchFieldElement} */ |
45 getSearchField: function() { | 56 getSearchField: function() { |
46 return this.$.search; | 57 return this.$.search; |
47 }, | 58 }, |
48 | 59 |
60 /** | |
61 * @param {boolean} showMenuPromo | |
62 * @param {boolean} narrow | |
63 * @return {boolean} Whether to show the menu promo tooltip. | |
64 */ | |
65 computeShowingMenuPromo_: function(showMenuPromo, narrow) { | |
66 return showMenuPromo && narrow; | |
67 }, | |
68 | |
49 /** @private */ | 69 /** @private */ |
50 onMenuTap_: function(e) { | 70 onMenuTap_: function() { |
51 this.fire('cr-menu-tap'); | 71 this.fire('cr-menu-tap'); |
52 } | 72 this.onMenuPromoCloseTap_(); |
73 }, | |
74 | |
75 /** @private */ | |
76 onMenuPromoCloseTap_: function() { | |
77 this.fire('cr-menu-promo-shown'); | |
tsergeant
2016/08/25 04:51:00
This is potentially confusing, should this be cr-m
Dan Beam
2016/09/09 03:12:08
This didn't actually close it; it just told the pa
| |
78 }, | |
79 | |
80 /** @private */ | |
81 showingMenuPromoChanged_: function() { | |
82 Polymer.RenderStatus.afterNextRender(this, function() { | |
83 if (this.showingMenuPromo_) | |
84 this.$$('paper-tooltip').show(); | |
85 }.bind(this)); | |
86 }, | |
87 | |
88 /** | |
89 * @param {string} title | |
90 * @param {boolean} showingMenuPromo | |
91 * @return {string} The title if the menu promo isn't showing, else "". | |
92 */ | |
93 titleIfNotShowingMenuPromo_: function(title, showingMenuPromo) { | |
94 return showingMenuPromo ? '' : title; | |
95 }, | |
53 }); | 96 }); |
OLD | NEW |