Merge remote branch 'origin/xorg/1.0.2/master' into xorg/master
[platal.git] / htdocs / javascript / profile.js
1 /***************************************************************************
2 * Copyright (C) 2003-2010 Polytechnique.org *
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
21 // Page initialization {{{1
22
23 function wizPage_onLoad(id)
24 {
25 switch (id) {
26 case 'general':
27 var i = 1;
28 while ($('.edu_' + i).length != 0) {
29 prepareType(i - 1);
30 ++i;
31 }
32 break;
33 case 'adresses':
34 checkCurrentAddress();
35 break;
36 case 'poly':
37 updateGroupSubLink();
38 break;
39 case 'deco':
40 for (var i in names) {
41 if ($('#medal_' + i).length != 0) {
42 getMedalName(i);
43 buildGrade(i, $('#medal_' + i).find('[name*=medal_' + i + '_grade]').val());
44 }
45 }
46 break;
47 case 'emploi':
48 if ($('#job_0').find("[name='jobs[0][name]']").val() == '') {
49 registerEnterpriseAutocomplete(0);
50 }
51 break;
52 }
53 }
54
55 var educationDegree;
56 var educationDegreeAll;
57 var educationDegreeName;
58 var subgrades;
59 var names;
60
61 // Names {{{1
62
63 function toggleNamesAdvanced()
64 {
65 $('.names_advanced').toggle();
66 }
67
68 function addSearchName(isFemale)
69 {
70 var i = 0;
71 while ($('#search_name_' + i).length != 0) {
72 i++;
73 }
74 $('#search_name_' + i)
75 .updateHtml('profile/ajax/searchname/' + i + '/' + isFemale,
76 function(data) {
77 $('#searchname').before(data);
78 changeNameFlag(i);
79 });
80 }
81
82 function removeSearchName(i, isFemale)
83 {
84 $('#search_name_' + i).remove();
85 updateNameDisplay(isFemale);
86 }
87
88 function changeNameFlag(i)
89 {
90 $('#flag_' + i).remove();
91 var typeid = $('#search_name_' + i).find('select').val();
92 var type = $('#search_name_' + i).find('select :selected').text();
93 if ($('[name=sn_type_' + typeid + '_' + i + ']').val() > 0) {
94 $('#flag_cb_' + i).after('<span id="flag_' + i + '">&nbsp;' +
95 '<img src="images/icons/flag_green.gif" alt="site public" title="site public" />' +
96 '<input type="hidden" name="search_names[' + i + '][pub]" value="1"/>' +
97 '<input type="hidden" name="search_names[' + i + '][typeid]" value="' + typeid + '"/>' +
98 '<input type="hidden" name="search_names[' + i + '][type]" value="' + type + '"/></span>');
99 } else {
100 $('#flag_cb_' + i).after('<span id="flag_' + i + '">&nbsp;' +
101 '<img src="images/icons/flag_red.gif" alt="site privé" title="site privé" />' +
102 '<input type="hidden" name="search_names[' + i + '][typeid]" value="' + typeid + '"/>' +
103 '<input type="hidden" name="search_names[' + i + '][type]" value="' + type + '"/></span>');
104 }
105 }
106
107 function updateNameDisplay(isFemale)
108 {
109 var searchnames = '';
110 for (var i = 0; i < 10; i++) {
111 if ($('#search_name_' + i).find(':text').val()) {
112 searchnames += $('#search_name_' + i).find('[name*=typeid]').val() + ';';
113 searchnames += $('#search_name_' + i).find(':text').val() + ';;';
114 }
115 }
116 $.xget('profile/ajax/buildnames/' + searchnames + '/' + isFemale,
117 function(data){
118 var name = data.split(';');
119 $('#public_name').html(name[0]);
120 $('#private_name').html(name[0] + name[1]);
121 });
122 }
123
124 function toggleParticle(id)
125 {
126 if ($('#search_name_' + id).find("[name*='[particle]']").val() == '') {
127 $('#search_name_' + id).find("[name*='[particle]']").val(1);
128 } else {
129 $('#search_name_' + id).find("[name*='[particle]']").val('');
130 }
131 }
132
133 // Promotions {{{1
134
135 function togglePromotionEdition()
136 {
137 $(".promotion_edition").toggle();
138 }
139
140 // Nationalities {{{1
141
142 function delNationality(i)
143 {
144 $('#nationality' + i).hide().find('select').val('');
145 }
146
147 function addNationality()
148 {
149 var i = 0;
150 if ($('#nationality2').find('select').val() == "") {
151 i = 2;
152 } else if ($('#nationality3').find('select').val() == "") {
153 i = 3;
154 }
155 if ((i == 2) || (i == 3)) {
156 $('#nationality' + i).show();
157 }
158 }
159
160 // Education {{{1
161
162 function prepareType(id)
163 {
164 var edu = $('.edu_' + id).find("[name='edus[" + id + "][eduid]']").val() - 1;
165 var sel = $('.edu_' + id).find('[name=edu_' + id + '_tmp]').val();
166 var html = '';
167 if (educationDegree[edu]) {
168 var length = educationDegree[edu].length;
169 } else {
170 var length = 0;
171 }
172 for (i = 0; i < length; ++i) {
173 html += '<option value="' + educationDegree[edu][i] + '"';
174 if (sel == educationDegree[edu][i]) {
175 html += ' selected="selected"';
176 }
177 html += '>' + educationDegreeName[educationDegree[edu][i] - 1] + '</option>';
178 }
179 // XXX: to be removed once SQL table profile_merge_issues is.
180 if (sel != '' && html == '') {
181 html += '<option value="' + sel + '" selected="selected">' + educationDegreeName[sel - 1] + '</option>';
182 }
183 $('.edu_' + id).find("[name='edus[" + id + "][degreeid]']").html(html);
184 }
185
186 function addEdu()
187 {
188 var i = 0;
189 var j = 0;
190 var prefix = 'edu_';
191 var class_parity;
192
193 while (!$('#edu_add').hasClass(prefix + i)) {
194 if ($('.' + prefix + i).length != 0) {
195 j++;
196 }
197 i++;
198 }
199 if (j % 2) {
200 class_parity = 'pair';
201 } else {
202 class_parity = 'impair';
203 }
204 $('#edu_add').removeClass(prefix + i);
205 i++;
206 $('#edu_add').addClass(prefix + i);
207 i--;
208 $.get(platal_baseurl + 'profile/ajax/edu/' + i + '/' + class_parity,
209 function(data) {
210 $('#edu_add').before(data);
211 prepareType(i);
212 });
213 }
214
215 function removeEdu(i)
216 {
217 var prefix = 'edu_';
218 $('.' + prefix + i).remove();
219 while (!$('#edu_add').hasClass(prefix + i)) {
220 $('.' + prefix + i).toggleClass('pair');
221 $('.' + prefix + i).toggleClass('impair');
222 i++;
223 }
224 }
225
226 // Networking {{{1
227
228 function addNetworking()
229 {
230 var i = 0;
231 while ($('#networking_' + i).length != 0) {
232 i++;
233 }
234 var namefirst = '';
235 var html = '<tr id="networking_' + i + '">'
236 + ' <td colspan="2">'
237 + ' <div style="float: left; width: 200px;">'
238 + ' <span class="flags">'
239 + ' <input type="checkbox" name="networking[' + i + '][pub]"/>'
240 + ' <img src="images/icons/flag_green.gif" alt="site public" title="site public">'
241 + ' </span>&nbsp;'
242 + ' <select name="networking[' + i + '][type]" onchange="javascript:updateNetworking(' + i + ');">';
243 for (nw in nw_list) {
244 if (namefirst == '') {
245 namefirst = nw;
246 }
247 html += ' <option value="' + nw_list[nw] + '">' + nw + '</option>';
248 }
249 html += '</select>'
250 + ' <input type="hidden" name="networking[' + i + '][name]" value="' + namefirst + '"/>'
251 + ' </div>'
252 + ' <div style="float: left">'
253 + ' <input type="text" name="networking[' + i + '][address]" value="" size="30"/>'
254 + ' <a href="javascript:removeNetworking(' + i + ')">'
255 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer cet élément"/>'
256 + ' </a>'
257 + ' </div>'
258 + ' </td>'
259 + '</tr>';
260
261 $('#networking').before(html);
262 }
263
264 function removeNetworking(id)
265 {
266 $('#networking_' + id).remove();
267 }
268
269 function updateNetworking(i)
270 {
271 $('#networking_' + i).find("[name='networking[" + i + "][name]']").val($('#networking_' + i).find('select option:selected').text());
272 }
273
274 // Addresses {{{1
275
276 function toggleAddress(id, val)
277 {
278 $('#addresses_' + id + '_grayed').toggle();
279 $('#addresses_' + id).toggle();
280 $('#addresses_' + id + '_cont').find('[name*=removed]').val(val);
281 checkCurrentAddress();
282 }
283
284 function checkCurrentAddress(id)
285 {
286 var hasCurrentAddress = id ? true : false;
287 var i = 0;
288 while ($('#addresses_' + i + '_cont').length != 0) {
289 if ($('#addresses_' + i + '_cont').find('[name*=removed]').val() == 1) {
290 $('#addresses_' + i + '_cont').find('[name*=current]').attr('checked', false);
291 }
292 if (!hasCurrentAddress && $('#addresses_' + i + '_cont').find('[name*=current]:checked').length != 0) {
293 hasCurrentAddress = true;
294 } else {
295 $('#addresses_' + i + '_cont').find('[name*=current]').attr('checked', false);
296 }
297 i++;
298 }
299 if (!hasCurrentAddress) {
300 i = 0;
301 while ($('#addresses_' + i + '_cont').length != 0) {
302 if ($('#addresses_' + i + '_cont').find('[name*=removed]').val() == 0) {
303 $('#addresses_' + i + '_cont').find('[name*=current]').attr('checked', 'checked');
304 break;
305 }
306 i++;
307 }
308 }
309 if (id) {
310 $('#addresses_' + id + '_cont').find('[name*=current]').attr('checked', 'checked');
311 }
312 }
313
314 function addAddress()
315 {
316 var i = 0;
317 while ($('#addresses_' + i + '_cont').length != 0) {
318 i++;
319 }
320 $('#add_address').before('<div id="addresses_' + i + '_cont"></div>');
321 $('#addresses_' + i + '_cont').updateHtml('profile/ajax/address/' + i,
322 checkCurrentAddress());
323 }
324
325 function addressChanged(prefid)
326 {
327 $('#' + prefid + '_cont').find('[name*=changed]').val("1");
328 }
329
330 function validGeoloc(prefid, id, geoloc)
331 {
332 if (geoloc == 1) {
333 $('#' + prefid + '_cont').find('[name*=text]').val($('#' + prefid + '_cont').find('[name*=geocodedText]').val());
334 $('#' + prefid + '_cont').find('[name*=postalText]').val('');
335 }
336 if (geoloc > 0) {
337 $('#' + prefid + '_cont').find("[name*='[geocodedText]']").remove();
338 }
339 $('#' + prefid + '_cont').find('[name*=text]').removeClass('error');
340 $('#' + prefid + '_cont').find('[name*=geocodeChosen]').val(geoloc);
341 $('.' + prefid + '_geoloc').remove();
342 }
343
344 // {{{1 Phones
345
346 function addTel(prefid, prefname)
347 {
348 var i = 0;
349 var prefix = prefid + '_';
350 while ($('#' + prefix + i).length != 0) {
351 i++;
352 }
353 $('#' + prefix + 'add').before('<div id="' + prefix + i + '" style="clear: both; padding-top: 4px; padding-bottom: 4px"></div>');
354 $('#' + prefix + i).updateHtml('profile/ajax/tel/' + prefid + '/' + prefname + '/' + i);
355 }
356
357 function removeTel(prefname, prefid, id)
358 {
359 var total = 0;
360 while ($('#' + prefid + '_' + total).length != 0) {
361 ++total;
362 }
363 $('#' + prefid + '_' + id).remove();
364 for (var i = parseInt(id) + 1; i < total; ++i) {
365 renumberPhone(prefname, prefid, i);
366 }
367 }
368
369 function addPhoneComment(id)
370 {
371 $('#' + id + '_comment').show();
372 $('#' + id + '_addComment').hide();
373 }
374
375 function removePhoneComment(id, pref)
376 {
377 $('#' + id + '_comment').hide();
378 $('#' + id + '_comment').find("[name='" + pref + "[comment]']").val('');
379 $('#' + id + '_addComment').show();
380 }
381
382 function renumberPhone(prefname, prefid, i)
383 {
384 var telid = i - 1;
385 var telprefOld = prefname + '[' + i + ']';
386 var telpref = prefname + '[' + telid + ']';
387 var idOld = prefid + '_' + i;
388 var id = prefid + '_' + telid;
389
390 $('#' + idOld).attr('id', id);
391 $('#' + id).find('div.titre').html('N°' + i);
392 $('#' + id).find('a.removeTel').attr('href', 'javascript:removeTel(\'' + prefname + '\',\'' + prefid + '\',' + telid + ')');
393 $('#' + id).find('select').attr('name', telpref + '[type]');
394 $('#' + id).find("[name='" + telprefOld + "[display]']").attr('name', telpref + '[display]');
395 $('#' + id).find("[name='" + telprefOld + "[comment]']").attr('name', telpref + '[comment]');
396 $('#' + id).find('a.removePhoneComment').attr('href', 'javascript:removePhoneComment(' + id + ',' + telpref + ')');
397 $('#' + id).find('#' + idOld + '_addComment').attr('id', id + '_addComment');
398 $('#' + id).find('#' + id + '_addComment').attr('href', 'javascript:addPhoneComment(' + id + ')');
399 $('#' + id).find('#' + idOld + '_comment').attr('id', id + '_comment');
400 $('#' + id).find("[name='" + telprefOld + "[pub]']").attr('name', telpref + '[pub]');
401 }
402
403 // {{{1 Groups
404
405 function addBinet()
406 {
407 var id = $('#binets_table').find('[name=binets_sel]').val();
408 var text = $('#binets_table').find('select option:selected').text();
409 var html = '<tr id="binets_' + id + '">'
410 + ' <td>'
411 + ' <input type="hidden" name="binets[' + id + ']" value="' + text + '" />'
412 + ' </td>'
413 + ' <td>'
414 + ' <div style="float: left; width: 70%">'
415 + text
416 + ' </div>'
417 + ' <a href="javascript:removeElement(\'binets\',' + id + ')">'
418 + ' <img src="images/icons/cross.gif" alt="cross" title="Supprimer ce groupe" />'
419 + ' </a>'
420 + ' </td>'
421 + '</tr>';
422 $('#binets_table').after(html);
423 updateElement('binets');
424 }
425
426 function updateGroupSubLink()
427 {
428 var href = $('[name*=groupesx_sub]').val() ? $('[name*=groupesx_sub]').val() : 'http://www.polytechnique.net';
429 $('#groupesx_sub').attr('href', href);
430 }
431
432 // {{{1 Medals
433
434 function updateMedal()
435 {
436 var val = $('#medals').find('[name*=medal_sel]').val();
437 if (val && ($('#medal_' + val).length == 0)) {
438 $('#medal_add').show();
439 } else {
440 $('#medal_add').hide();
441 }
442 }
443
444 function getMedalName(id)
445 {
446 $('#medal_name_' + id).html(names[id]);
447 }
448
449 function buildGrade(id, current)
450 {
451 var grade;
452 var subg = subgrades[id];
453 var obj = $('#medal_grade_' + id);
454 if (!subg) {
455 obj.prepend('<input type="hidden" name="medals[' + id + '][grade]" value="0" />');
456 } else {
457 var html = 'Agrafe : <select name="medals[' + id + '][grade]">';
458 html += '<option value="0">Non précisée</option>';
459 for (grade = 0 ; grade < subg.length ; grade++) {
460 html += '<option value="' + subg[grade][0] + '"';
461 if (subg[grade][0] == current) {
462 html += ' selected="selected"';
463 }
464 html += '>' + subg[grade][1] + '</option>';
465 }
466
467 html += '</select>';
468 obj.prepend(html);
469 }
470 }
471
472 function makeAddProcess(id)
473 {
474 return function(data)
475 {
476 $('#medals').after(data);
477 updateMedal();
478 getMedalName(id);
479 buildGrade(id, 0);
480 };
481 }
482
483 function addMedal()
484 {
485 var id = $('#medals').find('[name=medal_sel]').val();
486 $.get(platal_baseurl + 'profile/ajax/medal/' + id, makeAddProcess(id));
487 }
488
489 function removeMedal(id)
490 {
491 $("#medal_" + id).remove();
492 updateMedal();
493 }
494
495 // Jobs {{{1
496
497 function removeJob(id, pref)
498 {
499 $('#' + id + '_cont').hide();
500 if ($('#' + id).find("[name='" + pref + "[new]']").val() == '0') {
501 $('#' + id + '_grayed').show();
502 $('#' + id + '_grayed_name').html($('#' + id).find("[name='" + pref + "[name]']").val());
503 }
504 $('#' + id).find("[name='" + pref + "[removed]']").val('1');
505 }
506
507 function restoreJob(id, pref)
508 {
509 $('#' + id + '_cont').show();
510 $('#' + id + '_grayed').hide();
511 $('#' + id).find("[name='" + pref + "[removed]']").val('0');
512 }
513
514 function makeAddJob(id)
515 {
516 return function(data)
517 {
518 $('#add_job').before(data);
519 registerEnterpriseAutocomplete(id);
520 };
521 }
522
523 function addJob()
524 {
525 var i = 0;
526 while ($('#job_' + i).length != 0) {
527 ++i;
528 }
529 $.get(platal_baseurl + 'profile/ajax/job/' + i, makeAddJob(i));
530 }
531
532 function addEntreprise(id)
533 {
534 $('.entreprise_' + id).toggle();
535 }
536
537 /**
538 * Adds a job term in job profile page
539 * @param jobid id of profile's job among his different jobs
540 * @param jtid id of job term to add
541 * @param full_name full text of job term
542 * @return false if the term already exist for this job, true otherwise
543 */
544 function addJobTerm(jobid, jtid, full_name)
545 {
546 var termid = 0;
547 var parentpath;
548 var formvarname;
549 if (jobid < 0) {
550 parentpath = '';
551 jobid = '';
552 formvarname = 'terms';
553 } else {
554 parentpath = '#job_'+jobid+' ';
555 formvarname = 'jobs['+jobid+'][terms]';
556 }
557 var lastJobTerm = $(parentpath + '.job_term:last');
558 if (lastJobTerm.length != 0) {
559 termid = parseInt(lastJobTerm.children('input').attr('name').replace(/^(jobs\[[0-9]+\]\[terms\]|terms)\[([0-9]+)\]\[jtid\]/, '$2')) + 1;
560 if ($('#job'+jobid+'_term'+jtid).length > 0) {
561 return false;
562 }
563 }
564 var newdiv = '<div class="job_term" id="job'+jobid+'_term'+jtid+'">'+
565 '<span>'+full_name+'</span>'+
566 '<input type="hidden" name="'+formvarname+'['+termid+'][jtid]" value="'+jtid+'" />'+
567 '<img title="Retirer ce mot-clef" alt="retirer" src="images/icons/cross.gif" />'+
568 '</div>';
569 if (lastJobTerm.length == 0) {
570 $(parentpath + '.job_terms').prepend(newdiv);
571 } else {
572 lastJobTerm.after(newdiv);
573 }
574 $('#job'+jobid+'_term'+jtid+' img').css('cursor','pointer').click(removeJobTerm);
575 return true;
576 }
577
578 /**
579 * Remove a job term in job profile page.
580 * Must be called from a button in a div containing the term
581 */
582 function removeJobTerm()
583 {
584 $(this).parent().remove();
585 }
586
587 /**
588 * Prepare display for autocomplete suggestions in job terms
589 * @param row an array of (title of term, id of term)
590 * @return text to display
591 * If id is negative, it is because there are too much terms to
592 * be displayed.
593 */
594 function displayJobTerm(row)
595 {
596 if (row[1] < 0) {
597 return '... <em>parcourir les résultats dans un arbre</em> ...';
598 }
599 return row[0];
600 }
601
602 /**
603 * Function called when a job term has been selected from autocompletion
604 * in search
605 * @param li is the list item (<li>) that has been clicked
606 * The context is the jsquery autocomplete object.
607 */
608 function selectJobTerm(li)
609 {
610 var jobid = this.extraParams.jobid;
611 if (li.extra[0] >= 0) {
612 addJobTerm(jobid,li.extra[0],$(li).text());
613 }
614 var search_input;
615 if (jobid < 0) {
616 search_input = $('.term_search')[0];
617 } else {
618 search_input = $('#job_'+jobid+' .term_search')[0];
619 }
620 if (li.extra[0] >= 0) {
621 search_input.value = '';
622 search_input.focus();
623 } else {
624 search_input.value = li.selectValue.replace(/%$/,'');
625 toggleJobTermsTree(jobid, li.selectValue);
626 }
627 }
628
629 /**
630 * Function to show or hide a terms tree in job edition
631 * @param jobid is the id of the job currently edited
632 */
633 function toggleJobTermsTree(jobid, textfilter)
634 {
635 var treepath;
636 if (jobid < 0) {
637 treepath = '';
638 } else {
639 treepath = '#job_'+jobid+' ';
640 }
641 treepath += '.term_tree';
642 if ($(treepath + ' ul').length > 0) {
643 $(treepath).empty().removeClass().addClass('term_tree');
644 if (!textfilter) {
645 return;
646 }
647 }
648 createJobTermsTree(treepath, 'profile/ajax/tree/jobterms/all', 'job' + jobid, 'chooseJobTerm', textfilter);
649 }
650
651 /**
652 * Function called when a job term is chosen from terms tree
653 * @param treeid is the full id of the tree (must look like job3)
654 * @param jtid is the id of the job term chosen
655 * @param fullname is the complete name (understandable without context) of the term
656 */
657 function chooseJobTerm(treeid, jtid, fullname)
658 {
659 addJobTerm(treeid.replace(/^job(.*)$/, '$1'), jtid, fullname);
660 }
661
662 // {{{1 Skills
663
664 function addSkill(cat)
665 {
666 var val = $('#' + cat + '_table').find('[name=' + cat + '_sel]').val();
667 var text = $('#' + cat + '_table').find('[name=' + cat + '_sel] :selected').text();
668 $.get(platal_baseurl + 'profile/ajax/skill/' + cat + '/' + val,
669 function(data) {
670 $('#' + cat).append(data);
671 $('#' + cat + '_' + val + '_title').text(text);
672 updateElement(cat);
673 });
674 }
675
676 // {{{1 Mentor
677
678 function addCountry()
679 {
680 var val = $('#countries_table').find('[name=countries_sel] :selected').val();
681 var text = $('#countries_table').find('[name=countries_sel] :selected').text();
682 var html = '<div id="countries_' + val + '" style="clear: both; margin-bottom: 0.7em">'
683 + ' <a href="javascript:removeElement(\'countries\',\'' + val + '\')" style="display: block; float:right">'
684 + ' <img src="images/icons/cross.gif" alt="" title="Supprimer ce pays" />'
685 + ' </a>'
686 + ' <div style="float: left; width: 50%">' + text + '</div>'
687 + ' <input type="hidden" name="countries[' + val + ']" value="' + text + '" />'
688 + '</div>';
689 $('#countries').append(html);
690 updateElement('countries');
691 }
692
693 function registerEnterpriseAutocomplete(id)
694 {
695 $(".enterpriseName").each(
696 function() {
697 if (id == -1 || this.name == "jobs[" + id + "][name]") {
698 $(this).autocomplete(platal_baseurl + "search/autocomplete/entreprise",
699 {
700 selectOnly:1,
701 field:this.name,
702 matchSubset:0,
703 width:$(this).width()
704 });
705 }
706 });
707
708 $(".sectorName").each(
709 function() {
710 if (id == -1 || this.name == "jobs[" + id + "][subSubSectorName]") {
711 $(this).autocomplete(platal_baseurl + "search/autocomplete/subSubSector",
712 {
713 selectOnly:1,
714 field:this.name,
715 matchSubset:0,
716 width:$(this).width()
717 });
718 }
719 });
720 }
721
722 // {{{1 Multiusage functions
723
724 function updateElement(cat)
725 {
726 var val = $('#' + cat + '_table').find('[name=' + cat + '_sel]').val();
727 if (val == '' || $('#' + cat + '_' + val).length != 0) {
728 $('#' + cat + '_add').hide();
729 } else {
730 $('#' + cat + '_add').show();
731 }
732 }
733
734 function removeElement(cat, id)
735 {
736 $('#' + cat + '_' + id).remove();
737 updateElement(cat);
738 }
739
740 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: