autocomplete, continued

This commit is contained in:
Rolux 2010-02-19 19:49:48 +05:30
parent 2b9893c514
commit fbedfe5da5
2 changed files with 30 additions and 15 deletions

View File

@ -454,8 +454,9 @@ requires
$(function() { $(function() {
// fixme: how to do this better? // fixme: how to do this better?
// in firefox, keypress doesn't fire for up/down // in firefox on mac, keypress doesn't fire for up/down
// if the cursor is at the start/end of an input element // if the cursor is at the start/end of an input element
// on linux, it doesn't seem to fire if the input element has focus
if ($.browser.mozilla) { if ($.browser.mozilla) {
$document.keypress(keypress); $document.keypress(keypress);
$document.keydown(function(event) { $document.keydown(function(event) {
@ -1652,6 +1653,9 @@ requires
} }
if (options.autocomplete) { if (options.autocomplete) {
that.$input.attr({
autocomplete: "off"
});
self.autocompleteId = self.options.id + "_menu"; // fixme: we do this in other places ... are we doing it the same way? var name? self.autocompleteId = self.options.id + "_menu"; // fixme: we do this in other places ... are we doing it the same way? var name?
self.autocompleteMenu = new Ox.Menu({ self.autocompleteMenu = new Ox.Menu({
element: that, element: that,
@ -1701,7 +1705,7 @@ requires
} }
function callback(items) { function callback(items) {
var selected = 0; var selected = -1;
if (items.length) { if (items.length) {
items = $.map(items, function(title, position) { items = $.map(items, function(title, position) {
if (that.$input.val().toLowerCase() == Ox.stripTags(title.toLowerCase())) { if (that.$input.val().toLowerCase() == Ox.stripTags(title.toLowerCase())) {

View File

@ -63,6 +63,18 @@
extras: [ extras: [
new Ox.Input({ new Ox.Input({
autocomplete: { autocomplete: {
"Find: Title": [
"A bout de souffle",
"Casino",
"Diaries, Notes and Sketches",
"L'age d'or",
"Far From Heaven",
"In girum imus nocte et consumimur igni",
"It Felt Like a Kiss",
"Mulholland Dr.",
"Querelle",
"Vertigo"
],
"Find: Director": [ "Find: Director": [
"Luis Buñuel", "Luis Buñuel",
"Adam Curtis", "Adam Curtis",
@ -75,24 +87,23 @@
"Jonas Mekas", "Jonas Mekas",
"Martin Scorsese" "Martin Scorsese"
], ],
"Find: Title": [ "Find: Country": [
"A bout de souffle", "Austria",
"Casino", "Canada",
"Diaries, Notes and Sketches", "France",
"L'age d'or", "Germany",
"Far From Heaven", "Italy",
"In girum imus nocte et consumimur igni", "Japan",
"It Felt Like a Kiss", "Spain",
"Mulholland Dr.", "Swizerland",
"Querelle", "UK",
"Vertigo" "USA"
] ]
}, },
clear: true, clear: true,
highlight: true, highlight: true,
id: "find", id: "find",
placeholder: ["Find: Director", "Find: Title"], placeholder: ["Find: Title", "Find: Director", "Find: Country"],
selected: 1
}).width(256) }).width(256)
], ],
menus: [ menus: [