update EditableContent
This commit is contained in:
parent
f1c8fb39a7
commit
cd14cc517c
1 changed files with 20 additions and 4 deletions
|
@ -3,7 +3,11 @@ Ox.EditableContent = function(options, self) {
|
||||||
self = self || {};
|
self = self || {};
|
||||||
var that = Ox.Element({
|
var that = Ox.Element({
|
||||||
element: options.type == 'div' ? '<div>' : '<span>',
|
element: options.type == 'div' ? '<div>' : '<span>',
|
||||||
tooltip: options.tooltip
|
tooltip: options.tooltip ? function(e) {
|
||||||
|
return that.hasClass('OxEditableContentInput') ? ''
|
||||||
|
: Ox.isString(options.tooltip) ? options.tooltip
|
||||||
|
: options.tooltip(e);
|
||||||
|
} : null
|
||||||
}, self)
|
}, self)
|
||||||
.defaults({
|
.defaults({
|
||||||
clickLink: null,
|
clickLink: null,
|
||||||
|
@ -54,9 +58,15 @@ Ox.EditableContent = function(options, self) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
if (self.options.type == '<span>') {
|
||||||
that.css({padding: that.text() ? 0 : '0 2px'});
|
that.css({padding: that.text() ? 0 : '0 2px'});
|
||||||
|
} else if (that.html().match(/<div><br><\/div>$/)) {
|
||||||
|
that.html(
|
||||||
|
that.html().replace(/<div><br><\/div>$/, '<br>')
|
||||||
|
)
|
||||||
|
}
|
||||||
//Ox.print('TEXT', that.text())
|
//Ox.print('TEXT', that.text())
|
||||||
//Ox.print('HTML', that.html())
|
Ox.print('HTML', that.html());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +104,10 @@ Ox.EditableContent = function(options, self) {
|
||||||
if (value) {
|
if (value) {
|
||||||
that.text(value);
|
that.text(value);
|
||||||
} else {
|
} else {
|
||||||
that.css({padding: '0 2px'}).text('');
|
that.text('');
|
||||||
|
if (self.options.type == 'span') {
|
||||||
|
that.css({padding: '0 2px'});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
self.options.editing = true;
|
self.options.editing = true;
|
||||||
that.gainFocus();
|
that.gainFocus();
|
||||||
|
@ -151,6 +164,9 @@ Ox.EditableContent = function(options, self) {
|
||||||
that.removeClass('OxEditableContentInput')
|
that.removeClass('OxEditableContentInput')
|
||||||
.attr({contenteditable: false})
|
.attr({contenteditable: false})
|
||||||
.html(formatValue());
|
.html(formatValue());
|
||||||
|
if (self.options.type == 'span') {
|
||||||
|
that.css({padding: 0});
|
||||||
|
}
|
||||||
that.triggerEvent('submit', {value: self.options.value});
|
that.triggerEvent('submit', {value: self.options.value});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue