Happy New Year!
[platal.git] / templates / search / referent.tpl
CommitLineData
0337d704 1{**************************************************************************}
2{* *}
12262f13 3{* Copyright (C) 2003-2011 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
23
ff3eb9b7 24{if $plset_count}
a9cd2bab 25{include core=plset.tpl}
ff3eb9b7 26{else}
7a3f546b 27{include wiki=Docs.Emploi}
ff3eb9b7 28{/if}
0337d704 29
e2c528e1 30<a id="mentors"></a>
1d414e12 31
0337d704 32<p>
a7de4ef7 33Actuellement, {$mentors_number} mentors et référents se sont déclarés sur {#globals.core.sitename#}.
0337d704 34</p>
35
3ac45f10
PC
36{javascript name=jquery.jstree}
37{javascript name=jobtermstree}
ff3eb9b7 38<script type="text/javascript">//<![CDATA[
ff3eb9b7 39
f4e39c19 40var baseurl = platal_baseurl + "referent/";
66f2b6b3 41{literal}
ff3eb9b7 42
459e6f81
PC
43/** Hides or display tree of all job terms */
44function toggleJobTermsTree()
ff3eb9b7 45{
459e6f81
PC
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;
ff3eb9b7 55 }
459e6f81 56 chooseJobTermInTree(null,li.extra[1],li.selectValue);
ff3eb9b7 57}
58
459e6f81
PC
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)
ff3eb9b7 63{
459e6f81
PC
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':'')+')';
ff3eb9b7 68}
69
459e6f81
PC
70/** Function called by job terms tree when an item is clicked */
71function chooseJobTermInTree(treeid, jtid, full_name)
3ac45f10 72{
459e6f81
PC
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;
3ac45f10
PC
102}
103
ff3eb9b7 104{/literal}
105//]]></script>
106
459e6f81
PC
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">
0337d704 109 <tr class="impair">
110 <td class="titre">
3ac45f10 111 Mot-clef&nbsp;:
0337d704 112 </td>
ff3eb9b7 113 <td>
459e6f81
PC
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}"/>
3ac45f10 116 <a id="jobTermsTreeToggle" href="#">{icon name=table title="Tous les mots-clefs"}</a>
0337d704 117 </td>
118 </tr>
3ac45f10
PC
119 <tr class="impair" style="display:none">
120 <td colspan="2">
121 <div id="mentoring_terms"></div>
0337d704 122 </td>
123 </tr>
459e6f81
PC
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>
0337d704 139 </table>
140 <div class="center" style="margin-top: 1em;">
459e6f81 141 <input id="search_referent" type="submit" value="Chercher" />
0337d704 142 </div>
143</form>
144
578aa461 145<script type="text/javascript">
3ac45f10
PC
146{literal}
147$(function() {
459e6f81
PC
148 createJobTermsTree('#mentoring_terms', 'profile/ajax/tree/jobterms/mentors', 'mentor', 'chooseJobTermInTree');
149 $("#jobtermText").autocomplete(baseurl + "autocomplete",
3ac45f10
PC
150 {
151 "selectOnly":1,
459e6f81
PC
152 "width":$("#jobtermText").width()*2,
153 "onItemSelect" : selectJobTerm,
154 "formatItem" : displayJobTerm,
155 "matchSubset" : false
3ac45f10
PC
156 });
157 $('#jobTermsTreeToggle').click(toggleJobTermsTree);
3ac45f10 158{/literal}
459e6f81
PC
159 {if $smarty.request.jobterm}
160 updateJobTerm("{$smarty.request.jobterm}", "{$smarty.request.country}");
161 {/if}
162{rdelim});
578aa461 163</script>
a7de4ef7 164{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}