Look: Meilleur comportement des formulaires ajax qui ne "bouge plus".

This commit is contained in:
Laurent Destailleur 2007-05-25 23:24:21 +00:00
parent b3fdf3e836
commit 4f383835f4
11 changed files with 151 additions and 137 deletions

View File

@ -1349,7 +1349,7 @@ if ($_GET['propalid'] > 0)
$var=true; $var=true;
print '<tr '.$bc[$var].">\n"; print '<tr '.$bc[$var].">\n";
print '<td><textarea cols="70" name="np_desc" rows="'.ROWS_2.'"></textarea></td>'; print '<td><textarea class="flat" cols="70" name="np_desc" rows="'.ROWS_2.'"></textarea></td>';
print '<td align="center">'; print '<td align="center">';
if($societe->tva_assuj == "0") if($societe->tva_assuj == "0")
{ {
@ -1389,7 +1389,7 @@ if ($_GET['propalid'] > 0)
$html->select_produits('','idprod','',$conf->produit->limit_size); $html->select_produits('','idprod','',$conf->produit->limit_size);
} }
if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '<br>'; if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '<br>';
print '<textarea cols="70" name="np_desc" rows="'.ROWS_2.'"></textarea>'; print '<textarea cols="70" name="np_desc" rows="'.ROWS_2.'" class="flat"></textarea>';
print '</td>'; print '</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td align="right"><input type="text" size="2" name="qty" value="1"></td>'; print '<td align="right"><input type="text" size="2" name="qty" value="1"></td>';

View File

@ -818,8 +818,20 @@ class Form
global $langs,$conf; global $langs,$conf;
if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)
{ {
print $langs->trans("RefOrLabel").' : <input type="text" size="16" name="keysearch'.$htmlname.'" id="keysearch'.$htmlname.'">'; print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&price_level='.$price_level.'&type=1','working'); print '<td class="nobordernopadding" width="30" nowrap="nowrap">';
print $langs->trans("RefOrLabel").':</td>';
print '<td class="nobordernopadding" align="left" width="16">';
print ajax_updater_indicator($htmlname,'working');
print '</td>';
print '<td><input type="text" size="16" name="keysearch'.$htmlname.'" id="keysearch'.$htmlname.'">';
print '</td>';
print '</tr>';
print '<tr class="nocellnopadd">';
print '<td class="nobordernopadding" colspan="3">';
print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&price_level='.$price_level.'&type=1','');
print '</td></tr>';
print '</table>';
} }
else else
{ {

View File

@ -100,19 +100,18 @@ $bc[true]=' class="bg2"';
function pHeader($soutitre,$next,$action='set') function pHeader($soutitre,$next,$action='set')
{ {
global $charset; global $conf;
global $langs; global $langs;
$langs->load("main"); $langs->load("main");
$langs->load("admin"); $langs->load("admin");
// On force contenu en ISO-8859-1 // On force contenu dans format sortie
header("Content-type: text/html; charset=".$charset); header("Content-type: text/html; charset=".$conf->character_set_client);
//header("Content-type: text/html; charset=UTF-8");
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n"; print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
print '<html>'; print '<html>';
print '<head>'; print '<head>';
print '<meta http-equiv="content-type" content="text/html; charset='.$charset.'">'; print '<meta http-equiv="content-type" content="text/html; charset='.$conf->character_set_client.'">';
print '<link rel="stylesheet" type="text/css" href="./default.css">'; print '<link rel="stylesheet" type="text/css" href="./default.css">';
print '<title>'.$langs->trans("DolibarrSetup").'</title>'; print '<title>'.$langs->trans("DolibarrSetup").'</title>';
print '</head>'; print '</head>';

View File

@ -322,7 +322,7 @@ class CMailFile
$out.= "--" . $this->mime_boundary . $this->eol; $out.= "--" . $this->mime_boundary . $this->eol;
if ($this->msgishtml) if ($this->msgishtml)
{ {
$out.= "Content-Type: text/html; charset=iso-8859-1".$this->eol; $out.= "Content-Type: text/html; charset=".$conf->charset_output.$this->eol;
} }
$out.= $this->eol; $out.= $this->eol;
} }

View File

@ -2638,21 +2638,27 @@ function num_lines($texte)
return $nblines; return $nblines;
} }
function ajax_updater_indicator($htmlname,$indicator='working')
{
$script.='<span id="indicator'.$htmlname.'" style="display: none">'.img_gif('Working...',$indicator).'</span>';
return $script;
}
/** /**
\brief Récupère la valeur d'un champ, effectue un traitement Ajax et affiche le résultat \brief Récupère la valeur d'un champ, effectue un traitement Ajax et affiche le résultat
\param htmlname nom et id du champ \param htmlname nom et id du champ
\param keysearch nom et id complémentaire du champ de collecte \param keysearch nom et id complémentaire du champ de collecte
\param url chemin du fichier de réponse : /chemin/fichier.php \param url chemin du fichier de réponse : /chemin/fichier.php
\param option champ supplémentaire de recherche dans les paramètres \param option champ supplémentaire de recherche dans les paramètres
\param indicator nom de l'image gif sans l'extension \param indicator Nom de l'image gif sans l'extension
\return script script complet \return script script complet
*/ */
function ajax_updater($htmlname,$keysearch,$url,$option='',$indicator='working') function ajax_updater($htmlname,$keysearch,$url,$option='',$indicator='working')
{ {
$script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="">'; $script='';
$script.= '<span id="indicator'.$htmlname.'" style="display: none">'.img_gif('Working...',$indicator).'</span>'; if ($indicator) $script.=ajax_updater_indicator($htmlname,$indicator);
$script.= '<script type="text/javascript">'; $script.='<script type="text/javascript">';
$script.= 'var myIndicator'.$htmlname.' = { $script.='var myIndicator'.$htmlname.' = {
onCreate: function(){ onCreate: function(){
if($F("'.$keysearch.$htmlname.'")){ if($F("'.$keysearch.$htmlname.'")){
Element.show(\'indicator'.$htmlname.'\'); Element.show(\'indicator'.$htmlname.'\');
@ -2665,8 +2671,8 @@ function ajax_updater($htmlname,$keysearch,$url,$option='',$indicator='working')
} }
} }
};'; };';
$script.= 'Ajax.Responders.register(myIndicator'.$htmlname.');'; $script.='Ajax.Responders.register(myIndicator'.$htmlname.');';
$script.= 'new Form.Element.Observer($("'.$keysearch.$htmlname.'"), 1, $script.='new Form.Element.Observer($("'.$keysearch.$htmlname.'"), 1,
function(){ function(){
var myAjax = new Ajax.Updater( { var myAjax = new Ajax.Updater( {
success: \'ajdynfield'.$htmlname.'\'}, success: \'ajdynfield'.$htmlname.'\'},
@ -2675,8 +2681,9 @@ function ajax_updater($htmlname,$keysearch,$url,$option='',$indicator='working')
parameters: "'.$keysearch.'="+$F("'.$keysearch.$htmlname.'")+"&htmlname='.$htmlname.$option.'" parameters: "'.$keysearch.'="+$F("'.$keysearch.$htmlname.'")+"&htmlname='.$htmlname.$option.'"
}); });
});'; });';
$script.= '</script>'; $script.='</script>';
$script.= '<div class="notopnoleftnoright" id="ajdynfield'.$htmlname.'"></div>'; $script.='<div class="nocellnopadd" id="ajdynfield'.$htmlname.'"></div>';
$script.='<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="">';
return $script; return $script;
} }

View File

@ -521,11 +521,11 @@ else
/** /**
* \brief Affiche en-tete HTML * \brief Affiche en-tete HTML
* \param head lignes d'en-tete head * \param head Lignes d'en-tete head optionnelles
* \param title titre page web * \param title Titre page web
* \param target target du menu Accueil * \param disablejs N'affiche pas les liens vers les js (Ex: qd fonction utilisée par sous formulaire Ajax)
*/ */
function top_htmlhead($head, $title="", $target="") function top_htmlhead($head, $title='', $disablejs=0)
{ {
global $user, $conf, $langs, $db, $micro_start_time; global $user, $conf, $langs, $db, $micro_start_time;
@ -536,10 +536,10 @@ function top_htmlhead($head, $title="", $target="")
if (! $conf->css) $conf->css ='/theme/eldy/eldy.css.php'; if (! $conf->css) $conf->css ='/theme/eldy/eldy.css.php';
//header("Content-type: text/html; charset=UTF-8"); //header("Content-type: text/html; charset=UTF-8");
header("Content-type: text/html; charset=".$_SESSION['charset']); header("Content-type: text/html; charset=".$conf->character_set_client);
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
// print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd>'; //print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd>';
print "\n"; print "\n";
print "<html>\n"; print "<html>\n";
print "<head>\n"; print "<head>\n";
@ -549,10 +549,10 @@ function top_htmlhead($head, $title="", $target="")
// Affiche meta // Affiche meta
print '<meta name="robots" content="noindex,nofollow">'."\n"; // Evite indexation par robots print '<meta name="robots" content="noindex,nofollow">'."\n"; // Evite indexation par robots
print '<meta name="author" content="'.$langs->trans("DevelopmentTeam").'">'."\n"; print '<meta name="author" content="DevelopmentTeam">'."\n";
// Affiche title // Affiche title
if (strlen($title) > 0) if ($title)
{ {
print '<title>Dolibarr - '.$title.'</title>'; print '<title>Dolibarr - '.$title.'</title>';
} }
@ -574,20 +574,22 @@ function top_htmlhead($head, $title="", $target="")
print '<link rel="stylesheet" type="text/css" media="print" HREF="'.DOL_URL_ROOT.'/theme/print.css">'."\n"; print '<link rel="stylesheet" type="text/css" media="print" HREF="'.DOL_URL_ROOT.'/theme/print.css">'."\n";
// Definition en alternate style sheet des feuilles de styles les plus maintenues // Definition en alternate style sheet des feuilles de styles les plus maintenues
// Les navigateurs qui supportent sont rares. // Les navigateurs qui supportent sont rares. Plus aucun connu.
/*
print '<link rel="alternate stylesheet" type="text/css" title="Eldy" href="'.DOL_URL_ROOT.'/theme/eldy/eldy.css.php">'."\n"; print '<link rel="alternate stylesheet" type="text/css" title="Eldy" href="'.DOL_URL_ROOT.'/theme/eldy/eldy.css.php">'."\n";
print '<link rel="alternate stylesheet" type="text/css" title="Freelug" href="'.DOL_URL_ROOT.'/theme/freelug/freelug.css.php">'."\n"; print '<link rel="alternate stylesheet" type="text/css" title="Freelug" href="'.DOL_URL_ROOT.'/theme/freelug/freelug.css.php">'."\n";
print '<link rel="alternate stylesheet" type="text/css" title="Yellow" href="'.DOL_URL_ROOT.'/theme/yellow/yellow.css">'."\n"; print '<link rel="alternate stylesheet" type="text/css" title="Yellow" href="'.DOL_URL_ROOT.'/theme/yellow/yellow.css">'."\n";
*/
print '<link rel="top" title="'.$langs->trans("Home").'" href="'.DOL_URL_ROOT.'/">'."\n"; print '<link rel="top" title="'.$langs->trans("Home").'" href="'.DOL_URL_ROOT.'/">'."\n";
print '<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1">'."\n"; print '<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1">'."\n";
print '<link rel="author" title="'.$langs->trans("DevelopmentTeam").'" href="http://www.dolibarr.org">'."\n"; print '<link rel="author" title="'.$langs->trans("DevelopmentTeam").'" href="http://www.dolibarr.org">'."\n";
if ($conf->use_javascript || $conf->use_ajax) if (! $disablejs && ($conf->use_javascript || $conf->use_ajax))
{ {
print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/lib/lib_head.js"></script>'."\n"; print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/lib/lib_head.js"></script>'."\n";
} }
if ($conf->use_ajax) if (! $disablejs && $conf->use_ajax)
{ {
print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/lib/prototype.js"></script>'."\n"; print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/lib/prototype.js"></script>'."\n";
print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/scriptaculous.js"></script>'."\n"; print '<script language="javascript" type="text/javascript" src="'.DOL_URL_ROOT.'/includes/scriptaculous/src/scriptaculous.js"></script>'."\n";

View File

@ -34,7 +34,7 @@ $langs->load("main");
top_htmlhead("", "", 1); top_htmlhead("", "", 1);
print '<body id="mainbody">'."\n"; print '<body class="nocellnopadd">'."\n";
// Generation liste de produits // Generation liste de produits
if(isset($_GET['keysearch']) && !empty($_GET['keysearch'])) if(isset($_GET['keysearch']) && !empty($_GET['keysearch']))

View File

@ -81,7 +81,7 @@ if ($user->societe_id > 0)
top_htmlhead("", $langs->trans("SearchTown"), ""); top_htmlhead("", $langs->trans("SearchTown"));
print "<body>"; print "<body>";

View File

@ -26,13 +26,11 @@
\version $Revision$ \version $Revision$
*/ */
require('../master.inc.php'); require('../main.inc.php');
//header("Content-type: text/html; charset=UTF-8"); top_htmlhead("", "", 1);
header("Content-type: text/html; charset=iso-8859-1");
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; print '<body id="mainbody">';
print "\n<html>";
print "\n<body>";
// Generation liste des pays // Generation liste des pays
if(isset($_POST['pays']) && !empty($_POST['pays'])) if(isset($_POST['pays']) && !empty($_POST['pays']))

View File

@ -36,7 +36,7 @@ $WS_DOL_URL='http://ec.europa.eu/taxation_customs/vies/api/checkVatPort';
$WS_METHOD = 'checkVat'; $WS_METHOD = 'checkVat';
top_htmlhead("", $langs->trans("VATIntraCheckableOnEUSite"), ""); top_htmlhead("", $langs->trans("VATIntraCheckableOnEUSite"));
print '<body style="margin: 10px">'; print '<body style="margin: 10px">';
print '<div>'; print '<div>';
print '<div>'; print '<div>';

View File

@ -348,12 +348,9 @@ class Translate {
* [en] Send header and return a string of html start page * [en] Send header and return a string of html start page
* \return string html header avec charset * \return string html header avec charset
*/ */
function lang_header() function lang_header()
{ {
//header("Content-Type: text/html; charset=$charset");
$texte = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$this->charset_output."\">\n"; $texte = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=".$this->charset_output."\">\n";
return $texte; return $texte;
} }
@ -364,7 +361,6 @@ class Translate {
* \param searchalt cherche aussi dans langue alternative * \param searchalt cherche aussi dans langue alternative
* \return boolean true si existe, false sinon * \return boolean true si existe, false sinon
*/ */
function file_exists($filename,$searchalt=0) function file_exists($filename,$searchalt=0)
{ {
// Test si fichier dans répertoire de la langue // Test si fichier dans répertoire de la langue