improve editable and tooltip
This commit is contained in:
parent
b957106624
commit
e7c36dacc8
2 changed files with 18 additions and 4 deletions
|
@ -89,11 +89,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
|
||||||
});
|
});
|
||||||
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'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -106,6 +106,7 @@ Ox.Editable = function(options, self) {
|
||||||
function edit() {
|
function edit() {
|
||||||
var height, width;
|
var height, width;
|
||||||
if (self.options.editable && !self.options.editing) {
|
if (self.options.editable && !self.options.editing) {
|
||||||
|
self.options.editing = true;
|
||||||
self.originalValue = self.options.value;
|
self.originalValue = self.options.value;
|
||||||
self.minWidth = 8;
|
self.minWidth = 8;
|
||||||
self.maxWidth = that.parent().width();
|
self.maxWidth = that.parent().width();
|
||||||
|
@ -157,7 +158,7 @@ Ox.Editable = function(options, self) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
self.$input.focusInput(false);
|
self.$input.focusInput(false);
|
||||||
}, 0);
|
}, 0);
|
||||||
self.options.editing = true;
|
that.$tooltip.options({title: ''});
|
||||||
that.triggerEvent('edit', {editing: true});
|
that.triggerEvent('edit', {editing: true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,16 +189,28 @@ Ox.Editable = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function submit() {
|
function submit() {
|
||||||
|
self.options.editing = false;
|
||||||
self.options.value = Ox.parseHTML(self.$input.value());
|
self.options.value = Ox.parseHTML(self.$input.value());
|
||||||
self.$input.options({value: formatInputValue()}).hide();
|
self.$input.options({value: formatInputValue()}).hide();
|
||||||
self.$test.html(formatTestValue());
|
self.$test.html(formatTestValue());
|
||||||
self.$value.html(formatValue()).show();
|
self.$value.html(formatValue()).show();
|
||||||
self.options.editing = false;
|
that.$tooltip.options({title: self.options.tooltip});
|
||||||
that.triggerEvent('submit', {
|
that.triggerEvent('submit', {
|
||||||
value: self.options.value
|
value: self.options.value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.setOption = function(key, value) {
|
||||||
|
if (key == 'height' || key == 'width') {
|
||||||
|
var css = {};
|
||||||
|
css[key] = value + 'px';
|
||||||
|
Ox.print(key, 'VALUE', value)
|
||||||
|
self.$test && self.$test.css(css);
|
||||||
|
self.$input && self.$input.css(css);
|
||||||
|
self.$input && self.$input.find(self.options.type).css(css);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
that.css = function(css) {
|
that.css = function(css) {
|
||||||
self.css = css;
|
self.css = css;
|
||||||
that.$element.css(css);
|
that.$element.css(css);
|
||||||
|
|
|
@ -30,6 +30,7 @@ Ox.Tooltip = function(options, self) {
|
||||||
self.setOption = function(key, value) {
|
self.setOption = function(key, value) {
|
||||||
if (key == 'title') {
|
if (key == 'title') {
|
||||||
that.html(value);
|
that.html(value);
|
||||||
|
value === '' && that.detach();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue