First stab at enyo rewrite
[blerg.git] / www / jssrc / blerg / Controls.js
1 enyo.kind({
2         name: "blerg.Controls",
3         kind: "Control",
4         style: "float: right",
5         classes: "blerg-controls",
6         published: {
7                 loggedIn: false
8         },
9         components: [
10                 {name: "loggedOutControls", components: [
11                         {tag: "form", onsubmit: "doLogin", classes: "login", components: [
12                                 {kind: "onyx.Groupbox", components: [
13                                         {kind: "onyx.InputDecorator", components: [
14                                                 {name: "username", kind: "onyx.Input", placeholder: "Username"}
15                                         ]},
16                                         {kind: "onyx.InputDecorator", components: [
17                                                 {name: "password", kind: "onyx.Input", placeholder: "Password", type: "password"}
18                                         ]},
19                                 ]},
20                                 {kind: "onyx.Button", content: "Login", onclick: "doLogin"}
21                         ]}
22                 ]},
23                 {name: "loggedInControls", showing: false, components: [
24                         {name: "greeting"},
25                         {kind: "onyx.Toolbar", components: [
26                                 {kind: "onyx.Button", content: "Write", onClick: "writeClicked"},
27                                 {kind: "onyx.Button", content: "Hearsay", onClick: "chatterClicked"},
28                                 {kind: "onyx.Button", content: "Stalking", onClick: "feedClicked"}
29                         ]},
30                         {components: [
31                                 {name: "rssButton", showing: false, kind: "blerg.Link", components: [
32                                         {kind: "Image", src: "/images/rss.png", width: 16, height: 16},
33                                         {noDom: true, content: " RSS"}
34                                 ]}
35                         ]}
36                 ]}
37         ],
38         showRSS: function(url) {
39                 this.$.rssButton.show();
40                 if (url)
41                         this.$.rssButton.setAttribute('href', url);
42         },
43         hideRSS: function() {
44                 this.$.rssButton.hide();
45         },
46         loggedInChanged: function() {
47                 if (this.loggedIn) {
48                         this.$.loggedOutControls.hide();
49                         this.$.loggedInControls.show();
50                 } else {
51                         this.$.loggedOutControls.show();
52                         this.$.loggedInControls.hide();
53                 }
54         },
55         doLogin: function() {
56                 this.bubble('onTryLogin', {
57                         username: this.$.username.getValue(),
58                         password: this.$.password.getValue()
59                 });
60         }
61 });