X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=htdocs%2Fjavascript%2Fprofile.js;h=97de16714c01f1356a05ec052da1f52ff5f995fe;hb=821198c7f5394839f6421c54a32ae2a0dca19b3d;hp=3a10c1700580defa8a392778afa7cf95d2d73430;hpb=57fa97b3b0820a76b26a1d17c078c3663b161922;p=platal.git diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index 3a10c17..97de167 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -66,9 +66,12 @@ publicity['public'] = 2; // Names {{{1 -function toggleNamesAdvanced() +function toggleNamesAdvanced(togglePrivate) { - $('.names_advanced').toggle(); + $('.names_advanced_public').toggle(); + if (togglePrivate) { + $('.names_advanced_private').toggle(); + } } function addSearchName(isFemale) @@ -77,12 +80,10 @@ function addSearchName(isFemale) while ($('#search_name_' + i).length != 0) { i++; } - $('#search_name_' + i) - .updateHtml('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); + }); } function removeSearchName(i, isFemale) @@ -91,34 +92,29 @@ function removeSearchName(i, isFemale) updateNameDisplay(isFemale); } -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(' ' + - 'site public' + - '' + - '' + - ''); - } else { - $('#flag_cb_' + i).after(' ' + - 'site privé' + - '' + - ''); - } -} - function updateNameDisplay(isFemale) { + var lastnames = new Array('lastname_main', 'lastname_ordinary', 'lastname_marital', 'pseudonym'); + var firstnames = new Array('firstname_main', 'firstname_ordinary'); var searchnames = ''; - for (var i = 0; i < 10; i++) { + + for (var i = 0; i < 4; ++i) { + searchnames += $('.names_advanced').find('[name*=' + lastnames[i] + ']').val() + ';'; + } + searchnames += '-;' + for (var i = 0; i < 2; ++i) { + searchnames += $('.names_advanced').find('[name*=' + firstnames[i] + ']').val() + ';'; + } + searchnames += '-'; + + var has_private = false; + 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(':text').val() + ';;'; + searchnames += ';' + $('#search_name_' + i).find('[name*=type]').val() + ';' + $('#search_name_' + i).find(':text').val(); + has_private = true; } } + searchnames += (has_private ? '' : ';'); $.xget('profile/ajax/buildnames/' + searchnames + '/' + isFemale, function(data){ var name = data.split(';'); @@ -127,15 +123,6 @@ function updateNameDisplay(isFemale) }); } -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() @@ -277,6 +264,44 @@ function updateNetworking(i) $('#networking_' + i).find("[name='networking[" + i + "][name]']").val($('#networking_' + i).find('select option:selected').text()); } +// Hobby {{{1 + +function addHobby() +{ + var i = 0; + while ($('#hobby_' + i).length != 0) { + ++i; + } + var html = '' + + ' ' + + '
' + + ' ' + + ' ' + + ' site public' + + '  ' + + ' ' + + '
' + + '
' + + ' ' + + ' ' + + ' cross' + + ' ' + + '
' + + ' ' + + ''; + + $('#hobby').before(html); +} + +function removeHobby(id) +{ + $('#hobby_' + id).remove(); +} + // Addresses {{{1 function toggleAddress(id, val) @@ -317,25 +342,39 @@ function checkCurrentAddress(id) } } -function addAddress() +function addAddress(pid) { var i = 0; while ($('#addresses_' + i + '_cont').length != 0) { i++; } $('#add_address').before('
'); - $('#addresses_' + i + '_cont').updateHtml('profile/ajax/address/' + i, + $('#addresses_' + i + '_cont').updateHtml('profile/ajax/address/' + i + '/' + pid, checkCurrentAddress()); } -function addressChanged(prefid) +function addressChanged(prefid, color) { + var text = $('#' + prefid + '_cont').find("[name*='[text]']").val(); $('#' + prefid + '_cont').find('[name*=changed]').val("1"); + $.xpost('map_url/', { text:text, color:color }, function(data) { + if (data) { + $('#' + prefid + '_static_map_url').show(); + $('#' + prefid + '_static_map_url').find('img').attr('src', data); + } else { + $('#' + prefid + '_static_map_url').hide(); + $('#' + prefid + '_geocoding_removal').find('[name*=request]:checkbox').removeAttr('checked'); + } + }); } -function deleteGeocoding(prefid, hrpid) +function deleteGeocoding(prefid) { - var confirmation = confirm( + if($('#' + prefid + '_geocoding_removal').find('[name*=request]:checkbox:checked').length == 0) { + return true; + } + + return confirm( "La localisation de l'adresse sert à deux choses : te placer dans " + "le planisphère et te faire apparaître dans la recherche avancée par " + "pays, région, département, ville... La supprimer t'en fera disparaître. " @@ -343,12 +382,6 @@ function deleteGeocoding(prefid, hrpid) + "est réellement erronée. Avant de supprimer cette localisation, l'équipe de " + "Polytechnique.org tentera de la réparer.\n\nConfirmes-tu ta " + "demande de suppression de cette localisation ?"); - - if (confirmation) { - var address = $('#' + prefid).find("[name*='[text]']").val(); - $.xpost('profile/ajax/address/del/' + hrpid, { address:address }); - $('#' + prefid + '_geocoding_removal').html('Localisation en attente de validation.'); - } } // {{{1 Phones @@ -562,13 +595,13 @@ function makeAddJob(id) }; } -function addJob() +function addJob(pid) { var i = 0; while ($('#jobs_' + i).length != 0) { ++i; } - $.xget('profile/ajax/job/' + i, makeAddJob(i)); + $.xget('profile/ajax/job/' + i + '/' + pid, makeAddJob(i)); } function addEntreprise(id) @@ -627,44 +660,28 @@ function removeJobTerm() } /** - * 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 '... parcourir les résultats dans un arbre ...'; - } - return row[0]; -} - -/** * Function called when a job term has been selected from autocompletion * in search * @param li is the list item (
  • ) that has been clicked * The context is the jsquery autocomplete object. */ -function selectJobTerm(li) +function selectJobTerm(id, value, jobid) { - var jobid = this.extraParams.jobid; - if (li.extra[0] >= 0) { - addJobTerm(jobid,li.extra[0],$(li).text()); + if (id >= 0) { + addJobTerm(jobid, id, value); } var search_input; if (jobid < 0) { search_input = $('.term_search')[0]; } else { - search_input = $('#jobs_'+jobid+' .term_search')[0]; + search_input = $('#jobs_' + jobid + ' .term_search')[0]; } - if (li.extra[0] >= 0) { + if (id >= 0) { search_input.value = ''; search_input.focus(); } else { - search_input.value = li.selectValue.replace(/%$/,''); - toggleJobTermsTree(jobid, li.selectValue); + search_input.value = value.replace(/%$/, ''); + toggleJobTermsTree(jobid, ''); // Use given value instead } } @@ -736,31 +753,18 @@ function addCountry() function registerEnterpriseAutocomplete(id) { - $(".enterpriseName").each( - function() { + $('.enterprise_name').each(function() { if (id == -1 || this.name == "jobs[" + id + "][name]") { - $(this).autocomplete($.plURL("search/autocomplete/entreprise"), - { - selectOnly:1, - field:this.name, - matchSubset:0, - width:$(this).width() - }); - } - }); - - $(".sectorName").each( - function() { - if (id == -1 || this.name == "jobs[" + id + "][subSubSectorName]") { - $(this).autocomplete($.plURL("search/autocomplete/subSubSector"), - { - selectOnly:1, - field:this.name, - matchSubset:0, - width:$(this).width() - }); + $(this).autocomplete({ + source: $.plURL('search/autocomplete/entreprise/') + this.name, + change: function(event, ui) { + if (ui.item != null && ui.item.field != null) { + $(this).val(ui.item.field); + } + } + }); } - }); + }); } // {{{1 Multiusage functions