[Bese-devel] javascript
Lou Vanek
vanek at acd.net
Tue Jun 27 11:22:54 UTC 2006
Attila Lendvai wrote:
>> Moving all javascript load scripts out of HEAD and after the opening body
>> tag is a better solution since it's simpler than what I came up
>> with. Should probably make this part of a new <ucw:body tag.
>
>
> Lou, what happens if you replace the window render function with
> something like the paste at the end of this mail? it's the old render
> function in window.lisp except that the script definitions were moved
> into the <:body tag.
>
> if it solves your troubles i'll commit it, as it didn't change
> anything for me locally.
>
> - attila
>
> (alias 101 on irc &no 'its not lisp code :)
>
>
>
>
> (defmethod render :wrapping ((window simple-window-component))
> "This convience method assumes: 1) the stylesheet is
> external (as opposed to inlined) or is not used; 2) the script
> file is javascript and is external or is no script is used and 3)
> the title is simply the value of the title slot in the WINDOW (no
> dynamic titles)."
> (<:as-is "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0
> Transitional//EN\"
> \"http://www.w3.org/TR/xhtml1/DTD/transitional.dtd\">"
> #\Newline)
> (<:html
> (<:head
> (<:meta :http-equiv "Content-Type" :content
> (window-component.content-type window))
> (<:title (<:as-html (window-component.title window)))
> (awhen (window-component.icon window)
> (<:link :rel "icon"
> :type "image/x-icon"
> :href it))
> (dolist (stylesheet (ensure-list (window-component.stylesheet window)))
> (<:link :rel "stylesheet"
> :href stylesheet
> :type "text/css")))
> (let* ((app (context.application *context*))
> (url-prefix (application.url-prefix app)))
> (<:body
> (<ucw:script `(setf dj-config (create
> :is-debug ,(if (debug-on-error app)
> 'true
> 'false)
> :base-loader-uri ,(strcat
> url-prefix "dojo/"))))
> (<:script :type "text/javascript" :src (strcat url-prefix
> "dojo/dojo.js"))
> (<:script :type "text/javascript" :src (strcat url-prefix
> "ucw/js/per-application.js"))
> (dolist* ((type value &key with-url-prefix)
> (window-component.javascript window))
> (ecase type
> (:src
> ;; most browsers (firefox, safari and ie at least) really,
> ;; really, really don't like empty script tags. The "" forces
> ;; yaclml to generate a seperate closing tag.
> (<:script :type "text/javascript" :src (if with-url-prefix
> (strcat url-prefix
> value)
> value)
> ""))
> (:js
> (<:script :type "text/javascript" (<:as-is (js:js* value))))
> (:script
> (<:script :type "text/javascript" (<:as-is value)))))
> (call-next-method)))))
On first blush this seemed to solve most of the problems: it works as
expected on ff, opera 9 still complains about an undefined dojo variable
(but I don't care any more about opera), and IE6 worked correctly.
That is, until I noticed a brief error flash on the 302 redirect.
Since this change isn't included in the 302 redirect the error is still
occurring, but now only _between_ pages during the 302 redirect.
I still think this code needs to be taken out of this render method so
that other methods may reuse it, such as the 302 send-redirect function.
There are two other small problems, at least on my system: I had to comment
out the DOCTYPE line because it's being included elsewhere (the yaclml <:html tag),
and I had to comment out the dojo.js line because it's being included
elsewhere, too (otherwise I get two DOCTYPE and two src="dojo.js" lines).
But this is better than before.
Lou Vanek
More information about the bese-devel
mailing list