X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=templates%2Fsearch%2Fadv.form.tpl;h=6f38815530d6e7e1a2094e6ec11b0297b923699d;hb=e7737284cdd0e8dba0ced26c4778dd31a2fae50d;hp=3806eb76edef7d3d60f69f6fa20094ad702a099b;hpb=e999a40a812f8a2f350d69c5e1611669ff8937d1;p=platal.git diff --git a/templates/search/adv.form.tpl b/templates/search/adv.form.tpl index 3806eb7..6f38815 100644 --- a/templates/search/adv.form.tpl +++ b/templates/search/adv.form.tpl @@ -26,292 +26,12 @@
Voulez-vous télécharger le tableau des adresses postales pour la recette précédente ?
{/if} - - // display an autocomplete row : blabla (nb of found matches) - function make_format_autocomplete(block) { - return function(row) { - regexp = new RegExp('(' + RegExp.escape(block.value) + ')', 'i'); - - name = row[0].htmlEntities().replace(regexp, '$1<\/strong>'); - - if (row[1] === "-1") { - return '…'; - } - - if (row[1] === "-2") { - return 'aucun camarade trouvé pour '+row[0].htmlEntities()+'<\/em>'; - } - - camarades = (row[1] > 1) ? "camarades" : "camarade"; - - return name + ' - ' + row[1].htmlEntities() + ' ' + camarades + '<\/em>'; - }; - } - - 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', ''); - } - - $("[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); - } - } - }); - - } - - 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'; - - if (j == 3) { - $('tr#locality_text').hide() - $("select[name='localityTxt']").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); - } - } - }); - } - - 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; - } - - 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); - } - } - - // when changing school, open diploma choice - function changeSchool(schoolId) { - $(".autocompleteTarget[name='school']").attr('value',schoolId); - - if (schoolId) { - $(".autocomplete[name='schoolTxt']").addClass('hidden_valid'); - } else { - $(".autocomplete[name='schoolTxt']").removeClass('hidden_valid'); - } - - $("[name='diploma']").parent().load(baseurl + 'list/diploma/', { school:schoolId }, function() { - $("select[name='diploma']").attr('value', '{/literal}{$smarty.request.diploma}{literal}'); - }); - } - - // when checking/unchecking "only_referent", disable/enable some fields - function changeOnlyReferent() { - if ($("#only_referent").is(':checked')) { - $("input[name='entreprise']").attr('disabled', true); - } else { - $("input[name='entreprise']").removeAttr('disabled'); - } - } - - // when choosing a job term in tree, hide tree and set job term field - function searchForJobTerm(treeid, jtid, full_name) { - $(".term_tree").remove(); - $("input[name='jobtermTxt']").val(full_name).addClass("hidden_valid").show(); - $("input[name='jobterm']").val(jtid); - } - - function cancel_autocomplete(field, realfield) { - $(".autocomplete[name='"+field+"']").removeClass('hidden_valid').val('').focus(); - if (typeof(realfield) != "undefined") { - $(".autocompleteTarget[name='"+realfield+"']").val(''); - } - return; - } - - // when choosing autocomplete from list, must validate - function select_autocomplete(name) { - nameRealField = name.replace(/Txt$/, ''); - - // nothing to do if field is not a text field for a list - if (nameRealField == name) - return null; - - // 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(name, nameRealField); - 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) { - if (i.extra[0] < 0) { - cancel_autocomplete('schoolTxt', 'school'); - i.extra[1] = ''; - } - changeSchool(i.extra[1]); - } - - // change field in list and display text field as valid - return function(i) { - nameRealField = this.field.replace(/Txt$/, ''); - - if (i.extra[0] < 0) { - cancel_autocomplete(this.field, nameRealField); - return; - } - - $(".autocompleteTarget[name='"+nameRealField+"']").attr('value',i.extra[1]); - - $(".autocomplete[name='"+this.field+"']").addClass('hidden_valid'); - } - } - - $(function() { - $(".autocompleteTarget").hide(); - $(".autocomplete").show().each(function() { - targeted = $("../.autocompleteTarget",this)[0]; - - if (targeted && targeted.value) { - me = $(this); - - $.get(baseurl + 'list/'+ targeted.name +'/'+targeted.value, {},function(textValue) { - me.attr('value', textValue); - me.addClass('hidden_valid'); - }); - } - - $(this).autocomplete(baseurl + "autocomplete/"+this.name,{ - selectOnly:1, - formatItem:make_format_autocomplete(this), - field:this.name, - onItemSelect:select_autocomplete(this.name), - matchSubset:0, - width:$(this).width()}); - }); - - $(".autocomplete").change(function() { $(this).removeClass('hidden_valid'); }); - - 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(''); }); - - changeSchool({/literal}'{$smarty.request.school}'{literal}); - - $(".autocompleteToSelect").each(function() { - var fieldName = $(this).attr('href'); - - $(this).attr('href', baseurl + 'list/'+fieldName).click(function() { - var oldval = $("input.autocompleteTarget[name='"+fieldName+"']")[0].value; - - $(".autocompleteTarget[name='"+fieldName+"']").parent().load(baseurl + 'list/'+fieldName,{}, - function(selectBox) { - $(".autocompleteTarget[name='"+fieldName+"']").remove(); - $(".autocomplete[name='"+fieldName+"Txt']").remove(); - $("select[name='"+fieldName+"']").attr('value', oldval); - }); - - return false; - }); - }).parent().find('.autocomplete').change(function() { - // If we change the value in the type="text" field, then the value in the 'integer id' field must not be used, - // to ensure that, we unset it - $(this).parent().find('.autocompleteTarget').val(''); - }); - - $("#only_referent").change(function() { changeOnlyReferent(); }); - - }); -/** Regexps to wipe out from search queries */ -var default_form_values = [ /&woman=0(&|$)/, /&subscriber=0(&|$)/, /&alive=0(&|$)/, /&egal[12]=[^&]*&promo[12]=(&|$)/g, /&networking_type=0(&|$)/, /&[^&=]+=(&|$)/g ]; -/** Uses javascript to clean form from all empty fields */ -function cleanForm(f) { - var query = $(f).formSerialize(); - var old_query; - for (var i in default_form_values) { - var reg = default_form_values[i]; - if (typeof(reg) != "undefined") { - do { - old_query = query; - query = query.replace(reg, '$1'); - } while (old_query != query); - } - } - query = query.replace(/^&*(.*)&*$/, '$1'); - if (query == "rechercher=Chercher") { - alert("Aucun critère n'a été spécifié"); - return false; - } - document.location = baseurl + 'adv?' + query; - return false; -} ---> -{/literal} -