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 {name: "replyButton", content: "Replying to", showing: false},
19 {name: "previewButton", content: "Preview"},
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 {kind: "Scroller", components: [
31 {name: "replyView", classes: "record", allowHtml: true},
33 {kind: "Scroller", components: [
34 {name: "preview", classes: "record", allowHtml: true},
36 {kind: "Scroller", components: [
37 {name: "helpContent", allowHtml: true},
40 {name: "api", kind: "blerg.API",
41 onPostSuccessful: "postSuccessful",
42 onPostFailed: "postFailed"}
45 this.inherited(arguments);
48 return this.$.postContent.getValue();
50 setData: function(inVal) {
51 this.$.postContent.setValue(inVal);
53 closePost: function() {
54 this.bubble('onPostVisibility', {showing: false});
57 this.$.api.post(this.getData());
59 postSuccessful: function() {
62 if (location.hash != '#' + blerg.API.username) {
63 location.hash = '#' + blerg.API.username
64 this.bubble('onNavigate');
66 this.bubble('onReload');
69 postFailed: function() {
70 alert('Could not post!');
72 postVisibilityUpdate: function(inSender, inEvent) {
73 if (inEvent.showing) {
75 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);
83 if (inEvent.replyto) {
84 this.$.replyButton.show();
85 this.$.replyButton.setActive(true);
86 this.$.replyView.setContent(inEvent.replyto);
88 this.$.replyButton.hide();
89 this.$.previewButton.setActive(true);
92 // Need to reflow manually because this is hidden by default
93 this.$.toolbar.reflow();
99 updatePreview: function(inSender, inEvent) {
100 this.$.preview.setContent(blerg.Util.blergFormat(this.getData()));
102 loggedIn: function() {
103 this.$.postButton.setDisabled(false);
104 this.$.loginReminder.hide();
106 loggedOut: function() {
107 this.$.postButton.setDisabled(true);
108 this.$.loginReminder.show();
110 loadHelp: function() {
111 if (this.$.helpContent.getContent() == '') {
112 var req = new enyo.Ajax({
113 url: baseURL + '/doc/post_help.html',
116 req.response(function(inSender, inResponse) {
117 this.$.helpContent.setContent(inResponse);
122 switchBottomPanel: function(inSender, inEvent) {
123 var active = inSender.getActive();
124 var index = inSender.children.indexOf(active);
125 this.$.bottomPanel.setIndex(index);