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 || {};
|
||||
var that = Ox.Element({
|
||||
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)
|
||||
.defaults({
|
||||
clickLink: null,
|
||||
|
@ -54,9 +58,15 @@ Ox.EditableContent = function(options, self) {
|
|||
return false;
|
||||
}
|
||||
setTimeout(function() {
|
||||
that.css({padding: that.text() ? 0 : '0 2px'});
|
||||
if (self.options.type == '<span>') {
|
||||
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('HTML', that.html())
|
||||
Ox.print('HTML', that.html());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +104,10 @@ Ox.EditableContent = function(options, self) {
|
|||
if (value) {
|
||||
that.text(value);
|
||||
} else {
|
||||
that.css({padding: '0 2px'}).text('');
|
||||
that.text('');
|
||||
if (self.options.type == 'span') {
|
||||
that.css({padding: '0 2px'});
|
||||
}
|
||||
}
|
||||
self.options.editing = true;
|
||||
that.gainFocus();
|
||||
|
@ -151,6 +164,9 @@ Ox.EditableContent = function(options, self) {
|
|||
that.removeClass('OxEditableContentInput')
|
||||
.attr({contenteditable: false})
|
||||
.html(formatValue());
|
||||
if (self.options.type == 'span') {
|
||||
that.css({padding: 0});
|
||||
}
|
||||
that.triggerEvent('submit', {value: self.options.value});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue