Javascript cleanup again.
[platal.git] / templates / search / referent.tpl
... / ...
CommitLineData
1{**************************************************************************}
2{* *}
3{* Copyright (C) 2003-2010 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>
33Actuellement, {$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
40var baseurl = platal_baseurl + "referent/";
41{literal}
42
43/** Hides or display tree of all job terms */
44function toggleJobTermsTree()
45{
46 $('#mentoring_terms').closest('tr').toggle();
47 return false;
48}
49
50/** Function called by autocomplete when a term is selected */
51function selectJobTerm(li)
52{
53 if (li.extra[1] < 0) {
54 return;
55 }
56 chooseJobTermInTree(null,li.extra[1],li.selectValue);
57}
58
59/** Prepares display for a jobterm in select's dropdown
60 * @param row the returned row from ajax : text, nb, id
61 */
62function 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 */
71function 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 */
79function updateJobTerm(jtid, country)
80{
81 $('#jobterm').val(jtid);
82 $('#country_chg').closest('tr').show();
83 $('#keywords').show();
84 $('#country_chg').load(platal_baseurl + '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 */
94function 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(baseurl + "autocomplete",
150 {
151 "selectOnly":1,
152 "width":$("#jobtermText").width()*2,
153 "onItemSelect" : selectJobTerm,
154 "formatItem" : displayJobTerm,
155 "matchSubset" : false
156 });
157 $('#jobTermsTreeToggle').click(toggleJobTermsTree);
158{/literal}
159 {if $smarty.request.jobterm}
160 updateJobTerm("{$smarty.request.jobterm}", "{$smarty.request.country}");
161 {/if}
162{rdelim});
163</script>
164{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}