forked from 0x2620/oxjs
rename Ox.UI source files, remove Ox. prefix
This commit is contained in:
parent
005d50c389
commit
91e1065aab
101 changed files with 0 additions and 0 deletions
69
source/Ox.UI/js/Form/ObjectInput.js
Normal file
69
source/Ox.UI/js/Form/ObjectInput.js
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
'use strict';
|
||||
|
||||
/*@
|
||||
Ox.ObjectInput <f:Ox.Element> Object Input
|
||||
([options[, self]]) -> <o> Object Input
|
||||
options <o> Options
|
||||
self <o> Shared private variable
|
||||
@*/
|
||||
Ox.ObjectInput = function(options, self) {
|
||||
|
||||
self = self || {};
|
||||
var that = Ox.Element({}, self)
|
||||
.defaults({
|
||||
elements: [],
|
||||
labelWidth: 128,
|
||||
value: {},
|
||||
width: 256
|
||||
})
|
||||
.options(options || {})
|
||||
.update({
|
||||
value: function() {
|
||||
setValue(self.options.value);
|
||||
}
|
||||
})
|
||||
.addClass('OxObjectInput')
|
||||
.css({
|
||||
width: self.options.width + 'px',
|
||||
height: self.options.elements.length * 24 - 8 + 'px'
|
||||
});
|
||||
|
||||
if (Ox.isEmpty(self.options.value)) {
|
||||
self.options.value = getValue();
|
||||
} else {
|
||||
setValue(self.options.value);
|
||||
}
|
||||
|
||||
self.options.elements.forEach(function($element) {
|
||||
$element.options({
|
||||
labelWidth: self.options.labelWidth,
|
||||
width: self.options.width
|
||||
})
|
||||
.bindEvent({
|
||||
change: function(data) {
|
||||
self.options.value = getValue();
|
||||
that.triggerEvent('change', {
|
||||
value: self.options.value
|
||||
});
|
||||
}
|
||||
})
|
||||
.appendTo(that);
|
||||
});
|
||||
|
||||
function getValue() {
|
||||
var value = {};
|
||||
self.options.elements.forEach(function(element) {
|
||||
value[element.options('id')] = element.value();
|
||||
});
|
||||
return value;
|
||||
}
|
||||
|
||||
function setValue(value) {
|
||||
self.options.elements.forEach(function(element) {
|
||||
element.value(value[element.options('id')]);
|
||||
});
|
||||
}
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue