Skip to content
Extraits de code Groupes Projets
Valider 8ccdeb8e rédigé par cerdic's avatar cerdic
Parcourir les fichiers

optimisation : ne pas repeter x fois le meme code javascript (renato)

parent 6b8b3b2d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -208,6 +208,16 @@ function affiche_arbre_plugins($liste_plugins,$liste_plugins_actifs){ ...@@ -208,6 +208,16 @@ function affiche_arbre_plugins($liste_plugins,$liste_plugins_actifs){
$visible = @isset($deplie[$current_dir]); $visible = @isset($deplie[$current_dir]);
$maxiter=1000; $maxiter=1000;
echo http_script("// http://doc.spip.org/@verifchange\n".
"function verifchange(id) {\n".
"if(this.checked == true)\n".
"{\n".
" document.getElementById(id).className = 'nomplugin_on';\n".
"}\n".
"else {\n".
" document.getElementById(id).className = 'nomplugin';\n".
"}\n".
"}\n");
while (count($liste_plugins) && $maxiter--){ while (count($liste_plugins) && $maxiter--){
// le rep suivant // le rep suivant
$dir = dirname(reset($liste_plugins)); $dir = dirname(reset($liste_plugins));
...@@ -236,21 +246,7 @@ function ligne_plug($plug_file, $actif, $id){ ...@@ -236,21 +246,7 @@ function ligne_plug($plug_file, $actif, $id){
$erreur = false; $erreur = false;
$vals = array(); $vals = array();
$info = plugin_get_infos($plug_file); $info = plugin_get_infos($plug_file);
$s = "<script type='text/javascript'>"; $s = "<div id='$plug_file' class='nomplugin".($actif?'_on':'')."'>";
$s .= <<<EOF
// http://doc.spip.org/@verifchange
function verifchange$id(inputp) {
if(inputp.checked == true)
{
document.getElementById('$plug_file').className = 'nomplugin_on';
}
else {
document.getElementById('$plug_file').className = 'nomplugin';
}
}
EOF;
$s .= "</script>";
$s .= "<div id='$plug_file' class='nomplugin".($actif?'_on':'')."'>";
if (isset($info['erreur'])){ if (isset($info['erreur'])){
$s .= "<div style='background:".$GLOBALS['couleur_claire']."'>"; $s .= "<div style='background:".$GLOBALS['couleur_claire']."'>";
$erreur = true; $erreur = true;
...@@ -286,7 +282,7 @@ EOF; ...@@ -286,7 +282,7 @@ EOF;
if (!$erreur){ if (!$erreur){
$s .= "<input type='checkbox' name='statusplug_$plug_file' value='O' id='label_$id_input'"; $s .= "<input type='checkbox' name='statusplug_$plug_file' value='O' id='label_$id_input'";
$s .= $actif?" checked='checked'":""; $s .= $actif?" checked='checked'":"";
$s .= " onclick='verifchange$id(this)' /> <label for='label_$id_input' style='display:none'>"._T('activer_plugin')."</label>"; $s .= " onclick='verifchange.apply(this,[\"$plug_file\"])' /> <label for='label_$id_input' style='display:none'>"._T('activer_plugin')."</label>";
} }
$id_input++; $id_input++;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter