forked from 0x2620/oxjs
form elements rewrite, part 1
This commit is contained in:
parent
cf567e5608
commit
7f83cd3141
30 changed files with 1061 additions and 958 deletions
|
|
@ -3,17 +3,17 @@
|
|||
Ox.SelectInput = function(options, self) {
|
||||
|
||||
var that;
|
||||
|
||||
self = Ox.extend(self || {}, {
|
||||
options: Ox.extend({
|
||||
inputWidth: 128,
|
||||
items: [],
|
||||
label: '',
|
||||
labelWidth: 128,
|
||||
max: 0,
|
||||
max: 1,
|
||||
min: 1,
|
||||
placeholder: '',
|
||||
title: '',
|
||||
value: options.max == 1 ? '' : [],
|
||||
width: 384
|
||||
}, options)
|
||||
});
|
||||
|
|
@ -28,21 +28,26 @@ Ox.SelectInput = function(options, self) {
|
|||
max: self.options.max,
|
||||
min: self.options.min,
|
||||
title: self.options.title,
|
||||
value: self.options.value,
|
||||
width: self.options.width
|
||||
})
|
||||
.bindEvent({
|
||||
change: function(data) {
|
||||
if (self.options.title) {
|
||||
self.$select.options({title: data.selected[0].title});
|
||||
self.$select.options({
|
||||
title: Ox.getObjectById(self.options.items, data.value).title
|
||||
});
|
||||
}
|
||||
if (data.selected[0].id == self.other) {
|
||||
self.$select.options({width: self.otherWidth})
|
||||
.addClass('OxOverlapRight');
|
||||
self.$input.show();
|
||||
} else {
|
||||
if (data.value != self.other) {
|
||||
self.$select.options({width: self.options.width})
|
||||
.removeClass('OxOverlapRight')
|
||||
self.$input.hide();
|
||||
self.options.value = data.value
|
||||
} else {
|
||||
self.$select.options({width: self.otherWidth})
|
||||
.addClass('OxOverlapRight');
|
||||
self.$input.show().focusInput(true);
|
||||
self.options.value = self.$input.options('value');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -51,6 +56,12 @@ Ox.SelectInput = function(options, self) {
|
|||
placeholder: self.options.placeholder,
|
||||
width: 0
|
||||
})
|
||||
.bindEvent({
|
||||
change: function(data) {
|
||||
Ox.print('DATA:', data)
|
||||
self.options.value = data.value;
|
||||
}
|
||||
})
|
||||
.hide();
|
||||
|
||||
that = Ox.FormElementGroup({
|
||||
|
|
@ -58,12 +69,19 @@ Ox.SelectInput = function(options, self) {
|
|||
self.$select,
|
||||
self.$input
|
||||
],
|
||||
join: function(value) {
|
||||
return value[value[0] == self.other ? 1 : 0]
|
||||
},
|
||||
split: function(value) {
|
||||
return Ox.map(self.options.items, function(item, i) {
|
||||
return i < item.length - 1 ? item.id : null;
|
||||
}).indexOf(value) > -1 ? [value, ''] : [self.other, value];
|
||||
},
|
||||
width: self.options.width
|
||||
});
|
||||
|
||||
that.value = function() {
|
||||
return self.$select.value() == self.other
|
||||
? self.$input.value() : self.$select.value();
|
||||
self.setOption = function(key, value) {
|
||||
// ...
|
||||
};
|
||||
|
||||
return that;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue