1
0
Fork 0
forked from 0x2620/oxjs

add mail svg; update form elements; change 'focusInput()' signature

This commit is contained in:
rlx 2011-12-18 09:29:35 +00:00
commit 4701245038
8 changed files with 104 additions and 18 deletions

View file

@ -180,6 +180,10 @@ Ox.Button = function(options, self) {
return that;
}
that.value = function() {
return self.options.title;
};
return that;
};

View file

@ -53,6 +53,7 @@ Ox.ButtonGroup = function(options, self) {
size: self.options.size,
style: self.options.style,
title: button.title,
tooltip: button.tooltip,
type: self.options.type
})
.bindEvent('select', function() {
@ -84,6 +85,12 @@ Ox.ButtonGroup = function(options, self) {
}
};
that.value = function() {
return self.optionGroup.selected().map(function(i) {
return self.options.buttons[i].id;
});
};
return that;
};

View file

@ -828,12 +828,8 @@ Ox.Input = function(options, self) {
} else if (key == 'disabled') {
self.$input.attr({disabled: value});
} else if (key == 'height') {
that.css({
height: value + 'px'
});
self.$input.css({
height: value + 'px'
});
that.css({height: value + 'px'});
self.$input.css({height: value - 6 + 'px'});
} else if (key == 'labelWidth') {
self.$label.options({width: value});
inputWidth = getInputWidth();
@ -874,15 +870,25 @@ Ox.Input = function(options, self) {
return that;
}
that.focusInput = function(select) {
// fixme: don't we have a convention that booleans are false by default?
select = Ox.isUndefined(select) ? true : select;
/*@
focusInput <f> Focus input element
(select) -> <o> Input object
(start, end) -> <o> Input object
select <b|false> If true, select all, otherwise position cursor at the end
start <n> Selection start (can be negative)
end <n> Selection end (can be negative), or equal to start if omitted
@*/
that.focusInput = function() {
var length = self.$input.val().length,
start = Ox.isNumber(arguments[0])
? (arguments[0] < 0 ? length + arguments[0] : arguments[0])
: 0,
stop = Ox.isNumber(arguments[1])
? (arguments[1] < 0 ? length + arguments[1] : arguments[1])
: Ox.isNumber(arguments[0]) ? arguments[0]
: arguments[0] ? length : 0;
self.$input.focus();
if (select) {
cursor(0, self.$input.val().length);
} else {
cursor(self.$input.val().length);
}
cursor(start, stop);
return that;
};

View file

@ -236,12 +236,12 @@ Ox.Select = function(options, self) {
() -> <o> returns object of selected items with id, title
@*/
that.selected = function() {
return /*self.checked*/self.optionGroup.checked().map(function(v) {
return self.options.selectable ? self.optionGroup.checked().map(function(v) {
return {
id: self.options.items[v].id,
title: self.options.items[v].title
};
});
}) : [];
};
/*@