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 if (location.hash != '#' + blerg.API.username) {
44 qlink(blerg.API.username);
46 this.bubble('onReload');
49 postFailed: function() {
50 alert('Could not post!');
52 postVisibilityUpdate: function(inSender, inEvent) {
53 if (inEvent.showing) {
55 this.$.postContent.focus();
56 if (inEvent.data && this.getData() == "") {
57 this.setData(inEvent.data);
58 this.$.postContent.node.setSelectionRange(inEvent.data.length, inEvent.data.length);
64 resizePostContent: function(inSender, inEvent) {
65 if (this.resizePostContentTimeout)
66 clearTimeout(this.resizePostContentTimeout);
67 this.resizePostContentTimeout = setTimeout(function() {
68 var n = this.$.postContent.hasNode();
71 var c = this.getData();
72 var lines = Math.floor(c.length / (100 * (n.clientWidth / 1000))) + 1;
73 var m = c.match(/\r?\n/g);
77 this.$.postContent.setStyle("");
79 this.$.postContent.setStyle("height: " + (lines * 17) + "pt");
81 this.resizePostContentTimeout = null;
84 loggedIn: function() {
85 this.$.postButton.setDisabled(false);
86 this.$.loginReminder.hide();
88 loggedOut: function() {
89 this.$.postButton.setDisabled(true);
90 this.$.loginReminder.show();