6 onPostVisibility: "postVisibilityUpdate",
11 {tag: "h2", content: "What's on your mind?"},
12 {kind: "onyx.InputDecorator", alwaysLooksFocused: true, classes: "content-decorator", fit: true, components: [
13 {name: "postContent", kind: "onyx.TextArea", classes: "content", onkeyup: "updatePreview", attributes: {tabindex: 4}}
15 {name: "toolbar", kind: "FittableColumns", classes: "toolbar", components: [
16 {classes: "switcher", components: [
17 {kind: "onyx.RadioGroup", onActivate: "switchBottomPanel", components: [
18 {content: "Replying to"},
23 {classes: "buttons", fit: true, components: [
24 {name: "loginReminder", tag: "span", classes: "blerg-error", style: "margin-right: 8px", content: "You must log in before posting."},
25 {kind: "onyx.Button", content: "Close", onclick: "closePost", classes: "onyx-negative", attributes: {tabindex: 6}},
26 {name: "postButton", kind: "onyx.Button", content: "Post", onclick: "doPost", classes: "onyx-affirmative", disabled: true, attributes: {tabindex: 5}}
29 {name: "bottomPanel", kind: "Panels", classes: "bottom-panel", draggable: false, fit: true, components: [
30 {content: "In reply to:"},
31 {kind: "Scroller", components: [
32 {name: "preview", classes: "record", allowHtml: true},
34 {kind: "Scroller", components: [
35 {name: "helpContent", allowHtml: true},
38 {name: "api", kind: "blerg.API",
39 onPostSuccessful: "postSuccessful",
40 onPostFailed: "postFailed"}
43 this.inherited(arguments);
46 return this.$.postContent.getValue();
48 setData: function(inVal) {
49 this.$.postContent.setValue(inVal);
51 closePost: function() {
52 this.bubble('onPostVisibility', {showing: false});
55 this.$.api.post(this.getData());
57 postSuccessful: function() {
60 if (location.hash != '#' + blerg.API.username) {
61 location.hash = '#' + blerg.API.username
62 this.bubble('onNavigate');
64 this.bubble('onReload');
67 postFailed: function() {
68 alert('Could not post!');
70 postVisibilityUpdate: function(inSender, inEvent) {
71 if (inEvent.showing) {
73 // Need to reflow manually because this is hidden by default
74 this.$.toolbar.reflow();
76 this.$.postContent.focus();
77 if (inEvent.data && this.getData() == "") {
78 this.setData(inEvent.data);
79 this.$.postContent.node.setSelectionRange(inEvent.data.length, inEvent.data.length);
85 updatePreview: function(inSender, inEvent) {
86 this.$.preview.setContent(blerg.Util.blergFormat(this.getData()));
88 loggedIn: function() {
89 this.$.postButton.setDisabled(false);
90 this.$.loginReminder.hide();
92 loggedOut: function() {
93 this.$.postButton.setDisabled(true);
94 this.$.loginReminder.show();
96 loadHelp: function() {
97 if (this.$.helpContent.getContent() == '') {
98 var req = new enyo.Ajax({
99 url: baseURL + '/doc/post_help.html',
102 req.response(function(inSender, inResponse) {
103 this.$.helpContent.setContent(inResponse);
108 switchBottomPanel: function(inSender, inEvent) {
109 var active = inSender.getActive();
110 var index = inSender.children.indexOf(active);
111 this.$.bottomPanel.setIndex(index);