X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fprofile.js;h=f0ca309b4487c23c9c9bbdabb4f389b93e3fe95e;hb=63c891790bd2fe0fd5319908cbeafee7e06a5a3b;hp=ce2273e00ed5474e47ff8237c1cfa9d36ff3225f;hpb=cecdf74795e71ed038411915dad5e0dff6ea51fa;p=platal.git diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index ce2273e..f0ca309 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2003-2010 Polytechnique.org * + * Copyright (C) 2003-2011 Polytechnique.org * * http://opensource.polytechnique.org/ * * * * This program is free software; you can redistribute it and/or modify * @@ -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() @@ -71,10 +77,12 @@ function addSearchName(isFemale) while ($('#search_name_' + i).length != 0) { i++; } - Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i + '/' + isFemale, function(data){ - $('#searchname').before(data); - changeNameFlag(i); - }); + $('#search_name_' + i) + .updateHtml('profile/ajax/searchname/' + i + '/' + isFemale, + function(data) { + $('#searchname').before(data); + changeNameFlag(i); + }); } function removeSearchName(i, isFemale) @@ -111,11 +119,12 @@ function updateNameDisplay(isFemale) searchnames += $('#search_name_' + i).find(':text').val() + ';;'; } } - Ajax.update_html(null, 'profile/ajax/buildnames/' + searchnames + '/' + isFemale, function(data){ - var name = data.split(';'); - $('#public_name').html(name[0]); - $('#private_name').html(name[0] + name[1]); - }); + $.xget('profile/ajax/buildnames/' + searchnames + '/' + isFemale, + function(data){ + var name = data.split(';'); + $('#public_name').html(name[0]); + $('#private_name').html(name[0] + name[1]); + }); } function toggleParticle(id) @@ -161,7 +170,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); } @@ -194,7 +211,7 @@ function addEdu() i++; $('#edu_add').addClass(prefix + i); i--; - $.get(platal_baseurl + 'profile/ajax/edu/' + i + '/' + class_parity, + $.xget('profile/ajax/edu/' + i + '/' + class_parity, function(data) { $('#edu_add').before(data); prepareType(i); @@ -307,7 +324,8 @@ function addAddress() i++; } $('#add_address').before('
'); - Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress()); + $('#addresses_' + i + '_cont').updateHtml('profile/ajax/address/' + i, + checkCurrentAddress()); } function addressChanged(prefid) @@ -319,11 +337,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 +349,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 +357,7 @@ function addTel(prefid, prefname) i++; } $('#' + prefix + 'add').before('
'); - Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i); + $('#' + prefix + i).updateHtml('profile/ajax/tel/' + prefid + '/' + prefname + '/' + i + '/' + subField + '/' + mainField + '/' + mainId); } function removeTel(prefname, prefid, id) @@ -472,7 +489,7 @@ function makeAddProcess(id) function addMedal() { var id = $('#medals').find('[name=medal_sel]').val(); - $.get(platal_baseurl + 'profile/ajax/medal/' + id, makeAddProcess(id)); + $.xget('profile/ajax/medal/' + id, makeAddProcess(id)); } function removeMedal(id) @@ -512,10 +529,10 @@ 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)); + $.xget('profile/ajax/job/' + i, makeAddJob(i)); } function addEntreprise(id) @@ -540,23 +557,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); } @@ -583,7 +600,7 @@ function removeJobTerm() function displayJobTerm(row) { if (row[1] < 0) { - return '... précise ta recherche ...'; + return '... parcourir les résultats dans un arbre ...'; } return row[0]; } @@ -596,39 +613,47 @@ function displayJobTerm(row) */ function selectJobTerm(li) { - if (li.extra[0] < 0) { - return; - } var jobid = this.extraParams.jobid; - addJobTerm(jobid,li.extra[0],$(li).text()); + if (li.extra[0] >= 0) { + addJobTerm(jobid,li.extra[0],$(li).text()); + } var search_input; 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 = ''; + search_input.focus(); + } else { + search_input.value = li.selectValue.replace(/%$/,''); + toggleJobTermsTree(jobid, li.selectValue); } - search_input.value = ''; - search_input.focus(); } /** * Function to show or hide a terms tree in job edition * @param jobid is the id of the job currently edited */ -function toggleJobTermsTree(jobid) +function toggleJobTermsTree(jobid, textfilter) { + $('#term_tree_comment').toggle(); + var treepath; if (jobid < 0) { treepath = ''; } else { - treepath = '#job_'+jobid+' '; + treepath = '#jobs_'+jobid+' '; } treepath += '.term_tree'; if ($(treepath + ' ul').length > 0) { $(treepath).empty().removeClass().addClass('term_tree'); - return; + if (!textfilter) { + return; + } } - createJobTermsTree(treepath, 'profile/ajax/tree/jobterms/all', 'job' + jobid, 'chooseJobTerm'); + createJobTermsTree(treepath, 'profile/ajax/tree/jobterms/all', 'job' + jobid, 'chooseJobTerm', textfilter); } /** @@ -648,7 +673,7 @@ function addSkill(cat) { var val = $('#' + cat + '_table').find('[name=' + cat + '_sel]').val(); var text = $('#' + cat + '_table').find('[name=' + cat + '_sel] :selected').text(); - $.get(platal_baseurl + 'profile/ajax/skill/' + cat + '/' + val, + $.xget('profile/ajax/skill/' + cat + '/' + val, function(data) { $('#' + cat).append(data); $('#' + cat + '_' + val + '_title').text(text); @@ -678,7 +703,7 @@ function registerEnterpriseAutocomplete(id) $(".enterpriseName").each( function() { if (id == -1 || this.name == "jobs[" + id + "][name]") { - $(this).autocomplete(platal_baseurl + "search/autocomplete/entreprise", + $(this).autocomplete($.plURL("search/autocomplete/entreprise"), { selectOnly:1, field:this.name, @@ -691,7 +716,7 @@ function registerEnterpriseAutocomplete(id) $(".sectorName").each( function() { if (id == -1 || this.name == "jobs[" + id + "][subSubSectorName]") { - $(this).autocomplete(platal_baseurl + "search/autocomplete/subSubSector", + $(this).autocomplete($.plURL("search/autocomplete/subSubSector"), { selectOnly:1, field:this.name, @@ -720,4 +745,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: