Add mailing list headers to newsletters
[platal.git] / templates / search / referent.tpl
1 {**************************************************************************}
2 {*                                                                        *}
3 {*  Copyright (C) 2003-2013 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
24 {if $plset_count}
25 {include core=plset.tpl}
26 {else}
27 {include wiki=Docs.Emploi}
28 {/if}
29
30 <a id="mentors"></a>
31
32 <p>
33 Actuellement, {$mentors_number} mentors et référents se sont déclarés sur {#globals.core.sitename#}.
34 </p>
35
36 {javascript name=jquery.jstree}
37 {javascript name=jobtermstree}
38 <script type="text/javascript">//<![CDATA[
39
40 var baseurl = $.plURL("referent/");
41 {literal}
42
43 /** Hides or display tree of all job terms */
44 function toggleJobTermsTree()
45 {
46   $('#mentoring_terms').closest('tr').toggle();
47   return false;
48 }
49
50 /** Function called by autocomplete when a term is selected */
51 function selectJobTerm(id, value)
52 {
53     if (value < 0) {
54         return;
55     }
56     chooseJobTermInTree(null, id, value);
57 }
58
59 /** Prepares display for a jobterm in select's dropdown
60  * @param row the returned row from ajax : text, nb, id
61  */
62 function displayJobTerm(row)
63 {
64   if (row[1] < 0) {
65     return '<em>... précise ta recherche ... <\/em>';
66   }
67   return row[0]+' ('+row[1]+' camarade'+((row[1] > 1)?'s':'')+')';
68 }
69
70 /** Function called by job terms tree when an item is clicked */
71 function chooseJobTermInTree(treeid, jtid, full_name)
72 {
73   $('#jobtermText').val(full_name);
74   $('#mentoring_terms').closest('tr').hide();
75   updateJobTerm(jtid, $('#country_chg select').val());
76 }
77
78 /** Changes job term and proposes the different countries linked */
79 function updateJobTerm(jtid, country)
80 {
81   $('#jobterm').val(jtid);
82   $('#country_chg').closest('tr').show();
83   $('#keywords').show();
84   $('#country_chg').load($.plURL('search/referent/countries/' + jtid), function(response, status, xhr) {
85     if (country) {
86       if (status != "error") {
87         $('#country_chg select').val(country);
88       }
89     }
90   });
91 }
92
93 /** Function called when validating form */
94 function validateSearchForm(f)
95 {
96   if (!f.jobterm.value) {
97     alert('Il faut choisir un mot clef avant de lancer la recherche.');
98     $('#jobtermText').val('').focus();
99     return false;
100   }
101   return true;
102 }
103
104 {/literal}
105 //]]></script>
106
107 <form action="{$smarty.server.REQUEST_URI}" method="get" onsubmit="return validateSearchForm(this)">
108   <table cellpadding="0" cellspacing="0" summary="Formulaire de recherche de référents" class="bicol">
109     <tr class="impair">
110       <td class="titre">
111         Mot-clef&nbsp;:
112       </td>
113       <td>
114         <input type="text" name="jobtermText" id="jobtermText" size="32" value="{$smarty.request.jobtermText}"/>
115         <input type="hidden" name="jobterm" id="jobterm" value="{$smarty.request.jobterm}"/>
116         <a id="jobTermsTreeToggle" href="#">{icon name=table title="Tous les mots-clefs"}</a>
117       </td>
118     </tr>
119     <tr class="impair" style="display:none">
120       <td colspan="2">
121         <div id="mentoring_terms"></div>
122       </td>
123     </tr>
124     <tr class="pair" style="display:none">
125       <td class="titre">
126         Pays bien connus du référent&nbsp;:
127       </td>
128       <td id="country_chg">
129       </td>
130     </tr>
131     <tr class="impair" style="display:none" id="keywords">
132       <td class="titre">
133         Expertise (recherche texte)&nbsp;:
134       </td>
135       <td>
136         <input type="text" value="{$smarty.request.expertise}" size="30" name="expertise" />
137       </td>
138     </tr>
139   </table>
140   <div class="center" style="margin-top: 1em;">
141     <input id="search_referent" type="submit" value="Chercher" />
142   </div>
143 </form>
144
145 <script type="text/javascript">
146 {literal}
147 $(function() {
148   createJobTermsTree('#mentoring_terms', 'profile/ajax/tree/jobterms/mentors', 'mentor', 'chooseJobTermInTree');
149   $('#jobtermText').autocomplete({
150       source: $.plURL(baseurl + 'autocomplete'),
151       select: function(event, ui) {
152           selectJobTerm(ui.item.id, ui.item.value);
153       },
154       change: function(event, ui) {
155           if (ui.item != null && ui.item.field != null) {
156               $(this).val(ui.item.field);
157           }
158       }
159   });
160   $('#jobTermsTreeToggle').click(toggleJobTermsTree);
161 {/literal}
162   {if $smarty.request.jobterm}
163   updateJobTerm("{$smarty.request.jobterm}", "{$smarty.request.country}");
164   {/if}
165 {rdelim});
166 </script>
167 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}