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