some changes to Ox.Editable

This commit is contained in:
rlx 2011-10-25 14:40:02 +00:00
parent 2bd4156f6c
commit 7ecb0b2011

View file

@ -24,6 +24,7 @@ Ox.Editable = function(options, self) {
editable: true, editable: true,
editing: false, editing: false,
format: null, format: null,
placeholder: '',
tooltip: '', tooltip: '',
value: '', value: '',
width: 256, width: 256,
@ -80,7 +81,7 @@ Ox.Editable = function(options, self) {
changeOnKeypress: true, changeOnKeypress: true,
style: 'square', style: 'square',
type: self.options.type, type: self.options.type,
value: Ox.stripTags(self.options.value) value: Ox.parseHTML(self.options.value)
}, self.options.type == 'textarea' ? { }, self.options.type == 'textarea' ? {
width: self.options.width width: self.options.width
} : {})) } : {}))
@ -115,7 +116,7 @@ Ox.Editable = function(options, self) {
: self.options.value : self.options.value
); );
self.$test.html(self.options.value.replace(/ /g, ' ')); self.$test.html(self.options.value.replace(/ /g, ' '));
height = self.$test.height(); height = self.options.height || self.$test.height();
//height = Math.max(self.$test.height(), 14); //height = Math.max(self.$test.height(), 14);
width = Math.max(self.$test.width() + 2, 8); width = Math.max(self.$test.width() + 2, 8);
width = Ox.limit(self.$test.width() + 2, self.minWidth, self.maxWidth) width = Ox.limit(self.$test.width() + 2, self.minWidth, self.maxWidth)
@ -128,11 +129,11 @@ Ox.Editable = function(options, self) {
} else { } else {
self.$input.options({ self.$input.options({
height: height, height: height,
width: width + Ox.UI.SCROLLBAR_SIZE width: width// + Ox.UI.SCROLLBAR_SIZE
}); });
self.$input.find('textarea').css({ self.$input.find('textarea').css({
height: height + 'px', height: height + 'px',
width: width + Ox.UI.SCROLLBAR_SIZE + 'px' width: width /*+ Ox.UI.SCROLLBAR_SIZE*/ + 'px'
}); });
} }
@ -151,7 +152,7 @@ Ox.Editable = function(options, self) {
self.minWidth = 8 self.minWidth = 8
self.maxWidth = that.parent().width(); self.maxWidth = that.parent().width();
Ox.print('MAX WIDTH', self.maxWidth); Ox.print('MAX WIDTH', self.maxWidth);
height = self.$value.height(); height = self.options.height || self.$value.height();
width = self.$value.width(); width = self.$value.width();
self.$value.hide(); self.$value.hide();
//self.$test.show(); //self.$test.show();
@ -168,7 +169,7 @@ Ox.Editable = function(options, self) {
} else { } else {
self.$input.find('textarea').css({ self.$input.find('textarea').css({
height: height + 'px', height: height + 'px',
width: width + Ox.UI.SCROLLBAR_SIZE + 'px' width: width + 'px'
}); });
} }
// fixme: why can't this be chained? // fixme: why can't this be chained?
@ -190,7 +191,8 @@ Ox.Editable = function(options, self) {
} }
function submit() { function submit() {
self.options.value = self.$input.value(); self.options.value = self.$input.value().trim();
self.$input.value(self.options.value);
self.$value.html( self.$value.html(
self.options.format self.options.format
? self.options.format(self.options.value) ? self.options.format(self.options.value)