fix formatting of editables that span multiple lines

This commit is contained in:
rlx 2012-01-15 21:08:06 +05:30
parent 688ae65cf1
commit d156ede914

View file

@ -122,12 +122,12 @@ Ox.Editable = function(options, self) {
if (self.options.editable && !self.options.editing) { if (self.options.editable && !self.options.editing) {
self.options.editing = true; self.options.editing = true;
self.originalValue = self.options.value; self.originalValue = self.options.value;
self.minWidth = 8; /*
self.maxWidth = that.parent().width(); height = self.options.type == 'input'
self.minHeight = 14; ? self.minHeight : self.options.height || self.$value.height();
self.maxHeight = that.parent().height();
height = self.options.height || self.$value.height();
width = self.options.width || self.$value.width(); width = self.options.width || self.$value.width();
*/
self.$value.hide(); self.$value.hide();
Ox.Log('Form', 'H:::', self.options.height, height) Ox.Log('Form', 'H:::', self.options.height, height)
if (!self.$test) { if (!self.$test) {
@ -155,6 +155,12 @@ Ox.Editable = function(options, self) {
}); });
self.$input.find('input').css(self.css); self.$input.find('input').css(self.css);
} }
self.minWidth = 8;
self.maxWidth = that.parent().width();
self.minHeight = 13;
self.maxHeight = self.options.type == 'input' ? self.minHeight : that.parent().height();
height = self.options.height || Ox.limit(self.$test.height(), self.minHeight, self.maxHeight);
width = self.options.width || Ox.limit(self.$test.width(), self.minWidth, self.maxWidth);
self.$input.options({ self.$input.options({
width: width, width: width,
height: height height: height
@ -193,7 +199,7 @@ Ox.Editable = function(options, self) {
function formatTestValue() { function formatTestValue() {
return self.options.type == 'input' return self.options.type == 'input'
? self.options.value.replace(/ /g, ' ') ? Ox.encodeHTML(self.options.value) //.replace(/ /g, ' ')
: Ox.encodeHTML(self.options.value || ' ') : Ox.encodeHTML(self.options.value || ' ')
.replace(/\n$/, '\n ') .replace(/\n$/, '\n ')
.replace(/\n/g, '<br/>') .replace(/\n/g, '<br/>')