took out some overrides out utils to a new overrides.js
parent
815e78339f
commit
b59c10a1e9
@ -0,0 +1,51 @@
|
||||
if ('undefined' !== typeof window) {
|
||||
|
||||
(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();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//http://stackoverflow.com/questions/511088/use-javascript-to-place-cursor-at-end-of-text-in-text-input-element
|
||||
$.fn.putCursorAtEnd = function() {
|
||||
return this.each(function() {
|
||||
$(this).focus();
|
||||
|
||||
if (this.setSelectionRange) {
|
||||
var len = $(this).val().length * 2;
|
||||
this.setSelectionRange(len, len);
|
||||
} else {
|
||||
$(this).val($(this).val());
|
||||
}
|
||||
this.scrollTop = 999999;
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery || {fn:{}});
|
||||
}
|
Loading…
Reference in New Issue