forked from 0x2620/oxjs
add SelectInput
This commit is contained in:
parent
da0742e542
commit
3d3be10e2c
5 changed files with 118 additions and 13 deletions
|
|
@ -36,7 +36,8 @@ Ox.ObjectArrayInput = function(options, self) {
|
|||
Ox.print('addInput', index)
|
||||
self.$element.splice(index, 0, Ox.Element()
|
||||
.css({
|
||||
height: (self.options.inputs.length + 1) * 24 + 'px'
|
||||
width: self.options.width + 'px',
|
||||
height: (self.options.inputs.length + 1) * 24 - 8 + 'px'
|
||||
})
|
||||
);
|
||||
if (index == 0) {
|
||||
|
|
@ -59,7 +60,7 @@ Ox.ObjectArrayInput = function(options, self) {
|
|||
title: self.options.buttonTitles.remove,
|
||||
width: self.buttonWidth
|
||||
})
|
||||
.css({float: 'left', margin: '8px 8px 0 0'})
|
||||
.css({float: 'left', margin: '8px 4px 0 0'})
|
||||
.bind({
|
||||
click: function() {
|
||||
var index = $(this).parent().data('index');
|
||||
|
|
@ -75,7 +76,7 @@ Ox.ObjectArrayInput = function(options, self) {
|
|||
title: self.options.buttonTitles.add,
|
||||
width: self.buttonWidth
|
||||
})
|
||||
.css({float: 'left', margin: '8px 0 0 0'})
|
||||
.css({float: 'left', margin: '8px 0 0 4px'})
|
||||
.bind({
|
||||
click: function() {
|
||||
var index = $(this).parent().data('index');
|
||||
|
|
@ -99,13 +100,17 @@ Ox.ObjectArrayInput = function(options, self) {
|
|||
}
|
||||
|
||||
function updateInputs() {
|
||||
var length = self.$element.length;
|
||||
self.$element.forEach(function($element, i) {
|
||||
$element.data({index: i});
|
||||
$element
|
||||
[i == 0 ? 'addClass' : 'removeClass']('OxFirst')
|
||||
[i == length - 1 ? 'addClass' : 'removeClass']('OxLast')
|
||||
.data({index: i});
|
||||
self.$removeButton[i].options({
|
||||
disabled: self.$element.length == 1,
|
||||
disabled: length == 1,
|
||||
});
|
||||
self.$addButton[i].options({
|
||||
disabled: self.$element.length == self.options.max
|
||||
disabled: length == self.options.max
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue