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