', 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});