X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=templates%2Fsearch%2Fadv.form.tpl;h=ba7e7a540ba7d88fe7d8e43c09aec3425e7fde6f;hb=304cdf32d7c38afbd381909545021fc44c8a0e05;hp=1ea13aca9f7668a420075c43b69d3d6d852f9643;hpb=45ea6160465aeba0aa780e49c12272819dedffd1;p=platal.git diff --git a/templates/search/adv.form.tpl b/templates/search/adv.form.tpl index 1ea13ac..ba7e7a5 100644 --- a/templates/search/adv.form.tpl +++ b/templates/search/adv.form.tpl @@ -51,50 +51,80 @@ }; } - // when changing country, open up administrativearea choice - function changeCountry(a2) { - $(".autocompleteTarget[name='country']").attr('value',a2); + function setAddress(i, j, values) + { + var types = new Array('country', 'administrative_area_level_1', 'administrative_area_level_2', 'administrative_area_level_3', 'locality', 'sublocality'); + var prev_type = types[i]; + var next_type = types[j]; + var next_list = next_type + '_list'; + + if (j == 3) { + $('tr#locality_text').hide() + $("select[name='localityTxt']").attr('value', ''); + } - if (a2) { - $(".autocomplete[name='countryTxt']").addClass('hidden_valid'); + $("[name='" + next_type + "']").parent().load(baseurl + 'list/' + next_type, { previous:prev_type, value:values[i] }, function() { + if ($("select[name='" + next_type + "']").children("option").size() > 1) { + $("tr#" + next_list).show(); + $("select[name='" + next_type + "']").attr('value', values[j]); + if (j < 6) { + setAddress(j, j + 1, values); + } + } else { + $("tr#" + next_list).hide(); + $("select[name='" + next_type + "']").attr('value', ''); + if (j < 6) { + setAddress(i, j + 1, values); + } + } + }); - $("[name='administrativearea']").parent().load(baseurl + 'list/administrativearea/', { country:a2 }, function() { - if ($("select[name='administrativearea']").children("option").size() > 1) { - $("select[name='administrativearea']").attr('value', '{/literal}{$smarty.request.administrativearea}{literal}'); + } - $("tr#administrativearea_list").show(); - } else { - $("select[name='administrativearea']").attr('value', ''); + function displayNextAddressComponent(i, j, value) + { + var types = new Array('country', 'administrative_area_level_1', 'administrative_area_level_2', 'administrative_area_level_3', 'locality', 'sublocality'); + var prev_type = types[i]; + var next_type = types[j]; + var next_list = next_type + '_list'; - $("tr#administrativearea_list").hide(); - } - }); - } else { - $(".autocomplete[name='countryTxt']").removeClass('hidden_valid'); + if (j == 3) { + $('tr#locality_text').hide() + $("select[name='localityTxt']").attr('value', ''); + } - $("select[name='administrativearea']").attr('value', ''); - $("select[name='subadministrativearea']").attr('value', ''); + $("[name='" + next_type + "']").parent().load(baseurl + 'list/' + next_type, { previous:prev_type, value:value }, function() { + $("select[name='" + next_type + "']").attr('value', ''); + if ($("select[name='" + next_type + "']").children("option").size() > 1) { + $("tr#" + next_list).show(); + } else { + $("tr#" + next_list).hide(); + if (j < 6) { + displayNextAddressComponent(i, j + 1, value); + } + } + }); + } - $("tr#administrativearea_list").hide(); - $("tr#subadministrativearea_list").hide(); + function changeAddressComponents(type, value) + { + var types = new Array('country', 'administrative_area_level_1', 'administrative_area_level_2', 'administrative_area_level_3', 'locality', 'sublocality'); + var i = 0, j = 0; + + while (types[i] != type && i < 6) { + ++i; } - } - // when changing administrativearea, open up subadministrativearea choice - function changeAdministrativeArea(id) { - if (id) { - $("[name='subadministrativearea']").parent().load(baseurl + 'list/subadministrativearea/', { administrativearea:id }, function() { - if ($("select[name='subadministrativearea']").children("option").size() > 1) { - $("select[name='subadministrativearea']").attr('value', '{/literal}{$smarty.request.subadministrativearea}{literal}'); - $("tr#subadministrativearea_list").show(); - } else { - $("select[name='subadministrativearea']").attr('value', ''); - $("tr#subadministrativearea_list").hide(); - } - }); - } else { - $("select[name='subadministrativearea']").attr('value', ''); - $("tr#subadministrativearea_list").hide(); + j = i + 1; + while (j < 6) { + $("select[name='" + types[j] + "']").attr('value', ''); + $("tr#" + types[j] + "_list").hide(); + ++j; + } + + if (value != '' && i < 5) { + $("select[name='" + type + "']").attr('value', value); + displayNextAddressComponent(i, i + 1, value); } } @@ -145,15 +175,20 @@ if (nameRealField == name) return null; - // if changing country, might want to open administrativearea choice - if (nameRealField == 'country') + // When changing country or locality, open next address component. + if (nameRealField == 'country' || nameRealField == 'locality') { return function(i) { + nameRealField = name.replace(/Txt$/, ''); if (i.extra[0] < 0) { - cancel_autocomplete('countryTxt', 'country'); + cancel_autocomplete(name, nameRealField); i.extra[1] = ''; } - changeCountry(i.extra[1]); + $("[name='" + nameRealField + "']").parent().load(baseurl + 'list/' + nameRealField, function() { + $("select[name='" + nameRealField + "']").attr('value', i.extra[1]); + }); + changeAddressComponents(nameRealField, i.extra[1]); } + } if (nameRealField == 'school') return function(i) { @@ -204,10 +239,23 @@ $(".autocomplete").change(function() { $(this).removeClass('hidden_valid'); }); - $(".autocomplete[name='countryTxt']").change(function() { changeCountry(''); }); - - changeCountry({/literal}'{$smarty.request.country}'{literal}); - changeAdministrativeArea({/literal}'{$smarty.request.administrativearea}'{literal}); + if ({/literal}'{$smarty.request.country}'{literal} != '') { + $("[name='country']").parent().load(baseurl + 'list/country', function() { + $("select[name='country']").attr('value', {/literal}'{$smarty.request.country}'{literal}); + }); + setAddress(0, 1, new Array({/literal}'{$smarty.request.country}'{literal}, + {/literal}'{$smarty.request.administrative_area_level_1}'{literal}, + {/literal}'{$smarty.request.administrative_area_level_2}'{literal}, + {/literal}'{$smarty.request.administrative_area_level_3}'{literal}, + {/literal}'{$smarty.request.locality}'{literal}, + {/literal}'{$smarty.request.sublocality}'{literal}) + ); + } else { + var types = new Array('administrative_area_level_1', 'administrative_area_level_2', 'administrative_area_level_3', 'locality', 'sublocality'); + for (var i = 0; i < 5; ++i) { + $("tr#" + types[i] + '_list').hide(); + } + } $(".autocomplete[name='schoolTxt']").change(function() { changeSchool(''); }); @@ -235,7 +283,6 @@ }); $("#only_referent").change(function() { changeOnlyReferent(); }); - changeOnlyReferent(); }); /** Regexps to wipe out from search queries */ @@ -277,6 +324,12 @@ function cleanForm(f) { + @@ -306,6 +359,11 @@ function cleanForm(f) {  et  + @@ -345,6 +403,27 @@ function cleanForm(f) { + A une redirection active + + + + + + + +
+ + + + + +
+ + + En vie @@ -372,10 +451,6 @@ function cleanForm(f) { - - - - - + - + + + + + + + + + + + + + + + + + @@ -413,7 +510,7 @@ function cleanForm(f) { - + @@ -495,6 +592,36 @@ function cleanForm(f) { + + + + + + + + + + + +
Géographie
Ville ou code postal
Pays {icon name="table" title="Tous les pays"}
Région, province, état… - +
Département, comté… - + +
Canton… + +
Ville
Ville + +
Arrondissement, quartier… +
Description
Mots-clefs
Corps d'origine + +
Corps actuel + +
Grade + +
Commentaire contient