diff --git a/app/views/status_messages/new.html.haml b/app/views/status_messages/new.html.haml index f6cb104bc856969380ae5a52c6851e4159dc8d19..ba0cfb603bcb406ed4a2edc224cfb6ea40c1bddb 100644 --- a/app/views/status_messages/new.html.haml +++ b/app/views/status_messages/new.html.haml @@ -1,19 +1,15 @@ -# Copyright (c) 2010-2011, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - - = javascript_include_tag "publisher.js" :javascript - $(document).ready(function() - { - var person = {name: '#{@person.name}', handle: '#{@person.diaspora_handle}' }; - Publisher.autocompletion.onSelect($("#status_message_fake_text"),person,'#{@person.name}'); - $("#publisher #status_message_fake_text").val(function(index, value){ return value + " " }); - $("#publisher").bind('ajax:success', function(){location.reload();}); - Publisher.bookmarklet = true; - }); + Mentions.options.prefillMention = #{@person.to_json}; + + $(function() { + $("#publisher").bind('ajax:success', function(){ location.reload(); }); + Publisher.bookmarklet = true; + }); #new_status_message_pane .span-15.last diff --git a/config/assets.yml b/config/assets.yml index a98446b21ad1c03c79ece74ef659ab6c2c125bfe..72b759643473c178c7956c13f3a66423f3f236b5 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -76,6 +76,10 @@ javascripts: - public/javascripts/aspect-edit-pane.js - public/javascripts/fileuploader-custom.js people: + - public/javascripts/aspect-edit-pane.js + - public/javascripts/fileuploader-custom.js + people: + - public/javascripts/vendor/jquery.autoSuggest.custom.js - public/javascripts/vendor/jquery.autoSuggest.custom.js - public/javascripts/aspect-edit-pane.js photos: diff --git a/public/javascripts/mentions.js b/public/javascripts/mentions.js index 2f38130d40de83eb41abad08786d69cab648f395..f9f9d5c025a7a902ed19089f9581912f0bc135c2 100644 --- a/public/javascripts/mentions.js +++ b/public/javascripts/mentions.js @@ -1,15 +1,12 @@ var Mentions = { initialize: function(mentionsInput) { - Mentions.fetchContacts(function(data) { + mentionsInput.mentionsInput(Mentions.options); + + $.getJSON($(".selected_contacts_link").attr("href"), function(data) { Mentions.contacts = data; - mentionsInput.mentionsInput(Mentions.options); }); }, - fetchContacts: function(callback) { - $.getJSON($(".selected_contacts_link").attr("href"), callback); - }, - options: { elastic: false, diff --git a/public/javascripts/vendor/jquery.mentionsInput.js b/public/javascripts/vendor/jquery.mentionsInput.js index 789dfd2ab500adff950a33ae40ff9d4f5d8c685a..a61746ac6e3893621b49be82cc8631ad347692d2 100644 --- a/public/javascripts/vendor/jquery.mentionsInput.js +++ b/public/javascripts/vendor/jquery.mentionsInput.js @@ -64,7 +64,7 @@ var elmInputBox, elmInputWrapper, elmAutocompleteList, elmWrapperBox, elmMentionsOverlay, elmActiveAutoCompleteItem; var mentionsCollection = []; var inputBuffer = []; - var currentDataQuery; + var currentDataQuery = ''; function initTextarea() { elmInputBox = $(input); @@ -329,6 +329,10 @@ initTextarea(); initAutocomplete(); initMentionsOverlay(); + + if(options.prefillMention) { + addMention(options.prefillMention); + } }, val : function (callback) {