X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjssrc%2Fblerg%2FPost.js;h=b4ab559b6b00a3f44d7c0b40d5be5b55c2e8c801;hb=HEAD;hp=2aa7c3a7a3a7f66462cc7726204c25ab7b320a07;hpb=f3923c00ac2967a36685d35fa42224538c6a2d79;p=blerg.git diff --git a/www/jssrc/blerg/Post.js b/www/jssrc/blerg/Post.js index 2aa7c3a..b4ab559 100644 --- a/www/jssrc/blerg/Post.js +++ b/www/jssrc/blerg/Post.js @@ -5,29 +5,32 @@ enyo.kind({ handlers: { onPostVisibility: "postVisibilityUpdate", onLogin: "loggedIn", - onLogout: "loggedOut" + onLogout: "loggedOut", + onkeydown: "keyHandler" }, components: [ {tag: "h2", content: "What's on your mind?"}, {kind: "onyx.InputDecorator", alwaysLooksFocused: true, classes: "content-decorator", fit: true, components: [ {name: "postContent", kind: "onyx.TextArea", classes: "content", onkeyup: "updatePreview", attributes: {tabindex: 4}} ]}, - {name: "toolbar", kind: "FittableColumns", classes: "toolbar", components: [ - {classes: "switcher", components: [ - {kind: "onyx.RadioGroup", onActivate: "switchBottomPanel", components: [ - {content: "Replying to"}, - {content: "Preview"}, - {content: "Help"} - ]} - ]}, + {name: "toolbar", classes: "toolbar", components: [ {classes: "buttons", fit: true, components: [ {name: "loginReminder", tag: "span", classes: "blerg-error", style: "margin-right: 8px", content: "You must log in before posting."}, {kind: "onyx.Button", content: "Close", onclick: "closePost", classes: "onyx-negative", attributes: {tabindex: 6}}, {name: "postButton", kind: "onyx.Button", content: "Post", onclick: "doPost", classes: "onyx-affirmative", disabled: true, attributes: {tabindex: 5}} ]}, + {classes: "switcher", components: [ + {kind: "onyx.RadioGroup", onActivate: "switchBottomPanel", components: [ + {name: "replyButton", content: "Replying to", showing: false}, + {name: "previewButton", content: "Preview"}, + {content: "Help"} + ]} + ]} ]}, {name: "bottomPanel", kind: "Panels", classes: "bottom-panel", draggable: false, fit: true, components: [ - {content: "In reply to:"}, + {kind: "Scroller", components: [ + {name: "replyView", classes: "record", allowHtml: true}, + ]}, {kind: "Scroller", components: [ {name: "preview", classes: "record", allowHtml: true}, ]}, @@ -70,17 +73,35 @@ enyo.kind({ postVisibilityUpdate: function(inSender, inEvent) { if (inEvent.showing) { this.show(); - // Need to reflow manually because this is hidden by default - this.$.toolbar.reflow(); - this.reflow(); this.$.postContent.focus(); + if (inEvent.data && this.getData() == "") { this.setData(inEvent.data); this.$.postContent.node.setSelectionRange(inEvent.data.length, inEvent.data.length); + this.updatePreview(); } + + if (inEvent.replyto) { + this.$.replyButton.show(); + this.$.replyButton.setActive(true); + this.$.replyView.setContent(inEvent.replyto); + } else { + this.$.replyButton.hide(); + this.$.previewButton.setActive(true); + } + + // Need to reflow manually because this is hidden by default + this.$.toolbar.reflow(); + this.reflow(); } else { - this.hide(); + this.$.postContent.node.blur(); + setTimeout(function() { + this.hide(); + this.removeClass('exit'); + }.bind(this), 500); } + this.addRemoveClass('enter', inEvent.showing); + this.addRemoveClass('exit', !inEvent.showing); }, updatePreview: function(inSender, inEvent) { this.$.preview.setContent(blerg.Util.blergFormat(this.getData())); @@ -113,4 +134,9 @@ enyo.kind({ this.loadHelp(); } }, + keyHandler: function(inSender, inEvent) { + if (inEvent.which == 27) { + this.closePost(); + } + } });