Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #411: support Android #418

Merged
merged 1 commit into from
May 23, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 25 additions & 27 deletions autocomplete_light/static/autocomplete_light/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,29 @@ the constructor, setup is done in this method. This allows to:
- and *then* setup the instance.
*/
yourlabs.Autocomplete.prototype.initialize = function() {
var ie = yourlabs.getInternetExplorerVersion();

this.input
.on('blur.autocomplete', $.proxy(this.inputBlur, this))
.on('click.autocomplete', $.proxy(this.inputClick, this))
.on('keypress.autocomplete', $.proxy(this.inputKeypress, this))
.on('keyup.autocomplete', $.proxy(this.inputKeyup, this))
.on('keydown.autocomplete', $.proxy(this.inputKeydown, this));
.on('focus.autocomplete', $.proxy(this.inputClick, this))
.on('keydown.autocomplete', $.proxy(this.inputKeyup, this));

if (ie == -1 || ie > 9) {
this.input.on('input.autocomplete', $.proxy(this.refresh, this));
}
else
{
var events = [
'keyup.autocomplete',
'keypress.autocomplete',
'cut.autocomplete',
'paste.autocomplete'
]

this.input.on(events.join(' '), function($e) {
$.proxy(this.inputKeyup, this);
})
}

/*
Bind mouse events to fire signals. Because the same signals will be
Expand All @@ -274,10 +291,11 @@ yourlabs.Autocomplete.prototype.initialize = function() {
yourlabs.Autocomplete.prototype.destroy = function(input) {
input
.unbind('blur.autocomplete')
.unbind('click.autocomplete')
.unbind('focus.autocomplete')
.unbind('input.autocomplete')
.unbind('keydown.autocomplete')
.unbind('keypress.autocomplete')
.unbind('keyup.autocomplete')
.unbind('keydown.autocomplete');
};

yourlabs.Autocomplete.prototype.inputBlur = function(e) {
Expand Down Expand Up @@ -334,6 +352,7 @@ yourlabs.Autocomplete.prototype.inputKeyup = function(e) {
case 16: // shift
case 17: // ctrl
case 18: // alt
this.move(e);
break;

case 9: // tab
Expand Down Expand Up @@ -364,27 +383,6 @@ yourlabs.Autocomplete.prototype.inputKeyup = function(e) {
}
};

yourlabs.Autocomplete.prototype.inputKeydown = function(e) {
// Don't handle keypresses on hidden inputs (ie. with limited choices)
if (!this.input.is(':visible')) return;

// Avoid double call to move().
this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27]);

this.move(e);
};

// This function is in charge of keyboard usage.
yourlabs.Autocomplete.prototype.inputKeypress = function(e) {
// Don't handle keypresses on hidden inputs (ie. with limited choices)
if (!this.input.is(':visible')) return;

// Return if it already handled by inputKeydown.
if (this.suppressKeyPressRepeat) return;

this.move(e);
};

// This function is in charge of ensuring that a relevant autocomplete is
// shown.
yourlabs.Autocomplete.prototype.show = function(html) {
Expand Down