mentions now work for stream publisher

This commit is contained in:
Dan Hansen 2012-01-16 13:01:04 -06:00 committed by Dennis Collinson
parent 94ad9264f1
commit 3b4e3fd87e
2 changed files with 14 additions and 16 deletions

View file

@ -54,7 +54,7 @@ var Publisher = {
clear: function(){ clear: function(){
$("#photodropzone").find('li').remove(); $("#photodropzone").find('li').remove();
$("#publisher textarea").removeClass("with_attachments") Publisher.input().removeClass("with_attachments")
.css('paddingBottom', '') .css('paddingBottom', '')
.mentionsInput("reset"); .mentionsInput("reset");
}, },

View file

@ -100,11 +100,12 @@
elmMentionsOverlay.prependTo(elmWrapperBox); elmMentionsOverlay.prependTo(elmWrapperBox);
} }
function updateValues() { function updateNames() {
var syntaxMessage = getInputBoxValue(); var syntaxMessage = getInputBoxValue();
_.each(mentionsCollection, function (mention) { _.each(mentionsCollection, function (mention) {
var textSyntax = settings.templates.mentionItemSyntax({ name : mention.name, type : 'contact', id : mention.id, mention : mention }); var textSyntax = settings.templates.mentionItemSyntax({ name : mention.name, type : 'contact', id : mention.id, mention: mention });
syntaxMessage = syntaxMessage.replace(mention.name, textSyntax); syntaxMessage = syntaxMessage.replace(mention.name, textSyntax);
}); });
@ -162,7 +163,7 @@
// Mentions & syntax message // Mentions & syntax message
elmInputBox.val(updatedMessageText); elmInputBox.val(updatedMessageText);
updateValues(); updateNames();
// Set correct focus and selection // Set correct focus and selection
elmInputBox.focus(); elmInputBox.focus();
@ -174,9 +175,9 @@
} }
function onAutoCompleteItemClick(e) { function onAutoCompleteItemClick(e) {
var elmTarget = $(this); var mention = $(this).data("mention");
addMention(elmTarget.data("mention")); addMention(mention);
return false; return false;
} }
@ -186,7 +187,7 @@
} }
function onInputBoxInput(e) { function onInputBoxInput(e) {
updateValues(); updateNames();
updateMentionsCollection(); updateMentionsCollection();
hideAutoComplete(); hideAutoComplete();
@ -270,9 +271,9 @@
elmAutocompleteList.show(); elmAutocompleteList.show();
// Filter items that has already been mentioned // Filter items that has already been mentioned
var mentionValues = _.pluck(mentionsCollection, 'value'); var mentionedNames = _.pluck(mentionsCollection, 'name');
results = _.reject(results, function (item) { results = _.reject(results, function (item) {
return _.include(mentionValues, item.name); return _.include(mentionedNames, item.name);
}); });
if (!results.length) { if (!results.length) {
@ -289,14 +290,12 @@
'display' : utils.htmlEncode(item.name), 'display' : utils.htmlEncode(item.name),
'type' : utils.htmlEncode(item.type), 'type' : utils.htmlEncode(item.type),
'content' : utils.highlightTerm(utils.htmlEncode((item.name)), query) 'content' : utils.highlightTerm(utils.htmlEncode((item.name)), query)
})); })).data('mention', item);
if (index === 0) { if (index === 0) {
selectAutoCompleteItem(elmListItem); selectAutoCompleteItem(elmListItem);
} }
elmListItem.data("mention", item);
if (settings.showAvatars) { if (settings.showAvatars) {
var elmIcon; var elmIcon;
@ -342,10 +341,9 @@
}, },
reset : function () { reset : function () {
debugger;
elmInputBox.val(''); elmInputBox.val('');
mentionsCollection = []; mentionsCollection = [];
updateValues(); updateNames();
}, },
getMentions : function (callback) { getMentions : function (callback) {