6 onPostVisibility: "postVisibilityUpdate",
10 resizePostContentTimeout: null,
12 {tag: "h2", content: "What's on your mind?"},
13 {kind: "onyx.InputDecorator", components: [
14 {name: "postContent", classes: "content", kind: "onyx.TextArea", onkeydown: "resizePostContent", attributes: {tabindex: 4}}
16 {classes: "buttons", components: [
17 {name: "loginReminder", tag: "span", classes: "blerg-error", style: "margin-right: 8px; vertical-align: 60%", content: "You must log in before posting."},
18 {kind: "onyx.Button", content: "Close", onclick: "closePost", classes: "onyx-negative", attributes: {tabindex: 6}},
19 {name: "postButton", kind: "onyx.Button", content: "Post", onclick: "doPost", classes: "onyx-affirmative", disabled: true, attributes: {tabindex: 5}}
21 {name: "api", kind: "blerg.API",
22 onPostSuccessful: "postSuccessful",
23 onPostFailed: "postFailed"}
26 this.inherited(arguments);
29 return this.$.postContent.getValue();
31 setData: function(inVal) {
32 this.$.postContent.setValue(inVal);
34 closePost: function() {
35 this.bubble('onPostVisibility', {showing: false});
38 this.$.api.post(this.getData());
40 postSuccessful: function() {
43 this.href = '#' + blerg.API.username;
45 postFailed: function() {
46 alert('Could not post!');
48 postVisibilityUpdate: function(inSender, inEvent) {
49 if (inEvent.showing) {
51 this.$.postContent.focus();
52 if (inEvent.data && this.getData() == "") {
53 this.setData(inEvent.data);
54 this.$.postContent.node.setSelectionRange(inEvent.data.length, inEvent.data.length);
60 resizePostContent: function(inSender, inEvent) {
61 if (this.resizePostContentTimeout)
62 clearTimeout(this.resizePostContentTimeout);
63 this.resizePostContentTimeout = setTimeout(function() {
64 var n = this.$.postContent.hasNode();
67 var c = this.getData();
68 var lines = Math.floor(c.length / (100 * (n.clientWidth / 1000))) + 1;
69 var m = c.match(/\r?\n/g);
73 this.$.postContent.setStyle("");
75 this.$.postContent.setStyle("height: " + (lines * 17) + "pt");
77 this.resizePostContentTimeout = null;
80 loggedIn: function() {
81 this.$.postButton.setDisabled(false);
82 this.$.loginReminder.hide();
84 loggedOut: function() {
85 this.$.postButton.setDisabled(true);
86 this.$.loginReminder.show();