From fbedfe5da594c6d3de5112b50b7c8d512ce96d08 Mon Sep 17 00:00:00 2001 From: Rolux Date: Fri, 19 Feb 2010 19:49:48 +0530 Subject: [PATCH] autocomplete, continued --- build/js/ox.ui.js | 8 ++++++-- demos/test/index.html | 37 ++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 57352b7..e9f9964 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -454,8 +454,9 @@ requires $(function() { // 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 + // on linux, it doesn't seem to fire if the input element has focus if ($.browser.mozilla) { $document.keypress(keypress); $document.keydown(function(event) { @@ -1652,6 +1653,9 @@ requires } 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.autocompleteMenu = new Ox.Menu({ element: that, @@ -1701,7 +1705,7 @@ requires } function callback(items) { - var selected = 0; + var selected = -1; if (items.length) { items = $.map(items, function(title, position) { if (that.$input.val().toLowerCase() == Ox.stripTags(title.toLowerCase())) { diff --git a/demos/test/index.html b/demos/test/index.html index 7f0f6aa..fdd9cd8 100644 --- a/demos/test/index.html +++ b/demos/test/index.html @@ -63,6 +63,18 @@ extras: [ new Ox.Input({ 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": [ "Luis Buñuel", "Adam Curtis", @@ -75,24 +87,23 @@ "Jonas Mekas", "Martin Scorsese" ], - "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: Country": [ + "Austria", + "Canada", + "France", + "Germany", + "Italy", + "Japan", + "Spain", + "Swizerland", + "UK", + "USA" ] }, clear: true, highlight: true, id: "find", - placeholder: ["Find: Director", "Find: Title"], - selected: 1 + placeholder: ["Find: Title", "Find: Director", "Find: Country"], }).width(256) ], menus: [