1
0
Fork 0
forked from 0x2620/oxjs

add find-as-you-type to video player

This commit is contained in:
rolux 2011-05-17 21:08:25 +02:00
commit 8e8b9c18a4
2 changed files with 34 additions and 24 deletions

View file

@ -19,6 +19,7 @@ Ox.Input <f:Ox.Element> Input Element
<f> function(key, value, blur, callback), returns value
autovalidate <f> --remote validation--
clear <b> if true, has clear button
changeOnKeypress <b> if true, fire change event while typing
disabled <b> if true, is disabled
height <n> px (for type='textarea' and type='range' with orientation='horizontal')
id <s> element id
@ -70,6 +71,7 @@ Ox.Input = function(options, self) {
autocompleteSelectHighlight: false,
autocompleteSelectSubmit: false,
autovalidate: null,
changeOnKeypress: false,
clear: false,
disabled: false,
key: '',
@ -173,7 +175,7 @@ Ox.Input = function(options, self) {
}
$.extend(self, {
bindKeyboard: self.options.autocomplete || self.options.autovalidate,
bindKeyboard: self.options.autocomplete || self.options.autovalidate || self.options.changeOnKeypress,
hasPasswordPlaceholder: self.options.type == 'password' && self.options.placeholder,
inputWidth: getInputWidth()
});
@ -391,20 +393,20 @@ Ox.Input = function(options, self) {
oldCursor = arguments[1];
}
if(Ox.isFunction(self.options.autovalidate)) {
if(self.options.key) {
self.options.autovalidate(self.options.key, self.options.value,
blur, autovalidateCallback);
if (Ox.isFunction(self.options.autovalidate)) {
if (self.options.key) {
self.options.autovalidate(
self.options.key, self.options.value, blur, autovalidateCallback
);
} else {
self.options.autovalidate(self.options.value, blur,
autovalidateCallback);
self.options.autovalidate(
self.options.value, blur, autovalidateCallback
);
}
} else {
if(Ox.isRegExp(self.options.autovalidate)) {
} else if (Ox.isRegExp(self.options.autovalidate)) {
autovalidateCallback(autovalidateFunction(self.options.value));
} else {
autovalidateTypeFunction(self.options.type, self.options.value);
}
} else {
autovalidateTypeFunction(self.options.type, self.options.value);
}
function autovalidateFunction(value) {
@ -635,6 +637,11 @@ Ox.Input = function(options, self) {
self.options.value = value;
self.options.autocomplete && autocomplete(oldValue, oldCursor);
self.options.autovalidate && autovalidate(oldValue, oldCursor);
self.options.changeOnKeypress && that.triggerEvent({
change: {
value: self.options.value
}
});
}
}, 0);
}