diff --git a/Changelog.md b/Changelog.md index 71826ff7d..e8aae35ce 100644 --- a/Changelog.md +++ b/Changelog.md @@ -33,7 +33,7 @@ bind to an UNIX socket at `unix:tmp/diaspora.sock`. Please change your local * Use a fixed width for the mobile drawer [#6057](https://github.com/diaspora/diaspora/pull/6057) * Replace jquery.autoresize with autosize [#6104](https://github.com/diaspora/diaspora/pull/6104) * Improve mobile conversation design [#6087](https://github.com/diaspora/diaspora/pull/6087) -* Replace remaining faceboxes with Bootstrap modals [#6106](https://github.com/diaspora/diaspora/pull/6106) +* Replace remaining faceboxes with Bootstrap modals [#6106](https://github.com/diaspora/diaspora/pull/6106) [#6161](https://github.com/diaspora/diaspora/pull/6161) * Rewrite header using Bootstrap 3 [#6109](https://github.com/diaspora/diaspora/pull/6109) [#6130](https://github.com/diaspora/diaspora/pull/6130) [#6132](https://github.com/diaspora/diaspora/pull/6132) * Use upstream CSS mappings for Entypo [#6158](https://github.com/diaspora/diaspora/pull/6158) diff --git a/app/assets/javascripts/app/pages/contacts.js b/app/assets/javascripts/app/pages/contacts.js index a213a0d1c..b3675af6a 100644 --- a/app/assets/javascripts/app/pages/contacts.js +++ b/app/assets/javascripts/app/pages/contacts.js @@ -8,7 +8,8 @@ app.pages.Contacts = Backbone.View.extend({ "click #contacts_visibility_toggle" : "toggleContactVisibility", "click #chat_privilege_toggle" : "toggleChatPrivilege", "click #change_aspect_name" : "showAspectNameForm", - "keyup #contact_list_search" : "searchContactList" + "keyup #contact_list_search" : "searchContactList", + "click .conversation_button": "showMessageModal" }, initialize: function(opts) { @@ -77,6 +78,10 @@ app.pages.Contacts = Backbone.View.extend({ this.stream.search($(e.target).val()); }, + showMessageModal: function(){ + app.helpers.showModal("#conversationModal"); + }, + setupAspectSorting: function() { $("#aspect_nav .list-group").sortable({ items: "a.aspect[data-aspect-id]", diff --git a/app/assets/javascripts/app/views/aspect_create_view.js b/app/assets/javascripts/app/views/aspect_create_view.js index 0ec50afa2..fa9de946c 100644 --- a/app/assets/javascripts/app/views/aspect_create_view.js +++ b/app/assets/javascripts/app/views/aspect_create_view.js @@ -4,7 +4,8 @@ app.views.AspectCreate = app.views.Base.extend({ templateName: "aspect_create_modal", events: { - "click .btn.btn-primary": "createAspect" + "click .btn.btn-primary": "createAspect", + "keypress input#aspect_name": "inputKeypress" }, initialize: function(opts) { @@ -30,6 +31,13 @@ app.views.AspectCreate = app.views.Base.extend({ return this.$("#aspect_name").val(); }, + inputKeypress: function(evt) { + if(evt.which === 13) { + evt.preventDefault(); + this.createAspect(); + } + }, + createAspect: function() { var aspect = new app.models.Aspect({ "person_id": this._personId, diff --git a/app/helpers/contacts_helper.rb b/app/helpers/contacts_helper.rb index a9ff48b92..7d3154bcb 100644 --- a/app/helpers/contacts_helper.rb +++ b/app/helpers/contacts_helper.rb @@ -13,8 +13,7 @@ module ContactsHelper content_tag :i, nil, class: "entypo-mail contacts-header-icon", - title: t("contacts.index.start_a_conversation"), - data: {toggle: "modal", target: "#conversationModal"} + title: t("contacts.index.start_a_conversation") end end end diff --git a/spec/javascripts/app/views/aspect_create_view_spec.js b/spec/javascripts/app/views/aspect_create_view_spec.js index 96eabfe7f..1961cff08 100644 --- a/spec/javascripts/app/views/aspect_create_view_spec.js +++ b/spec/javascripts/app/views/aspect_create_view_spec.js @@ -40,6 +40,24 @@ describe("app.views.AspectCreate", function() { }); }); + describe("#inputKeypress", function() { + beforeEach(function() { + this.view.render(); + spyOn(this.view, "createAspect"); + }); + + it("should call createAspect if the enter key was pressed", function() { + var e = $.Event("keypress", { which: 13 }); + this.view.inputKeypress(e); + expect(this.view.createAspect).toHaveBeenCalled(); + }); + + it("shouldn't call createAspect if another key was pressed", function() { + var e = $.Event("keypress", { which: 42 }); + this.view.inputKeypress(e); + expect(this.view.createAspect).not.toHaveBeenCalled(); + }); + }); describe("#createAspect", function() { beforeEach(function() {