| 1 | {**************************************************************************} |
| 2 | {* *} |
| 3 | {* Copyright (C) 2003-2007 Polytechnique.org *} |
| 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 | <script type="text/javascript">//<![CDATA[ |
| 24 | {literal} |
| 25 | function removeObject(id, pref) |
| 26 | { |
| 27 | document.getElementById(id).style.display = "none"; |
| 28 | document.forms.prof_annu[pref + "[removed]"].value = "1"; |
| 29 | } |
| 30 | |
| 31 | function restoreObject(id, pref) |
| 32 | { |
| 33 | document.getElementById(id).style.display = ''; |
| 34 | document.forms.prof_annu[pref + "[removed]"].value = "0"; |
| 35 | } |
| 36 | |
| 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); |
| 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); |
| 86 | } |
| 87 | |
| 88 | function addAddress() |
| 89 | { |
| 90 | var i = 0; |
| 91 | while (getAddressElement(i, 'pub') != null) { |
| 92 | i++; |
| 93 | } |
| 94 | $("#add_adr").before('<div id="addresses_' + i + '_cont"></div>'); |
| 95 | Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress); |
| 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 | |
| 110 | {/literal} |
| 111 | //]]></script> |
| 112 | |
| 113 | {foreach key=i item=adr from=$addresses} |
| 114 | <div id="{"addresses_`$i`_cont"}"> |
| 115 | {include file="profile/adresses.address.tpl" i=$i adr=$adr} |
| 116 | </div> |
| 117 | {/foreach} |
| 118 | {if $addresses|@count eq 0} |
| 119 | <div id="addresses_0"> |
| 120 | {include file="profile/adresses.address.tpl" i=0 adr=0} |
| 121 | </div> |
| 122 | {/if} |
| 123 | |
| 124 | <div id="add_adr" class="center"> |
| 125 | <a href="javascript:addAddress()"> |
| 126 | {icon name=add title="Ajouter une adresse"} Ajouter une adresse |
| 127 | </a> |
| 128 | </div> |
| 129 | |
| 130 | {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} |