From 65ecc611124a7d98cddeac82285bcaa0c75b2150 Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 27 Feb 2013 10:45:02 +0000 Subject: [PATCH] EditableContent: trigger edit/open events --- source/Ox.UI/js/Form/EditableContent.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/Ox.UI/js/Form/EditableContent.js b/source/Ox.UI/js/Form/EditableContent.js index fa3595f5..7f611fd7 100644 --- a/source/Ox.UI/js/Form/EditableContent.js +++ b/source/Ox.UI/js/Form/EditableContent.js @@ -145,7 +145,10 @@ Ox.EditableContent = function(options, self) { } self.options.editing = true; 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() { - var range, selection; + var range = document.createRange(), + selection = window.getSelection(); that.$element[0].focus(); - selection = window.getSelection(); selection.removeAllRanges(); - range = document.createRange(); range.selectNodeContents(that.$element[0]); selection.addRange(range); setTimeout(function() {