[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH] JS Rewrite of onChange event on the radio box (
From: |
Pierre Mauduit |
Subject: |
[Maposmatic-dev] [PATCH] JS Rewrite of onChange event on the radio box (html form) |
Date: |
Tue, 22 Dec 2009 10:41:32 +0100 |
From: Pierre Mauduit <address@hidden>
---
www/templates/maposmatic/index.html | 161 +++++++++++++++++++----------------
1 files changed, 89 insertions(+), 72 deletions(-)
diff --git a/www/templates/maposmatic/index.html
b/www/templates/maposmatic/index.html
index d9e7734..d618c4f 100644
--- a/www/templates/maposmatic/index.html
+++ b/www/templates/maposmatic/index.html
@@ -28,11 +28,39 @@
{% block extralink %}
<script type="text/javascript" src="/smedia/jquery.js"></script>
+
{{ form.media }}
{% endblock %}
{% block extrajs %}
-String.prototype.startsWith = function(str) { return this.indexOf(str) === 0; }
+
+var elemFound = 0;
+var unusableToken = 0;
+
+function pageinit()
+{
+ document.getElementById('id_mode_0').setAttribute('onclick',
+ "area_selection_mode_switch('admin-mode')");
+ document.getElementById('id_mode_1').setAttribute('onclick',
+ "area_selection_mode_switch('bbox-mode')");
+
+ if (document.getElementById('id_mode_1').checked)
+ area_selection_mode_switch('bbox-mode');
+ else
+ area_selection_mode_switch('admin-mode');
+
+ $('#id_administrative_city').keypress(function (e)
+ {
+ /* disable autoposting (keypress on
return(13))
+ * doing a search instead */
+ if (e.which == 13)
+ {
+ validate_city_search();
+ return false;
+ }
+ });
+}
+
function area_selection_mode_switch(mode)
{
@@ -73,52 +101,48 @@ function reset_osmid_field()
$("#id_administrative_osmid").attr("value", "");
}
-function pageinit()
-{
- document.getElementById('id_mode_0').setAttribute('onclick',
- "area_selection_mode_switch('admin-mode')");
- document.getElementById('id_mode_1').setAttribute('onclick',
- "area_selection_mode_switch('bbox-mode')");
- if (document.getElementById('id_mode_1').checked)
- area_selection_mode_switch('bbox-mode');
- else
- area_selection_mode_switch('admin-mode');
- $('#id_administrative_city').keypress(function (e)
- {
- /* disable autoposting (keypress on
return(13))
- * doing a search instead */
- if (e.which == 13)
- {
- validate_city_search();
- return false;
- }
- });
+
+
+
+
+function languages_select(country)
+{
+ var nonhidden = null;
+ $('#id_map_language').find('option').each(function() {
+ var ischoosen = $(this).val().match(".._" + country.toUpperCase() + "\..*")
!= null || $(this).val() == 'C';
+ if (! ischoosen) {
+ $(this).hide();
+ }
+ else {
+ $(this).show();
+ if (nonhidden == null)
+ nonhidden = $(this);
+ }
+ });
+
+ nonhidden.attr('selected', 'selected');
}
-var elemFound = 0;
-var unusableToken = 0;
+function languages_show_all()
+{
+ $('#id_map_language').find('option').each(function() {
+ $(this).show();
+ });
+}
-function toggle_form_validation(enableForm)
+function update_hidden(obj)
{
+ toggle_form_validation("true");
- if (enableForm == "true")
- {
- $("#id-go-next-btn").removeAttr("disabled");
- $("#id-go-next-btn").attr("class", "btn-enabled");
- $("#id-go-next-btn").attr("title", "{% trans "Generate" %}");
- $("#id-go-next-btn").attr("src", "/smedia/Go-next.png");
- }
- else
- {
- $("#id-go-next-btn").attr("disabled", "true");
- $("#id-go-next-btn").attr("class", "btn-disabled");
- $("#id-go-next-btn").attr("title", "{% trans "Please fill in the form
before trying to proceed" %}");
- $("#id-go-next-btn").attr("src", "/smedia/Go-next-disabled.png");
- }
+ $("#id_administrative_osmid").attr("value", obj.value);
+ $("#id_administrative_city").attr("value", obj.attr("display_name"));
}
+String.prototype.startsWith = function(str) { return this.indexOf(str) === 0; }
+
+
function validate_city_search()
{
@@ -142,10 +166,18 @@ function validate_city_search()
{
if (item.ocitysmap_params['admin_level'] == 8)
{
- $("#result_nominatim_search").append("<li><input
onchange=\"javascript:update_hidden(this,'"
- +item.display_name+"'); languages_select('" +
item.country_code + "');\" type=\"radio\" name=\"administrative_tmp_osmid\"
value=\""
- +item.ocitysmap_params['id']+"\"
id=\"rd"+item.ocitysmap_params['id']+"\"/><label for=\"rd"+
- item.ocitysmap_params['id']+"\">"
+item.display_name+"</label></li>");
+ var rad_identifier = "radio" + item.ocitysmap_params["id"];
+ $("#result_nominatim_search").append("<li><input
type=\"radio\" id=\""+ rad_identifier + "\" /><label for=\""+rad_identifier
+"\">"+item.display_name+"</label></li>");
+ $("#" +
rad_identifier).attr("name","administrative_tmp_osmid");
+ $("#" +
rad_identifier).attr("value",'"'+item.ocitysmap_params['id'] +'"');
+
+ $("#" + rad_identifier).attr("display_name",
item.display_name);
+
+ $("#" + rad_identifier).change(function ()
+ {
+ update_hidden($(this));
+
languages_select(item.country_code);
+ });
elemFound = elemFound + 1;
}
@@ -169,39 +201,24 @@ function validate_city_search()
});
}
-function languages_select(country)
-{
- var nonhidden = null;
- $('#id_map_language').find('option').each(function() {
- var ischoosen = $(this).val().match(".._" + country.toUpperCase() + "\..*")
!= null || $(this).val() == 'C';
- if (! ischoosen) {
- $(this).hide();
- }
- else {
- $(this).show();
- if (nonhidden == null)
- nonhidden = $(this);
- }
- });
-
- nonhidden.attr('selected', 'selected');
-}
-
-function languages_show_all()
+function toggle_form_validation(enableForm)
{
- $('#id_map_language').find('option').each(function() {
- $(this).show();
- });
-}
-function update_hidden(obj, nloc)
-{
- toggle_form_validation("true");
-
- $("#id_administrative_osmid").attr("value", obj.value);
- $("#id_administrative_city").attr("value", nloc);
+ if (enableForm == "true")
+ {
+ $("#id-go-next-btn").removeAttr("disabled");
+ $("#id-go-next-btn").attr("class", "btn-enabled");
+ $("#id-go-next-btn").attr("title", "{% trans "Generate" %}");
+ $("#id-go-next-btn").attr("src", "/smedia/Go-next.png");
+ }
+ else
+ {
+ $("#id-go-next-btn").attr("disabled", "true");
+ $("#id-go-next-btn").attr("class", "btn-disabled");
+ $("#id-go-next-btn").attr("title", "{% trans "Please fill in the form
before trying to proceed" %}");
+ $("#id-go-next-btn").attr("src", "/smedia/Go-next-disabled.png");
+ }
}
-
{% endblock %}
{% block menu-home %}
--
1.6.5.7
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Maposmatic-dev] [PATCH] JS Rewrite of onChange event on the radio box (html form),
Pierre Mauduit <=