Ali Ghassemi | 5dcb6d3 | 2014-06-11 16:42:08 -0700 | [diff] [blame] | 1 | <link rel="import" href="/libs/vendor/polymer/polymer/polymer.html"> |
| 2 | <link rel="import" href="/libs/vendor/polymer/paper-input/paper-input.html"> |
| 3 | <link rel="import" href="/libs/vendor/polymer/paper-button/paper-button.html"> |
Ali Ghassemi | 2ebd75b | 2014-06-02 15:16:34 -0700 | [diff] [blame] | 4 | |
| 5 | <polymer-element name="p2b-publish" attributes="publishState"> |
| 6 | |
Ali Ghassemi | 5dcb6d3 | 2014-06-11 16:42:08 -0700 | [diff] [blame] | 7 | <template id="template"> |
Ali Ghassemi | 2ebd75b | 2014-06-02 15:16:34 -0700 | [diff] [blame] | 8 | <link rel="stylesheet" href="../common/common.css"> |
Ali Ghassemi | 5dcb6d3 | 2014-06-11 16:42:08 -0700 | [diff] [blame] | 9 | <link rel="stylesheet" href="component.css"> |
Ali Ghassemi | 5e2d3d8 | 2014-07-11 10:21:03 -0700 | [diff] [blame^] | 10 | <paper-input id="publishNameInput" label="Name to publish under (e.g. john-tablet)" error="You must pick a name!" floatinglabel/></paper-input> |
Ali Ghassemi | 5dcb6d3 | 2014-06-11 16:42:08 -0700 | [diff] [blame] | 11 | <paper-button class="paper colored" inkColor="#3367d6" on-click="{{ publishAction }}">Publish</paper-button> |
Ali Ghassemi | 2ebd75b | 2014-06-02 15:16:34 -0700 | [diff] [blame] | 12 | </template> |
| 13 | <script> |
| 14 | Polymer('p2b-publish', { |
Ali Ghassemi | 2ebd75b | 2014-06-02 15:16:34 -0700 | [diff] [blame] | 15 | |
| 16 | /* |
Ali Ghassemi | 3443eca | 2014-06-17 11:25:01 -0700 | [diff] [blame] | 17 | * Publish action. Fires when user decided to publish the p2b service. |
Ali Ghassemi | 2ebd75b | 2014-06-02 15:16:34 -0700 | [diff] [blame] | 18 | * user-entered name of the service will be provided as value of the event |
Ali Ghassemi | 5dcb6d3 | 2014-06-11 16:42:08 -0700 | [diff] [blame] | 19 | * @event |
Ali Ghassemi | 2ebd75b | 2014-06-02 15:16:34 -0700 | [diff] [blame] | 20 | */ |
| 21 | publishAction: function() { |
Ali Ghassemi | 5e2d3d8 | 2014-07-11 10:21:03 -0700 | [diff] [blame^] | 22 | var name = this.$.publishNameInput.value.trim(); |
Ali Ghassemi | 5dcb6d3 | 2014-06-11 16:42:08 -0700 | [diff] [blame] | 23 | if(name === "") { |
| 24 | this.$.publishNameInput.invalid = true; |
| 25 | this.$.publishNameInput.classList.toggle('invalid', true); |
| 26 | return; |
| 27 | } |
| 28 | this.fire('publish', { publishName: name }); |
Ali Ghassemi | 2ebd75b | 2014-06-02 15:16:34 -0700 | [diff] [blame] | 29 | } |
| 30 | }); |
| 31 | </script> |
| 32 | </polymer-element> |