[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]

[wml] Problems with JS functions and navbars


Stephan Petersen told me last week that rollover effect was broken on
the WML website. It was due to changes i made on July and commented out
in http://www.engelschall.com/sw/wml/news/list/msg01858.shtml

I guess many of you could be affected by this error too, so i would like
to discuss this issue here.

In wml::std::tags the <javascript> tag divert its content into the HEAD
section, to fix a bug reported by Chris Marston about function scope.
IMO this behaviour is what we need.

When a document generate multiple files (as multilingual documents do),
javascript functions must be put into each output file. For this reason,
i defined <navbar:jsfuncs>, which print definiton of javascript
functions, and discard itself so that these functions are printed only
once.  As explained in wml::des::navbar(3), use this tag outside of
any slice terms to make sure every output file contain right JS
functions.  This problem was raised by Stephan Petersen, and he took
time to help me providing a robust solution.

But there is one case where this fails: in pages with more than one
navbar, if the first one is text only, no JS code is inserted.
This problem is hairy, because <navbar:jsfuncs> is evaluated in pass 2,
and navbars are built in pass 3.  So i think the only solution is to
write those Javascript functions even with text-only navbars.
I applied the following patch to the unstable branch, and will apply it
to the stable branch if there is no objection.

Index: navbar.src
RCS file: /home/barbier/Projets/Wml/cvs/wml/wml_include/des/navbar.src,v
retrieving revision 1.34
diff -u -u -r1.34 navbar.src
--- navbar.src	2000/10/02 08:27:14	1.34
+++ navbar.src	2000/10/30 00:01:50
@@ -553,12 +553,14 @@
     $mcode =~ s|^\s+||;
     $mcode =~ s|\s+$||;
     $O .= $mcode."\n";
+    $P = <<'EOT';
+<navbar:jsfuncs />
     #   prefix the output with some JavaScript
     #   aux functions and the preloading of used images
     if ($#preload >= 0) {
-        $P = <<'EOT';
-<navbar:jsfuncs />
+        $P .= <<'EOT';
 if (document.images) {

Denis Barbier
WML Maintainer
Website META Language (WML)                www.engelschall.com/sw/wml/
Official Support Mailing List                   sw-wml@engelschall.com
Automated List Manager                       majordomo@engelschall.com