Improves job edition and email combobox display.
[platal.git] / htdocs / javascript / profile.js
CommitLineData
46ae38a9 1/***************************************************************************
8d84c630 2 * Copyright (C) 2003-2009 Polytechnique.org *
46ae38a9
FB
3 * http://opensource.polytechnique.org/ *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., *
18 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
19 ***************************************************************************/
20
8c7ac79e 21// Page initialization {{{1
46ae38a9
FB
22
23function wizPage_onLoad(id)
24{
25 switch (id) {
26 case 'general':
6505acf7
SJ
27 var i = 1;
28 while ($('.edu_' + i).length != 0) {
29 prepareType(i - 1);
30 ++i;
043bbacf 31 }
46ae38a9 32 break;
041a5cec
SJ
33 case 'adresses':
34 checkCurrentAddress();
35 break;
46ae38a9 36 case 'poly':
6505acf7 37 updateGroupSubLink();
46ae38a9
FB
38 break;
39 case 'deco':
40 for (var i in names) {
6505acf7
SJ
41 if ($('#medal_' + i).length != 0) {
42 getMedalName(i);
43 buildGrade(i, $('#medal_' + i).find('[name*=medal_' + i + '_grade]').val());
46ae38a9
FB
44 }
45 }
46 break;
47 case 'emploi':
6505acf7
SJ
48 for (var i = 0 ; $('#job_' + i).length != 0; ++i) {
49 updateJobSector(i, $('#job_' + i).find("[name*='[ss_secteur]']").val());
50 updateJobSubSector(i, $('#job_' + i).find("[name*='[sss_secteur]']").val());
46ae38a9
FB
51 }
52 break;
53 }
54}
55
f711b03f
SJ
56var educationDegree;
57var educationDegreeAll;
58var educationDegreeName;
46ae38a9
FB
59var subgrades;
60var names;
8c7ac79e 61
8c7ac79e
SJ
62// Names {{{1
63
e1082e20 64function toggleNamesAdvanced()
6e32823c 65{
e1082e20 66 $('.names_advanced').toggle();
6e32823c
SJ
67}
68
b04882ff
PC
69function addSearchName()
70{
6e32823c
SJ
71 var i = 0;
72 while ($('#search_name_' + i).length != 0) {
73 i++;
74 }
75 Ajax.update_html('search_name_' + i, 'profile/ajax/searchname/' + i, function(data){
76 $('#searchname').before(data);
77 changeNameFlag(i);
78 });
b04882ff 79}
46ae38a9 80
b04882ff
PC
81function removeSearchName(i)
82{
6e32823c
SJ
83 $('#search_name_' + i).remove();
84 updateNameDisplay();
85}
86
87function changeNameFlag(i)
88{
89 $('#flag_' + i).remove();
90 var typeid = $('#search_name_' + i).find('select').val();
91 var type = $('#search_name_' + i).find('select :selected').text();
6505acf7 92 if ($('[name=sn_type_' + typeid + '_' + i + ']').val() > 0) {
6e32823c
SJ
93 $('#flag_cb_' + i).after('<span id="flag_' + i + '">&nbsp;' +
94 '<img src="images/icons/flag_green.gif" alt="site public" title="site public" />' +
95 '<input type="hidden" name="search_names[' + i + '][pub]" value="1"/>' +
96 '<input type="hidden" name="search_names[' + i + '][typeid]" value="' + typeid + '"/>' +
97 '<input type="hidden" name="search_names[' + i + '][type]" value="' + type + '"/></span>');
98 } else {
99 $('#flag_cb_' + i).after('<span id="flag_' + i + '">&nbsp;' +
100 '<img src="images/icons/flag_red.gif" alt="site privé" title="site privé" />' +
101 '<input type="hidden" name="search_names[' + i + '][typeid]" value="' + typeid + '"/>' +
102 '<input type="hidden" name="search_names[' + i + '][type]" value="' + type + '"/></span>');
103 }
104}
105
106function updateNameDisplay()
107{
108 var searchnames = '';
109 for (var i = 0; i < 10; i++) {
110 if ($('#search_name_' + i).find(':text').val()) {
111 searchnames += $('#search_name_' + i).find('[name*=typeid]').val() + ';';
6e32823c
SJ
112 searchnames += $('#search_name_' + i).find(':text').val() + ';;';
113 }
114 }
115 Ajax.update_html(null, 'profile/ajax/buildnames/' + searchnames, function(data){
116 var name = data.split(';');
117 $('#public_name').html(name[0]);
118 $('#private_name').html(name[0] + name[1]);
119 });
b04882ff 120}
46ae38a9 121
8c7ac79e
SJ
122// Nationalities {{{1
123
8450c2aa
SJ
124function delNationality(i)
125{
126 $('#nationalite' + i).hide().find('select').val('');
127}
128
129function addNationality()
130{
131 var i = 0;
132 if ($('#nationalite2').find('select').val() == "") {
133 i = 2;
134 } else if ($('#nationalite3').find('select').val() == "") {
135 i = 3;
136 }
137 if ((i == 2) || (i == 3)) {
138 $('#nationalite' + i).show();
139 }
140}
141
6505acf7
SJ
142// Education {{{1
143
144function prepareType(id)
145{
146 var edu = $('.edu_' + id).find("[name='edus[" + id + "][eduid]']").val() - 1;
147 var sel = $('.edu_' + id).find('[name=edu_' + id + '_tmp]').val();
148 var html = '';
149 var length = educationDegree[edu].length;
150 for (i = 0; i < length; ++i) {
151 html += '<option value="' + educationDegree[edu][i] + '"';
152 if (sel == educationDegree[edu][i]) {
153 html += ' selected="selected"';
154 }
155 html += '>' + educationDegreeName[educationDegree[edu][i] - 1] + '</option>';
156 }
157 $('.edu_' + id).find("[name='edus[" + id + "][degreeid]']").html(html);
158}
159
160function addEdu()
161{
162 var i = 0;
163 var j = 0;
164 var prefix = 'edu_';
165 var class_parity;
166
167 while (!$('#edu_add').hasClass(prefix + i)) {
168 if ($('.' + prefix + i).length != 0) {
169 j++;
170 }
171 i++;
172 }
173 if (j % 2) {
174 class_parity = 'pair';
175 } else {
176 class_parity = 'impair';
177 }
178 $('#edu_add').removeClass(prefix + i);
179 i++;
180 $('#edu_add').addClass(prefix + i);
181 i--;
182 $.get(platal_baseurl + 'profile/ajax/edu/' + i + '/' + class_parity,
183 function(data) {
184 $('#edu_add').before(data);
185 prepareType(i);
186 });
187}
188
189function removeEdu(i)
190{
191 var prefix = 'edu_';
192 $('.' + prefix + i).remove();
193 while (!$('#edu_add').hasClass(prefix + i)) {
194 $('.' + prefix + i).toggleClass('pair');
195 $('.' + prefix + i).toggleClass('impair');
196 i++;
197 }
198}
199
8c7ac79e
SJ
200// Networking {{{1
201
d1a2252a
GB
202function addNetworking()
203{
204 var i = 0;
6505acf7 205 while ($('#networking_' + i).length != 0) {
d1a2252a
GB
206 i++;
207 }
92c3f9e5 208 var namefirst = '';
d1a2252a 209 var html = '<tr id="networking_' + i + '">'
92c3f9e5
GB
210 + ' <td colspan="2">'
211 + ' <div style="float: left; width: 200px;">'
212 + ' <span class="flags">'
213 + ' <input type="checkbox" name="networking[' + i + '][pub]"/>'
214 + ' <img src="images/icons/flag_green.gif" alt="site public" title="site public">'
215 + ' </span>&nbsp;'
6505acf7 216 + ' <select name="networking[' + i + '][type]" onchange="javascript:updateNetworking(' + i + ');">';
92c3f9e5
GB
217 for (nw in nw_list) {
218 if (namefirst == '') {
219 namefirst = nw;
220 }
221 html += ' <option value="' + nw_list[nw] + '">' + nw + '</option>';
222 }
223 html += '</select>'
6505acf7 224 + ' <input type="hidden" name="networking[' + i + '][name]" value="' + namefirst + '"/>'
92c3f9e5
GB
225 + ' </div>'
226 + ' <div style="float: left">'
227 + ' <input type="text" name="networking[' + i + '][address]" value="" size="30"/>'
228 + ' <a href="javascript:removeNetworking(' + i + ')">'
229 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer cet élément"/>'
230 + ' </a>'
231 + ' </div>'
d1a2252a
GB
232 + ' </td>'
233 + '</tr>';
234
92c3f9e5 235 $('#networking').before(html);
d1a2252a
GB
236}
237
238function removeNetworking(id)
239{
240 $('#networking_' + id).remove();
241}
242
92c3f9e5 243function updateNetworking(i)
d1a2252a 244{
6505acf7 245 $('#networking_' + i).find("[name='networking[" + i + "][name]']").val($('#networking_' + i).find('select option:selected').text());
d1a2252a
GB
246}
247
8c7ac79e 248// Addresses {{{1
46ae38a9 249
041a5cec 250function toggleAddress(id, val)
46ae38a9 251{
041a5cec
SJ
252 $('#addresses_' + id + '_grayed').toggle();
253 $('#addresses_' + id).toggle();
254 $('#addresses_' + id + '_cont').find('[name*=removed]').val(val);
255 checkCurrentAddress();
46ae38a9
FB
256}
257
041a5cec 258function checkCurrentAddress(id)
46ae38a9 259{
041a5cec 260 var hasCurrentAddress = id ? true : false;
46ae38a9 261 var i = 0;
041a5cec
SJ
262 while ($('#addresses_' + i + '_cont').length != 0) {
263 if ($('#addresses_' + i + '_cont').find('[name*=removed]').val() == 1) {
264 $('#addresses_' + i + '_cont').find('[name*=current]').attr('checked', false);
265 }
266 if (!hasCurrentAddress && $('#addresses_' + i + '_cont').find('[name*=current]:checked').length != 0) {
267 hasCurrentAddress = true;
268 } else {
269 $('#addresses_' + i + '_cont').find('[name*=current]').attr('checked', false);
46ae38a9
FB
270 }
271 i++;
272 }
041a5cec 273 if (!hasCurrentAddress) {
46ae38a9 274 i = 0;
041a5cec
SJ
275 while ($('#addresses_' + i + '_cont').length != 0) {
276 if ($('#addresses_' + i + '_cont').find('[name*=removed]').val() == 0) {
277 $('#addresses_' + i + '_cont').find('[name*=current]').attr('checked', 'checked');
278 break;
279 }
280 i++;
46ae38a9
FB
281 }
282 }
041a5cec
SJ
283 if (id) {
284 $('#addresses_' + id + '_cont').find('[name*=current]').attr('checked', 'checked');
46ae38a9
FB
285 }
286}
287
46ae38a9
FB
288function addAddress()
289{
290 var i = 0;
041a5cec 291 while ($('#addresses_' + i + '_cont').length != 0) {
46ae38a9
FB
292 i++;
293 }
041a5cec
SJ
294 $('#add_address').before('<div id="addresses_' + i + '_cont"></div>');
295 Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress());
46ae38a9
FB
296}
297
041a5cec 298function addressChanged(id)
043bbacf 299{
041a5cec 300 $('#addresses_' + id + '_cont').find('[name*=changed]').val("1");
043bbacf
SJ
301}
302
041a5cec 303function validGeoloc(id, geoloc)
043bbacf 304{
041a5cec
SJ
305 if (geoloc == 1) {
306 $('#addresses_' + id + '_cont').find('[name*=text]').val($('#addresses_' + id + '_cont').find('[name*=geoloc]').val());
5a10ab14 307 $('#addresses_' + id + '_cont').find('[name*=postalText]').val($('#addresses_' + id + '_cont').find('[name*=geocodedPostalText]').val());
041a5cec 308 }
5112531d
SJ
309 if (geoloc > 0) {
310 $('#addresses_' + id + '_cont').find("[name='addresses[" + id + "][geoloc]']").remove();
311 }
041a5cec
SJ
312 $('#addresses_' + id + '_cont').find('[name*=text]').removeClass('error');
313 $('#addresses_' + id + '_cont').find('[name*=geoloc_choice]').val(geoloc);
314 $('.addresses_' + id + '_geoloc').remove();
043bbacf
SJ
315}
316
8c7ac79e
SJ
317// {{{1 Phones
318
bde2be3b 319function addTel(prefid, prefname)
46ae38a9
FB
320{
321 var i = 0;
bde2be3b 322 var prefix = prefid + '_';
6505acf7 323 while ($('#' + prefix + i).length != 0) {
46ae38a9
FB
324 i++;
325 }
bde2be3b
GB
326 $('#' + prefix + 'add').before('<div id="' + prefix + i + '" style="clear: both; padding-top: 4px; padding-bottom: 4px"></div>');
327 Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i);
46ae38a9
FB
328}
329
bde2be3b
GB
330function removeTel(id)
331{
332 $('#' + id).remove();
333}
334
6505acf7 335function addPhoneComment(id)
bde2be3b 336{
6505acf7
SJ
337 $(id + '_comment').show();
338 $(id + '_addComment').hide();
bde2be3b
GB
339}
340
341function removePhoneComment(id, pref)
342{
6505acf7
SJ
343 $(id + '_comment').hide();
344 $(id + '_comment').find("[name='" + pref + "[comment]']").val('');
345 $(id + '_addComment').show();
bde2be3b 346}
46ae38a9 347
6505acf7 348// {{{1 Groups
46ae38a9 349
6505acf7 350function addBinet()
46ae38a9 351{
6505acf7
SJ
352 var id = $('#binets_table').find('[name=binets_sel]').val();
353 var text = $('#binets_table').find('select option:selected').text();
354 var html = '<tr id="binets_' + id + '">'
355 + ' <td>'
356 + ' <input type="hidden" name="binets[' + id + ']" value="' + text + '" />'
357 + ' </td>'
358 + ' <td>'
359 + ' <div style="float: left; width: 70%">'
360 + text
361 + ' </div>'
362 + ' <a href="javascript:removeElement(\'binets\', ' + id + ')">'
363 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />'
364 + ' </a>'
365 + ' </td>'
366 + '</tr>';
367 $('#binets_table').after(html);
368 updateElement('binets');
46ae38a9
FB
369}
370
6505acf7 371function updateGroupSubLink()
46ae38a9 372{
6505acf7
SJ
373 var href = $('[name*=groupesx_sub]').val() ? $('[name*=groupesx_sub]').val() : 'http://www.polytechnique.net';
374 $('#groupesx_sub').attr('href', href);
46ae38a9
FB
375}
376
6505acf7 377// {{{1 Medals
46ae38a9
FB
378
379function updateMedal()
380{
6505acf7
SJ
381 var val = $('#medals').find('[name*=medal_sel]').val();
382 if (val && ($('#medal_' + val).length == 0)) {
383 $('#medal_add').show();
46ae38a9 384 } else {
6505acf7 385 $('#medal_add').hide();
46ae38a9
FB
386 }
387}
388
389function getMedalName(id)
390{
6505acf7 391 $('#medal_name_' + id).html(names[id]);
46ae38a9
FB
392}
393
394function buildGrade(id, current)
395{
396 var grade;
397 var subg = subgrades[id];
398 var obj = $('#medal_grade_' + id);
399 if (!subg) {
400 obj.prepend('<input type="hidden" name="medals[' + id + '][grade]" value="0" />');
401 } else {
402 var html = 'Agrafe : <select name="medals[' + id + '][grade]">';
403 html += '<option value="0">Non précisée</option>';
404 for (grade = 0 ; grade < subg.length ; grade++) {
405 html += '<option value="' + subg[grade][0] + '"';
406 if (subg[grade][0] == current) {
407 html += ' selected="selected"';
408 }
409 html += '>' + subg[grade][1] + '</option>';
410 }
411
412 html += '</select>';
413 obj.prepend(html);
414 }
415}
416
417function makeAddProcess(id)
418{
419 return function(data)
420 {
421 $('#medals').after(data);
422 updateMedal();
423 getMedalName(id);
424 buildGrade(id, 0);
425 };
426}
427
428function addMedal()
429{
6505acf7 430 var id = $('#medals').find('[name=medal_sel]').val();
46ae38a9
FB
431 $.get(platal_baseurl + 'profile/ajax/medal/' + id, makeAddProcess(id));
432}
433
434function removeMedal(id)
435{
436 $("#medal_" + id).remove();
437 updateMedal();
438}
439
8c7ac79e 440// Jobs {{{1
46ae38a9
FB
441
442function removeJob(id, pref)
443{
6505acf7
SJ
444 $('#' + id + '_cont').hide();
445 if ($('#' + id).find("[name='" + id + "[new]']").val() == '0') {
446 $('#' + id + '_grayed').show();
447 $('#' + id + '_grayed_name').html($('#' + id).find("[name='" + id + "[name]']").val());
46ae38a9 448 }
6505acf7 449 $('#' + id).find("[name='" + id + "[removed]']").val('1');
46ae38a9
FB
450}
451
452function restoreJob(id, pref)
453{
6505acf7
SJ
454 $('#' + id + '_cont').show();
455 $('#' + id + '_grayed').hide();
456 $('#' + id).find("[name='" + id + "[removed]']").val('0');
46ae38a9
FB
457}
458
6505acf7 459function updateJobSector(id, sel)
46ae38a9 460{
6505acf7
SJ
461 var sector = $('#job_' + id).find("[name*='[secteur]']").val();
462 if (sector == '') {
463 sector = '-1';
46ae38a9 464 }
6505acf7 465 Ajax.update_html('job_' + id + '_ss_secteur', 'profile/ajax/secteur/' + id + '/job_' + id + '/jobs[' + id + ']/' + sector + '/' + sel);
c7139c07
SJ
466}
467
6505acf7 468function updateJobSubSector(id, sel)
c7139c07 469{
6505acf7
SJ
470 var subSector = $('#job_' + id).find("[name*='[ss_secteur]']").val();
471 if (subSector == '') {
472 subSector = '-1';
c7139c07 473 }
6505acf7 474 Ajax.update_html('job_' + id + '_sss_secteur', 'profile/ajax/ssecteur/' + id + '/' + subSector + '/' + sel);
c7139c07
SJ
475}
476
b814a8b8 477function displayAllSector(id)
c7139c07 478{
b814a8b8
SJ
479 $('.sector_text_' + id).remove();
480 $('.sector_' + id).show();
46ae38a9
FB
481}
482
483function makeAddJob(id)
484{
485 return function(data)
486 {
487 $('#add_job').before(data);
16594a1a 488 registerEnterpriseAutocomplete(id);
6505acf7 489 updateSector('job_' + id, 'jobs[' + id + ']', '');
46ae38a9
FB
490 };
491}
492
493function addJob()
494{
495 var i = 0;
6505acf7 496 while ($('#job_' + i).length != 0) {
46ae38a9
FB
497 ++i;
498 }
499 $.get(platal_baseurl + 'profile/ajax/job/' + i, makeAddJob(i));
500}
501
b814a8b8
SJ
502function addEntreprise(id)
503{
504 $('.entreprise_' + id).toggle();
505}
46ae38a9 506
8c7ac79e 507// {{{1 Skills
46ae38a9 508
46ae38a9
FB
509function addSkill(cat)
510{
6505acf7
SJ
511 var val = $('#' + cat + '_table').find('[name=' + cat + '_sel]').val();
512 var text = $('#' + cat + '_table').find('[name=' + cat + '_sel] :selected').text();
46ae38a9
FB
513 $.get(platal_baseurl + 'profile/ajax/skill/' + cat + '/' + val,
514 function(data) {
6505acf7
SJ
515 $('#' + cat).append(data);
516 $('#' + cat + '_' + val + '_title').text(text);
517 updateElement(cat);
46ae38a9
FB
518 });
519}
520
6505acf7 521// {{{1 Mentor
46ae38a9
FB
522
523function addCountry()
524{
6505acf7
SJ
525 var val = $('#countries_table').find('[name=countries_sel] :selected').val();
526 var text = $('#countries_table').find('[name=countries_sel] :selected').text();
46ae38a9 527 var html = '<div id="countries_' + val + '" style="clear: both; margin-bottom: 0.7em">'
6505acf7 528 + ' <a href="javascript:removeElement(\'countries\', \'' + val + '\')" style="display: block; float:right">'
46ae38a9
FB
529 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />'
530 + ' </a>'
1d414e12
PC
531 + ' <div style="float: left; width: 50%">' + text + '</div>'
532 + ' <input type="hidden" name="countries[' + val + ']" value="' + text + '" />'
46ae38a9
FB
533 + '</div>';
534 $('#countries').append(html);
6505acf7 535 updateElement('countries');
46ae38a9
FB
536}
537
6505acf7 538function updateSubSector()
46ae38a9 539{
6505acf7
SJ
540 var s = $('#secteur_sel').find('[name=secteur_sel]').val();
541 var ss = $('#ss_secteur_sel').find("[name='jobs[-1][ss_secteur]']").val();
542 if ((s == '' || ss == '') || $('#secteurs_' + s + '_' + ss).length != 0) {
543 $('#secteurs_add').hide();
544 } else {
545 $('#secteurs_add').show();
546 }
46ae38a9 547}
6505acf7
SJ
548
549function removeSector(s, ss)
46ae38a9 550{
6505acf7
SJ
551 $('#secteurs_' + s + '_' + ss).remove();
552 updateSubSector();
46ae38a9
FB
553}
554
6505acf7 555function updateSector()
46ae38a9 556{
6505acf7 557 var secteur = $('#secteur_sel').find('[name=secteur_sel]').val();
46ae38a9
FB
558 if (secteur == '') {
559 secteur = '-1';
6505acf7 560 $('#ss_secteur_sel').html('');
76a2858c 561 return;
46ae38a9 562 }
5fecdf6d 563 $.get(platal_baseurl + 'profile/ajax/secteur/-1/0/0/' + secteur,
46ae38a9 564 function(data) {
6505acf7
SJ
565 data = '<a href="javascript:addSector()" style="display: none; float: right" id="secteurs_add">'
566 + ' <img src="images/icons/add.gif" alt="" title="Ajouter ce secteur" />'
567 + '</a>' + data;
568 $('#ss_secteur_sel').html(data);
569 $('#ss_secteur_sel').find("[name='jobs[-1][ss_secteur]']").change(updateSubSector);
46ae38a9
FB
570 });
571}
572
6505acf7 573function addSector()
46ae38a9 574{
6505acf7
SJ
575 var s = $('#secteur_sel').find('[name=secteur_sel]').val();
576 var ss = $('#ss_secteur_sel').find("[name='jobs[-1][ss_secteur]']").val();
577 var sst = $('#ss_secteur_sel').find("[name='jobs[-1][ss_secteur]'] :selected").text();
46ae38a9
FB
578
579 var html = '<div id="secteurs_' + s + '_' + ss + '" style="clear: both; margin-top: 0.5em" class="titre">'
6505acf7
SJ
580 + ' <a href="javascript:removeSector(\'' + s + '\', \'' + ss + '\')" style="display: block; float: right">'
581 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce secteur" />'
582 + ' </a>'
583 + ' <input type="hidden" name="secteurs[' + s + '][' + ss + ']" value="' + sst + '" />'
584 + ' ' + sst
585 + '</div>';
46ae38a9 586 $('#secteurs').append(html);
6505acf7 587 updateSubSector();
46ae38a9
FB
588}
589
16594a1a
FB
590function registerEnterpriseAutocomplete(id)
591{
16594a1a
FB
592 $(".enterprise_name").each(
593 function() {
16594a1a
FB
594 if (id == -1 || this.name == "jobs[" + id + "][name]") {
595 $(this).autocomplete(platal_baseurl + "search/autocomplete/entreprise",
596 {
6505acf7
SJ
597 selectOnly:1,
598 field:this.name,
599 matchSubset:0,
600 width:$(this).width()
16594a1a
FB
601 });
602 }
6505acf7 603 });
c7139c07
SJ
604
605 $(".sector_name").each(
606 function() {
607 if (id == -1 || this.name == "jobs[" + id + "][sss_secteur_name]") {
608 $(this).autocomplete(platal_baseurl + "search/autocomplete/sss_secteur",
609 {
6505acf7
SJ
610 selectOnly:1,
611 field:this.name,
612 matchSubset:0,
613 width:$(this).width()
c7139c07
SJ
614 });
615 }
6505acf7
SJ
616 });
617}
618
619// {{{1 Multiusage functions
620
621function updateElement(cat)
622{
623 var val = $('#' + cat + '_table').find('[name=' + cat + '_sel]').val();
624 if (val == '' || $('#' + cat + '_' + val).length != 0) {
625 $('#' + cat + '_add').hide();
626 } else {
627 $('#' + cat + '_add').show();
628 }
629}
630
631function removeElement(cat, id)
632{
633 $('#' + cat + '_' + id).remove();
634 updateElement(cat);
16594a1a
FB
635}
636
46ae38a9 637// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: