Typo.
[platal.git] / htdocs / javascript / profile.js
index b8b1c2c..97de167 100644 (file)
@@ -66,9 +66,12 @@ publicity['public']  = 2;
 
 // Names {{{1
 
-function toggleNamesAdvanced()
+function toggleNamesAdvanced(togglePrivate)
 {
-    $('.names_advanced').toggle();
+    $('.names_advanced_public').toggle();
+    if (togglePrivate) {
+        $('.names_advanced_private').toggle();
+    }
 }
 
 function addSearchName(isFemale)
@@ -261,6 +264,44 @@ function updateNetworking(i)
     $('#networking_' + i).find("[name='networking[" + i + "][name]']").val($('#networking_' + i).find('select option:selected').text());
 }
 
+// Hobby {{{1
+
+function addHobby()
+{
+    var i = 0;
+    while ($('#hobby_' + i).length != 0) {
+        ++i;
+    }
+    var html = '<tr id="hobby_' + i + '">'
+        + '  <td colspan="2">'
+        + '    <div style="float: left; width: 200px;">'
+        + '      <span class="flags">'
+        + '        <input type="checkbox" name="hobbies[' + i + '][pub]"/>'
+        + '        <img src="images/icons/flag_green.gif" alt="site public" title="site public">'
+        + '      </span>&nbsp;'
+        + '      <select name="hobbies[' + i + '][type]">'
+        + '        <option value="Sport">Sport</option>'
+        + '        <option value="Loisir">Loisir</option>'
+        + '        <option value="Hobby">Hobby</option>'
+        + '      </select>'
+        + '    </div>'
+        + '    <div style="float: left">'
+        + '      <input type="text" name="hobbies[' + i + '][text]" value="" size="30"/>'
+        + '      <a href="javascript:removeHobby(' + i + ')">'
+        + '        <img src="images/icons/cross.gif" alt="cross" title="Supprimer cet élément"/>'
+        + '      </a>'
+        + '    </div>'
+        + '  </td>'
+        + '</tr>';
+
+    $('#hobby').before(html);
+}
+
+function removeHobby(id)
+{
+    $('#hobby_' + id).remove();
+}
+
 // Addresses {{{1
 
 function toggleAddress(id, val)
@@ -619,44 +660,28 @@ function removeJobTerm()
 }
 
 /**
- * Prepare display for autocomplete suggestions in job terms
- * @param row an array of (title of term, id of term)
- * @return text to display
- * If id is negative, it is because there are too much terms to
- * be displayed.
- */
-function displayJobTerm(row)
-{
-    if (row[1] < 0) {
-        return '... <em>parcourir les résultats dans un arbre</em> ...';
-    }
-    return row[0];
-}
-
-/**
  * Function called when a job term has been selected from autocompletion
  * in search
  * @param li is the list item (<li>) that has been clicked
  * The context is the jsquery autocomplete object.
  */
-function selectJobTerm(li)
+function selectJobTerm(id, value, jobid)
 {
-    var jobid = this.extraParams.jobid;
-    if (li.extra[0] >= 0) {
-        addJobTerm(jobid,li.extra[0],$(li).text());
+    if (id >= 0) {
+        addJobTerm(jobid, id, value);
     }
     var search_input;
     if (jobid < 0) {
         search_input = $('.term_search')[0];
     } else {
-        search_input = $('#jobs_'+jobid+' .term_search')[0];
+        search_input = $('#jobs_' + jobid + ' .term_search')[0];
     }
-    if (li.extra[0] >= 0) {
+    if (id >= 0) {
         search_input.value = '';
         search_input.focus();
     } else {
-        search_input.value = li.selectValue.replace(/%$/,'');
-        toggleJobTermsTree(jobid, li.selectValue);
+        search_input.value = value.replace(/%$/, '');
+        toggleJobTermsTree(jobid, ''); // Use given value instead
     }
 }
 
@@ -728,31 +753,18 @@ function addCountry()
 
 function registerEnterpriseAutocomplete(id)
 {
-    $(".enterpriseName").each(
-      function() {
+    $('.enterprise_name').each(function() {
         if (id == -1 || this.name == "jobs[" + id + "][name]") {
-            $(this).autocomplete($.plURL("search/autocomplete/entreprise"),
-                                 {
-                                     selectOnly:1,
-                                     field:this.name,
-                                     matchSubset:0,
-                                     width:$(this).width()
-                                 });
+            $(this).autocomplete({
+                source: $.plURL('search/autocomplete/entreprise/') + this.name,
+                change: function(event, ui) {
+                    if (ui.item != null && ui.item.field != null) {
+                        $(this).val(ui.item.field);
+                    }
+                }
+            });
         }
-      });
-
-    $(".sectorName").each(
-      function() {
-        if (id == -1 || this.name == "jobs[" + id + "][subSubSectorName]") {
-            $(this).autocomplete($.plURL("search/autocomplete/subSubSector"),
-                                 {
-                                     selectOnly:1,
-                                     field:this.name,
-                                     matchSubset:0,
-                                     width:$(this).width()
-                                 });
-        }
-      });
+    });
 }
 
 // {{{1 Multiusage functions