mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
fixed auto complete for insertion in the middle, 6am commits FTW
This commit is contained in:
@@ -187,6 +187,40 @@
|
||||
|
||||
if ('undefined' !== typeof window) {
|
||||
window.utils = module.exports;
|
||||
|
||||
(function ($, undefined) {
|
||||
$.fn.getCursorPosition = function() {
|
||||
var el = $(this).get(0);
|
||||
var pos = 0;
|
||||
if('selectionStart' in el) {
|
||||
pos = el.selectionStart;
|
||||
} else if('selection' in document) {
|
||||
el.focus();
|
||||
var Sel = document.selection.createRange();
|
||||
var SelLength = document.selection.createRange().text.length;
|
||||
Sel.moveStart('character', -el.value.length);
|
||||
pos = Sel.text.length - SelLength;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
$.fn.selectRange = function(start, end) {
|
||||
if(!end) end = start;
|
||||
return this.each(function() {
|
||||
if (this.setSelectionRange) {
|
||||
this.focus();
|
||||
this.setSelectionRange(start, end);
|
||||
} else if (this.createTextRange) {
|
||||
var range = this.createTextRange();
|
||||
range.collapse(true);
|
||||
range.moveEnd('character', end);
|
||||
range.moveStart('character', start);
|
||||
range.select();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
}
|
||||
|
||||
})('undefined' === typeof module ? {
|
||||
|
||||
Reference in New Issue
Block a user