List Info

Thread: Re: YUI loader and your own modules




Re: YUI loader and your own modules
country flaguser name
United States
2008-07-09 19:17:36

Actually thats still per instance. and now i see the path stuff and
dependancies.

But what i think i need to do is the following but this means the
modules have to added to every instance of the loader. I am assuming
you can only do one insert for every loader instance. Which isnt
really desirable id like to be able to insert stuff when ever i like
and progressively add stuff on events without having to create a
loader every time. Meh, this is me being whingy because dojo's is so
much more powerful and flexible for solving the dependancy problem.

(function() {

ORCHESTRAL.common.util.YUILoader = function() {
ORCHESTRAL.common.util.YUILoader.superclass.constructor.call();

this.addModule({
name: 'orchestraldom',
type: 'js',
fullpath: '/common/javascript/orchestral/util/dom.js',
requires: ['dom']
});
}

YAHOO.extend(ORCHESTRAL.common.util.YUILoader, YAHOO.util.Editor);
})();
YAHOO.register("orchestral-yuiloader",
ORCHESTRAL.common.util.YUILoader, {version: '2.1', build: '1'});

__._,_.___
.

__,_._,___
Re: Re: YUI loader and your own modules
country flaguser name
Spain
2008-07-10 02:30:33

I have all my module definitions in a single source file along several
other utility functions. I include that file in all my pages, just a
simple <script> tag. It already gives me an instance of Loader already
set up with all my modules. Whether you add your dependencies to the
Loader base class, which you can, though it's not a good idea, by
modifying the moduleInfo object:

http://developer.yahoo.com/yui/docs/YAHOO.util.YUILoader.html#property_moduleInfo

or you use addModule (much safer) you will have to add code somewhere
and include that, somewhere. I don't see much difference, I just have
it all in one include file and then I get everything set up.

Actually, later on I went a little further. I have all the code of my
pages in separate files from the HTML, so there is a .js file for every
.html file. I am not talking about the library files, those shared
across different pages but the specific code for each page. Each .js
file is registered at the end using YAHOO.register. Each of those files
is added as a module via addModule, stating all its dependencies with
other library files, YUI's or my own library files. The filename
(without the extension) is used as the name of the module. Every HTML
file has only two <script> tags, one to load the aggregate
yuiloader-dom-events and the other my basic utilities JavaScript file.
The code in it will take the name of the HTML file from
window.location.href, strip off the .html extension and use it in the
requires property of Loader and then call insert. I just took a look at
it and it is really messy with building the menu and setting up some
other things, it is not really clear enough to show, really, but that's
the basic idea. Only two includes per html page and all gets loaded and
working.

Satyam

wendymcameron wrote:
&gt; Actually thats still per instance. and now i see the path stuff and
> dependancies.
>
> But what i think i need to do is the following but this means the
> modules have to added to every instance of the loader. I am assuming
> you can only do one insert for every loader instance. Which isnt
>; really desirable id like to be able to insert stuff when ever i like
>; and progressively add stuff on events without having to create a
> loader every time. Meh, this is me being whingy because dojo's is so
> much more powerful and flexible for solving the dependancy problem.
>
>; (function() {
>
> ORCHESTRAL.common.util.YUILoader = function() {
> ORCHESTRAL.common.util.YUILoader.superclass.constructor.call();
>
> this.addModule({
&gt; name: 'orchestraldom',
&gt; type: 'js',
&gt; fullpath: '/common/javascript/orchestral/util/dom.js',
> requires: ['dom']
> });
> }
>
> YAHOO.extend(ORCHESTRAL.common.util.YUILoader, YAHOO.util.Editor);
> })();
&gt; YAHOO.register(";orchestral-yuiloader",
> ORCHESTRAL.common.util.YUILoader, {version: '2.1', build: '1'});
&gt;
>
> ------------------------------------
&gt;
> Yahoo! Groups Links
&gt;
>
>
>;
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com
> Version: 8.0.138 / Virus Database: 270.4.7/1542 - Release Date: 09/07/2008 6:50
>;
>
>
>

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )