JAB Creations
2007-Apr-20 03:02 UTC
Script.aculo.us modularized and for application/xhtml+xml
Hello everyone!
Right now my first working preview of the 28th version of my site
(http://www.jabcreations.net/) uses Script.aculo.us. However after
figuring out how to modularize user events and therefor removing all
JavaScript except for the head includes I''ve decided to give visitors
the option to change DHTML libraries with Script.aculo.us being one of
those choices. It''s currently implemented (and on) by default on
preview one.
I''ve encountered two problems, have solved and want to share one
problem/solution, and need help with the second problem!
The first problem was that since I''m a standards evangelist I
currently serve my site as XHTML 1.1 as application/xhtml+xml by
default. Thankfully the problem was minor: document.write. My
solution...
- - - - -
require: function(libraryName)
{
// inserting via DOM fails in Safari 2.0, so brute force approach
if (document.getElementById)
{
var l=document.createElementNS("http:www.w3.org/1999/
xhtml","script");
l.setAttribute("type", "text/javascript1");
l.setAttribute("src",
"''+libraryName+''");
document.getElementsByTagName("head")[0].appendChild(l);
}
else
{
document.write(''<script type="text/javascript"
src="''+libraryName
+''"></script>'');
}
},
- - - - -
Since I''ve modularized JavaScript events and want to use modularized
DHTML libraries I naturally want to keep my file management within
reason. I keep all my JavaScript inside of a /script/ directory. I
also have a specific file naming scheme to help keep me organized.
This is how my directory looks like locally right now...
scripts-2.8.js
scripts-2.8_functions.js
scripts-2.8_functions-onload.js
scripts-2.8-dhtml-jquery.js
scripts-2.8-dhtml-jquery-functions.js
scripts-2.8-dhtml-jquery-functions-onload.js
scripts-2.8-dhtml-jquery-interface.js
scripts-2.8-dhtml-scriptaculous.js
scripts-2.8-dhtml-scriptaculous-effects.js
scripts-2.8-dhtml-scriptaculous-functions.js
scripts-2.8-dhtml-scriptaculous-functions-onload.js
scripts-2.8-dhtml-scriptaculous-prototype.js
Depending on the user''s preferences (DHTML enabled and which DHTML
library) will determine which files are loaded (specifically onload
files which load the base functions and if DHTML is enabled the
functions for the desired library).
I''ve unsuccessfully tried to edit the main script file so the scripts
see each other (which doesn''t make sense because they should by
default anyway at least under my understanding). I''ve tried
"scripts-2.8-dhtml-scriptaculous''+libraryName+''" in
one example though
this could either be wrong or the prototype file could be looking for
the base script in return, I''m not sure. The error I''m
encountering
though is throwing it''s own message...
- - - -
Error: uncaught exception: script.aculo.us requires the Prototype
JavaScript framework >= 1.5.0
- - - -
I''d like to have Script.aculo.us featured in the second preview of
version 2.8 of my site though I can not afford to have numerous files
without an acceptable naming scheme when I''m working with potentially
several different and separate libraries. When it works it works
pretty good (some artifacting problems in IE7 though with the version
I''m using).
Of course I''m still working on the second preview but to have
Script.aculo.us work DHTML will need to be enabled (requires broadband
choice by user). I plan on testing each browser with both libraries to
avoid artifacting but that will take a lot of work to implement
correctly though Script.aculo.us and jquery will both be available
options in the second preview which once I get this problem solved
will allow me to modularize Script.aculo.us events and then update
my .net preview site. An advanced thanks for any help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---