/***************************************************************************
- * Copyright (C) 2003-2009 Polytechnique.org *
+ * Copyright (C) 2003-2010 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
case 'emploi':
for (var i = 0 ; $('#job_' + i).length != 0; ++i) {
updateJobSector(i, $('#job_' + i).find("[name='jobs[" + i + "][subSector]']").val());
- updateJobSubSector(i, $('#job_' + i).find("[name='jobs[" + i + "][subSubsector]']").val());
+ updateJobSubSector(i, $('#job_' + i).find("[name='jobs[" + i + "][subSubSector]']").val());
+ updateJobAlternates(i);
+ }
+ if ($('#job_0').find("[name='jobs[0][name]']").val() == '') {
+ registerEnterpriseAutocomplete(0);
}
break;
}
$('.names_advanced').toggle();
}
-function addSearchName()
+function addSearchName(isFemale)
{
var i = 0;
while ($('#search_name_' + i).length != 0) {
i++;
}
- Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i, function(data){
+ Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i + '/' + isFemale, function(data){
$('#searchname').before(data);
changeNameFlag(i);
});
}
-function removeSearchName(i)
+function removeSearchName(i, isFemale)
{
$('#search_name_' + i).remove();
- updateNameDisplay();
+ updateNameDisplay(isFemale);
}
function changeNameFlag(i)
}
}
-function updateNameDisplay()
+function updateNameDisplay(isFemale)
{
var searchnames = '';
for (var i = 0; i < 10; i++) {
searchnames += $('#search_name_' + i).find(':text').val() + ';;';
}
}
- Ajax.update_html(null, 'profile/ajax/buildnames/' + searchnames, function(data){
+ 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]);
});
}
+function toggleParticle(id)
+{
+ if ($('#search_name_' + id).find("[name*='[particle]']").val() == '') {
+ $('#search_name_' + id).find("[name*='[particle]']").val(1);
+ } else {
+ $('#search_name_' + id).find("[name*='[particle]']").val('');
+ }
+}
+
+// Promotions {{{1
+
+function togglePromotionEdition()
+{
+ $(".promotion_edition").toggle();
+}
+
// Nationalities {{{1
function delNationality(i)
{
- $('#nationalite' + i).hide().find('select').val('');
+ $('#nationality' + i).hide().find('select').val('');
}
function addNationality()
{
var i = 0;
- if ($('#nationalite2').find('select').val() == "") {
+ if ($('#nationality2').find('select').val() == "") {
i = 2;
- } else if ($('#nationalite3').find('select').val() == "") {
+ } else if ($('#nationality3').find('select').val() == "") {
i = 3;
}
if ((i == 2) || (i == 3)) {
- $('#nationalite' + i).show();
+ $('#nationality' + i).show();
}
}
function validGeoloc(prefid, id, geoloc)
{
if (geoloc == 1) {
- $('#' + prefid + '_cont').find('[name*=text]').val($('#' + prefid + '_cont').find('[name*=geoloc]').val());
+ $('#' + prefid + '_cont').find('[name*=text]').val($('#' + prefid + '_cont').find('[name*=geocodedText]').val());
$('#' + prefid + '_cont').find('[name*=postalText]').val($('#' + prefid + '_cont').find('[name*=geocodedPostalText]').val());
}
if (geoloc > 0) {
- $('#' + prefid + '_cont').find("[name*='[geoloc]']").remove();
+ $('#' + prefid + '_cont').find("[name*='[geocodedText]']").remove();
+ $('#' + prefid + '_cont').find("[name*='[geocodedPostalText]']").remove();
}
$('#' + prefid + '_cont').find('[name*=text]').removeClass('error');
- $('#' + prefid + '_cont').find('[name*=geoloc_choice]').val(geoloc);
+ $('#' + prefid + '_cont').find('[name*=geocodeChosen]').val(geoloc);
$('.' + prefid + '_geoloc').remove();
}
Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i);
}
-function removeTel(id)
+function removeTel(prefname, prefid, id)
{
- $('#' + id).remove();
+ var total = 0;
+ while ($('#' + prefid + '_' + total).length != 0) {
+ ++total;
+ }
+ $('#' + prefid + '_' + id).remove();
+ for (var i = parseInt(id) + 1; i < total; ++i) {
+ renumberPhone(prefname, prefid, i);
+ }
}
function addPhoneComment(id)
{
- $(id + '_comment').show();
- $(id + '_addComment').hide();
+ $('#' + id + '_comment').show();
+ $('#' + id + '_addComment').hide();
}
function removePhoneComment(id, pref)
{
- $(id + '_comment').hide();
- $(id + '_comment').find("[name='" + pref + "[comment]']").val('');
- $(id + '_addComment').show();
+ $('#' + id + '_comment').hide();
+ $('#' + id + '_comment').find("[name='" + pref + "[comment]']").val('');
+ $('#' + id + '_addComment').show();
+}
+
+function renumberPhone(prefname, prefid, i)
+{
+ var telid = i - 1;
+ var telprefOld = prefname + '[' + i + ']';
+ var telpref = prefname + '[' + telid + ']';
+ var idOld = prefid + '_' + i;
+ var id = prefid + '_' + telid;
+
+ $('#' + idOld).attr('id', id);
+ $('#' + id).find('div.titre').html('N°' + i);
+ $('#' + id).find('a.removeTel').attr('href', 'javascript:removeTel(\'' + prefname + '\',\'' + prefid + '\',' + telid + ')');
+ $('#' + id).find('select').attr('name', telpref + '[type]');
+ $('#' + id).find("[name='" + telprefOld + "[display]']").attr('name', telpref + '[display]');
+ $('#' + id).find("[name='" + telprefOld + "[comment]']").attr('name', telpref + '[comment]');
+ $('#' + id).find('a.removePhoneComment').attr('href', 'javascript:removePhoneComment(' + id + ',' + telpref + ')');
+ $('#' + id).find('#' + idOld + '_addComment').attr('id', id + '_addComment');
+ $('#' + id).find('#' + id + '_addComment').attr('href', 'javascript:addPhoneComment(' + id + ')');
+ $('#' + id).find('#' + idOld + '_comment').attr('id', id + '_comment');
+ $('#' + id).find("[name='" + telprefOld + "[pub]']").attr('name', telpref + '[pub]');
}
// {{{1 Groups
+ ' <div style="float: left; width: 70%">'
+ text
+ ' </div>'
- + ' <a href="javascript:removeElement(\'binets\', ' + id + ')">'
+ + ' <a href="javascript:removeElement(\'binets\',' + id + ')">'
+ ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />'
+ ' </a>'
+ ' </td>'
Ajax.update_html('job_' + id + '_subSubSector', 'profile/ajax/sub_sector/' + id + '/' + subSector + '/' + sel);
}
+function updateJobAlternates(id)
+{
+ var subSubSector = $('#job_' + id).find("[name='jobs[" + id + "][subSubSector]']").val();
+ if (subSubSector != '') {
+ Ajax.update_html('job_' + id + '_alternates', 'profile/ajax/alternates/' + id + '/' + subSubSector);
+ }
+}
+
+function emptyJobSubSector(id)
+{
+ Ajax.update_html('job_' + id + '_subSubSector', 'profile/ajax/sub_sector/' + id + '/-1/-1');
+}
+
+function emptyJobAlternates(id)
+{
+ Ajax.update_html('job_' + id + '_alternates', 'profile/ajax/alternates/' + id + '/-1');
+}
+
function displayAllSector(id)
{
$('.sector_text_' + id).remove();
{
$('#add_job').before(data);
registerEnterpriseAutocomplete(id);
- updateSector('job_' + id, 'jobs[' + id + ']', '');
};
}
$('.entreprise_' + id).toggle();
}
+/**
+ * Adds a job term in job profile page
+ * @param jobid id of profile's job among his different jobs
+ * @param jtid id of job term to add
+ * @param full_name full text of job term
+ * @return false if the term already exist for this job, true otherwise
+ */
+function addJobTerm(jobid, jtid, full_name)
+{
+ var termid = 0;
+ var parentpath;
+ var formvarname;
+ if (jobid < 0) {
+ parentpath = '';
+ jobid = '';
+ formvarname = 'terms';
+ } else {
+ parentpath = '#job_'+jobid+' ';
+ formvarname = 'jobs['+jobid+'][terms]';
+ }
+ var lastJobTerm = $(parentpath + '.job_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 = '<div class="job_term" id="job'+jobid+'_term'+jtid+'">'+
+ '<span>'+full_name+'</span>'+
+ '<input type="hidden" name="'+formvarname+'['+termid+'][jtid]" value="'+jtid+'" />'+
+ '<img title="Retirer ce mot-clef" alt="retirer" src="images/icons/cross.gif" />'+
+ '</div>';
+ if (lastJobTerm.length == 0) {
+ $(parentpath + '.job_terms').prepend(newdiv);
+ } else {
+ lastJobTerm.after(newdiv);
+ }
+ $('#job'+jobid+'_term'+jtid+' img').css('cursor','pointer').click(removeJobTerm);
+ return true;
+}
+
+/**
+ * Remove a job term in job profile page.
+ * Must be called from a button in a div containing the term
+ */
+function removeJobTerm()
+{
+ $(this).parent().remove();
+}
+
+/**
+ * Prepare display for autocomplete suggestions in job terms
+ * @param row an array of (title of term, id of term)
+ * @return text to display
+ * If id is negative, it is because there are too much terms to
+ * be displayed.
+ */
+function displayJobTerm(row)
+{
+ if (row[1] < 0) {
+ return '... <em>précise ta recherche</em> ...';
+ }
+ return row[0];
+}
+
+/**
+ * Function called when a job term has been selected from autocompletion
+ * in search
+ * @param li is the list item (<li>) that has been clicked
+ * The context is the jsquery autocomplete object.
+ */
+function selectJobTerm(li)
+{
+ if (li.extra[0] < 0) {
+ return;
+ }
+ var jobid = this.extraParams.jobid;
+ 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.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)
+{
+ var treepath;
+ if (jobid < 0) {
+ treepath = '';
+ } else {
+ treepath = '#job_'+jobid+' ';
+ }
+ treepath += '.term_tree';
+ if ($(treepath + ' ul').length > 0) {
+ $(treepath).empty().removeClass().addClass('term_tree');
+ return;
+ }
+ createJobTermsTree(treepath, 'profile/ajax/tree/jobterms/all', 'job' + jobid, 'chooseJobTerm');
+}
+
+/**
+ * Function called when a job term is chosen from terms tree
+ * @param treeid is the full id of the tree (must look like job3)
+ * @param jtid is the id of the job term chosen
+ * @param fullname is the complete name (understandable without context) of the term
+ */
+function chooseJobTerm(treeid, jtid, fullname)
+{
+ addJobTerm(treeid.replace(/^job(.*)$/, '$1'), jtid, fullname);
+}
+
// {{{1 Skills
function addSkill(cat)
var val = $('#countries_table').find('[name=countries_sel] :selected').val();
var text = $('#countries_table').find('[name=countries_sel] :selected').text();
var html = '<div id="countries_' + val + '" style="clear: both; margin-bottom: 0.7em">'
- + ' <a href="javascript:removeElement(\'countries\', \'' + val + '\')" style="display: block; float:right">'
+ + ' <a href="javascript:removeElement(\'countries\',\'' + val + '\')" style="display: block; float:right">'
+ ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />'
+ ' </a>'
+ ' <div style="float: left; width: 50%">' + text + '</div>'
function updateSubSector()
{
var s = $('#sectorSelection').find('[name=sectorSelection]').val();
- var ss = $('#selectedSubSector').find("[name='jobs[-1][subSector]']").val();
+ var ss = $('#subSectorSelection').find("[name='jobs[-1][subSector]']").val();
if ((s == '' || ss == '') || $('#sectors_' + s + '_' + ss).length != 0) {
$('#addSector').hide();
} else {
var sector = $('#sectorSelection').find('[name=sectorSelection]').val();
if (sector == '') {
sector = '-1';
- $('#selectedSubSector').html('');
+ $('#subSectorSelection').html('');
return;
}
$.get(platal_baseurl + 'profile/ajax/sector/-1/0/0/' + sector,
function(data) {
data = '<a href="javascript:addSector()" style="display: none; float: right" id="addSector">'
- + ' <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
+ + ' <img src="images/icons/add.gif" alt="Ajouter ce secteur" title="Ajouter ce secteur" />'
+ '</a>' + data;
- $('#selectedSubSector').html(data);
- $('#selectedSubSector').find("[name='jobs[-1][subSector]']").change(updateSubSector);
+ $('#subSectorSelection').html(data);
+ $('#subSectorSelection').find("[name='jobs[-1][subSector]']").change(updateSubSector);
});
}
function addSector()
{
var s = $('#sectorSelection').find('[name=sectorSelection]').val();
- var ss = $('#selectedSubSector').find("[name='jobs[-1][subSector]']").val();
- var sst = $('#selectedSubSector').find("[name='jobs[-1][subSector]'] :selected").text();
+ var ss = $('#subSectorSelection').find("[name='jobs[-1][subSector]']").val();
+ var sst = $('#subSectorSelection').find("[name='jobs[-1][subSector]'] :selected").text();
var html = '<div id="sectors_' + s + '_' + ss + '" style="clear: both; margin-top: 0.5em" class="titre">'
- + ' <a href="javascript:removeSector(\'' + s + '\', \'' + ss + '\')" style="display: block; float: right">'
+ + ' <a href="javascript:removeSector(\'' + s + '\',\'' + ss + '\')" style="display: block; float: right">'
+ ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce secteur" />'
+ ' </a>'
+ ' <input type="hidden" name="sectors[' + s + '][' + ss + ']" value="' + sst + '" />'
function registerEnterpriseAutocomplete(id)
{
- $(".enterprise_name").each(
+ $(".enterpriseName").each(
function() {
if (id == -1 || this.name == "jobs[" + id + "][name]") {
$(this).autocomplete(platal_baseurl + "search/autocomplete/entreprise",
}
});
- $(".sector_name").each(
+ $(".sectorName").each(
function() {
- if (id == -1 || this.name == "jobs[" + id + "][subSubSector]") {
+ if (id == -1 || this.name == "jobs[" + id + "][subSubSectorName]") {
$(this).autocomplete(platal_baseurl + "search/autocomplete/subSubSector",
{
selectOnly:1,