r7321 - in spip: dist ecrire/img_pack ecrire/inc

Author: esj@rezo.net
Date: 2006-09-04 00:34:57 +0200 (lun, 04 sep 2006)
New Revision: 7321

Log:
Optimisation du mini-navigateur de rubrique (suite de [7190]):

- la partie JavaScript du code fabriqué ne comporte plus une copie trancodée des titres et Url figurant déjà dans la partie HTML: les fonctions JS vont les chercher dans le DOM.

- suite à la correction [7190], l'appel de la méthode abort est supprimé, et du coup il n'est plus nécessaire de mémoriser dans un tableau global tous les appels à Ajax effectués dans cette page. De meme, il n'est pas nécessaire de mémoriser dans un tableau global l'emplacement des gif animés. La seule globale restante est le cache évitant d'effectuer plusieurs fois la meme requete Ajax.

Remarque: ce code aurait été posté plus tot si le mot clé This dans l'attribut
d'une balise A désignait, comme pour toute autre balise, la balise elle-meme,
non pas, de manière absurdement dérogatoire, l'attribut Href de cette balise.
W3C, priez pour nous.

Modified:
   spip/dist/style_prive.html
   spip/ecrire/img_pack/layer.js
   spip/ecrire/inc/actions.php
   spip/ecrire/inc/mini_nav.php

Details: http://trac.rezo.net/trac/spip/changeset/7321

Remarque: ce code aurait été posté plus tot si le mot clé This dans
l'attribut d'une balise A désignait, comme pour toute autre balise, la
balise elle-meme, non pas, de manière absurdement dérogatoire, l'attribut
Href de cette balise.

Qu'entends-tu par là ? On utiise tout le temps this.href, où this
représente le noeud a, comme pour tout le reste ?

W3C, priez pour nous.

Amen :slight_smile:

-- Fil

Le 4 sept. 06 à 10:30, Fil a écrit :

Remarque: ce code aurait été posté plus tot si le mot clé This dans
l'attribut d'une balise A désignait, comme pour toute autre balise, la
balise elle-meme, non pas, de manière absurdement dérogatoire, l'attribut
Href de cette balise.

Qu'entends-tu par là ? On utiise tout le temps this.href, où this
représente le noeud a, comme pour tout le reste ?

<img src='x' onclick='alert(this)'> affiche "[object IMG]"
<a href='X' onclick='alert(this)'> affiche X et pas "[object A]"

Essaye l'exemple ci-dessous.

E.

<html>
   <head>
     <title>this</title>
   </head>

   <body>
     <h1>this</h1><div>
<a href='http://trac.rezo.net/trac/spip/timeline’ onclick='alert(this)'>spip</a>
</div><div>
<img src='foo.gif' onclick="alert(this)" />
</div>
   </body>
</html>

<img src='x' onclick='alert(this)'> affiche "[object IMG]"
<a href='X' onclick='alert(this)'> affiche X et pas "[object A]"

Essaye l'exemple ci-dessous.

Ah oui, tiens... Stupéfiant !

-- Fil

Déesse A. ha scritto:

Le 4 sept. 06 à 10:30, Fil a écrit :

<img src='x' onclick='alert(this)'> affiche "[object IMG]"
<a href='X' onclick='alert(this)'> affiche X et pas "[object A]"

Essaye l'exemple ci-dessous.

E.

<html>
   <head>
     <title>this</title>
   </head>

   <body>
     <h1>this</h1><div>
<a href='http://trac.rezo.net/trac/spip/timeline’ onclick='alert (this)'>spip</a>
</div><div>
<img src='foo.gif' onclick="alert(this)" />
</div>
   </body>
</html>

This is not really true. "alert" triggers toString method of its argument to show its content in the message box. if "this" is the "a" element, this.toString is equal to its href attribute, because for the anchor prototype, the toString method is defined in this way.

