1
0
Fork 0
forked from 0x2620/oxjs

resolve focus issues with video player find element

This commit is contained in:
rlx 2011-10-29 10:01:28 +00:00
commit ec7ec4d707
4 changed files with 48 additions and 35 deletions

View file

@ -185,12 +185,12 @@ Ox.Input = function(options, self) {
]
}
Ox.extend(self, {
bindKeyboard: self.options.autocomplete || self.options.autovalidate ||
self.options.changeOnKeypress,
hasPasswordPlaceholder: self.options.type == 'password' && self.options.placeholder,
inputWidth: getInputWidth()
});
self.bindKeyboard = self.options.autocomplete
|| self.options.autovalidate
|| self.options.changeOnKeypress;
self.hasPasswordPlaceholder = self.options.type == 'password'
&& self.options.placeholder;
self.inputWidth = getInputWidth();
if (self.options.clear) {
self.$button = Ox.Button({
@ -578,7 +578,6 @@ Ox.Input = function(options, self) {
self.options.validate && validate();
if (self.bindKeyboard) {
Ox.UI.$document.unbind('keydown', keydown);
//Ox.UI.$document.unbind('keypress', keypress);
}
// fixme: for some reason, if options.type is set, no change event fires
// as a workaround, blur sends a value. remove later...
@ -662,9 +661,8 @@ Ox.Input = function(options, self) {
}
function focus() {
//Ox.print('focus()')
if (
that.hasClass('OxFocus') || // fixme: this is just a workaround, since for some reason, focus() gets called twice on focus
// that.hasClass('OxFocus') || // fixme: this is just a workaround, since for some reason, focus() gets called twice on focus
(self.$autocompleteMenu && self.$autocompleteMenu.is(':visible')) ||
(self.hasPasswordPlaceholder && self.$input.is(':visible'))
) {
@ -675,7 +673,6 @@ Ox.Input = function(options, self) {
that.is('.OxError') && that.removeClass('OxError');
self.options.placeholder && setPlaceholder();
if (self.bindKeyboard) {
//Ox.print('binding...')
// fixme: different in webkit and firefox (?), see keyboard handler, need generic function
Ox.UI.$document.keydown(keydown);
//Ox.UI.$document.keypress(keypress);
@ -698,10 +695,11 @@ Ox.Input = function(options, self) {
newValue = oldValue.substr(0, oldCursor[0] - 1),
hasDeletedSelectedEnd = (event.keyCode == 8 || event.keyCode == 46) &&
oldCursor[0] < oldCursor[1] && oldCursor[1] == oldValue.length;
Ox.print('CHANGE ON KEYPRESS', self.options.changeOnKeypress);
if (
event.keyCode != 9 &&
(self.options.type == 'textarea' || event.keyCode != 13) &&
event.keyCode != 27
event.keyCode != 9 // tab
&& (self.options.type == 'textarea' || event.keyCode != 13) // enter
&& event.keyCode != 27 // escape
) { // fixme: can't 13 and 27 return false?
setTimeout(function() { // wait for val to be set
var value = self.$input.val();
@ -723,9 +721,9 @@ Ox.Input = function(options, self) {
}, 0);
}
if (
(event.keyCode == 38 || event.keyCode == 40) &&
self.options.autocompleteSelect &&
self.$autocompleteMenu.is(':visible')
(event.keyCode == 38 || event.keyCode == 40) // up/down
&& self.options.autocompleteSelect
&& self.$autocompleteMenu.is(':visible')
) {
//return false;
}
@ -843,6 +841,7 @@ Ox.Input = function(options, self) {
}
that.focusInput = function(select) {
// fixme: don't we have a convention that booleans are false by default?
select = Ox.isUndefined(select) ? true : select;
self.$input.focus();
if (select) {
@ -1407,8 +1406,8 @@ Ox.InputElement_ = function(options, self) {
//Ox.print('InputElement self.options', self.options)
self.bindKeyboard = self.options.autocomplete || self.options.autocorrect ||
self.options.autosuggest || self.options.autovalidate;
self.bindKeyboard = self.options.autocomplete || self.options.autocorrect
|| self.options.autosuggest || self.options.autovalidate;
if (self.options.autosuggest) {
self.autosuggestId = self.options.id + 'Menu'; // fixme: we do this in other places ... are we doing it the same way? var name?
@ -1588,7 +1587,6 @@ Ox.InputElement_ = function(options, self) {
}
if (self.bindKeyboard) {
Ox.UI.$document.unbind('keydown', keydown);
//Ox.UI.$document.unbind('keypress', keypress);
}
}