From 9534f4b0cf441d9d188f789386daebc14bb0b753 Mon Sep 17 00:00:00 2001 From: Bartosz Kostrowiecki Date: Fri, 24 Feb 2017 12:55:59 +0100 Subject: [PATCH 1/3] Adds conserveTriggerChar to options --- jquery.mentionsInput.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/jquery.mentionsInput.js b/jquery.mentionsInput.js index e75bb0a..607579f 100644 --- a/jquery.mentionsInput.js +++ b/jquery.mentionsInput.js @@ -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 }, @@ -219,7 +220,7 @@ hideAutoComplete(); // Mentions and syntax message - var updatedMessageText = start + mention.value + ' ' + end; + var updatedMessageText = start + (settings.conserveTriggerChar ? settings.triggerChar : '') + mention.value + ' ' + end; elmInputBox.val(updatedMessageText); //Set the value to the txt area elmInputBox.trigger('mention'); updateValues(); From 127d374359f7843df63d053dff7aac158800feec Mon Sep 17 00:00:00 2001 From: Bartosz Kostrowiecki Date: Fri, 24 Feb 2017 13:10:30 +0100 Subject: [PATCH 2/3] Changes addMention function. Based on plugin settings the value is with triggerChar or without. --- jquery.mentionsInput.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jquery.mentionsInput.js b/jquery.mentionsInput.js index 607579f..d44249f 100644 --- a/jquery.mentionsInput.js +++ b/jquery.mentionsInput.js @@ -209,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 @@ -220,7 +224,7 @@ hideAutoComplete(); // Mentions and syntax message - var updatedMessageText = start + (settings.conserveTriggerChar ? settings.triggerChar : '') + mention.value + ' ' + end; + var updatedMessageText = start + mention.value + ' ' + end; elmInputBox.val(updatedMessageText); //Set the value to the txt area elmInputBox.trigger('mention'); updateValues(); From 28191a662bc8eef9b3154a5aff6d3d9adf305b4f Mon Sep 17 00:00:00 2001 From: Bartosz Kostrowiecki Date: Fri, 24 Feb 2017 13:26:21 +0100 Subject: [PATCH 3/3] Update docs. Fix #100 --- assets/style.css | 4 ++++ docs/assets/style.css | 4 ++++ docs/index.html | 8 ++++++++ index.html | 7 +++++++ 4 files changed, 23 insertions(+) diff --git a/assets/style.css b/assets/style.css index f86105f..be4ecfb 100644 --- a/assets/style.css +++ b/assets/style.css @@ -101,6 +101,10 @@ code { margin-left: 20px; } +code.inline { + margin-left: 0; +} + pre { font-size: 12px; padding: 2px 0 2px 12px; diff --git a/docs/assets/style.css b/docs/assets/style.css index f86105f..be4ecfb 100644 --- a/docs/assets/style.css +++ b/docs/assets/style.css @@ -101,6 +101,10 @@ code { margin-left: 20px; } +code.inline { + margin-left: 0; +} + pre { font-size: 12px; padding: 2px 0 2px 12px; diff --git a/docs/index.html b/docs/index.html index cfaa327..f1d24f6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -105,6 +105,14 @@

Configuration

mentions input field. + + + conserveTriggerChar + false + + If this option is true, the triggerChar will be included into mention text. + + minChars 2 diff --git a/index.html b/index.html index 3ec97ac..2e01cc3 100644 --- a/index.html +++ b/index.html @@ -106,6 +106,13 @@

Configuration

mentions input field. + + conserveTriggerChar + false + + If this option is true, the triggerChar will be included into mention text. + + minChars 2