Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/conserve trigger char in output #167

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ code {
margin-left: 20px;
}

code.inline {
margin-left: 0;
}

pre {
font-size: 12px;
padding: 2px 0 2px 12px;
Expand Down
4 changes: 4 additions & 0 deletions docs/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ code {
margin-left: 20px;
}

code.inline {
margin-left: 0;
}

pre {
font-size: 12px;
padding: 2px 0 2px 12px;
Expand Down
8 changes: 8 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ <h2>Configuration</h2>
mentions input field.
</td>
</tr>
<tr>
<tr>
<td><b>conserveTriggerChar</b></td>
<td><tt>false</tt></td>
<td class="definition">
If this option is true, the <code class="inline">triggerChar</code> will be included into mention text.
</td>
</tr>
<tr>
<td><b>minChars</b></td>
<td><tt>2</tt></td>
Expand Down
7 changes: 7 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ <h2>Configuration</h2>
mentions input field.
</td>
</tr>
<tr>
<td><b>conserveTriggerChar</b></td>
<td><tt>false</tt></td>
<td class="definition">
If this option is true, the <code class="inline">triggerChar</code> will be included into mention text.
</td>
</tr>
<tr>
<td><b>minChars</b></td>
<td><tt>2</tt></td>
Expand Down
21 changes: 13 additions & 8 deletions jquery.mentionsInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@

//Default settings
var defaultSettings = {
triggerChar : '@', //Char that respond to event
onDataRequest : $.noop, //Function where we can search the data
minChars : 2, //Minimum chars to fire the event
allowRepeat : false, //Allow repeat mentions
showAvatars : true, //Show the avatars
elastic : true, //Grow the textarea automatically
defaultValue : '',
onCaret : false,
triggerChar : '@', //Char that respond to event
onDataRequest : $.noop, //Function where we can search the data
minChars : 2, //Minimum chars to fire the event
allowRepeat : false, //Allow repeat mentions
showAvatars : true, //Show the avatars
elastic : true, //Grow the textarea automatically
defaultValue : '',
onCaret : false,
conserveTriggerChar : false,
classes : {
autoCompleteItemActive : "active" //Classes to apply in each item
},
Expand Down Expand Up @@ -208,6 +209,10 @@
var end = currentMessage.substr(currentCaretPosition, currentMessage.length);
var startEndIndex = (start + mention.value).length + 1;

if (settings.conserveTriggerChar) {
mention.value = settings.triggerChar + mention.value;
}

// See if there's the same mention in the list
if( !_.find(mentionsCollection, function (object) { return object.id == mention.id; }) ) {
mentionsCollection.push(mention);//Add the mention to mentionsColletions
Expand Down