diff --git a/Changelog.md b/Changelog.md index 9a2d8affd..6b2163418 100644 --- a/Changelog.md +++ b/Changelog.md @@ -115,6 +115,7 @@ by them self. * Remove unnecessary dotted CSS borders. [#2940](https://github.com/diaspora/diaspora/issues/2940) * Fix default image url in profiles table. [#3795](https://github.com/diaspora/diaspora/issues/3795) * Fix mobile buttons are only clickable when scrolled to the top. [#4102](https://github.com/diaspora/diaspora/issues/4102) +* Fix regression in bookmarklet causing uneditable post contents. [#4057](https://github.com/diaspora/diaspora/issues/4057) ## Features @@ -126,7 +127,8 @@ by them self. * Add multiphoto for mobile post. [#4065](https://github.com/diaspora/diaspora/issues/4065) * Add hotkeys to navigate in stream [#4089](https://github.com/diaspora/diaspora/pull/4089) * Add a brief explanatory text about external services connections to services index page [#3064](https://github.com/diaspora/diaspora/issues/3064) -* Shift + Enter will submit the comment. [#4096](github.com/diaspora/diaspora/pull/4096) +* Add a preview for posts in the stream [#4099](https://github.com/diaspora/diaspora/issues/4099) +* Add shortcut key Shift to submit comments and publish posts. [#4096](github.com/diaspora/diaspora/pull/4096) # 0.0.3.4 diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 0c00fc2d7..3776b6048 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -15,6 +15,7 @@ app.views.Publisher = Backbone.View.extend(_.extend( el : "#publisher", events : { + "keydown #status_message_fake_text" : "keyDown", "focus textarea" : "open", "click #hide_publisher" : "clear", "submit form" : "createStatusMessage", @@ -88,7 +89,7 @@ app.views.Publisher = Backbone.View.extend(_.extend( // clear state this.clear(); }, - + createPostPreview : function(evt) { if(evt){ evt.preventDefault(); } @@ -166,6 +167,14 @@ app.views.Publisher = Backbone.View.extend(_.extend( } }, + keyDown : function(evt) { + if( evt.keyCode == 13 && evt.shiftKey ) { + this.$("form").submit(); + this.open(); + return false; + } + }, + clear : function() { // clear text(s) this.el_input.val(''); @@ -205,7 +214,6 @@ app.views.Publisher = Backbone.View.extend(_.extend( // fetch contacts for mentioning Mentions.fetchContacts(); - return this; }, diff --git a/spec/javascripts/app/views/publisher_view_spec.js b/spec/javascripts/app/views/publisher_view_spec.js index fd2e51783..e40c66466 100644 --- a/spec/javascripts/app/views/publisher_view_spec.js +++ b/spec/javascripts/app/views/publisher_view_spec.js @@ -106,6 +106,22 @@ describe("app.views.Publisher", function() { expect(this.view.$("input[name='photos[]']").length).toBe(0); }) }); + + describe("publishing a post with keyboard", function(){ + it("should submit the form when shift+enter is pressed", function(){ + this.view.render(); + var form = this.view.$("form") + var submitCallback = jasmine.createSpy().andReturn(false); + form.submit(submitCallback); + + var e = $.Event("keydown", { keyCode: 13 }); + e.shiftKey = true; + this.view.keyDown(e); + + expect(submitCallback).toHaveBeenCalled(); + expect($(this.view.el)).not.toHaveClass("closed"); + }) + }) }); context("#toggleService", function(){