[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH 19/24] Cleanup and comment the suggest JS code
From: |
Maxime Petazzoni |
Subject: |
[Maposmatic-dev] [PATCH 19/24] Cleanup and comment the suggest JS code |
Date: |
Sun, 10 Jan 2010 15:54:13 +0100 |
---
www/media/osm_map.js | 39 ++++++++++++++++++++-------------------
1 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/www/media/osm_map.js b/www/media/osm_map.js
index 103710c..165554e 100644
--- a/www/media/osm_map.js
+++ b/www/media/osm_map.js
@@ -156,6 +156,13 @@ function suggest(input, results, osm_id, button, options) {
return $('#rad' + id);
}
+ /* Empty and close the suggestion box. */
+ function closeSuggest() {
+ $results.empty();
+ $results.hide();
+ }
+
+ /* Handle the JSON result. */
function handleNominatimResults(data, textResult) {
var unusable_token = false;
closeSuggest();
@@ -190,7 +197,9 @@ function suggest(input, results, osm_id, button, options) {
break;
case 9: // TAB
case 13: // OK
- selectCurrentResult();
+ var elt = getCurrentResult();
+ if (elt)
+ setResult(elt);
return false;
break;
case 38: // UP
@@ -210,11 +219,6 @@ function suggest(input, results, osm_id, button, options) {
}
}
- function clearResult() {
- $osm_id.val('');
- setFormActivation(false);
- }
-
/* Returns the currently selected result. */
function getCurrentResult() {
var children = $results.children('li.' + options.selectedClass);
@@ -223,13 +227,6 @@ function suggest(input, results, osm_id, button, options) {
return false;
}
- /* Set the form to the currently selected result. */
- function selectCurrentResult() {
- var elt = getCurrentResult();
- if (elt)
- setResult(elt);
- }
-
/* Set the form to the given result. */
function setResult(elt) {
$osm_id.val(elt.attr('id').substring(3));
@@ -238,12 +235,21 @@ function suggest(input, results, osm_id, button, options)
{
setFormActivation(true);
}
+ function clearResult() {
+ $osm_id.val('');
+ setFormActivation(false);
+ }
+
+ /** Functions to manipulate the current selection. */
+
+ /* Set the currently selected item in the drop-down list. */
function setSelectedResultTo(elt) {
$results.children('li').removeClass(options.selectedClass);
if (elt)
elt.addClass(options.selectedClass);
}
+ /* Move to the previous valid result. */
function prevResult() {
var current = getCurrentResult();
var new_result;
@@ -259,6 +265,7 @@ function suggest(input, results, osm_id, button, options) {
setSelectedResultTo(new_result);
}
+ /* Move to the next valid result. */
function nextResult() {
var current = getCurrentResult();
var new_result;
@@ -273,11 +280,5 @@ function suggest(input, results, osm_id, button, options) {
setSelectedResultTo(new_result);
}
-
- /* Empty and close the suggestion box. */
- function closeSuggest() {
- $results.empty();
- $results.hide();
- }
}
--
1.6.3.3.261.g85c6
- [Maposmatic-dev] [PATCH 09/24] Complete site-wide UI overhaul., (continued)
- [Maposmatic-dev] [PATCH 09/24] Complete site-wide UI overhaul., Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 10/24] Updated translations to follow the small changes made during the redesign., Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 11/24] Small typographic fix, Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 12/24] Add a link on the header, Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 13/24] HTML fixes, Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 14/24] New automatic suggestion mechanism, Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 15/24] Restored the two columns layout., Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 16/24] Put the map generation form on its own page, Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 17/24] PO file update for UI changes. French is translated, Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 18/24] More work on the form behavior, added info note for unselectable items, Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 19/24] Cleanup and comment the suggest JS code,
Maxime Petazzoni <=
- [Maposmatic-dev] [PATCH 20/24] Removed JQuery from the main page, it's not needed there, Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 21/24] Finished the form behavior with language preselection, Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 22/24] PO files update, Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 23/24] Fix layout and stylesheet for browser compatibility, Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH 24/24] Improve suggest box behavior and usability, Maxime Petazzoni, 2010/01/10
- [Maposmatic-dev] [PATCH] Avoid resetting the language selector with empty contents, Maxime Petazzoni, 2010/01/10