diff --git a/app/assets/javascripts/app/helpers/modal_helper.js b/app/assets/javascripts/app/helpers/modal_helper.js index 77e84034e..01aaac4b7 100644 --- a/app/assets/javascripts/app/helpers/modal_helper.js +++ b/app/assets/javascripts/app/helpers/modal_helper.js @@ -7,6 +7,7 @@ modalBody.load(url, function(){ $(id).find("#modalWaiter").remove(); + $(id).trigger("modal:loaded"); }); }; })(); diff --git a/app/assets/javascripts/app/views/profile_header_view.js b/app/assets/javascripts/app/views/profile_header_view.js index 3b63be3ae..906736895 100644 --- a/app/assets/javascripts/app/views/profile_header_view.js +++ b/app/assets/javascripts/app/views/profile_header_view.js @@ -15,6 +15,8 @@ app.views.ProfileHeader = app.views.Base.extend({ initialize: function(opts) { this.photos = _.has(opts, 'photos') ? opts.photos : null; this.contacts = _.has(opts, 'contacts') ? opts.contacts : null; + $("#mentionModal").on("modal:loaded", this.mentionModalLoaded.bind(this)); + $("#mentionModal").on("hidden.bs.modal", this.mentionModalHidden); }, presenter: function() { @@ -52,10 +54,30 @@ app.views.ProfileHeader = app.views.Base.extend({ return (this.contacts && this.contacts > 0); }, - showMentionModal: function(){ + showMentionModal: function() { app.helpers.showModal("#mentionModal"); }, + mentionModalLoaded: function() { + app.publisher = new app.views.Publisher({ + standalone: true, + prefillMention: _.extend({handle: this.model.get("diaspora_id")}, this.model.attributes) + }); + app.publisher.open(); + $("#publisher").bind("ajax:success", function() { + $("#mentionModal").modal("hide"); + app.publisher.clear(); + app.publisher.remove(); + location.reload(); + }); + }, + + mentionModalHidden: function() { + app.publisher.clear(); + app.publisher.remove(); + $("#mentionModal .modal-body").empty(); + }, + showMessageModal: function(){ app.helpers.showModal("#conversationModal"); }, diff --git a/app/views/status_messages/new.html.haml b/app/views/status_messages/new.html.haml index f1d7f9a8a..5eaf54d9d 100644 --- a/app/views/status_messages/new.html.haml +++ b/app/views/status_messages/new.html.haml @@ -4,16 +4,3 @@ :selected_aspects => @aspects_with_person, :person => @person } -:javascript - $(function() { - app.publisher = new app.views.Publisher({ - standalone: true, - prefillMention: #{json_escape @person.to_json} - }); - app.publisher.open(); - $("#publisher").bind('ajax:success', function(){ - $("#mentionModal").modal('hide'); - app.publisher.clear(); - location.reload(); - }); - });