forked from 0x2620/oxjs
add type field (still needs a better Ox.Select)
This commit is contained in:
parent
b299674717
commit
60662a437a
4 changed files with 130 additions and 26 deletions
|
|
@ -27,7 +27,7 @@ Ox.Select = function(options, self) {
|
|||
var self = self || {},
|
||||
that = new Ox.Element({
|
||||
tooltip: options.tooltip || ''
|
||||
}, self) // fixme: do we use 'div', or {}, or '', by default?
|
||||
}, self)
|
||||
.defaults({
|
||||
id: '',
|
||||
items: [],
|
||||
|
|
@ -74,11 +74,27 @@ Ox.Select = function(options, self) {
|
|||
self.checked = self.optionGroup.checked();
|
||||
}
|
||||
|
||||
if (self.options.label) {
|
||||
self.$label = Ox.Label({
|
||||
overlap: 'right',
|
||||
textAlign: 'right',
|
||||
title: self.options.label,
|
||||
width: self.options.labelWidth
|
||||
})
|
||||
.click(function() {
|
||||
// fixme: ???
|
||||
// that.focus();
|
||||
})
|
||||
.appendTo(that);
|
||||
};
|
||||
|
||||
if (self.options.type == 'text') {
|
||||
self.$title = $('<div>')
|
||||
.addClass('OxTitle')
|
||||
.css({
|
||||
width: (self.options.width - 22) + 'px'
|
||||
width: (self.options.width - 22 - (
|
||||
self.options.label ? self.options.labelWidth : 0
|
||||
)) + 'px'
|
||||
})
|
||||
.html(
|
||||
self.options.title ? self.options.title :
|
||||
|
|
@ -152,7 +168,7 @@ Ox.Select = function(options, self) {
|
|||
}
|
||||
|
||||
self.setOption = function(key, value) {
|
||||
|
||||
|
||||
};
|
||||
|
||||
/*@
|
||||
|
|
@ -174,7 +190,7 @@ Ox.Select = function(options, self) {
|
|||
id <s> item id
|
||||
@*/
|
||||
that.selectItem = function(id) {
|
||||
//Ox.print('selectItem', id, Ox.getObjectById(self.options.items, id).title)
|
||||
Ox.print('selectItem', id, Ox.getObjectById(self.options.items, id).title)
|
||||
self.options.type == 'text' && self.$title.html(
|
||||
Ox.getObjectById(self.options.items, id).title[0] // fixme: title should not have become an array
|
||||
);
|
||||
|
|
@ -192,6 +208,19 @@ Ox.Select = function(options, self) {
|
|||
};
|
||||
*/
|
||||
|
||||
that.value = function() {
|
||||
if (arguments.length == 0) {
|
||||
Ox.print('selected::', that.selected())
|
||||
return that.selected()[0].id;
|
||||
} else {
|
||||
/*
|
||||
Ox.print('ELSE');
|
||||
that.selectItem(arguments[0]);
|
||||
return that;
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue