diff --git a/dist/javascript/layer.js b/dist/javascript/layer.js index abef7731a67197fc1eaaf18f47da8e4eb37a3ed6..2274425dad605462c57030878c8bbfcbf7a46dbc 100644 --- a/dist/javascript/layer.js +++ b/dist/javascript/layer.js @@ -1,5 +1,6 @@ var memo_obj = new Array(); var url_chargee = new Array(); +var xhr_actifs = new Array(); var load_handlers = new Array(); function findObj_test_forcer(n, forcer) { @@ -113,20 +114,25 @@ function changerhighlight (couche) { function aff_selection (arg, idom, url) { + noeud = findObj_forcer(idom); if (noeud) { noeud.style.display = "none"; charger_node_url(url+arg, noeud); } + return false; } // selecteur de rubrique et affichage de son titre dans le bandeau -function aff_selection_titre(titre, id, idom) +function aff_selection_titre(titre, id, idom, nid) { - findObj_forcer('titreparent').value=titre; - findObj_forcer('id_parent').value=id; - findObj_forcer(idom).style.display='none'; + t = findObj_forcer('titreparent'); + t.value= titre; + t=findObj_forcer(nid); + t.value=id; + t=findObj_forcer(idom); + t.style.display='none'; } function aff_selection_provisoire(id, racine, url, col, sens,informer) @@ -142,6 +148,35 @@ function aff_selection_provisoire(id, racine, url, col, sens,informer) return false; } +// Lanche une requete Ajax a chaque frappe au clavier dans une balise de saisie. +// Si l'entree redevient vide, rappeler l'URL initiale si dispo. +// Sinon, controler au retour si le resultat est unique, +// auquel cas forcer la selection. + +function onkey_rechercher(valeur, rac, url, img, nid, init) { + var Field = findObj_forcer(rac); + if (!valeur.length) { + init = findObj_forcer(init); + if (init && init.href) { charger_node_url(init.href, Field);} + } else { + charger_node_url(url+valeur, + Field, + function () { + var n = Field.childNodes.length - 1; + // Safari = 0 & Firefox = 1 ! + // et gare aux negatifs en cas d'abort + if (!n || (n == 1)) { + noeud = Field.childNodes[n].firstChild; + aff_selection_titre(noeud.firstChild.nodeValue, noeud.title, rac, nid); + } + }, + img); + } + return false; +} + +function lancer_recherche(champ, cible) {} // obsolete + // // Cette fonction charge du contenu - dynamiquement - dans un // Ajax @@ -185,6 +220,10 @@ function triggerAjaxLoad(root) { load_handlers[i].apply( root ); } +// Alloue un gestionnaire Ajax, et le lance sur les parametres donnes +// Retourne False si l'allocation est impossible, +// le gestionnaire lui-meme autrement (utile pour memoriser ceux alloues). + function ajah(method, url, flux, rappel) { var xhr = createXmlHttp(); @@ -198,14 +237,22 @@ function ajah(method, url, flux, rappel) xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); } xhr.send(flux); - return true; + return xhr; } +// Avancees de la requete HTTP. +// Attention: +// 1. Opera dit toujours 0, pas 200 ou 404 etc +// 2. si la methode abort a ete invoquee, acceder au status provoque +// NS_ERROR_NOT_AVAILABLE +// il faut try/catch pour rester discret (l'avortement decidement ...) + function ajahReady(xhr, f) { if (xhr.readyState == 4) { - if (xhr.status > 200) // Opera dit toujours 0 ! - {f('Erreur HTTP : ' + xhr.status);} - else { f(xhr.responseText); } + try { s = xhr.status > 200} catch (e) {s = 0; } + if (s) // + {f('Erreur HTTP : ' + xhr.status);} + else { f(xhr.responseText); } } } @@ -232,9 +279,14 @@ function AjaxSqueeze(trig, id, f) g.innerHTML = ajax_image_searching; id.insertBefore(g, id.firstChild); } - return AjaxSqueezeNode(trig, id, f); + return !AjaxSqueezeNode(trig, id, f); } +// La fonction qui fait vraiment le travail decrit ci-dessus. +// Son premier argument est deja le noeud du DOM +// et son resultat booleen est inverse ce qui lui permet de retourner +// le gestionnaire Ajax comme valeur non fausse + function AjaxSqueezeNode(trig, noeud, f) { var i, s, g, callback; @@ -247,7 +299,7 @@ function AjaxSqueezeNode(trig, noeud, f) if (typeof(trig) == 'string') { i = trig.split('?'); trig = i[0] +'?var_ajaxcharset=utf-8&' + i[1]; - return !ajah('GET', trig, null, callback); + return ajah('GET', trig, null, callback); } for (i=0;i < trig.elements.length;i++) { @@ -262,7 +314,7 @@ function AjaxSqueezeNode(trig, noeud, f) s = trig.getAttribute('action'); if (typeof(s)!='string') // pour IE qui a foire la ligne precedente s = trig.attributes.action.value; - return !ajah('POST', // ou 'GET' + return ajah('POST', // ou 'GET' s , // s + '?'+ u, u, // null, callback); @@ -271,6 +323,8 @@ function AjaxSqueezeNode(trig, noeud, f) // Comme AjaxSqueeze, // mais avec un cache sur le noeud et un cache sur la reponse +// et une memorisation des greffes en attente afin de les abandonner +// (utile surtout a la frappe interactive au clavier) // De plus, la fonction optionnelle n'a pas besoin de greffer la reponse. function charger_id_url(myUrl, myField, jjscript) @@ -290,22 +344,24 @@ function charger_id_url(myUrl, myField, jjscript) function charger_node_url(myUrl, Field, jjscript, img) { - var r = url_chargee[myUrl]; // disponible en cache ? - if (r) { - retour_id_url(r, Field, jjscript); + if (url_chargee[myUrl]) { + retour_id_url(url_chargee[myUrl], Field, jjscript); triggerAjaxLoad(Field); return false; } else { - if (img) img.style.visibility = "visible"; - return AjaxSqueezeNode(myUrl, + if (img) img.style.visibility = "visible"; + if (xhr_actifs[Field]) { xhr_actifs[Field].abort(); } + xhr_actifs[Field] = AjaxSqueezeNode(myUrl, '', function (r) { + xhr_actifs[Field] = undefined; if (img) img.style.visibility = "hidden"; url_chargee[myUrl] = r; retour_id_url(r, Field, jjscript); - }) - } + }); + return !xhr_actifs[Field]; + } } function retour_id_url(r, Field, jjscript) diff --git a/dist/javascript/presentation.js b/dist/javascript/presentation.js index b197a6af812f1b0cb0bf4976d47ea51071add2cc..3475d99f3cb0a2e5018fd3d4e0f5529679f9cc50 100644 --- a/dist/javascript/presentation.js +++ b/dist/javascript/presentation.js @@ -159,23 +159,6 @@ function changeVisible(input, id, select, nonselect) { // livesearchlike... -function lancer_recherche(champ, cible) { - // Desactive pour l'instant (bouffe trop de ressources) - /* et a reprendre suite au cght d'interface Ajax du 7/8/06 - valeur = findObj(champ).value; - if (valeur.length > 3) { - charger_id_url('./?exec=recherche_sugg='+valeur,'sugg_recherche'); - charger_id_url('./?exec=recherche='+valeur,'resultats_recherche'); - } - */ -} - -function onkeypress_rechercher(champ, rac, url) { - valeur = findObj(champ).value; - if (valeur.length > 0) { - charger_id_url(url+valeur, rac); - } -} // effacement titre quand new=oui var antifocus=false; diff --git a/ecrire/exec/rechercher.php b/ecrire/exec/rechercher.php index ef715960ba8a2038e39aab1f6bef707d26f954ab..94fc339a952504c7df9dae22428ee64df3daa09d 100644 --- a/ecrire/exec/rechercher.php +++ b/ecrire/exec/rechercher.php @@ -12,87 +12,110 @@ if (!defined("_ECRIRE_INC_VERSION")) return; -# gerer un charset minimaliste en convertissant tout en unicode &#xxx; - // http://doc.spip.org/@exec_rechercher_dist function exec_rechercher_dist() { - global $id, $exclus, $type, $rac; - - $id = intval($id); - $exclus = intval($exclus); - $rac = htmlentities($rac); - - include_spip('inc/texte'); - $where = split("[[:space:]]+", $type); - if ($where) { - foreach ($where as $k => $v) - $where[$k] = "'%" . substr(str_replace("%","\%", spip_abstract_quote($v)),1,-1) . "%'"; - $where_titre = ("(titre LIKE " . join(" AND titre LIKE ", $where) . ")"); - $where_desc = ("(descriptif LIKE " . join(" AND descriptif LIKE ", $where) . ")"); - $where_id = ("(id_rubrique = " . join(" AND id_rubrique = ", $where) . ")"); - } else { - $where_titre = " 1=2"; - $where_desc = " 1=2"; - $where_id = " 1=2"; - } + global $id, $exclus, $type, $rac; - if ($exclus) { - include_spip('inc/rubriques'); - $where_exclus = " AND id_rubrique NOT IN (".calcul_branche($exclus).")"; - } else - $where_exclus = ''; - - $res = spip_query("SELECT id_rubrique, id_parent, titre FROM spip_rubriques WHERE $where_id$where_exclus"); - while ($row = spip_fetch_array($res)) { - $id_rubrique = $row["id_rubrique"]; - $rub[$id_rubrique]["titre"] = typo ($row["titre"]); - $rub[$id_rubrique]["id_parent"] = $row["id_parent"]; - $points[$id_rubrique] = $points[$id_rubrique] + 3; - } - $res = spip_query("SELECT id_rubrique, id_parent, titre FROM spip_rubriques WHERE $where_titre$where_exclus"); - while ($row = spip_fetch_array($res)) { - $id_rubrique = $row["id_rubrique"]; - $rub[$id_rubrique]["titre"] = typo ($row["titre"]); - $rub[$id_rubrique]["id_parent"] = $row["id_parent"]; - $points[$id_rubrique] = $points[$id_rubrique] + 2; - } - $res = spip_query("SELECT id_rubrique, id_parent, titre FROM spip_rubriques WHERE $where_desc$where_exclus"); - while ($row = spip_fetch_array($res)) { - $id_rubrique = $row["id_rubrique"]; - $rub[$id_rubrique]["titre"] = typo ($row["titre"]); - $rub[$id_rubrique]["id_parent"] = $row["id_parent"]; - $points[$id_rubrique] = $points[$id_rubrique] + 1; - } + $id = intval($id); + $exclus = intval($exclus); + $rac = htmlentities($rac); + + include_spip('inc/texte'); + $where = split("[[:space:]]+", $type); + if ($where) { + foreach ($where as $k => $v) + $where[$k] = "'%" . substr(str_replace("%","\%", spip_abstract_quote($v)),1,-1) . "%'"; + $where_titre = ("(titre LIKE " . join(" AND titre LIKE ", $where) . ")"); + $where_desc = ("(descriptif LIKE " . join(" AND descriptif LIKE ", $where) . ")"); + $where_id = ("(id_rubrique = " . join(" AND id_rubrique = ", $where) . ")"); + } else { + $where_titre = " 1=2"; + $where_desc = " 1=2"; + $where_id = " 1=2"; + } + + if ($exclus) { + include_spip('inc/rubriques'); + $where_exclus = " AND id_rubrique NOT IN (".calcul_branche($exclus).")"; + } else + $where_exclus = ''; + + $res = spip_query("SELECT id_rubrique, id_parent, titre FROM spip_rubriques WHERE $where_id$where_exclus"); + + $points = $rub = array(); + + while ($row = spip_fetch_array($res)) { + $id_rubrique = $row["id_rubrique"]; + $rub[$id_rubrique]["titre"] = typo ($row["titre"]); + $rub[$id_rubrique]["id_parent"] = $row["id_parent"]; + $points[$id_rubrique] = $points[$id_rubrique] + 3; + } + $res = spip_query("SELECT id_rubrique, id_parent, titre FROM spip_rubriques WHERE $where_titre$where_exclus"); + while ($row = spip_fetch_array($res)) { + $id_rubrique = $row["id_rubrique"]; + $rub[$id_rubrique]["titre"] = typo ($row["titre"]); + $rub[$id_rubrique]["id_parent"] = $row["id_parent"]; + $points[$id_rubrique] = $points[$id_rubrique] + 2; + } + $res = spip_query("SELECT id_rubrique, id_parent, titre FROM spip_rubriques WHERE $where_desc$where_exclus"); + while ($row = spip_fetch_array($res)) { + $id_rubrique = $row["id_rubrique"]; + $rub[$id_rubrique]["titre"] = typo ($row["titre"]); + $rub[$id_rubrique]["id_parent"] = $row["id_parent"]; + $points[$id_rubrique] = $points[$id_rubrique] + 1; + } - if ($points) { - arsort($points); - while (list($id,$pts) = each($points)) { - - $id_rubrique = $id; - $titre = $rub[$id]["titre"]; - $id_parent = $rub[$id]["id_parent"]; - - // Eviter une premiere fois d'afficher la rubrique exclue - if ($id_parent == 0) $style = "style='background-image: url(" . _DIR_IMG_PACK . "secteur-12.gif)'"; - else $style = ""; - $info = generer_url_ecrire('informer', "type=rubrique&rac=$rac&id="); - $onClick = " aff_selection($id_rubrique, '$rac" ."_selection', '$info');"; - - $btitre = strtr(str_replace("'", "’", - str_replace('"', """, textebrut($titre))), - "\n\r", " "); - - $ondbClick = "aff_selection_titre('$btitre',$id_rubrique,'selection_rubrique');"; - $ret .= "<div class='pashighlight' onClick=\"changerhighlight(this); $onClick\" ondblclick=\"$ondbClick$onClick\"><div class='arial11 petite-rubrique'$style>"; - $ret .= " $titre"; - $ret .= "</div></div>"; - } + + if ($points) { + arsort($points); + $style = " style='background-image: url(" . _DIR_IMG_PACK . "secteur-12.gif)'"; + foreach($rub as $k => $v) { + $rub[$k]['atts'] = ($v["id_parent"] ? $style : '') + . " class='arial11 petite-rubrique'"; } - if (!$ret) - $ret = "<div style='padding: 5px; color: red;'><b>" - .htmlentities($type) - ."</b> : "._T('avis_aucun_resultat')."</div>"; - ajax_retour($ret); + } + + ajax_retour(proposer_item($points, $rub, $rac)); + } + +// Resultat de la recherche interactive demandee par la fonction JS +// onkey_rechercher qui testera s'il comporte une seule balise au premier niveau +// car cela qui indique qu'un seul resultat a ete trouve. +// ==> attention a composer le message d'erreur avec au moins 2 balises + +function proposer_item ($ids, $titles, $rac) +{ + + if (!$ids) + return "<br /><br /><div style='padding: 5px; color: red;'><b>" + .htmlentities($type) + ."</b> : "._T('avis_aucun_resultat')."</div>"; + + $ret = ''; + $info = generer_url_ecrire('informer', "type=rubrique&rac=$rac&id="); + + $onClick = "aff_selection(this.firstChild.title,'$rac". "_selection','$info')"; + + $ondbClick = "aff_selection_titre(this.firstChild.firstChild.nodeValue,this.firstChild.title,'selection_rubrique', 'id_parent');"; + + foreach($ids as $id => $bof) { + + $titre = strtr(str_replace("'", "’", str_replace('"', """, textebrut($titles[$id]["titre"]))), "\n\r", " "); + + $ret .= "<div class='pashighlight'\nonClick=\"changerhighlight(this); " + . $onClick + . "\"\nondblclick=\"" + . $ondbClick + . $onClick + . " \"><div" + . $titles[$id]["atts"] + . " title='$id'> " + . $titre + . "</div></div>"; + } + return $ret; +} + ?> diff --git a/ecrire/inc/chercher_rubrique.php b/ecrire/inc/chercher_rubrique.php index 249ef9e82cf125ea6a2de42f43f611ca0a690e67..499ec9278c63b93132b2dec8aa11b9587e74a2ea 100644 --- a/ecrire/inc/chercher_rubrique.php +++ b/ecrire/inc/chercher_rubrique.php @@ -204,11 +204,11 @@ function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem=0) { $titre = _T('info_racine_site'); $titre = str_replace('&', '&', entites_html(textebrut(typo($titre)))); - $titre = "<input type='text' id='titreparent' name='titreparent' disabled='disabled' class='forml' value=\"" . $titre . "\" />"; + $init = " disabled='disabled' type='text' value=\"" . $titre . '"'; $url = generer_url_ecrire('selectionner',"id=$id_rubrique&type=$type" . (!$idem ? '' : ("&exclus=$idem&racine=" . ($restreint ? 'non' : 'oui')))); - return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $titre, $id_rubrique); + return construire_selecteur($url, '', 'selection_rubrique', 'id_parent', $init, $id_rubrique); } // construit un bloc comportant une icone clicable avec image animee a cote @@ -217,7 +217,7 @@ function selecteur_rubrique_ajax($id_rubrique, $type, $restreint, $idem=0) { // (la fonction JS charger_node ignore l'attribut id qui ne sert en fait pas; // getElement en mode Ajax est trop couteux). -function construire_selecteur($url, $js, $idom, $name, $titre='', $id=0) +function construire_selecteur($url, $js, $idom, $name, $init='', $id=0) { $icone = ($idom == 'selection_auteur') ? 'message.gif' : 'loupe.png'; return "<table width='100%'><tr width='100%'><td width='45'><a href='#'\nonclick=\"" @@ -232,7 +232,9 @@ function construire_selecteur($url, $js, $idom, $name, $titre='', $id=0) . "searching.gif' id='img_" . $idom . "' style='visibility: hidden;' /></td><td>" - . $titre + . "<input id='titreparent' name='titreparent'" + . $init + . " />" . "<input type='hidden' id='$name' name='$name' value='" . $id . "' /></td></tr></table><div id='" diff --git a/ecrire/inc/editer_auteurs.php b/ecrire/inc/editer_auteurs.php index 8e127e2626db641beb189bd0e48df27ef1eb5ae1..8eb5b91a518e36698bf29bb8133ce64df7904a72 100644 --- a/ecrire/inc/editer_auteurs.php +++ b/ecrire/inc/editer_auteurs.php @@ -277,6 +277,6 @@ function selecteur_auteur_ajax($id_article, $js, $text) include_spip('inc/chercher_rubrique'); $url = generer_url_ecrire('selectionner_auteur',"id_article=$id_article"); - return construire_selecteur($url, $js, 'selection_auteur', 'nouv_auteur', $text); + return $text . construire_selecteur($url, $js, 'selection_auteur', 'nouv_auteur', ' type="hidden"'); } ?> diff --git a/ecrire/inc/informer.php b/ecrire/inc/informer.php index 876b2ae096cac0f5096cbc9f84d691068610e3de..38a4c4bd99b031c81aac3f68a1c271564279b8ad 100644 --- a/ecrire/inc/informer.php +++ b/ecrire/inc/informer.php @@ -63,7 +63,7 @@ function inc_informer_dist($id, $col, $exclus, $rac, $type) . "<div style='text-align: $spip_lang_right;'>" . "<input type='submit' class='fondo' value='" . _T('bouton_choisir') - . "'\nonclick=\"aff_selection_titre('$titre',$id),'selection_rubrique'; return false;\" />" + . "'\nonclick=\"aff_selection_titre('$titre',$id,'selection_rubrique','id_parent'); return false;\" />" . "</div>" . "</div>"; } diff --git a/ecrire/inc/plonger.php b/ecrire/inc/plonger.php index adc957c1f8d51eed68eff6b4c6944801c867491c..6cae65d470a635555fd800d06803e49b4bf2a7ce 100644 --- a/ecrire/inc/plonger.php +++ b/ecrire/inc/plonger.php @@ -65,7 +65,7 @@ function inc_plonger_dist($id_rubrique, $idom="", $list=array(), $col = 1, $excl . "\"\nondblclick=\"" . "aff_selection_titre(this." . $acces - . "firstChild.firstChild.nodeValue,$id,'selection_rubrique');" + . "firstChild.firstChild.nodeValue,$id,'selection_rubrique','id_parent');" . "return aff_selection_provisoire($id,$args);" . "\">$titre</a>"; } diff --git a/ecrire/inc/selectionner.php b/ecrire/inc/selectionner.php index b2623d685eaf5c25bf1861fc7ba9e9b76d99e04e..920b616a1a7047ac610f5663b7653f2d9e4ff145 100644 --- a/ecrire/inc/selectionner.php +++ b/ecrire/inc/selectionner.php @@ -19,73 +19,94 @@ if (!defined("_ECRIRE_INC_VERSION")) return; // http://doc.spip.org/@inc_selectionner_dist function inc_selectionner_dist ($sel, $idom="",$fonction="", $exclus=0, $aff_racine=false, $recur=true) { - global $couleur_foncee, $spip_lang_right, $spip_lang_left; - - if (!$fonction) - $fonction = "document.location='" - . generer_url_ecrire('naviguer', "id_rubrique=::sel::") - . "';"; - if ($recur) $recur = mini_hier($sel); else $sel = 0; - $idom1 = $idom . "_champ_recherche"; - $idom2 = $idom . "_principal"; - $idom3 = $idom . "_selection"; - $idom4 = $idom . "_col_1"; - $idom5 = 'img_' . $idom4; - $idom6 = $idom."_fonc"; - if ($aff_racine) { $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&id="); - $onClick = " aff_selection(0,'$idom3', '$info');"; + $idom3 = $idom . "_selection"; + + $onClick = " aff_selection(0, '$idom3', '$info');"; $ondbClick = strtr(str_replace("'", "’", str_replace('"', """, textebrut(_T('info_racine_site')))), "\n\r", " "); - $ondbClick = "aff_selection_titre('$ondbClick',0,'selection_rubrique');"; + + $ondbClick = "aff_selection_titre('$ondbClick',0,'selection_rubrique','id_parent');"; + + $aff_racine = "<div class='arial11 petite-racine'\nonclick=\"" + . $onClick + . "\"\nondbclick=\"" + . $ondbClick + . $onClick + . "\">\n<div class='pashighlight'>" + . _T("info_racine_site") + . "</div></div>"; } + $url_init = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1", true); if ($recur) { - $plonger = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1", true); - $onClick .= "charger_id_url('$plonger', '$idom4');"; + $onClick .= "charger_id_url('$url_init', '$idom4');"; } $plonger = charger_fonction('plonger', 'inc'); $plonger = $plonger($sel, $idom, $recur, 1, $exclus); - + // url completee par la fonction JS onkeypress_rechercher $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&type="); + return construire_selectionner_hierarchie($idom, $plonger, $aff_racine, $url, 'id_parent', $url_init); +} + +function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init='') +{ + global $couleur_foncee, $spip_lang_right; + + $idom1 = $idom . "_champ_recherche"; + $idom2 = $idom . "_principal"; + $idom3 = $idom . "_selection"; + $idom4 = $idom . "_col_1"; + $idom5 = 'img_' . $idom4; + $idom6 = $idom."_fonc"; return "<div id='$idom'>" - . "<div style='display: none;'>" - . "<input type='text' id='$idom6' value=\"$fonction\" />" - . "</div>\n" + . "<a id='$idom6' style='visibility: hidden;'" + . ($url_init ? "href='$url_init'" : '') + . "></a>" . "<table width='100%' cellpadding='0' cellspacing='0'><tr>" - . "<td style='vertical-align: bottom;'>" - . "\n<div class='arial11 petite-racine'\nonclick=\"" - . $onClick - . "\"\nondbclick=\"" - . $ondbClick - . $onClick - . "\">\n<div class='pashighlight'>" - . _T("info_racine_site") - . "</div></div></td>\n<td>" + . "<td style='vertical-align: bottom;'>\n" + . $racine + . "</td>\n<td>" . http_img_pack("searching.gif", "*", "style='visibility: hidden;' id='$idom5'") - . "</td>" - . "\n<td style='text-align: $spip_lang_right'>" + . "</td><td style='text-align: $spip_lang_right'>" . "<input style='width: 100px;' type='search' id='$idom1'" - . "\nonkeypress=\"t=setTimeout('onkeypress_rechercher(\'" - . $idom1 - . "\',\'" - . $idom4 - . "\',\'" + // eliminer Return car il provoque la soumission (balise unique) + // ce serait encore mieux de ne le faire que s'il y a encore plusieurs + // resultats retournes par la recherche + . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3){return false;}\"" + // lancer la recherche apres le filtrage ci-dessus + . "\nonkeyup=\"return onkey_rechercher(this.value," + // la destination de la recherche + . "'$idom4'" +# . "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id" + . ",'" + // l'url effectuant la recherche . $url - . "\')', 200); key = event.keyCode; if (key == 13 || key == 3) { return false;} \" />" - . "</td></tr></table>\n<div id='$idom2'" + . "'," + // le noeud contenant un gif anime + // . "'idom5'" + . "this.parentNode.previousSibling.firstChild" + . ",'" + // la valeur de l'attribut Name a remplir + . $name + . "','" + // noeud invisible memorisant l'URL initiale (pour re-initialisation) + . $idom6 + . "')\"" + . " />" + . "\n</td></tr></table><div id='$idom2'" . " style='position: relative; height: 170px; background-color: white; border: 1px solid $couleur_foncee; overflow: auto;'><div id='$idom4'" . " class='arial1'>" - . $plonger + . $liste . "</div></div>\n<div id='$idom3'></div></div>\n"; } diff --git a/ecrire/inc/selectionner_auteur.php b/ecrire/inc/selectionner_auteur.php index c53942bc6997520046258bbf63e3265b66573777..9bdce9bbeb39900cdc25f536d74089bd24701545 100644 --- a/ecrire/inc/selectionner_auteur.php +++ b/ecrire/inc/selectionner_auteur.php @@ -13,6 +13,7 @@ if (!defined("_ECRIRE_INC_VERSION")) return; include_spip('inc/editer_auteurs'); +include_spip('inc/selectionner'); // // Affiche un mini-navigateur ajax sur les auteurs @@ -23,12 +24,6 @@ function inc_selectionner_auteur_dist($id_article) global $spip_lang_right, $couleur_foncee; $idom = 'bloc_selectionner_auteur'; - $idom1 = $idom . "_champ_recherche"; - $idom2 = $idom . "_principal"; - $idom3 = $idom . "_selection"; - $idom4 = $idom . "_col_1"; - $idom5 = 'img_' . $idom4; - $idom6 = $idom."_fonc"; $les_auteurs = determiner_auteurs_article($id_article); $futurs = selectionner_auteur_boucle(determiner_non_auteurs($les_auteurs, "nom, statut"), $idom); @@ -36,21 +31,7 @@ function inc_selectionner_auteur_dist($id_article) // url completee par la fonction JS onkeypress_rechercher $url = generer_url_ecrire('rechercher_auteur', "idom=$idom&nom="); - return "<div id='$idom'>" - . "<input style='width: 100px;' type='search' id='$idom1'" - . "\nonkeypress=\"t=setTimeout('onkeypress_rechercher(\'" - . $idom1 - . "\',\'" - . $idom4 - . "\',\'" - . $url - . "\')', 200); key = event.keyCode; if (key == 13 || key == 3) { return false;} \" />" - . http_img_pack("searching.gif", "*", "style='visibility: hidden;' id='$idom5'") - . "<div id='$idom2'" - . " style='position: relative; height: 170px; background-color: white; border: 1px solid $couleur_foncee; overflow: auto;'><div id='$idom4'" - . " class='arial1'>" - . $futurs - . "</div></div>\n<div id='$idom3'></div></div>\n"; + return construire_selectionner_hierarchie($idom, $futurs, '', $url, 'nouv_auteur'); } function selectionner_auteur_boucle($query, $idom) @@ -58,9 +39,7 @@ function selectionner_auteur_boucle($query, $idom) global $spip_lang_left; $info = generer_url_ecrire('informer_auteur', "id="); -# $args = "'$idom',this, '$col', '$spip_lang_left', '$info'"; $args = "'$idom" . "_selection', '$info'"; - $res = ''; while ($row = spip_fetch_array($query)) { @@ -76,6 +55,9 @@ function selectionner_auteur_boucle($query, $idom) // attention, les <a></a> doivent etre au premier niveau // et se suivrent pour que changerhighligth fonctionne + // De plus, leur zone doit avoir une balise et une seule + // autour de la valeur pertinente pour que aff_selection + // fonctionne (faudrait concentrer tout ca). $res .= "<a class='pashighlight'" . "\nonclick=\"changerhighlight(this);" @@ -85,7 +67,7 @@ function selectionner_auteur_boucle($query, $idom) . $commun . ";findObj_forcer('selection_auteur').style.display=" . "'none'; return false" - . "\">$titre</a>"; + . "\"><b>$titre</b></a>"; } return $res;