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 | ||
0b14f91d FB |
23 | <script type="text/javascript">//<![CDATA[ |
24 | {literal} | |
d5489b09 | 25 | function removeObject(id, pref) |
0b14f91d FB |
26 | { |
27 | document.getElementById(id).style.display = "none"; | |
28 | document.forms.prof_annu[pref + "[removed]"].value = "1"; | |
29 | } | |
0337d704 | 30 | |
9a1cb883 FB |
31 | function restoreObject(id, pref) |
32 | { | |
33 | document.getElementById(id).style.display = ''; | |
34 | document.forms.prof_annu[pref + "[removed]"].value = "0"; | |
35 | } | |
36 | ||
c6a7beb2 FB |
37 | function getAddressElement(adrid, adelement) |
38 | { | |
39 | return document.forms.prof_annu["addresses[" + adrid + "][" + adelement + "]"]; | |
40 | } | |
41 | ||
42 | function checkCurrentAddress(newCurrent) | |
43 | { | |
44 | var hasCurrent = false; | |
45 | var i = 0; | |
46 | while (getAddressElement(i, 'pub') != null) { | |
47 | var radio = getAddressElement(i, 'current'); | |
48 | var removed = getAddressElement(i, 'removed'); | |
49 | if (removed.value == "1" && radio.checked) { | |
50 | radio.checked = false; | |
51 | } else if (radio.checked && radio != newCurrent) { | |
52 | radio.checked = false; | |
53 | } else if (radio.checked) { | |
54 | hasCurrent = true; | |
55 | } | |
56 | i++; | |
57 | } | |
58 | if (!hasCurrent) { | |
59 | i = 0; | |
60 | while (getAddressElement(i, 'pub') != null) { | |
61 | var radio = getAddressElement(i, 'current'); | |
62 | var removed = getAddressElement(i, 'removed'); | |
63 | if (removed.value != "1") { | |
64 | radio.checked= true; | |
65 | return; | |
66 | } | |
67 | i++; | |
68 | } | |
69 | } | |
70 | } | |
71 | ||
72 | function removeAddress(id, pref) | |
73 | { | |
74 | removeObject(id, pref); | |
75 | checkCurrentAddress(null); | |
9a1cb883 FB |
76 | if (document.forms.prof_annu[pref + '[datemaj]'].value != '') { |
77 | document.getElementById(id + '_grayed').style.display = ''; | |
78 | } | |
79 | } | |
80 | ||
81 | function restoreAddress(id, pref) | |
82 | { | |
83 | document.getElementById(id + '_grayed').style.display = 'none'; | |
84 | checkCurrentAddress(null); | |
85 | restoreObject(id, pref); | |
c6a7beb2 FB |
86 | } |
87 | ||
88 | function addAddress() | |
89 | { | |
90 | var i = 0; | |
91 | while (getAddressElement(i, 'pub') != null) { | |
92 | i++; | |
93 | } | |
9a1cb883 FB |
94 | $("#add_adr").before('<div id="addresses_' + i + '_cont"></div>'); |
95 | Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress); | |
c6a7beb2 FB |
96 | } |
97 | ||
98 | function addTel(id) | |
99 | { | |
100 | var i = 0; | |
101 | var adid = 'addresses_' + id; | |
102 | var tel = adid + '_tel_'; | |
103 | while (document.getElementById(tel + i) != null) { | |
104 | i++; | |
105 | } | |
106 | $('#' + adid + '_add_tel').before('<div id="' + tel + i + '" style="clear: both"></div>'); | |
107 | Ajax.update_html(tel + i, 'profile/ajax/tel/' + id + '/' + i); | |
108 | } | |
109 | ||
32346370 FB |
110 | function validGeoloc(id, pref) |
111 | { | |
112 | document.getElementById(id + '_geoloc').style.display = 'none'; | |
113 | document.getElementById(id + '_geoloc_error').style.display = 'none'; | |
114 | document.getElementById(id + '_geoloc_valid').style.display = 'none'; | |
37d44b3b | 115 | document.forms.prof_annu[pref + "[parsevalid]"].value = "1"; |
32346370 FB |
116 | document.forms.prof_annu[pref + "[text]"].value = document.forms.prof_annu[pref + "[geoloc]"].value; |
117 | attachEvent(document.forms.prof_annu[pref + "[text]"], "click", | |
118 | function() { document.forms.prof_annu[pref + "[text]"].blur(); }); | |
119 | document.forms.prof_annu[pref + "[text]"].className = ''; | |
120 | } | |
121 | ||
122 | function validAddress(id, pref) | |
123 | { | |
124 | document.getElementById(id + '_geoloc').style.display = 'none'; | |
125 | document.getElementById(id + '_geoloc_error').style.display = 'none'; | |
126 | document.getElementById(id + '_geoloc_valid').style.display = 'none'; | |
1879c7b2 | 127 | document.forms.prof_annu[pref + "[parsevalid]"].value = "0"; |
32346370 FB |
128 | attachEvent(document.forms.prof_annu[pref + "[text]"], "click", |
129 | function() { document.forms.prof_annu[pref + "[text]"].blur(); }); | |
130 | document.forms.prof_annu[pref + "[text]"].className = ''; | |
131 | } | |
132 | ||
0b14f91d FB |
133 | {/literal} |
134 | //]]></script> | |
0337d704 | 135 | |
0b14f91d | 136 | {foreach key=i item=adr from=$addresses} |
9a1cb883 | 137 | <div id="{"addresses_`$i`_cont"}"> |
c6a7beb2 FB |
138 | {include file="profile/adresses.address.tpl" i=$i adr=$adr} |
139 | </div> | |
0b14f91d | 140 | {/foreach} |
c6a7beb2 | 141 | {if $addresses|@count eq 0} |
3950bc21 | 142 | <div id="addresses_0_cont"> |
c6a7beb2 FB |
143 | {include file="profile/adresses.address.tpl" i=0 adr=0} |
144 | </div> | |
145 | {/if} | |
146 | ||
147 | <div id="add_adr" class="center"> | |
148 | <a href="javascript:addAddress()"> | |
149 | {icon name=add title="Ajouter une adresse"} Ajouter une adresse | |
150 | </a> | |
151 | </div> | |
0b14f91d | 152 | |
a7de4ef7 | 153 | {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} |