loader.js revision 4fcbec6145d16637205990699912fb90f6a3807c
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * Loader dynamically loads script and css files. It includes the dependency
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * info for the version of the library in use, and will automatically pull in
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * dependencies for the modules requested. It supports rollup files and will
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * automatically use these when appropriate in order to minimize the number of
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * http connections required to load all of the dependencies. It can load the
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * files from the Yahoo! CDN, and it can utilize the combo service provided on
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * this network to reduce the number of http connections required to download
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * YUI files.
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * @module yui
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * @submodule loader
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * Loader dynamically loads script and css files. It includes the dependency
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * info for the version of the library in use, and will automatically pull in
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * dependencies for the modules requested. It supports rollup files and will
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * automatically use these when appropriate in order to minimize the number of
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * http connections required to load all of the dependencies. It can load the
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * files from the Yahoo! CDN, and it can utilize the combo service provided on
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * this network to reduce the number of http connections required to download
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * YUI files.
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * @class Loader
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * @constructor
eb6c1c09177446c3a7fa974e4658cbd555c5be18Luke Smith * @param o an optional set of configuration options. Valid options:
a3b15d60042c81a524cebb94370e5a234a19d04bLuke Smith * The base dir</li>
a3b15d60042c81a524cebb94370e5a234a19d04bLuke Smith * <li>secureBase:
a3b15d60042c81a524cebb94370e5a234a19d04bLuke Smith * The secure base dir (not implemented)</li>
* The YUI combo service base dir. Ex: http://yui.yahooapis.com/combo?</li>
* minified version of the files (e.g., event-min.js). The filter property
* <dd>Selects the debug versions of the library (e.g., event-debug.js).
* <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
* 'replaceStr': "-debug.js"
* Use the YUI combo service to reduce the number of http connections required to load your dependencies</li>
* A list of modules that should always be loaded when required, even if already present on the page</li>
* number of milliseconds before a timeout occurs when dynamically loading nodes. in not set, there is no timeout</li>
// http://yui.yahooapis.com/combo?2.5.2/build/yahoo/yahoo-min.js&2.5.2/build/dom/dom-min.js&2.5.2/build/event/event-min.js&2.5.2/build/autocomplete/autocomplete-min.js"
modules: {
dom: {
selector: {
node: {
anim: {
attribute: {
base: {
compat: {
cookie: { },
cssbase: {
cssfonts: {
cssgrids: {
cssreset: {
supersedes: ['dd-ddm-base', 'dd-ddm', 'dd-ddm-drop', 'dd-drag', 'dd-proxy', 'dd-constrain', 'dd-plugin', 'dd-drop', 'dd-drop-plugin', 'dd-drag-proxy'],
dump: { },
event: {
io: {
json: {
oop: {
queue: { },
substitute: {
yui: {
var _Y = {
dupsAllowed: {},
Y.Loader = function(o) {
this._internalCallback = null;
this._useYahooListener = false;
this.onSuccess = null;
this.onProgress = null;
this.onTimeout = null;
this.context = Y;
this.data = null;
this.insertBefore = null;
this.charset = null;
* @default http://yui.yahooapis.com/[YUI VERSION]/build/
* @default http://yui.yahooapis.com/combo?
this.combine = false;
this.ignoreRegistered = false;
this.ignore = null;
this.force = null;
this.allowRollup = true;
* minified version of the files (e.g., event-min.js). The filter property
* <dd>Selects the debug versions of the library (e.g., event-debug.js).
* <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
* 'replaceStr': "-debug.js"
this.filter = null;
this.required = {};
this.moduleInfo = {};
for (var i in defaults) {
this._internal = true;
this._internal = false;
this.rollups = null;
this.loadOptional = false;
this.sorted = [];
this.loaded = {};
this.attaching = null;
this.dirty = true;
this.inserted = {};
this.skipped = {};
this._config(o);
FILTERS: {
RAW: {
DEBUG: {
_config: function(o) {
var val = o[i];
if (o.hasOwnProperty(i)) {
for (var j in val) {
this[i] = val;
var f = this.filter;
if (L.isString(f)) {
f = f.toUpperCase();
* <dt>after:</dt> <dd>array of modules the components which, if present, should be sorted above this one</dd>
* <dt>fullpath:</dt> <dd>If fullpath is specified, this is used instead of the configured base + path</dd>
if (!o || !o.name) {
if (!o.type) {
this.dirty = true;
this.dirty = true;
if (!mod) {
d.push(r[i]);
m = this.getModule(r[i]);
d.push(r[i]);
m = this.getModule(r[i]);
if (o && this.loadOptional) {
d.push(o[i]);
if (m[ckey]) {
return m[ckey];
add(s[i]);
m[SUPER] = o;
return m[ckey];
calculate: function(o) {
if (o || this.dirty) {
this._config(o);
this._setup();
this._explode();
if (this.allowRollup) {
this._rollup();
this._reduce();
this._sort();
this.dirty = false;
_setup: function() {
if (!this.ignoreRegistered) {
if (this.ignore) {
if (l.hasOwnProperty(j)) {
if (this.force) {
if (this.force[i] in l) {
delete l[this.force[i]];
this.loaded = l;
_explode: function() {
if (r.hasOwnProperty(i)) {
if (req) {
_rollup: function() {
for (i in info) {
m = this.getModule(i);
if (m && m.rollup) {
rollups[i] = m;
var rolled = false;
for (i in rollups) {
if (!r[i] && !this.loaded[i]) {
if (!m.rollup) {
roll = false;
if (roll) {
if (roll) {
rolled = true;
this.getRequires(m);
if (!rolled) {
_reduce: function() {
var i, j, s, m, r=this.required;
if (i in this.loaded) {
m = this.getModule(i);
s = m && m.supersedes;
_attach: function() {
if (this.attaching) {
_onSuccess: function() {
this._pushEvents();
this._attach();
for (var i in this.skipped) {
delete this.inserted[i];
this.skipped = {};
var f = this.onSuccess;
this._attach();
var f = this.onFailure;
this._attach();
var f = this.onTimeout;
_sort: function() {
me = this;
if (ss) {
if (requires(a, s[k])) {
moved = true;
if (moved) {
if (!moved) {
this.sorted = s;
this.calculate(o);
if (!type) {
var self = this;
this._internalCallback = function() {
this._loading = true;
this._combineComplete = false;
this.loadNext();
if (!this._loading) {
this._combining = [];
s=this.sorted;
m = this.getModule(s[i]);
var callback=function(o) {
this._combineComplete = true;
this.inserted[c[i]] = true;
this._combineComplete = true;
if (mname) {
if (this.onProgress) {
s=this.sorted;
if (s[i] in this.inserted) {
if (s[i] === this._loading) {
m = this.getModule(s[i]);
this.inserted[s[i]] = true;
this.skipped[s[i]] = true;
this._loading = s[i];
onsuccess=function(o) {
self=this;
data: s[i],
this._loading = null;
if (this._internalCallback) {
var f = this._internalCallback;
this._internalCallback = null;
f.call(this);
this._onSuccess();
* In IE, the onAvailable/onDOMReady events need help when Event is
var r = ref || Y;
if (r.Event) {
u = u + path;