6 onPostVisibility: "postVisibilityUpdate",
10 resizePostContentTimeout: null,
12 {name: "helpContent", allowHtml: true, showing: false},
13 {style: "position: relative;", components: [
14 {tag: "h2", content: "What's on your mind?", style: "width: 75%;",},
15 {name: "showHelpLink", kind: "blerg.Link", onNavigate: "showHelp", content: "Help!", style: "position: absolute; right: 1pt; bottom: 1pt; font-weight: bold; font-size: large;"},
16 {name: "hideHelpLink", kind: "blerg.Link", onNavigate: "hideHelp", content: "Hide Help", style: "position: absolute; right: 1pt; bottom: 1pt; font-weight: bold; font-size: large;", showing: false}
18 {kind: "onyx.InputDecorator", components: [
19 {name: "postContent", classes: "content", kind: "onyx.TextArea", onkeydown: "resizePostContent", attributes: {tabindex: 4}}
21 {classes: "buttons", components: [
22 {name: "loginReminder", tag: "span", classes: "blerg-error", style: "margin-right: 8px; vertical-align: 60%;", content: "You must log in before posting."},
23 {kind: "onyx.Button", content: "Close", onclick: "closePost", classes: "onyx-negative", attributes: {tabindex: 6}},
24 {name: "postButton", kind: "onyx.Button", content: "Post", onclick: "doPost", classes: "onyx-affirmative", disabled: true, attributes: {tabindex: 5}}
26 {name: "api", kind: "blerg.API",
27 onPostSuccessful: "postSuccessful",
28 onPostFailed: "postFailed"}
31 this.inherited(arguments);
34 return this.$.postContent.getValue();
36 setData: function(inVal) {
37 this.$.postContent.setValue(inVal);
39 closePost: function() {
40 this.bubble('onPostVisibility', {showing: false});
43 this.$.api.post(this.getData());
45 postSuccessful: function() {
48 if (location.hash != '#' + blerg.API.username) {
49 qlink(blerg.API.username);
51 this.bubble('onReload');
54 postFailed: function() {
55 alert('Could not post!');
57 postVisibilityUpdate: function(inSender, inEvent) {
58 if (inEvent.showing) {
60 this.$.postContent.focus();
61 if (inEvent.data && this.getData() == "") {
62 this.setData(inEvent.data);
63 this.$.postContent.node.setSelectionRange(inEvent.data.length, inEvent.data.length);
69 resizePostContent: function(inSender, inEvent) {
70 if (this.resizePostContentTimeout)
71 clearTimeout(this.resizePostContentTimeout);
72 this.resizePostContentTimeout = setTimeout(function() {
73 var n = this.$.postContent.hasNode();
76 var c = this.getData();
77 var lines = Math.floor(c.length / (100 * (n.clientWidth / 1000))) + 1;
78 var m = c.match(/\r?\n/g);
82 this.$.postContent.setStyle("");
84 this.$.postContent.setStyle("height: " + (lines * 17) + "pt");
86 this.resizePostContentTimeout = null;
89 loggedIn: function() {
90 this.$.postButton.setDisabled(false);
91 this.$.loginReminder.hide();
93 loggedOut: function() {
94 this.$.postButton.setDisabled(true);
95 this.$.loginReminder.show();
97 showHelp: function() {
98 this.$.helpContent.show();
99 this.$.showHelpLink.hide();
100 this.$.hideHelpLink.show();
101 if (this.$.helpContent.getContent() == '') {
102 var req = new enyo.Ajax({
103 url: baseURL + '/doc/post_help.html',
106 req.response(function(inSender, inResponse) {
107 this.$.helpContent.setContent(inResponse);
112 hideHelp: function() {
113 this.$.helpContent.hide();
114 this.$.showHelpLink.show();
115 this.$.hideHelpLink.hide();