forked from 0x2620/oxjs
self.setOption ~> that.update
This commit is contained in:
parent
9ee0742b53
commit
005d50c389
56 changed files with 919 additions and 933 deletions
|
|
@ -34,6 +34,29 @@ Ox.Editable = function(options, self) {
|
|||
type: 'input'
|
||||
})
|
||||
.options(options || {})
|
||||
.update({
|
||||
editing: function() {
|
||||
if (self.options.editing) {
|
||||
// edit will toggle self.options.editing
|
||||
self.options.editing = false;
|
||||
edit();
|
||||
} else {
|
||||
submit();
|
||||
}
|
||||
},
|
||||
height: function() {
|
||||
setCSS({height: self.options.height + 'px'});
|
||||
},
|
||||
width: function() {
|
||||
setCSS({width: self.options.width + 'px'});
|
||||
},
|
||||
highlight: function() {
|
||||
self.$value.html(formatValue());
|
||||
},
|
||||
value: function() {
|
||||
self.$value.html(formatValue());
|
||||
}
|
||||
})
|
||||
.addClass('OxEditableElement' + (self.options.editable ? ' OxEditable' : ''))
|
||||
.on({
|
||||
click: function() {
|
||||
|
|
@ -196,6 +219,12 @@ Ox.Editable = function(options, self) {
|
|||
);
|
||||
}
|
||||
|
||||
function setCSS(css) {
|
||||
self.$test && self.$test.css(css);
|
||||
self.$input && self.$input.css(css);
|
||||
self.$input && self.$input.find(self.options.type).css(css);
|
||||
}
|
||||
|
||||
function setSizes() {
|
||||
var height, width;
|
||||
self.$test.css({display: 'inline-block'});
|
||||
|
|
@ -227,28 +256,6 @@ Ox.Editable = function(options, self) {
|
|||
that.triggerEvent('submit', {value: self.options.value});
|
||||
}
|
||||
|
||||
self.setOption = function(key, value) {
|
||||
if (key == 'editing') {
|
||||
if (value) {
|
||||
// edit will toggle self.options.editing
|
||||
self.options.editing = false;
|
||||
edit();
|
||||
} else {
|
||||
submit();
|
||||
}
|
||||
} else if (key == 'height' || key == 'width') {
|
||||
var css = {};
|
||||
css[key] = value + 'px';
|
||||
self.$test && self.$test.css(css);
|
||||
self.$input && self.$input.css(css);
|
||||
self.$input && self.$input.find(self.options.type).css(css);
|
||||
} else if (key == 'highlight') {
|
||||
self.$value.html(formatValue());
|
||||
} else if (key == 'value') {
|
||||
self.$value.html(formatValue());
|
||||
}
|
||||
};
|
||||
|
||||
that.css = function(css) {
|
||||
self.css = css;
|
||||
that.$element.css(css);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue