EditableContent: trigger edit/open events
This commit is contained in:
parent
90d8661641
commit
65ecc61112
1 changed files with 6 additions and 4 deletions
|
@ -145,7 +145,10 @@ Ox.EditableContent = function(options, self) {
|
||||||
}
|
}
|
||||||
self.options.editing = true;
|
self.options.editing = true;
|
||||||
that.gainFocus();
|
that.gainFocus();
|
||||||
setTimeout(updateSelection, 50);
|
setTimeout(updateSelection);
|
||||||
|
that.triggerEvent('edit');
|
||||||
|
} else if (!self.options.editable) {
|
||||||
|
that.triggerEvent('open');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,11 +204,10 @@ Ox.EditableContent = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSelection() {
|
function updateSelection() {
|
||||||
var range, selection;
|
var range = document.createRange(),
|
||||||
that.$element[0].focus();
|
|
||||||
selection = window.getSelection();
|
selection = window.getSelection();
|
||||||
|
that.$element[0].focus();
|
||||||
selection.removeAllRanges();
|
selection.removeAllRanges();
|
||||||
range = document.createRange();
|
|
||||||
range.selectNodeContents(that.$element[0]);
|
range.selectNodeContents(that.$element[0]);
|
||||||
selection.addRange(range);
|
selection.addRange(range);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
|
Loading…
Reference in a new issue