Try

  <html>
     <head>
       <title>this</title>
     </head>

     <body>
       <h1>this</h1><div>
  <a href='http://trac.rezo.net/trac/spip/timeline’ onclick='alert
  (this.innerHTML)'>spip</a>
  </div><div>
  <img src='foo.gif' onclick="alert(this)" />
  </div>
     </body>
  </html>

and this will show that this is really the "a" element.

If you had problems, maybe an implicit conversion object->string is performed somewhere in your code.

Renato

Le 4 sept. 06 à 11:40, Renato Formato a écrit :

This is not really true. "alert" triggers toString method of its argument to show its content in the message box. if "this" is the "a" element, this.toString is equal to its href attribute, because for the anchor prototype, the toString method is defined in this way.

Interesting, but not enough for me.

If you had problems, maybe an implicit conversion object->string is performed somewhere in your code.

I don't thing so. My problem is in mini_nav, line 62. Hitherto, there was a div element ressembling this:

<div onClick='changerhighlight(this);ajaxcall(X)'>

when I substituted a A element

<a onClick='changerhighlight(this);ajaxcall(this.href)' href='X'>

the changehighlight call did not work anymore. The only way I found is to write

<div><a onClick='changerhighlight(this.parentNode);ajaxcall(this.href)' href='X'>...</a></div>

and to throw away the "parentNode" at the beginning of changerhighlight.
Do you have a solution without this additionnal <div> (just to know, because it is of no importance now) ?

Emmanuel
  

Déesse A. ha scritto:

Do you have a solution without this additionnal <div> (just to know, because it is of no importance now) ?

Yes, I have, committed.

But I identified the problem that is blocking mini_nav in IE. When selecting a section, ajax is injecting html code inside an element, let's say choix_parent_col_2, where this code has the root element choix_parent_col_2, with the same id. FF seems to recognize the problem and automatically replaces the root element with the receiving element. IE does not fix this and you will end up with :

<div id="choix_parent_col_2">
  <div id="choix_parent_col_2">

  </div>
</div>

that will cause an error during processing, stopping execution in retour_id_url as Field variable is no more an element object (the error is style has no properties). The stop causes not to execute the final line of aff_selection_provisoire, return false, causing the page to reload.

For the solution, i have to say, I'm not able to propose one at the moment...a suivre, right? :slight_smile:

Renato

Le 4 sept. 06 à 16:18, Renato Formato a écrit :

Déesse A. ha scritto:

Do you have a solution without this additionnal <div> (just to know,
because it is of no importance now) ?

Yes, I have, committed.

Sorry Renato, but now the highlight does not work anymore, neither in FF nor Safari.
Here is the real problem, and it is due to the fact that changerhlight(this) transmits the href attribute rather than the node A.

But I identified the problem that is blocking mini_nav in IE. When
selecting a section, ajax is injecting html code inside an element,
let's say choix_parent_col_2, where this code has the root element
choix_parent_col_2, with the same id.

Yes, your are right !
You should have commited this fix instead ;-).

Ciao,

  Emmanuel

Déesse A. ha scritto:

Sorry Renato, but now the highlight does not work anymore, neither in FF nor Safari.
Here is the real problem, and it is due to the fact that changerhlight(this) transmits the href attribute rather than the node A.

It works for me with FF and Safari. I changed the stylesheet. Try to delete SPIP cache.

Renato

Le 4 sept. 06 à 17:30, Renato Formato a écrit :

Déesse A. ha scritto:

Sorry Renato, but now the highlight does not work anymore, neither in FF
nor Safari.
Here is the real problem, and it is due to the fact that
changerhlight(this) transmits the href attribute rather than the node A.

It works for me with FF and Safari. I changed the stylesheet. Try to
delete SPIP cache.

I did it already, and do it once again, it's still does not work.

???

E.

Le 4 sept. 06 à 17:33, Déesse A. a écrit :

It works for me with FF and Safari. I changed the stylesheet. Try to
delete SPIP cache.

I did it already, and do it once again, it's still does not work.

???

Sorry, I made the update in a wrong directory.
Meanwhile, I fixed the IE problem; I post the whole thing in a few minutes.

Emmanuel