From e7c36dacc86dbbeae68bf93d17bac396e6b68fde Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Sun, 6 Nov 2011 12:26:12 +0000 Subject: [PATCH] improve editable and tooltip --- source/Ox.UI/js/Form/Ox.Editable.js | 21 +++++++++++++++++---- source/Ox.UI/js/Window/Ox.Tooltip.js | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/source/Ox.UI/js/Form/Ox.Editable.js b/source/Ox.UI/js/Form/Ox.Editable.js index d18f9908..3f86ea01 100644 --- a/source/Ox.UI/js/Form/Ox.Editable.js +++ b/source/Ox.UI/js/Form/Ox.Editable.js @@ -89,11 +89,11 @@ Ox.Editable = function(options, self) { } else { self.$input.options({ height: height, - width: width// + Ox.UI.SCROLLBAR_SIZE + width: width }); self.$input.find('textarea').css({ height: height + 'px', - width: width /*+ Ox.UI.SCROLLBAR_SIZE*/ + 'px' + width: width + 'px' }); } /* @@ -106,6 +106,7 @@ Ox.Editable = function(options, self) { function edit() { var height, width; if (self.options.editable && !self.options.editing) { + self.options.editing = true; self.originalValue = self.options.value; self.minWidth = 8; self.maxWidth = that.parent().width(); @@ -157,7 +158,7 @@ Ox.Editable = function(options, self) { setTimeout(function() { self.$input.focusInput(false); }, 0); - self.options.editing = true; + that.$tooltip.options({title: ''}); that.triggerEvent('edit', {editing: true}); } } @@ -188,16 +189,28 @@ Ox.Editable = function(options, self) { } function submit() { + self.options.editing = false; self.options.value = Ox.parseHTML(self.$input.value()); self.$input.options({value: formatInputValue()}).hide(); self.$test.html(formatTestValue()); self.$value.html(formatValue()).show(); - self.options.editing = false; + that.$tooltip.options({title: self.options.tooltip}); that.triggerEvent('submit', { 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) { self.css = css; that.$element.css(css); diff --git a/source/Ox.UI/js/Window/Ox.Tooltip.js b/source/Ox.UI/js/Window/Ox.Tooltip.js index 944feaf6..ed2b5525 100644 --- a/source/Ox.UI/js/Window/Ox.Tooltip.js +++ b/source/Ox.UI/js/Window/Ox.Tooltip.js @@ -30,6 +30,7 @@ Ox.Tooltip = function(options, self) { self.setOption = function(key, value) { if (key == 'title') { that.html(value); + value === '' && that.detach(); } };