X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fprofile.js;h=a173e4b96a2ef4208bedb4cb99f2aa55a0a3b237;hb=6fc390c771618c19a6af41c70ec5aa8f197e8bf0;hp=ef2c7efbee8e92a66aed144e173cc814d43a335a;hpb=f31c2a2484c122c1ed4928cb9d461917069e4418;p=platal.git diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index ef2c7ef..a173e4b 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -45,7 +45,7 @@ function wizPage_onLoad(id) } break; case 'emploi': - if ($('#job_0').find("[name='jobs[0][name]']").val() == '') { + if ($('#jobs_0').find("[name='jobs[0][name]']").val() == '') { registerEnterpriseAutocomplete(0); } break; @@ -58,6 +58,12 @@ var educationDegreeName; var subgrades; var names; +// Publicity follows the following ordering: private < ax < public. +var publicity = []; +publicity['private'] = 0; +publicity['ax'] = 1; +publicity['public'] = 2; + // Names {{{1 function toggleNamesAdvanced() @@ -161,7 +167,11 @@ function prepareType(id) var edu = $('.edu_' + id).find("[name='edus[" + id + "][eduid]']").val() - 1; var sel = $('.edu_' + id).find('[name=edu_' + id + '_tmp]').val(); var html = ''; - var length = educationDegree[edu].length; + if (educationDegree[edu]) { + var length = educationDegree[edu].length; + } else { + var length = 0; + } for (i = 0; i < length; ++i) { html += ''; + } $('.edu_' + id).find("[name='edus[" + id + "][degreeid]']").html(html); } @@ -319,11 +333,10 @@ function validGeoloc(prefid, id, geoloc) { if (geoloc == 1) { $('#' + prefid + '_cont').find('[name*=text]').val($('#' + prefid + '_cont').find('[name*=geocodedText]').val()); - $('#' + prefid + '_cont').find('[name*=postalText]').val($('#' + prefid + '_cont').find('[name*=geocodedPostalText]').val()); + $('#' + prefid + '_cont').find('[name*=postalText]').val(''); } if (geoloc > 0) { $('#' + prefid + '_cont').find("[name*='[geocodedText]']").remove(); - $('#' + prefid + '_cont').find("[name*='[geocodedPostalText]']").remove(); } $('#' + prefid + '_cont').find('[name*=text]').removeClass('error'); $('#' + prefid + '_cont').find('[name*=geocodeChosen]').val(geoloc); @@ -332,7 +345,7 @@ function validGeoloc(prefid, id, geoloc) // {{{1 Phones -function addTel(prefid, prefname) +function addTel(prefid, prefname, subField, mainField, mainId) { var i = 0; var prefix = prefid + '_'; @@ -340,7 +353,7 @@ function addTel(prefid, prefname) i++; } $('#' + prefix + 'add').before('
'); - Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i); + Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i + '/' + subField + '/' + mainField + '/' + mainId); } function removeTel(prefname, prefid, id) @@ -512,7 +525,7 @@ function makeAddJob(id) function addJob() { var i = 0; - while ($('#job_' + i).length != 0) { + while ($('#jobs_' + i).length != 0) { ++i; } $.get(platal_baseurl + 'profile/ajax/job/' + i, makeAddJob(i)); @@ -540,23 +553,23 @@ function addJobTerm(jobid, jtid, full_name) jobid = ''; formvarname = 'terms'; } else { - parentpath = '#job_'+jobid+' '; + parentpath = '#jobs_'+jobid+' '; formvarname = 'jobs['+jobid+'][terms]'; } - var lastJobTerm = $(parentpath + '.job_term:last'); + var lastJobTerm = $(parentpath + '.jobs_term:last'); if (lastJobTerm.length != 0) { termid = parseInt(lastJobTerm.children('input').attr('name').replace(/^(jobs\[[0-9]+\]\[terms\]|terms)\[([0-9]+)\]\[jtid\]/, '$2')) + 1; if ($('#job'+jobid+'_term'+jtid).length > 0) { return false; } } - var newdiv = '
'+ + var newdiv = '
'+ ''+full_name+''+ ''+ 'retirer'+ '
'; if (lastJobTerm.length == 0) { - $(parentpath + '.job_terms').prepend(newdiv); + $(parentpath + '.jobs_terms').prepend(newdiv); } else { lastJobTerm.after(newdiv); } @@ -604,7 +617,7 @@ function selectJobTerm(li) if (jobid < 0) { search_input = $('.term_search')[0]; } else { - search_input = $('#job_'+jobid+' .term_search')[0]; + search_input = $('#jobs_'+jobid+' .term_search')[0]; } if (li.extra[0] >= 0) { search_input.value = ''; @@ -625,7 +638,7 @@ function toggleJobTermsTree(jobid, textfilter) if (jobid < 0) { treepath = ''; } else { - treepath = '#job_'+jobid+' '; + treepath = '#jobs_'+jobid+' '; } treepath += '.term_tree'; if ($(treepath + ' ul').length > 0) { @@ -726,4 +739,42 @@ function removeElement(cat, id) updateElement(cat); } +function updateSubPublicity(subFieldId, name, mainPub) +{ + var subPub = $(subFieldId).find("[name='" + name + "']:checked").val(); + if (publicity[subPub] > publicity[mainPub]) { + $(subFieldId).find("[name='" + name + "']:checked").removeAttr('checked'); + $(subFieldId).find('[value=' + mainPub + ']').attr('checked', 'checked'); + } +} + +function updatePublicity(mainField, mainId, subField, subId) +{ + var mainFieldId = '#' + mainField + '_' + mainId; + var mainPub = $(mainFieldId).find("[name='" + mainField + "[" + mainId + "][pub]']:checked").val(); + if (subId == -1) { + var subFields = subField.split(','); + for (var i =0; i < subFields.length; ++i) { + var subFieldBaseId = mainFieldId + '_' + subFields[i]; + var name = mainField + '[' + mainId + '][' + subFields[i] + ']'; + if ($(subFieldBaseId).length != 0) { + updateSubPublicity(subFieldBaseId, name + '[pub]', mainPub); + updateSubPublicity(subFieldBaseId, mainField + '[' + mainId + '][' + subFields[i] + '_pub]', mainPub); + } + subId = 0; + while ($(subFieldBaseId + '_' + subId).length != 0) { + updateSubPublicity(subFieldBaseId + '_' + subId, name + '[' + subId + '][pub]', mainPub); + ++subId; + } + } + } else { + if (subId == '') { + updateSubPublicity(mainFieldId + '_' + subField, mainField + '[' + mainId + '][' + subField + '_pub]', mainPub); + updateSubPublicity(mainFieldId + '_' + subField, mainField + '[' + mainId + '][' + subField + '][pub]', mainPub); + } else { + updateSubPublicity(mainFieldId + '_' + subField + '_' + subId, mainField + '[' + mainId + '][' + subField + '][' + subId + '][pub]', mainPub); + } + } +} + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: