blob: d17b40a37bb798aa4b21fe45600db74ad6f9fc5b [file] [log] [blame]
Ali Ghassemi5dcb6d32014-06-11 16:42:08 -07001<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 Ghassemi2ebd75b2014-06-02 15:16:34 -07004
5<polymer-element name="p2b-publish" attributes="publishState">
6
Ali Ghassemi5dcb6d32014-06-11 16:42:08 -07007 <template id="template">
Ali Ghassemi2ebd75b2014-06-02 15:16:34 -07008 <link rel="stylesheet" href="../common/common.css">
Ali Ghassemi5dcb6d32014-06-11 16:42:08 -07009 <link rel="stylesheet" href="component.css">
Ali Ghassemi5e2d3d82014-07-11 10:21:03 -070010 <paper-input id="publishNameInput" label="Name to publish under (e.g. john-tablet)" error="You must pick a name!" floatinglabel/></paper-input>
Ali Ghassemi5dcb6d32014-06-11 16:42:08 -070011 <paper-button class="paper colored" inkColor="#3367d6" on-click="{{ publishAction }}">Publish</paper-button>
Ali Ghassemi2ebd75b2014-06-02 15:16:34 -070012 </template>
13 <script>
14 Polymer('p2b-publish', {
Ali Ghassemi2ebd75b2014-06-02 15:16:34 -070015
16 /*
Ali Ghassemi3443eca2014-06-17 11:25:01 -070017 * Publish action. Fires when user decided to publish the p2b service.
Ali Ghassemi2ebd75b2014-06-02 15:16:34 -070018 * user-entered name of the service will be provided as value of the event
Ali Ghassemi5dcb6d32014-06-11 16:42:08 -070019 * @event
Ali Ghassemi2ebd75b2014-06-02 15:16:34 -070020 */
21 publishAction: function() {
Ali Ghassemi5e2d3d82014-07-11 10:21:03 -070022 var name = this.$.publishNameInput.value.trim();
Ali Ghassemi5dcb6d32014-06-11 16:42:08 -070023 if(name === "") {
24 this.$.publishNameInput.invalid = true;
25 this.$.publishNameInput.classList.toggle('invalid', true);
26 return;
27 }
28 this.fire('publish', { publishName: name });
Ali Ghassemi2ebd75b2014-06-02 15:16:34 -070029 }
30 });
31 </script>
32</polymer-element>