/***************************************************************************
- * Copyright (C) 2003-2008 Polytechnique.org *
+ * Copyright (C) 2003-2009 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
{
switch (id) {
case 'general':
- fillType(document.forms.prof_annu['appli1[type]'], document.forms.prof_annu['appli1[id]'].selectedIndex-1);
- selectType(document.forms.prof_annu['appli1[type]'], document.forms.prof_annu['appli1_tmp'].value);
- fillType(document.forms.prof_annu['appli2[type]'], document.forms.prof_annu['appli2[id]'].selectedIndex-1);
- selectType(document.forms.prof_annu['appli2[type]'], document.forms.prof_annu['appli2_tmp'].value);
+ var i = 0;
+ var prefix = 'edu_';
+ while ($('.' + prefix + i).length != 0) {
+ i++;
+ }
+ i--;
+ for (var j = 0; j < i; j++) {
+ prepareType(j);
+ }
break;
case 'poly':
updateGroupSubLink(document.forms.prof_annu.groupesx_sub);
for (var i = 0 ; document.getElementById('job_' + i) != null ; ++i) {
updateJobSecteur(i, 'job_' + i, 'jobs[' + i + ']',
document.forms.prof_annu["jobs[" + i + "][ss_secteur]"].value);
+ updateJobSousSecteur(i, 'job_' + i, 'jobs[' + i + ']',
+ document.forms.prof_annu["jobs[" + i + "][sss_secteur]"].value);
}
+ setTimeout('registerEnterpriseAutocomplete(-1)', 100);
break;
}
}
-var applisType;
-var applisTypeAll;
+var educationDegree;
+var educationDegreeAll;
+var educationDegreeName;
// General
var subgrades;
var names;
-function fillType(selectCtrl, appli, fill)
+function fillType(selectCtrl, edu, fill)
{
var i;
- var i0=0;
+ var i0 = 0;
- for (i = selectCtrl.options.length; i >=0; i--) {
+ for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null;
}
- if (fill || appli <0) {
+ if (fill || edu < 0) {
selectCtrl.options[0] = new Option(' ');
- i0=1;
+ i0 = 1;
+ }
+ if (edu >= 0) {
+ for (i = 0; i < educationDegree[edu].length; i++) {
+ selectCtrl.options[i0 + i] = new Option(educationDegreeName[educationDegree[edu][i] - 1], educationDegree[edu][i]);
+ }
+ } else if (fill) {
+ for (i = 0; i < educationDegreeAll.length; i++) {
+ selectCtrl.options[i0 + i] = new Option(educationDegreeName[educationDegreeAll[i] - 1], educationDegreeAll[i]);
+ }
}
- if (appli>=0)
- for (i=0; i < applisType[appli].length; i++)
- selectCtrl.options[i0+i] = new Option(applisType[appli][i]);
- else if (fill)
- for (i=0; i < applisTypeAll.length; i++)
- selectCtrl.options[i0+i] = new Option(applisTypeAll[i]);
}
function selectType(selectCtrl, type)
{
for (i = 0; i < selectCtrl.options.length; i++) {
- if (selectCtrl.options[i].text == type)
- selectCtrl.selectedIndex=i;
+ if (selectCtrl.options[i].value == type) {
+ selectCtrl.selectedIndex = i;
+ }
}
}
+function prepareType(i)
+{
+ fillType(document.forms.prof_annu["edus[" + i + "][degreeid]"], document.forms.prof_annu["edus[" + i + "][eduid]"].selectedIndex - 1);
+ selectType(document.forms.prof_annu["edus[" + i + "][degreeid]"], document.forms.prof_annu["edu_" + i + "_tmp"].value);
+}
+
+function displayNamesAdvanced()
+{
+ $('.names_advanced').show();
+}
+
function addSearchName()
{
- var i = 0;
- while (document.getElementById('search_name_' + i) != null) {
- i++;
- }
- $('#add_search_name').before('<div id="search_name_' + i + '" style="padding:2px" class="center"></div>');
- Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i,function(){
- $('#search_name_'+i+' input')[1].focus();
- });
+ var i = 0;
+ while ($('#search_name_' + i).length != 0) {
+ i++;
+ }
+ Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i, function(data){
+ $('#searchname').before(data);
+ changeNameFlag(i);
+ });
}
function removeSearchName(i)
{
- if (document.getElementById('search_name_'+i+'_new') != null) {
- $('#search_name_'+i).remove();
- } else {
- removeObject('search_name_'+i, 'search_name['+i+']');
- }
+ $('#search_name_' + i).remove();
+ updateNameDisplay();
+}
+
+function changeNameFlag(i)
+{
+ $('#flag_' + i).remove();
+ var typeid = $('#search_name_' + i).find('select').val();
+ var type = $('#search_name_' + i).find('select :selected').text();
+ if ($('[@name=sn_type_' + typeid + '_' + i + ']').val() > 0) {
+ $('#flag_cb_' + i).after('<span id="flag_' + i + '"> ' +
+ '<img src="images/icons/flag_green.gif" alt="site public" title="site public" />' +
+ '<input type="hidden" name="search_names[' + i + '][pub]" value="1"/>' +
+ '<input type="hidden" name="search_names[' + i + '][typeid]" value="' + typeid + '"/>' +
+ '<input type="hidden" name="search_names[' + i + '][type]" value="' + type + '"/></span>');
+ } else {
+ $('#flag_cb_' + i).after('<span id="flag_' + i + '"> ' +
+ '<img src="images/icons/flag_red.gif" alt="site privé" title="site privé" />' +
+ '<input type="hidden" name="search_names[' + i + '][typeid]" value="' + typeid + '"/>' +
+ '<input type="hidden" name="search_names[' + i + '][type]" value="' + type + '"/></span>');
+ }
+}
+
+function updateNameDisplay()
+{
+ var searchnames = '';
+ for (var i = 0; i < 10; i++) {
+ if ($('#search_name_' + i).find(':text').val()) {
+ searchnames += $('#search_name_' + i).find('[name*=typeid]').val() + ';';
+ searchnames += $('#search_name_' + i).find(':checked').length-1 + ';';
+ searchnames += $('#search_name_' + i).find(':text').val() + ';;';
+ }
+ }
+ Ajax.update_html(null, 'profile/ajax/buildnames/' + searchnames, function(data){
+ var name = data.split(';');
+ $('#public_name').html(name[0]);
+ $('#private_name').html(name[0] + name[1]);
+ });
+}
+
+function delNationality(i)
+{
+ $('#nationalite' + i).hide().find('select').val('');
+}
+
+function addNationality()
+{
+ var i = 0;
+ if ($('#nationalite2').find('select').val() == "") {
+ i = 2;
+ } else if ($('#nationalite3').find('select').val() == "") {
+ i = 3;
+ }
+ if ((i == 2) || (i == 3)) {
+ $('#nationalite' + i).show();
+ }
+}
+
+function addNetworking()
+{
+ var i = 0;
+ var nws = 'networking_';
+ while (document.getElementById(nws + i) != null) {
+ i++;
+ }
+ var namefirst = '';
+ var html = '<tr id="networking_' + i + '">'
+ + ' <td colspan="2">'
+ + ' <div style="float: left; width: 200px;">'
+ + ' <span class="flags">'
+ + ' <input type="checkbox" name="networking[' + i + '][pub]"/>'
+ + ' <img src="images/icons/flag_green.gif" alt="site public" title="site public">'
+ + ' </span> '
+ + ' <select id="networking_type_' + i + '" name="networking[' + i + '][type]" onchange="javascript:updateNetworking(' + i + ');">';
+ for (nw in nw_list) {
+ if (namefirst == '') {
+ namefirst = nw;
+ }
+ html += ' <option value="' + nw_list[nw] + '">' + nw + '</option>';
+ }
+ html += '</select>'
+ + ' <input type="hidden" id="networking_name_' + i + '" name="networking[' + i + '][name]" value="' + namefirst + '"/>'
+ + ' </div>'
+ + ' <div style="float: left">'
+ + ' <input type="text" name="networking[' + i + '][address]" value="" size="30"/>'
+ + ' <a href="javascript:removeNetworking(' + i + ')">'
+ + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer cet élément"/>'
+ + ' </a>'
+ + ' </div>'
+ + ' </td>'
+ + '</tr>';
+
+ $('#networking').before(html);
+}
+
+function removeNetworking(id)
+{
+ $('#networking_' + id).remove();
+}
+
+function updateNetworking(i)
+{
+ var name = document.getElementById('networking_name_' + i);
+ var type = document.getElementById('networking_type_' + i);
+ if (type != null && name != null) {
+ name.value = type.options[type.selectedIndex].text;
+ }
+
}
// Addresses
Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress);
}
-function addTel(id)
+function addEdu()
{
var i = 0;
- var adid = 'addresses_' + id;
- var tel = adid + '_tel_';
- while (document.getElementById(tel + i) != null) {
+ var j = 0;
+ var prefix = 'edu_';
+ var class_parity;
+
+ while (!$('#edu_add').hasClass(prefix + i)) {
+ if ($('.' + prefix + i).length != 0) {
+ j++;
+ }
+ i++;
+ }
+ if (j % 2) {
+ class_parity = 'pair';
+ } else {
+ class_parity = 'impair';
+ }
+ $('#edu_add').removeClass(prefix + i);
+ i++;
+ $('#edu_add').addClass(prefix + i);
+ i--;
+ $.get(platal_baseurl + 'profile/ajax/edu/' + i + '/' + class_parity,
+ function(data) {
+ $('#edu_add').before(data);
+ prepareType(i);
+ });
+}
+
+function removeEdu(i)
+{
+ var prefix = 'edu_';
+ $('.' + prefix + i).remove();
+ while (!$('#edu_add').hasClass(prefix + i)) {
+ $('.' + prefix + i).toggleClass('pair');
+ $('.' + prefix + i).toggleClass('impair');
i++;
}
- $('#' + adid + '_add_tel').before('<div id="' + tel + i + '" style="clear: both"></div>');
- Ajax.update_html(tel + i, 'profile/ajax/tel/' + id + '/' + i);
}
+function addTel(prefid, prefname)
+{
+ var i = 0;
+ var prefix = prefid + '_';
+ while (document.getElementById(prefix + i) != null) {
+ i++;
+ }
+ $('#' + prefix + 'add').before('<div id="' + prefix + i + '" style="clear: both; padding-top: 4px; padding-bottom: 4px"></div>');
+ Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i);
+}
+
+function removeTel(id)
+{
+ $('#' + id).remove();
+}
+
+function addPhoneComment(id, pref)
+{
+ document.getElementById(id+'_comment').style.display = '';
+ document.getElementById(id+'_addComment').style.display = 'none';
+}
+
+function removePhoneComment(id, pref)
+{
+ document.getElementById(id+'_comment').style.display = 'none';
+ document.forms.prof_annu[pref+ '[comment]'].value = '';
+ document.getElementById(id+'_addComment').style.display = '';
+}
// Geoloc
document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
document.forms.prof_annu[pref + "[text]"].value = document.forms.prof_annu[pref + "[geoloc]"].value;
document.forms.prof_annu[pref + "[cityid]"].value = document.forms.prof_annu[pref + "[geoloc_cityid]"].value;
- attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
- function() { document.forms.prof_annu[pref + "[text]"].blur(); });
+ $(document.forms.prof_annu[pref + "[text]"]).click(function() { document.forms.prof_annu[pref + "[text]"].blur(); });
document.forms.prof_annu[pref + "[text]"].className = '';
}
document.getElementById(id + '_geoloc_error').style.display = 'none';
document.getElementById(id + '_geoloc_valid').style.display = 'none';
document.forms.prof_annu[pref + "[parsevalid]"].value = "1";
- attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
- function() { document.forms.prof_annu[pref + "[text]"].blur(); });
+ $(document.forms.prof_annu[pref + "[text]"]).click(function() { document.forms.prof_annu[pref + "[text]"].blur(); });
document.forms.prof_annu[pref + "[text]"].className = '';
}
if (secteur == '') {
secteur = '-1';
}
- Ajax.update_html(id + '_ss_secteur', 'profile/ajax/secteur/' +nb + '/' + secteur + '/' + sel);
+ Ajax.update_html(id + '_ss_secteur', 'profile/ajax/secteur/' + nb + '/' + id + '/' + pref + '/' + secteur + '/' + sel);
+}
+
+function updateJobSousSecteur(nb, id, pref, sel)
+{
+ var ssecteur = document.forms.prof_annu[pref + '[ss_secteur]'].value;
+ if (ssecteur == '') {
+ ssecteur = '-1';
+ }
+ Ajax.update_html(id + '_sss_secteur', 'profile/ajax/ssecteur/' + nb + '/' + ssecteur + '/' + sel);
+}
+
+function displayAllSector(id)
+{
+ $('.sector_text_' + id).remove();
+ $('.sector_' + id).show();
}
function makeAddJob(id)
return function(data)
{
$('#add_job').before(data);
+ registerEnterpriseAutocomplete(id);
updateSecteur('job_' + id, 'jobs[' + id + ']', '');
};
}
$.get(platal_baseurl + 'profile/ajax/job/' + i, makeAddJob(i));
}
+function addEntreprise(id)
+{
+ $('.entreprise_' + id).toggle();
+}
// Skills
document.getElementById('ss_secteur_sel').innerHTML = '';
return;
}
- $.get(platal_baseurl + 'profile/ajax/secteur/-1/' + secteur,
+ $.get(platal_baseurl + 'profile/ajax/secteur/-1/0/0/' + secteur,
function(data) {
- data = '<a href="javascript:addSecteur()" style="display: none; float: right" id="secteurs_add">'
- + ' <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
- + '</a>' + data;
- document.getElementById('ss_secteur_sel').innerHTML = data;
- attachEvent(document.forms.prof_annu['jobs[-1][ss_secteur]'], 'change', updateSSecteur);
+ data = '<a href="javascript:addSecteur()" style="display: none; float: right" id="secteurs_add">'
+ + ' <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
+ + '</a>' + data;
+ document.getElementById('ss_secteur_sel').innerHTML = data;
+ $(document.forms.prof_annu['jobs[-1][ss_secteur]']).change(updateSSecteur);
});
}
updateSSecteur();
}
+function registerEnterpriseAutocomplete(id)
+{
+ $(".enterprise_name").each(
+ function() {
+ if (id == -1 || this.name == "jobs[" + id + "][name]") {
+ $(this).autocomplete(platal_baseurl + "search/autocomplete/entreprise",
+ {
+ selectOnly:1,
+ field:this.name,
+ matchSubset:0,
+ width:$(this).width()
+ });
+ }
+ }
+ );
+
+ $(".sector_name").each(
+ function() {
+ if (id == -1 || this.name == "jobs[" + id + "][sss_secteur_name]") {
+ $(this).autocomplete(platal_baseurl + "search/autocomplete/sss_secteur",
+ {
+ selectOnly:1,
+ field:this.name,
+ matchSubset:0,
+ width:$(this).width()
+ });
+ }
+ }
+ );
+}
+
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: