From f210f76677d3f175fcc593638d2fdd974896a25e Mon Sep 17 00:00:00 2001 From: Regis Houssin <regis@dolibarr.fr> Date: Mon, 12 Feb 2007 12:27:48 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20ajout=20d'une=20tempo=20avant=20l'execut?= =?UTF-8?q?ion=20de=20autofilltownfromzip=5Fsave=5Frefresh=5F*=20afin=20qu?= =?UTF-8?q?e=20les=20donn=E9es=20se=20mettent=20en=20place=20en=20Ajax?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/html.form.class.php | 16 ++++++++++++++-- htdocs/lib/lib_head.js | 11 +++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 556f8651791..0ce30b18155 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -325,10 +325,22 @@ class Form { $obj = $this->db->fetch_object($resql); $pays_id = $obj->rowid?$obj->rowid:''; + + // On applique un delai d'execution pour le bon fonctionnement + $mode = substr($htmloption,-9,6); + if ($mode == 'create') + { + $htmloption = 'onChange="ac_delay(\'autofilltownfromzip_save_refresh_create()\',\'500\')"'; + } + else + { + $htmloption = 'onChange="ac_delay(\'autofilltownfromzip_save_refresh_edit()\',\'500\')"'; + } + print '<div>'; - print '<input type="text" size="45" id="pays" name="pays" value="'.$obj->libelle.'" />'; + print '<input type="text" size="45" id="pays" name="pays" value="'.$obj->libelle.'" '.$htmloption.' />'; print '<span id="indicator1" style="display: none">'.img_gif('Working...','ajaxworking').'</span>'; - print '<input type="hidden" name="pays_id" id="pays_id" value="'.$pays_id.'" '.$htmloption.' />'; + print '<input type="hidden" name="pays_id" id="pays_id" value="'.$pays_id.'" />'; print '</div>'; print '<div id="hint" class="autocomplete"></div>'; print '<script type="text/javascript">'; diff --git a/htdocs/lib/lib_head.js b/htdocs/lib/lib_head.js index 004061dd4b9..c9296e110df 100644 --- a/htdocs/lib/lib_head.js +++ b/htdocs/lib/lib_head.js @@ -609,4 +609,15 @@ function ac_return(field, item){ id = idCache[0].replace('-idcache', ''); // et on l'affecte au champ cach� $(field.name+'_id').value = id; +} + +/*================================================================= + Purpose: Applique un d�lai avant execution + Input: funct, delay + Author: Regis Houssin + Licence: GPL +==================================================================*/ + function ac_delay(funct,delay) { + // d�lai exprim� en millisecondes avant le d�clenchement de l'action + setTimeout(funct,delay); } \ No newline at end of file -- GitLab