Commit | Line | Data |
---|---|---|
0337d704 | 1 | {**************************************************************************} |
2 | {* *} | |
5ddeb07c | 3 | {* Copyright (C) 2003-2007 Polytechnique.org *} |
0337d704 | 4 | {* http://opensource.polytechnique.org/ *} |
5 | {* *} | |
6 | {* This program is free software; you can redistribute it and/or modify *} | |
7 | {* it under the terms of the GNU General Public License as published by *} | |
8 | {* the Free Software Foundation; either version 2 of the License, or *} | |
9 | {* (at your option) any later version. *} | |
10 | {* *} | |
11 | {* This program is distributed in the hope that it will be useful, *} | |
12 | {* but WITHOUT ANY WARRANTY; without even the implied warranty of *} | |
13 | {* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} | |
14 | {* GNU General Public License for more details. *} | |
15 | {* *} | |
16 | {* You should have received a copy of the GNU General Public License *} | |
17 | {* along with this program; if not, write to the Free Software *} | |
18 | {* Foundation, Inc., *} | |
19 | {* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} | |
20 | {* *} | |
21 | {**************************************************************************} | |
22 | ||
23 | ||
0337d704 | 24 | <script type="text/javascript">//<![CDATA[ |
85cc366b FB |
25 | {literal} |
26 | var subgrades = new array(); | |
27 | var names = new array(); | |
28 | ||
a7c28fff FB |
29 | function update() |
30 | { | |
31 | var val = document.forms.prof_annu['medal_sel'].value; | |
32 | if (val == '' || document.getElementById('medal_' + val) != null) { | |
85cc366b | 33 | document.getElementById('medal_add').style.display = 'none'; |
a7c28fff | 34 | } else { |
85cc366b | 35 | document.getElementById('medal_add').style.display = ''; |
a7c28fff FB |
36 | } |
37 | } | |
38 | ||
85cc366b FB |
39 | function getMedalName(id) |
40 | { | |
41 | document.getElementById('medal_name_' + id).innerHTML = names[id]; | |
42 | } | |
3f428576 | 43 | |
85cc366b FB |
44 | function buildGrade(id, current) |
45 | { | |
46 | var grade; | |
47 | var subg = subgrades[id]; | |
48 | var obj = $('#medal_grade_' + id); | |
49 | if (!subg) { | |
50 | obj.prepend('<input type="hidden" name="medals[' + id + '][grade]" value="0" />'); | |
51 | } else { | |
52 | var html = 'Agrafe : <select name="medals[' + id + '][grade]">'; | |
53 | html += '<option value="0">Non précisée</option>'; | |
54 | for (grade = 0 ; grade < subg.length ; grade++) { | |
55 | html += '<option value="' + subg[grade][0] + '">' + subg[grade][1] + '</option>'; | |
20d7932b | 56 | } |
57 | ||
85cc366b FB |
58 | html += '</select>'; |
59 | obj.prepend(html); | |
20d7932b | 60 | } |
85cc366b FB |
61 | } |
62 | ||
4402b512 FB |
63 | function makeAddProcess(id) |
64 | { | |
65 | return function(data) | |
66 | { | |
67 | $('#medals').after(data); | |
68 | update(); | |
69 | getMedalName(id); | |
70 | buildGrade(id, 0); | |
71 | }; | |
72 | } | |
73 | ||
85cc366b FB |
74 | function add() |
75 | { | |
76 | var id = document.forms.prof_annu['medal_sel'].value; | |
4402b512 | 77 | $.get(platal_baseurl + 'profile/ajax/medal/' + id, makeAddProcess(id)); |
85cc366b FB |
78 | } |
79 | ||
80 | function remove(id) | |
81 | { | |
82 | $("#medal_" + id).remove(); | |
b545e664 | 83 | update(); |
85cc366b FB |
84 | } |
85 | ||
0337d704 | 86 | {/literal} |
20d7932b | 87 | {foreach from=$medal_list key=type item=list} |
85cc366b FB |
88 | {foreach from=$list item=m} |
89 | names[{$m.id}] = "{$m.text}"; | |
90 | {if $grades[$m.id]|@count} | |
91 | names[{$m.id}] = "{$m.text}"; | |
20d7932b | 92 | subgrades[{$m.id}] = new array({$grades[$m.id]|@count}); |
20d7932b | 93 | {foreach from=$grades[$m.id] item=g} |
85cc366b | 94 | subgrades[{$m.id}][{$g.gid-1}] = [{$g.gid},"{$g.text}"]; |
20d7932b | 95 | {/foreach} |
96 | {/if}{/foreach} | |
97 | {/foreach} | |
6457b5e4 | 98 | //]]></script> |
0337d704 | 99 | |
a7c28fff FB |
100 | <table class="bicol"> |
101 | <tr> | |
102 | <th> | |
103 | Médailles, Décorations, Prix, ... | |
104 | </th> | |
105 | </tr> | |
106 | <tr> | |
107 | <td> | |
108 | <div class="flags"> | |
109 | <div class="vert" style="float: left"> | |
110 | <input type="checkbox" name="medals_pub"{if $medals_pub eq 'public'} checked="checked"{/if} /> | |
111 | </div> | |
112 | <div class="texte"> | |
113 | ces informations sont normalement publiques (JO, ...) mais tu peux choisir de les associer a ta fiche publique | |
114 | </div> | |
115 | </div> | |
85cc366b | 116 | <div style="clear: both; margin-top: 0.2em" id="medals"> |
a7c28fff | 117 | <select name="medal_sel" onchange="update()"> |
0337d704 | 118 | <option value=''></option> |
119 | {foreach from=$medal_list key=type item=list} | |
a7c28fff | 120 | <optgroup label="{$trad[$type]}..."> |
0337d704 | 121 | {foreach from=$list item=m} |
122 | <option value="{$m.id}">{$m.text}</option> | |
123 | {/foreach} | |
124 | </optgroup> | |
125 | {/foreach} | |
126 | </select> | |
a7c28fff FB |
127 | <span id="medal_add"> |
128 | <a href="javascript:add();">{icon name=add title="Ajouter cette médaille"}</a> | |
0337d704 | 129 | </span> |
a7c28fff FB |
130 | </div> |
131 | {foreach from=$medals item=medal key=id} | |
132 | {include file="profile/deco.medal.tpl" medal=$medal id=$id} | |
133 | {/foreach} | |
134 | </td> | |
135 | </tr> | |
136 | </table> | |
137 | ||
138 | <script type="text/javascript"> | |
139 | update(); | |
140 | </script> | |
0337d704 | 141 | |
a7de4ef7 | 142 | {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} |