[Bese-devel] javascript

Attila Lendvai attila.lendvai at gmail.com
Tue Jun 27 08:24:25 UTC 2006


> 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)))))



More information about the bese-devel mailing list