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}}
23 this.inherited(arguments);
26 return this.$.postContent.getValue();
28 setData: function(inVal) {
29 this.$.postContent.setValue(inVal);
31 closePost: function() {
32 this.bubble('onPostVisibility', {showing: false});
35 this.bubble('onPost', {data: this.getData()});
37 postVisibilityUpdate: function(inSender, inEvent) {
38 if (inEvent.showing) {
40 this.$.postContent.focus();
41 if (inEvent.data && this.getData() == "") {
42 this.setData(inEvent.data);
43 this.$.postContent.node.setSelectionRange(inEvent.data.length, inEvent.data.length);
49 resizePostContent: function(inSender, inEvent) {
50 if (this.resizePostContentTimeout)
51 clearTimeout(this.resizePostContentTimeout);
52 this.resizePostContentTimeout = setTimeout(function() {
53 var n = this.$.postContent.hasNode();
56 var c = this.getData();
57 var lines = Math.floor(c.length / (100 * (n.clientWidth / 1000))) + 1;
58 var m = c.match(/\r?\n/g);
62 this.$.postContent.setStyle("");
64 this.$.postContent.setStyle("height: " + (lines * 17) + "pt");
66 this.resizePostContentTimeout = null;
69 loggedIn: function() {
70 this.$.postButton.setDisabled(false);
71 this.$.loginReminder.hide();
73 loggedOut: function() {
74 this.$.postButton.setDisabled(true);
75 this.$.loginReminder.show();