From 16594a1ac8d7cbff8a51e422a6a6d9e575129d9c Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Thu, 5 Jun 2008 23:04:01 +0200 Subject: [PATCH] Autocomplete enterprise name in profile edition. (Closes #836) Signed-off-by: Florent Bruneau --- htdocs/javascript/profile.js | 21 +++++++++++++++++++++ modules/profile.php | 2 +- templates/core/plwizard.tpl | 2 ++ templates/profile/jobs.job.tpl | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index 5c25580..22d0976 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -47,6 +47,7 @@ function wizPage_onLoad(id) updateJobSecteur(i, 'job_' + i, 'jobs[' + i + ']', document.forms.prof_annu["jobs[" + i + "][ss_secteur]"].value); } + registerEnterpriseAutocomplete(-1); break; } } @@ -350,6 +351,7 @@ function makeAddJob(id) return function(data) { $('#add_job').before(data); + registerEnterpriseAutocomplete(id); updateSecteur('job_' + id, 'jobs[' + id + ']', ''); }; } @@ -494,4 +496,23 @@ function removeSecteur(s, ss) updateSSecteur(); } +function registerEnterpriseAutocomplete(id) +{ + alert("coucou"); + $(".enterprise_name").each( + function() { + alert(this.name); + if (id == -1 || this.name == "jobs[" + id + "][name]") { + $(this).autocomplete(platal_baseurl + "search/autocomplete/entreprise", + { + selectOnly:1, + field:this.name, + matchSubset:0, + width:$(this).width() + }); + } + } + ); +} + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: diff --git a/modules/profile.php b/modules/profile.php index c72a9c0..bef05a8 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -302,9 +302,9 @@ class ProfileModule extends PLModule // Build the page $page->addJsLink('ajax.js'); - $page->addJsLink('profile.js'); $page->addJsLink('applis.js'); $page->addJsLink('grades.js'); + $page->addJsLink('profile.js'); $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true, true); require_once dirname(__FILE__) . '/profile/page.inc.php'; $wiz->addPage('ProfileGeneral', 'Général', 'general'); diff --git a/templates/core/plwizard.tpl b/templates/core/plwizard.tpl index 0222eb0..da75308 100644 --- a/templates/core/plwizard.tpl +++ b/templates/core/plwizard.tpl @@ -20,6 +20,8 @@ {* *} {**************************************************************************} {javascript name="jquery"} +{javascript name="jquery.autocomplete"} +