Typo.
[platal.git] / templates / search / referent.tpl
index ab57b71..0b1f12e 100644 (file)
@@ -1,6 +1,6 @@
 {**************************************************************************}
 {*                                                                        *}
-{*  Copyright (C) 2003-2010 Polytechnique.org                             *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
 {*  http://opensource.polytechnique.org/                                  *}
 {*                                                                        *}
 {*  This program is free software; you can redistribute it and/or modify  *}
 Actuellement, {$mentors_number} mentors et référents se sont déclarés sur {#globals.core.sitename#}.
 </p>
 
-{javascript name=ajax}
 {javascript name=jquery.jstree}
 {javascript name=jobtermstree}
 <script type="text/javascript">//<![CDATA[
 
-var baseurl = platal_baseurl + "referent/";
+var baseurl = $.plURL("referent/");
 {literal}
-var Ajax2 = new AjaxEngine();
 
 /** Hides or display tree of all job terms */
 function toggleJobTermsTree()
@@ -50,12 +48,12 @@ function toggleJobTermsTree()
 }
 
 /** Function called by autocomplete when a term is selected */
-function selectJobTerm(li)
+function selectJobTerm(id, value)
 {
-    if (li.extra[1] < 0) {
+    if (value < 0) {
         return;
     }
-    chooseJobTermInTree(null,li.extra[1],li.selectValue);
+    chooseJobTermInTree(null, id, value);
 }
 
 /** Prepares display for a jobterm in select's dropdown
@@ -83,7 +81,7 @@ function updateJobTerm(jtid, country)
   $('#jobterm').val(jtid);
   $('#country_chg').closest('tr').show();
   $('#keywords').show();
-  $('#country_chg').load(platal_baseurl + 'search/referent/countries/' + jtid, function(response, status, xhr) {
+  $('#country_chg').load($.plURL('search/referent/countries/' + jtid), function(response, status, xhr) {
     if (country) {
       if (status != "error") {
         $('#country_chg select').val(country);
@@ -148,13 +146,16 @@ function validateSearchForm(f)
 {literal}
 $(function() {
   createJobTermsTree('#mentoring_terms', 'profile/ajax/tree/jobterms/mentors', 'mentor', 'chooseJobTermInTree');
-  $("#jobtermText").autocomplete(baseurl + "autocomplete",
-  {
-    "selectOnly":1,
-    "width":$("#jobtermText").width()*2,
-    "onItemSelect" : selectJobTerm,
-    "formatItem" : displayJobTerm,
-    "matchSubset" : false
+  $('#jobtermText').autocomplete({
+      source: $.plURL(baseurl + 'autocomplete'),
+      select: function(event, ui) {
+          selectJobTerm(ui.item.id, ui.item.value);
+      },
+      change: function(event, ui) {
+          if (ui.item != null && ui.item.field != null) {
+              $(this).val(ui.item.field);
+          }
+      }
   });
   $('#jobTermsTreeToggle').click(toggleJobTermsTree);
 {/literal}