diff --git a/source/Ox.UI/js/Form/EditableContent.js b/source/Ox.UI/js/Form/EditableContent.js index 40640e5a..c238e43a 100644 --- a/source/Ox.UI/js/Form/EditableContent.js +++ b/source/Ox.UI/js/Form/EditableContent.js @@ -53,10 +53,10 @@ Ox.EditableContent = function(options, self) { self.$value = Ox.Element(self.options.type == 'span' ? '' : '
') .html(formatValue()) .on({ - blur: submit, + blur: self.options.submitOnBlur ? submit : blur, keydown: function(e) { if (self.options.editing) { - if (self.options.type == 'span' && e.keyCode == 13) { + if (e.keyCode == 13 && self.options.type == 'span') { submit(); return false; } else if (e.keyCode == 27) { @@ -69,11 +69,12 @@ Ox.EditableContent = function(options, self) { .appendTo(that); function blur() { - + Ox.print('BLUR!') } function cancel() { if (self.options.editing) { + Ox.print('CANCEL!') that.loseFocus(); self.options.editing = false; self.$value @@ -86,6 +87,7 @@ Ox.EditableContent = function(options, self) { function edit() { if (self.options.editable && !self.options.editing) { + Ox.print('EDIT!') var value = formatInputValue(); self.$value .addClass('OxEditableContentInput') @@ -141,11 +143,13 @@ Ox.EditableContent = function(options, self) { function submit() { if (self.options.editing) { + Ox.print('SUBMIT!') that.loseFocus(); self.options.editing = false; self.options.value = self.$value.text(); if (self.options.value.charCodeAt(0) == 160) { - self.options.value = ''; + // remove nbsp + self.options.value = self.options.value.substr(1); } self.$value .attr({contenteditable: false}) @@ -163,7 +167,7 @@ Ox.EditableContent = function(options, self) { range = document.createRange(); range.selectNodeContents(self.$value[0]); selection.addRange(range); - if (self.options.type != 'span') { + if (self.options.type == 'div') { setTimeout(function() { selection.collapseToEnd(); }, 0);