select input: fix size, keep input value around

This commit is contained in:
rolux 2014-05-18 02:45:34 +02:00
parent c88ce78e32
commit 8c4e7fbe84

View file

@ -11,6 +11,7 @@ Ox.SelectInput = function(options, self) {
var that;
self = Ox.extend(self || {}, {
options: Ox.extend({
inputValue: '',
inputWidth: 128,
items: [],
label: '',
@ -25,7 +26,7 @@ Ox.SelectInput = function(options, self) {
});
self.other = self.options.items[self.options.items.length - 1].id;
self.otherWidth = self.options.width - self.options.inputWidth - 3; // fixme: 3? obscure!
self.otherWidth = self.options.width - self.options.inputWidth;
self.$select = Ox.Select({
items: self.options.items,
@ -46,7 +47,8 @@ Ox.SelectInput = function(options, self) {
self.$input = Ox.Input({
placeholder: self.options.placeholder,
width: 0
width: self.options.inputWidth,
value: self.options.inputValue
})
.bindEvent({
change: function(data) {
@ -114,7 +116,7 @@ Ox.SelectInput = function(options, self) {
width: self.options.width
})
.removeClass('OxOverlapRight');
self.$input.hide().value('');
self.$input.hide();
} else {
self.$select.options({
title: Ox.getObjectById(self.options.items, self.other).title,
@ -122,7 +124,7 @@ Ox.SelectInput = function(options, self) {
width: self.otherWidth
})
.addClass('OxOverlapRight');
self.$input.show().value(self.options.value).focusInput();
self.$input.show().focusInput(true);
}
self.$select.options({title: getTitle()});
}