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: { |
27 type: Boolean, | 31 type: Boolean, |
28 value: false | 32 value: false |
29 }, | 33 }, |
30 | 34 |
| 35 // Whether to show menu promo tooltip. |
| 36 showMenuPromo: { |
| 37 type: Boolean, |
| 38 value: false, |
| 39 }, |
| 40 |
31 /** @private */ | 41 /** @private */ |
32 narrow_: { | 42 narrow_: { |
33 type: Boolean, | 43 type: Boolean, |
34 reflectToAttribute: true | 44 reflectToAttribute: true |
35 }, | 45 }, |
36 | 46 |
37 /** @private */ | 47 /** @private */ |
38 showingSearch_: { | 48 showingSearch_: { |
39 type: Boolean, | 49 type: Boolean, |
40 reflectToAttribute: true, | 50 reflectToAttribute: true, |
41 }, | 51 }, |
42 }, | 52 }, |
43 | 53 |
| 54 observers: [ |
| 55 'possiblyShowMenuPromo_(showMenu, showMenuPromo, showingSearch_)', |
| 56 ], |
| 57 |
44 /** @return {!CrToolbarSearchFieldElement} */ | 58 /** @return {!CrToolbarSearchFieldElement} */ |
45 getSearchField: function() { | 59 getSearchField: function() { |
46 return this.$.search; | 60 return this.$.search; |
47 }, | 61 }, |
48 | 62 |
49 /** @private */ | 63 /** @private */ |
50 onMenuTap_: function(e) { | 64 onMenuTap_: function() { |
51 this.fire('cr-menu-tap'); | 65 this.fire('cr-menu-tap'); |
52 } | 66 this.onMenuPromoCloseTap_(); |
| 67 }, |
| 68 |
| 69 /** @private */ |
| 70 onMenuPromoCloseTap_: function() { |
| 71 this.showMenuPromo = false; |
| 72 }, |
| 73 |
| 74 /** @private */ |
| 75 possiblyShowMenuPromo_: function() { |
| 76 Polymer.RenderStatus.afterNextRender(this, function() { |
| 77 if (this.showMenu && this.showMenuPromo && !this.showingSearch_) { |
| 78 this.$$('paper-tooltip').show(); |
| 79 this.fire('cr-menu-promo-shown'); |
| 80 } |
| 81 }.bind(this)); |
| 82 }, |
| 83 |
| 84 /** |
| 85 * @param {string} title |
| 86 * @param {boolean} showMenuPromo |
| 87 * @return {string} The title if the menu promo isn't showing, else "". |
| 88 */ |
| 89 titleIfNotShowMenuPromo_: function(title, showMenuPromo) { |
| 90 return showMenuPromo ? '' : title; |
| 91 }, |
53 }); | 92 }); |
OLD | NEW |