From 90d866164143df8d462cd6c67669ce6159173431 Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 27 Feb 2013 10:00:28 +0000 Subject: [PATCH] update EditableContent --- source/Ox.UI/js/Form/EditableContent.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/Ox.UI/js/Form/EditableContent.js b/source/Ox.UI/js/Form/EditableContent.js index e78d45de..fa3595f5 100644 --- a/source/Ox.UI/js/Form/EditableContent.js +++ b/source/Ox.UI/js/Form/EditableContent.js @@ -9,7 +9,7 @@ Ox.EditableContent = function(options, self) { : self.tooltip(e); } } - var that = Ox.Element(options.type == 'div' ? '
' : '', self) + var that = Ox.Element(options.type == 'textarea' ? '
' : '', self) .defaults({ clickLink: null, editable: true, @@ -21,7 +21,7 @@ Ox.EditableContent = function(options, self) { submitOnBlur: true, tags: null, tooltip: '', - type: 'span', + type: 'input', value: '' }) .options(options || {}) @@ -60,7 +60,7 @@ Ox.EditableContent = function(options, self) { }, keydown: function(e) { if (e.keyCode == 13) { - if (e.shiftKey || self.options.type == 'span') { + if (e.shiftKey || self.options.type == 'input') { submit(); } else { var selection = window.getSelection(), @@ -121,7 +121,7 @@ Ox.EditableContent = function(options, self) { that.removeClass('OxEditableContentInput') .attr({contenteditable: false}) .html(formatValue()); - if (self.options.type == 'span') { + if (self.options.type == 'input') { that.css({padding: 0}); } that.triggerEvent('cancel', {value: self.options.value}); @@ -139,19 +139,19 @@ Ox.EditableContent = function(options, self) { that.text(value); } else { that.text(''); - if (self.options.type == 'span') { + if (self.options.type == 'input') { that.css({padding: '0 2px'}); } } self.options.editing = true; that.gainFocus(); - setTimeout(updateSelection); + setTimeout(updateSelection, 50); } } function formatInputValue() { return Ox.decodeHTMLEntities( - self.options.type == 'span' + self.options.type == 'input' ? self.options.value : self.options.value.replace(//g, '\n\n') ); @@ -179,7 +179,7 @@ Ox.EditableContent = function(options, self) { that.text().replace(/\n\n+/g, '\0') ).replace(/\0/g, '\n\n').trim(); return ( - self.options.type == 'span' + self.options.type == 'input' ? Ox.encodeHTMLEntities(value) : Ox.sanitizeHTML(value, self.options.tags, self.options.replaceTags) ); @@ -193,7 +193,7 @@ Ox.EditableContent = function(options, self) { that.removeClass('OxEditableContentInput') .attr({contenteditable: false}) .html(formatValue()); - if (self.options.type == 'span') { + if (self.options.type == 'input') { that.css({padding: 0}); } that.triggerEvent('submit', {value: self.options.value});