maposmatic-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maposmatic-dev] [PATCH 11/13] Fix language selector to work on Chrome


From: Thomas Petazzoni
Subject: [Maposmatic-dev] [PATCH 11/13] Fix language selector to work on Chrome
Date: Thu, 5 Aug 2010 16:56:24 +0200

Signed-off-by: Thomas Petazzoni <address@hidden>
---
 www/media/map_rendering_form.js |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/www/media/map_rendering_form.js b/www/media/map_rendering_form.js
index 220d100..57e53c6 100644
--- a/www/media/map_rendering_form.js
+++ b/www/media/map_rendering_form.js
@@ -98,17 +98,29 @@ function preparePaperSizePanel()
  * the location to render. */
 var selectedCountry;
 
+/** Variable in which the HTML code of the language list is saved so
+ * that we can remove items from this list and still be able to
+ * repopulate with all items later. This is due to the unfortunate
+ * fact that many browsers to do support .hide() and .show() on
+ * <option> elements. */
+var savedLanguageList;
+
+/* Filter the set of available languages according to the country in
+ * which the administrative boundary is. There is no filtering done
+ * when the area is given by bounding box. */
 function prepareLanguagePanel()
 {
     var seen = false;
+
+    $('#id_map_language').html(savedLanguageList);
+
     $('#id_map_language').children('option').each(function() {
         if (! ($(this).val().match('.._' + selectedCountry.toUpperCase() + 
'\..*') != null
                || $(this).val() == 'C'))
-        {
-            $(this).hide();
-        }
-        else {
-            $(this).show();
+       {
+           $(this).remove();
+       }
+       else {
             if (! seen) {
                 $(this).attr("selected", "selected");
                 seen = true;
@@ -451,6 +463,8 @@ $(document).ready(function() {
   $('#id_mode_0').bind('click', function(e) { switchToAdminMode(); });
   $('#id_mode_1').bind('click', function(e) { switchToBBoxMode(); });
 
+  savedLanguageList = $('#id_map_language').html();
+
   suggest('#id_administrative_city', '#suggest',
           '#id_administrative_osmid',
           { selectedClass: 'selected',
-- 
1.7.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]