make collapseToEnd optional

This commit is contained in:
j 2013-09-26 21:35:28 +00:00
parent 6e6da8e000
commit 1246beb4da

View file

@ -12,6 +12,7 @@ Ox.EditableContent = function(options, self) {
var that = Ox.Element(options.type == 'textarea' ? '<div>' : '<span>', self)
.defaults({
clickLink: null,
collapseToEnd: true,
editable: true,
editing: false,
format: null,
@ -212,11 +213,13 @@ Ox.EditableContent = function(options, self) {
selection = window.getSelection();
that.$element[0].focus();
selection.removeAllRanges();
range.selectNodeContents(that.$element[0]);
selection.addRange(range);
setTimeout(function() {
selection.collapseToEnd();
});
if (self.options.collapseToEnd) {
range.selectNodeContents(that.$element[0]);
selection.addRange(range);
setTimeout(function() {
selection.collapseToEnd();
});
}
}
return that;