Skip to content
Extraits de code Groupes Projets
Valider 94ad9264 rédigé par danielgrippi's avatar danielgrippi Validation de Dennis Collinson
Parcourir les fichiers

DG DH; wip

parent 168d6cbd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
autocompleteListItemAvatar : _.template('<img src="<%= avatar %>" />'), autocompleteListItemAvatar : _.template('<img src="<%= avatar %>" />'),
autocompleteListItemIcon : _.template('<div class="icon <%= icon %>"></div>'), autocompleteListItemIcon : _.template('<div class="icon <%= icon %>"></div>'),
mentionsOverlay : _.template('<div class="mentions"><div></div></div>'), mentionsOverlay : _.template('<div class="mentions"><div></div></div>'),
mentionItemSyntax : _.template('@[<%= value %>](<%= type %>:<%= id %>)'), mentionItemSyntax : _.template('@[<%= name %>](<%= type %>:<%= id %>)'),
mentionItemHighlight : _.template('<strong><span><%= value %></span></strong>') mentionItemHighlight : _.template('<strong><span><%= name %></span></strong>')
} }
}; };
...@@ -104,15 +104,15 @@ ...@@ -104,15 +104,15 @@
var syntaxMessage = getInputBoxValue(); var syntaxMessage = getInputBoxValue();
_.each(mentionsCollection, function (mention) { _.each(mentionsCollection, function (mention) {
var textSyntax = settings.templates.mentionItemSyntax({ value : mention.value, type : 'contact', id : mention.id }); var textSyntax = settings.templates.mentionItemSyntax({ name : mention.name, type : 'contact', id : mention.id, mention : mention });
syntaxMessage = syntaxMessage.replace(mention.value, textSyntax); syntaxMessage = syntaxMessage.replace(mention.name, textSyntax);
}); });
var mentionText = utils.htmlEncode(syntaxMessage); var mentionText = utils.htmlEncode(syntaxMessage);
_.each(mentionsCollection, function (mention) { _.each(mentionsCollection, function (mention) {
var textSyntax = settings.templates.mentionItemSyntax({ value : utils.htmlEncode(mention.value), type : 'contact', id : mention.id }); var textSyntax = settings.templates.mentionItemSyntax({ name : utils.htmlEncode(mention.name), type : 'contact', id : mention.id, mention : mention });
var textHighlight = settings.templates.mentionItemHighlight({ value : utils.htmlEncode(mention.value) }); var textHighlight = settings.templates.mentionItemHighlight({ name : utils.htmlEncode(mention.name), mention : mention });
mentionText = mentionText.replace(textSyntax, textHighlight); mentionText = mentionText.replace(textSyntax, textHighlight);
}); });
...@@ -132,12 +132,12 @@ ...@@ -132,12 +132,12 @@
var inputText = getInputBoxValue(); var inputText = getInputBoxValue();
mentionsCollection = _.reject(mentionsCollection, function (mention, index) { mentionsCollection = _.reject(mentionsCollection, function (mention, index) {
return !mention.value || inputText.indexOf(mention.value) == -1; return !mention.name || inputText.indexOf(mention.name) == -1;
}); });
mentionsCollection = _.compact(mentionsCollection); mentionsCollection = _.compact(mentionsCollection);
} }
function addMention(value, id, type) { function addMention(mention) {
var currentMessage = getInputBoxValue(); var currentMessage = getInputBoxValue();
// Using a regex to figure out positions // Using a regex to figure out positions
...@@ -149,15 +149,11 @@ ...@@ -149,15 +149,11 @@
var start = currentMessage.substr(0, startCaretPosition); var start = currentMessage.substr(0, startCaretPosition);
var end = currentMessage.substr(currentCaretPosition, currentMessage.length); var end = currentMessage.substr(currentCaretPosition, currentMessage.length);
var startEndIndex = (start + value).length; var startEndIndex = (start + mention.name).length;
var updatedMessageText = start + value + end; var updatedMessageText = start + mention.name + end;
mentionsCollection.push({ mentionsCollection.push(mention);
id : id,
type : type,
value : value
});
// Cleaning before inserting the value, otherwise auto-complete would be triggered with "old" inputbuffer // Cleaning before inserting the value, otherwise auto-complete would be triggered with "old" inputbuffer
resetBuffer(); resetBuffer();
...@@ -180,7 +176,7 @@ ...@@ -180,7 +176,7 @@
function onAutoCompleteItemClick(e) { function onAutoCompleteItemClick(e) {
var elmTarget = $(this); var elmTarget = $(this);
addMention(elmTarget.attr('data-display'), elmTarget.attr('data-ref-id'), elmTarget.attr('data-ref-type')); addMention(elmTarget.data("mention"));
return false; return false;
} }
...@@ -295,10 +291,12 @@ ...@@ -295,10 +291,12 @@
'content' : utils.highlightTerm(utils.htmlEncode((item.name)), query) 'content' : utils.highlightTerm(utils.htmlEncode((item.name)), query)
})); }));
if (index === 0) { if (index === 0) {
selectAutoCompleteItem(elmListItem); selectAutoCompleteItem(elmListItem);
} }
elmListItem.data("mention", item);
if (settings.showAvatars) { if (settings.showAvatars) {
var elmIcon; var elmIcon;
...@@ -344,6 +342,7 @@ ...@@ -344,6 +342,7 @@
}, },
reset : function () { reset : function () {
debugger;
elmInputBox.val(''); elmInputBox.val('');
mentionsCollection = []; mentionsCollection = [];
updateValues(); updateValues();
......
...@@ -70,13 +70,14 @@ ...@@ -70,13 +70,14 @@
bottom: 0; bottom: 0;
color: white; color: white;
font-size: 14px; font-size: 14px;
left: 1px; font-family: Arial, Helvetica, sans-serif;
left: 4px;
line-height: normal; line-height: normal;
overflow: hidden; overflow: hidden;
padding: 6px 0px 3px; padding: 6px 0px 3px;
position: absolute; position: absolute;
right: 0; right: 0;
top: -1px; top: -2px;
white-space: pre-wrap; white-space: pre-wrap;
word-wrap: break-word; word-wrap: break-word;
...@@ -85,9 +86,9 @@ ...@@ -85,9 +86,9 @@
white-space: pre-wrap; white-space: pre-wrap;
width: 100%; width: 100%;
strong { background: #d8dfea; } strong {
background: #d8dfea;
em { font-weight: normal;
} }
} }
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter