publisher does inline mentions and sets the cursor to the end of the newly inserted result
This commit is contained in:
parent
3efc31c68f
commit
6eafd73d2c
2 changed files with 6 additions and 7 deletions
|
|
@ -278,7 +278,6 @@ $.Autocompleter = function(input, options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function hideResultsNow() {
|
function hideResultsNow() {
|
||||||
var wasVisible = select.visible();
|
|
||||||
select.hide();
|
select.hide();
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
stopLoading();
|
stopLoading();
|
||||||
|
|
@ -298,9 +297,6 @@ $.Autocompleter = function(input, options) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (wasVisible)
|
|
||||||
// position cursor at end of input field
|
|
||||||
$.Autocompleter.Selection(input, input.value.length, input.value.length);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function receiveData(q, data) {
|
function receiveData(q, data) {
|
||||||
|
|
@ -390,6 +386,9 @@ $.Autocompleter.defaults = {
|
||||||
resultsClass: "ac_results",
|
resultsClass: "ac_results",
|
||||||
loadingClass: "ac_loading",
|
loadingClass: "ac_loading",
|
||||||
onSelect: function(input, data, formatted){
|
onSelect: function(input, data, formatted){
|
||||||
|
if (select.visible())
|
||||||
|
// position cursor at end of input field
|
||||||
|
$.Autocompleter.Selection(input, input.value.length, input.value.length);
|
||||||
input.val(formatted);
|
input.val(formatted);
|
||||||
},
|
},
|
||||||
minChars: 1,
|
minChars: 1,
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ var Publisher = {
|
||||||
onSelect : function(visibleInput, data, formatted) {
|
onSelect : function(visibleInput, data, formatted) {
|
||||||
var visibleCursorIndex = visibleInput[0].selectionStart;
|
var visibleCursorIndex = visibleInput[0].selectionStart;
|
||||||
var visibleLoc = Publisher.autocompletion.addMentionToInput(visibleInput, visibleCursorIndex, formatted);
|
var visibleLoc = Publisher.autocompletion.addMentionToInput(visibleInput, visibleCursorIndex, formatted);
|
||||||
|
$.Autocompleter.Selection(visibleInput[0], visibleLoc[1], visibleLoc[1]);
|
||||||
|
|
||||||
var hiddenCursorIndex = visibleCursorIndex + Publisher.autocompletion.mentionList.offsetFrom(visibleCursorIndex);
|
var hiddenCursorIndex = visibleCursorIndex + Publisher.autocompletion.mentionList.offsetFrom(visibleCursorIndex);
|
||||||
var hiddenLoc = Publisher.autocompletion.addMentionToInput(Publisher.hiddenInput(), hiddenCursorIndex, Publisher.autocompletion.hiddenMentionFromPerson(data));
|
var hiddenLoc = Publisher.autocompletion.addMentionToInput(Publisher.hiddenInput(), hiddenCursorIndex, Publisher.autocompletion.hiddenMentionFromPerson(data));
|
||||||
|
|
@ -126,13 +126,13 @@ var Publisher = {
|
||||||
var stringEnd = inputContent.slice(stringLoc[1]);
|
var stringEnd = inputContent.slice(stringLoc[1]);
|
||||||
|
|
||||||
input.val(stringStart + formatted + stringEnd);
|
input.val(stringStart + formatted + stringEnd);
|
||||||
return [stringStart.length, stringStart.length + stringLoc[1]]
|
return [stringStart.length, stringStart.length + formatted.length]
|
||||||
},
|
},
|
||||||
|
|
||||||
findStringToReplace: function(value, cursorIndex){
|
findStringToReplace: function(value, cursorIndex){
|
||||||
var atLocation = value.lastIndexOf('@', cursorIndex);
|
var atLocation = value.lastIndexOf('@', cursorIndex);
|
||||||
if(atLocation == -1){return [0,0];}
|
if(atLocation == -1){return [0,0];}
|
||||||
var nextAt = value.indexOf(' @', cursorIndex+1);
|
var nextAt = cursorIndex//value.indexOf(' @', cursorIndex+1);
|
||||||
|
|
||||||
if(nextAt == -1){nextAt = value.length;}
|
if(nextAt == -1){nextAt = value.length;}
|
||||||
return [atLocation, nextAt];
|
return [atLocation, nextAt];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue