Input: submit when doubleclicking clear button; + some reformatting
This commit is contained in:
parent
7c7f97066e
commit
77f0c762a3
1 changed files with 23 additions and 20 deletions
|
@ -252,7 +252,10 @@ Ox.Input = function(options, self) {
|
|||
.css({
|
||||
float: 'right' // fixme: use css rule
|
||||
})
|
||||
.click(clear)
|
||||
.bindEvent({
|
||||
click: clear,
|
||||
doubleclick: submit
|
||||
})
|
||||
.appendTo(that);
|
||||
}
|
||||
|
||||
|
@ -641,9 +644,7 @@ Ox.Input = function(options, self) {
|
|||
self.options.validate && validate();
|
||||
self.bindKeyboard && Ox.UI.$document.off('keydown', keydown);
|
||||
if (!self.cancelled && !self.submitted) {
|
||||
that.triggerEvent('blur', {
|
||||
value: self.options.value
|
||||
});
|
||||
that.triggerEvent('blur', {value: self.options.value});
|
||||
self.options.value !== self.originalValue && that.triggerEvent('change', {
|
||||
value: self.options.value
|
||||
});
|
||||
|
@ -679,18 +680,21 @@ Ox.Input = function(options, self) {
|
|||
function clear() {
|
||||
// fixme: set to min, not zero
|
||||
// fixme: make this work for password
|
||||
that.triggerEvent('clear');
|
||||
self.options.value = '';
|
||||
if (self.options.type == 'float') {
|
||||
self.options.value = '0.0';
|
||||
} else if (self.options.type == 'int') {
|
||||
self.options.value = '0'
|
||||
if (!self.clearTimeout) {
|
||||
that.triggerEvent('clear');
|
||||
self.options.value = '';
|
||||
self.options.value = self.options.type == 'float' ? '0.0'
|
||||
: self.options.type == 'int' ? '0'
|
||||
: '';
|
||||
self.$input.val(self.options.value);
|
||||
cursor(0, self.options.value.length);
|
||||
self.options.changeOnKeypress && that.triggerEvent({
|
||||
change: {value: self.options.value}
|
||||
});
|
||||
self.clearTimeout = setTimeout(function() {
|
||||
self.clearTimeout = 0;
|
||||
}, 500);
|
||||
}
|
||||
self.$input.val(self.options.value);
|
||||
cursor(0, self.options.value.length);
|
||||
self.options.changeOnKeypress && that.triggerEvent({
|
||||
change: {value: self.options.value}
|
||||
});
|
||||
}
|
||||
|
||||
function clickArrow(i) {
|
||||
|
@ -785,8 +789,9 @@ Ox.Input = function(options, self) {
|
|||
var oldCursor = cursor(),
|
||||
oldValue = self.options.value,
|
||||
newValue = oldValue.toString().slice(0, oldCursor[0] - 1),
|
||||
hasDeletedSelectedEnd = (event.keyCode == 8 || event.keyCode == 46) &&
|
||||
oldCursor[0] < oldCursor[1] && oldCursor[1] == oldValue.length;
|
||||
hasDeletedSelectedEnd = (event.keyCode == 8 || event.keyCode == 46)
|
||||
&& oldCursor[0] < oldCursor[1]
|
||||
&& oldCursor[1] == oldValue.length;
|
||||
if (
|
||||
event.keyCode != 9 // tab
|
||||
&& (self.options.type == 'textarea' || event.keyCode != 13) // enter
|
||||
|
@ -883,9 +888,7 @@ Ox.Input = function(options, self) {
|
|||
self.$input.blur();
|
||||
self.submitted = false;
|
||||
//self.options.type == 'textarea' && self.$input.blur();
|
||||
that.triggerEvent('submit', {
|
||||
value: self.options.value
|
||||
});
|
||||
that.triggerEvent('submit', {value: self.options.value});
|
||||
}
|
||||
|
||||
function validate() {
|
||||
|
|
Loading…
Reference in a new issue