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

@ -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;
};