~bac/juju-gui/trunkcopy

« back to all changes in this revision

Viewing changes to lib/yui/build/loader-base/loader-base-debug.js

  • Committer: kapil.foss at gmail
  • Date: 2012-07-13 18:45:59 UTC
  • Revision ID: kapil.foss@gmail.com-20120713184559-2xl7be17egsrz0c9
reshape

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.5.1 (build 22)
3
 
Copyright 2012 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('loader-base', function(Y) {
8
 
 
9
 
/**
10
 
 * The YUI loader core
11
 
 * @module loader
12
 
 * @submodule loader-base
13
 
 */
14
 
 
15
 
if (!YUI.Env[Y.version]) {
16
 
 
17
 
    (function() {
18
 
        var VERSION = Y.version,
19
 
            BUILD = '/build/',
20
 
            ROOT = VERSION + BUILD,
21
 
            CDN_BASE = Y.Env.base,
22
 
            GALLERY_VERSION = 'gallery-2012.04.10-14-57',
23
 
            TNT = '2in3',
24
 
            TNT_VERSION = '4',
25
 
            YUI2_VERSION = '2.9.0',
26
 
            COMBO_BASE = CDN_BASE + 'combo?',
27
 
            META = { version: VERSION,
28
 
                              root: ROOT,
29
 
                              base: Y.Env.base,
30
 
                              comboBase: COMBO_BASE,
31
 
                              skin: { defaultSkin: 'sam',
32
 
                                           base: 'assets/skins/',
33
 
                                           path: 'skin.css',
34
 
                                           after: ['cssreset',
35
 
                                                          'cssfonts',
36
 
                                                          'cssgrids',
37
 
                                                          'cssbase',
38
 
                                                          'cssreset-context',
39
 
                                                          'cssfonts-context']},
40
 
                              groups: {},
41
 
                              patterns: {} },
42
 
            groups = META.groups,
43
 
            yui2Update = function(tnt, yui2, config) {
44
 
                    
45
 
                var root = TNT + '.' +
46
 
                        (tnt || TNT_VERSION) + '/' +
47
 
                        (yui2 || YUI2_VERSION) + BUILD,
48
 
                    base = (config && config.base) ? config.base : CDN_BASE,
49
 
                    combo = (config && config.comboBase) ? config.comboBase : COMBO_BASE;
50
 
 
51
 
                groups.yui2.base = base + root;
52
 
                groups.yui2.root = root;
53
 
                groups.yui2.comboBase = combo;
54
 
            },
55
 
            galleryUpdate = function(tag, config) {
56
 
                var root = (tag || GALLERY_VERSION) + BUILD,
57
 
                    base = (config && config.base) ? config.base : CDN_BASE,
58
 
                    combo = (config && config.comboBase) ? config.comboBase : COMBO_BASE;
59
 
 
60
 
                groups.gallery.base = base + root;
61
 
                groups.gallery.root = root;
62
 
                groups.gallery.comboBase = combo;
63
 
            };
64
 
 
65
 
 
66
 
        groups[VERSION] = {};
67
 
 
68
 
        groups.gallery = {
69
 
            ext: false,
70
 
            combine: true,
71
 
            comboBase: COMBO_BASE,
72
 
            update: galleryUpdate,
73
 
            patterns: { 'gallery-': { },
74
 
                        'lang/gallery-': {},
75
 
                        'gallerycss-': { type: 'css' } }
76
 
        };
77
 
 
78
 
        groups.yui2 = {
79
 
            combine: true,
80
 
            ext: false,
81
 
            comboBase: COMBO_BASE,
82
 
            update: yui2Update,
83
 
            patterns: {
84
 
                'yui2-': {
85
 
                    configFn: function(me) {
86
 
                        if (/-skin|reset|fonts|grids|base/.test(me.name)) {
87
 
                            me.type = 'css';
88
 
                            me.path = me.path.replace(/\.js/, '.css');
89
 
                            // this makes skins in builds earlier than
90
 
                            // 2.6.0 work as long as combine is false
91
 
                            me.path = me.path.replace(/\/yui2-skin/,
92
 
                                             '/assets/skins/sam/yui2-skin');
93
 
                        }
94
 
                    }
95
 
                }
96
 
            }
97
 
        };
98
 
 
99
 
        galleryUpdate();
100
 
        yui2Update();
101
 
 
102
 
        YUI.Env[VERSION] = META;
103
 
    }());
104
 
}
105
 
 
106
 
 
107
 
/**
108
 
 * Loader dynamically loads script and css files.  It includes the dependency
109
 
 * information for the version of the library in use, and will automatically pull in
110
 
 * dependencies for the modules requested. It can also load the
111
 
 * files from the Yahoo! CDN, and it can utilize the combo service provided on
112
 
 * this network to reduce the number of http connections required to download
113
 
 * YUI files.
114
 
 *
115
 
 * @module loader
116
 
 * @main loader
117
 
 * @submodule loader-base
118
 
 */
119
 
 
120
 
var NOT_FOUND = {},
121
 
    NO_REQUIREMENTS = [],
122
 
    MAX_URL_LENGTH = 1024,
123
 
    GLOBAL_ENV = YUI.Env,
124
 
    GLOBAL_LOADED = GLOBAL_ENV._loaded,
125
 
    CSS = 'css',
126
 
    JS = 'js',
127
 
    INTL = 'intl',
128
 
    VERSION = Y.version,
129
 
    ROOT_LANG = '',
130
 
    YObject = Y.Object,
131
 
    oeach = YObject.each,
132
 
    YArray = Y.Array,
133
 
    _queue = GLOBAL_ENV._loaderQueue,
134
 
    META = GLOBAL_ENV[VERSION],
135
 
    SKIN_PREFIX = 'skin-',
136
 
    L = Y.Lang,
137
 
    ON_PAGE = GLOBAL_ENV.mods,
138
 
    modulekey,
139
 
    cache,
140
 
    _path = function(dir, file, type, nomin) {
141
 
                        var path = dir + '/' + file;
142
 
                        if (!nomin) {
143
 
                            path += '-min';
144
 
                        }
145
 
                        path += '.' + (type || CSS);
146
 
 
147
 
                        return path;
148
 
                    };
149
 
 
150
 
/**
151
 
 * The component metadata is stored in Y.Env.meta.
152
 
 * Part of the loader module.
153
 
 * @property meta
154
 
 * @for YUI
155
 
 */
156
 
Y.Env.meta = META;
157
 
 
158
 
/**
159
 
 * Loader dynamically loads script and css files.  It includes the dependency
160
 
 * info for the version of the library in use, and will automatically pull in
161
 
 * dependencies for the modules requested. It can load the
162
 
 * files from the Yahoo! CDN, and it can utilize the combo service provided on
163
 
 * this network to reduce the number of http connections required to download
164
 
 * YUI files. You can also specify an external, custom combo service to host
165
 
 * your modules as well.
166
 
 
167
 
        var Y = YUI();
168
 
        var loader = new Y.Loader({
169
 
            filter: 'debug',
170
 
            base: '../../',
171
 
            root: 'build/',
172
 
            combine: true,
173
 
            require: ['node', 'dd', 'console']
174
 
        });
175
 
        var out = loader.resolve(true);
176
 
 
177
 
 * @constructor
178
 
 * @class Loader
179
 
 * @param {Object} config an optional set of configuration options.
180
 
 * @param {String} config.base The base dir which to fetch this module from
181
 
 * @param {String} config.comboBase The Combo service base path. Ex: `http://yui.yahooapis.com/combo?`
182
 
 * @param {String} config.root The root path to prepend to module names for the combo service. Ex: `2.5.2/build/`
183
 
 * @param {String|Object} config.filter A filter to apply to result urls. <a href="#property_filter">See filter property</a>
184
 
 * @param {Object} config.filters Per-component filter specification.  If specified for a given component, this overrides the filter config.
185
 
 * @param {Boolean} config.combine Use a combo service to reduce the number of http connections required to load your dependencies
186
 
 * @param {Array} config.ignore: A list of modules that should never be dynamically loaded
187
 
 * @param {Array} config.force A list of modules that should always be loaded when required, even if already present on the page
188
 
 * @param {HTMLElement|String} config.insertBefore Node or id for a node that should be used as the insertion point for new nodes
189
 
 * @param {Object} config.jsAttributes Object literal containing attributes to add to script nodes
190
 
 * @param {Object} config.cssAttributes Object literal containing attributes to add to link nodes
191
 
 * @param {Number} config.timeout The number of milliseconds before a timeout occurs when dynamically loading nodes.  If not set, there is no timeout
192
 
 * @param {Object} config.context Execution context for all callbacks
193
 
 * @param {Function} config.onSuccess Callback for the 'success' event
194
 
 * @param {Function} config.onFailure Callback for the 'failure' event
195
 
 * @param {Function} config.onCSS Callback for the 'CSSComplete' event.  When loading YUI components with CSS the CSS is loaded first, then the script.  This provides a moment you can tie into to improve the presentation of the page while the script is loading.
196
 
 * @param {Function} config.onTimeout Callback for the 'timeout' event
197
 
 * @param {Function} config.onProgress Callback executed each time a script or css file is loaded
198
 
 * @param {Object} config.modules A list of module definitions.  See <a href="#method_addModule">Loader.addModule</a> for the supported module metadata
199
 
 * @param {Object} config.groups A list of group definitions.  Each group can contain specific definitions for `base`, `comboBase`, `combine`, and accepts a list of `modules`.
200
 
 * @param {String} config.2in3 The version of the YUI 2 in 3 wrapper to use.  The intrinsic support for YUI 2 modules in YUI 3 relies on versions of the YUI 2 components inside YUI 3 module wrappers.  These wrappers change over time to accomodate the issues that arise from running YUI 2 in a YUI 3 sandbox.
201
 
 * @param {String} config.yui2 When using the 2in3 project, you can select the version of YUI 2 to use.  Valid values are `2.2.2`, `2.3.1`, `2.4.1`, `2.5.2`, `2.6.0`, `2.7.0`, `2.8.0`, `2.8.1` and `2.9.0` [default] -- plus all versions of YUI 2 going forward.
202
 
 */
203
 
Y.Loader = function(o) {
204
 
 
205
 
    var defaults = META.modules,
206
 
        self = this;
207
 
    
208
 
    //Catch no config passed.
209
 
    o = o || {};
210
 
 
211
 
    modulekey = META.md5;
212
 
 
213
 
    /**
214
 
     * Internal callback to handle multiple internal insert() calls
215
 
     * so that css is inserted prior to js
216
 
     * @property _internalCallback
217
 
     * @private
218
 
     */
219
 
    // self._internalCallback = null;
220
 
 
221
 
    /**
222
 
     * Callback that will be executed when the loader is finished
223
 
     * with an insert
224
 
     * @method onSuccess
225
 
     * @type function
226
 
     */
227
 
    // self.onSuccess = null;
228
 
 
229
 
    /**
230
 
     * Callback that will be executed if there is a failure
231
 
     * @method onFailure
232
 
     * @type function
233
 
     */
234
 
    // self.onFailure = null;
235
 
 
236
 
    /**
237
 
     * Callback for the 'CSSComplete' event.  When loading YUI components
238
 
     * with CSS the CSS is loaded first, then the script.  This provides
239
 
     * a moment you can tie into to improve the presentation of the page
240
 
     * while the script is loading.
241
 
     * @method onCSS
242
 
     * @type function
243
 
     */
244
 
    // self.onCSS = null;
245
 
 
246
 
    /**
247
 
     * Callback executed each time a script or css file is loaded
248
 
     * @method onProgress
249
 
     * @type function
250
 
     */
251
 
    // self.onProgress = null;
252
 
 
253
 
    /**
254
 
     * Callback that will be executed if a timeout occurs
255
 
     * @method onTimeout
256
 
     * @type function
257
 
     */
258
 
    // self.onTimeout = null;
259
 
 
260
 
    /**
261
 
     * The execution context for all callbacks
262
 
     * @property context
263
 
     * @default {YUI} the YUI instance
264
 
     */
265
 
    self.context = Y;
266
 
 
267
 
    /**
268
 
     * Data that is passed to all callbacks
269
 
     * @property data
270
 
     */
271
 
    // self.data = null;
272
 
 
273
 
    /**
274
 
     * Node reference or id where new nodes should be inserted before
275
 
     * @property insertBefore
276
 
     * @type string|HTMLElement
277
 
     */
278
 
    // self.insertBefore = null;
279
 
 
280
 
    /**
281
 
     * The charset attribute for inserted nodes
282
 
     * @property charset
283
 
     * @type string
284
 
     * @deprecated , use cssAttributes or jsAttributes.
285
 
     */
286
 
    // self.charset = null;
287
 
 
288
 
    /**
289
 
     * An object literal containing attributes to add to link nodes
290
 
     * @property cssAttributes
291
 
     * @type object
292
 
     */
293
 
    // self.cssAttributes = null;
294
 
 
295
 
    /**
296
 
     * An object literal containing attributes to add to script nodes
297
 
     * @property jsAttributes
298
 
     * @type object
299
 
     */
300
 
    // self.jsAttributes = null;
301
 
 
302
 
    /**
303
 
     * The base directory.
304
 
     * @property base
305
 
     * @type string
306
 
     * @default http://yui.yahooapis.com/[YUI VERSION]/build/
307
 
     */
308
 
    self.base = Y.Env.meta.base + Y.Env.meta.root;
309
 
 
310
 
    /**
311
 
     * Base path for the combo service
312
 
     * @property comboBase
313
 
     * @type string
314
 
     * @default http://yui.yahooapis.com/combo?
315
 
     */
316
 
    self.comboBase = Y.Env.meta.comboBase;
317
 
 
318
 
    /*
319
 
     * Base path for language packs.
320
 
     */
321
 
    // self.langBase = Y.Env.meta.langBase;
322
 
    // self.lang = "";
323
 
 
324
 
    /**
325
 
     * If configured, the loader will attempt to use the combo
326
 
     * service for YUI resources and configured external resources.
327
 
     * @property combine
328
 
     * @type boolean
329
 
     * @default true if a base dir isn't in the config
330
 
     */
331
 
    self.combine = o.base &&
332
 
        (o.base.indexOf(self.comboBase.substr(0, 20)) > -1);
333
 
    
334
 
    /**
335
 
    * The default seperator to use between files in a combo URL
336
 
    * @property comboSep
337
 
    * @type {String}
338
 
    * @default Ampersand
339
 
    */
340
 
    self.comboSep = '&';
341
 
    /**
342
 
     * Max url length for combo urls.  The default is 2048. This is the URL
343
 
     * limit for the Yahoo! hosted combo servers.  If consuming
344
 
     * a different combo service that has a different URL limit
345
 
     * it is possible to override this default by supplying
346
 
     * the maxURLLength config option.  The config option will
347
 
     * only take effect if lower than the default.
348
 
     *
349
 
     * @property maxURLLength
350
 
     * @type int
351
 
     */
352
 
    self.maxURLLength = MAX_URL_LENGTH;
353
 
 
354
 
    /**
355
 
     * Ignore modules registered on the YUI global
356
 
     * @property ignoreRegistered
357
 
     * @default false
358
 
     */
359
 
    //self.ignoreRegistered = false;
360
 
 
361
 
    /**
362
 
     * Root path to prepend to module path for the combo
363
 
     * service
364
 
     * @property root
365
 
     * @type string
366
 
     * @default [YUI VERSION]/build/
367
 
     */
368
 
    self.root = Y.Env.meta.root;
369
 
 
370
 
    /**
371
 
     * Timeout value in milliseconds.  If set, self value will be used by
372
 
     * the get utility.  the timeout event will fire if
373
 
     * a timeout occurs.
374
 
     * @property timeout
375
 
     * @type int
376
 
     */
377
 
    self.timeout = 0;
378
 
 
379
 
    /**
380
 
     * A list of modules that should not be loaded, even if
381
 
     * they turn up in the dependency tree
382
 
     * @property ignore
383
 
     * @type string[]
384
 
     */
385
 
    // self.ignore = null;
386
 
 
387
 
    /**
388
 
     * A list of modules that should always be loaded, even
389
 
     * if they have already been inserted into the page.
390
 
     * @property force
391
 
     * @type string[]
392
 
     */
393
 
    // self.force = null;
394
 
 
395
 
    self.forceMap = {};
396
 
 
397
 
    /**
398
 
     * Should we allow rollups
399
 
     * @property allowRollup
400
 
     * @type boolean
401
 
     * @default false
402
 
     */
403
 
    self.allowRollup = false;
404
 
 
405
 
    /**
406
 
     * A filter to apply to result urls.  This filter will modify the default
407
 
     * path for all modules.  The default path for the YUI library is the
408
 
     * minified version of the files (e.g., event-min.js).  The filter property
409
 
     * can be a predefined filter or a custom filter.  The valid predefined
410
 
     * filters are:
411
 
     * <dl>
412
 
     *  <dt>DEBUG</dt>
413
 
     *  <dd>Selects the debug versions of the library (e.g., event-debug.js).
414
 
     *      This option will automatically include the Logger widget</dd>
415
 
     *  <dt>RAW</dt>
416
 
     *  <dd>Selects the non-minified version of the library (e.g., event.js).
417
 
     *  </dd>
418
 
     * </dl>
419
 
     * You can also define a custom filter, which must be an object literal
420
 
     * containing a search expression and a replace string:
421
 
     *
422
 
     *      myFilter: {
423
 
     *          'searchExp': "-min\\.js",
424
 
     *          'replaceStr': "-debug.js"
425
 
     *      }
426
 
     *
427
 
     * @property filter
428
 
     * @type string| {searchExp: string, replaceStr: string}
429
 
     */
430
 
    // self.filter = null;
431
 
 
432
 
    /**
433
 
     * per-component filter specification.  If specified for a given
434
 
     * component, this overrides the filter config.
435
 
     * @property filters
436
 
     * @type object
437
 
     */
438
 
    self.filters = {};
439
 
 
440
 
    /**
441
 
     * The list of requested modules
442
 
     * @property required
443
 
     * @type {string: boolean}
444
 
     */
445
 
    self.required = {};
446
 
 
447
 
    /**
448
 
     * If a module name is predefined when requested, it is checked againsts
449
 
     * the patterns provided in this property.  If there is a match, the
450
 
     * module is added with the default configuration.
451
 
     *
452
 
     * At the moment only supporting module prefixes, but anticipate
453
 
     * supporting at least regular expressions.
454
 
     * @property patterns
455
 
     * @type Object
456
 
     */
457
 
    // self.patterns = Y.merge(Y.Env.meta.patterns);
458
 
    self.patterns = {};
459
 
 
460
 
    /**
461
 
     * The library metadata
462
 
     * @property moduleInfo
463
 
     */
464
 
    // self.moduleInfo = Y.merge(Y.Env.meta.moduleInfo);
465
 
    self.moduleInfo = {};
466
 
 
467
 
    self.groups = Y.merge(Y.Env.meta.groups);
468
 
 
469
 
    /**
470
 
     * Provides the information used to skin the skinnable components.
471
 
     * The following skin definition would result in 'skin1' and 'skin2'
472
 
     * being loaded for calendar (if calendar was requested), and
473
 
     * 'sam' for all other skinnable components:
474
 
     *
475
 
     *      skin: {
476
 
     *          // The default skin, which is automatically applied if not
477
 
     *          // overriden by a component-specific skin definition.
478
 
     *          // Change this in to apply a different skin globally
479
 
     *          defaultSkin: 'sam',
480
 
     *
481
 
     *          // This is combined with the loader base property to get
482
 
     *          // the default root directory for a skin. ex:
483
 
     *          // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/
484
 
     *          base: 'assets/skins/',
485
 
     *          
486
 
     *          // Any component-specific overrides can be specified here,
487
 
     *          // making it possible to load different skins for different
488
 
     *          // components.  It is possible to load more than one skin
489
 
     *          // for a given component as well.
490
 
     *          overrides: {
491
 
     *              calendar: ['skin1', 'skin2']
492
 
     *          }
493
 
     *      }
494
 
     * @property skin
495
 
     * @type {Object}
496
 
     */
497
 
    self.skin = Y.merge(Y.Env.meta.skin);
498
 
 
499
 
    /*
500
 
     * Map of conditional modules
501
 
     * @since 3.2.0
502
 
     */
503
 
    self.conditions = {};
504
 
 
505
 
    // map of modules with a hash of modules that meet the requirement
506
 
    // self.provides = {};
507
 
 
508
 
    self.config = o;
509
 
    self._internal = true;
510
 
 
511
 
 
512
 
    cache = GLOBAL_ENV._renderedMods;
513
 
 
514
 
    if (cache) {
515
 
        oeach(cache, function modCache(v, k) {
516
 
            self.moduleInfo[k] = Y.merge(v);
517
 
        });
518
 
 
519
 
        cache = GLOBAL_ENV._conditions;
520
 
 
521
 
        oeach(cache, function condCache(v, k) {
522
 
            self.conditions[k] = Y.merge(v);
523
 
        });
524
 
 
525
 
    } else {
526
 
        oeach(defaults, self.addModule, self);
527
 
    }
528
 
 
529
 
 
530
 
    /**
531
 
     * Set when beginning to compute the dependency tree.
532
 
     * Composed of what YUI reports to be loaded combined
533
 
     * with what has been loaded by any instance on the page
534
 
     * with the version number specified in the metadata.
535
 
     * @property loaded
536
 
     * @type {string: boolean}
537
 
     */
538
 
    self.loaded = GLOBAL_LOADED[VERSION];
539
 
 
540
 
 
541
 
    self._inspectPage();
542
 
 
543
 
    self._internal = false;
544
 
 
545
 
    self._config(o);
546
 
 
547
 
    self.forceMap = (self.force) ? Y.Array.hash(self.force) : {};       
548
 
 
549
 
    self.testresults = null;
550
 
 
551
 
    if (Y.config.tests) {
552
 
        self.testresults = Y.config.tests;
553
 
    }
554
 
 
555
 
    /**
556
 
     * List of rollup files found in the library metadata
557
 
     * @property rollups
558
 
     */
559
 
    // self.rollups = null;
560
 
 
561
 
    /**
562
 
     * Whether or not to load optional dependencies for
563
 
     * the requested modules
564
 
     * @property loadOptional
565
 
     * @type boolean
566
 
     * @default false
567
 
     */
568
 
    // self.loadOptional = false;
569
 
 
570
 
    /**
571
 
     * All of the derived dependencies in sorted order, which
572
 
     * will be populated when either calculate() or insert()
573
 
     * is called
574
 
     * @property sorted
575
 
     * @type string[]
576
 
     */
577
 
    self.sorted = [];
578
 
 
579
 
    /*
580
 
     * A list of modules to attach to the YUI instance when complete.
581
 
     * If not supplied, the sorted list of dependencies are applied.
582
 
     * @property attaching
583
 
     */
584
 
    // self.attaching = null;
585
 
 
586
 
    /**
587
 
     * Flag to indicate the dependency tree needs to be recomputed
588
 
     * if insert is called again.
589
 
     * @property dirty
590
 
     * @type boolean
591
 
     * @default true
592
 
     */
593
 
    self.dirty = true;
594
 
 
595
 
    /**
596
 
     * List of modules inserted by the utility
597
 
     * @property inserted
598
 
     * @type {string: boolean}
599
 
     */
600
 
    self.inserted = {};
601
 
 
602
 
    /**
603
 
     * List of skipped modules during insert() because the module
604
 
     * was not defined
605
 
     * @property skipped
606
 
     */
607
 
    self.skipped = {};
608
 
 
609
 
    // Y.on('yui:load', self.loadNext, self);
610
 
 
611
 
    self.tested = {};
612
 
 
613
 
    /*
614
 
     * Cached sorted calculate results
615
 
     * @property results
616
 
     * @since 3.2.0
617
 
     */
618
 
    //self.results = {};
619
 
 
620
 
};
621
 
 
622
 
Y.Loader.prototype = {
623
 
    /**
624
 
    Regex that matches a CSS URL. Used to guess the file type when it's not
625
 
    specified.
626
 
 
627
 
    @property REGEX_CSS
628
 
    @type RegExp
629
 
    @final
630
 
    @protected
631
 
    @since 3.5.0
632
 
    **/
633
 
    REGEX_CSS: /\.css(?:[?;].*)?$/i,
634
 
    
635
 
    /**
636
 
    * Default filters for raw and debug
637
 
    * @property FILTER_DEFS
638
 
    * @type Object
639
 
    * @final
640
 
    * @protected
641
 
    */
642
 
    FILTER_DEFS: {
643
 
        RAW: {
644
 
            'searchExp': '-min\\.js',
645
 
            'replaceStr': '.js'
646
 
        },
647
 
        DEBUG: {
648
 
            'searchExp': '-min\\.js',
649
 
            'replaceStr': '-debug.js'
650
 
        }
651
 
    },
652
 
    /*
653
 
    * Check the pages meta-data and cache the result.
654
 
    * @method _inspectPage
655
 
    * @private
656
 
    */
657
 
    _inspectPage: function() {
658
 
        
659
 
        //Inspect the page for CSS only modules and mark them as loaded.
660
 
        oeach(this.moduleInfo, function(v, k) {
661
 
            if (v.type && v.type === CSS) {
662
 
                if (this.isCSSLoaded(v.name)) {
663
 
                    Y.log('Found CSS module on page: ' + v.name, 'info', 'loader');
664
 
                    this.loaded[k] = true;
665
 
                }
666
 
            }
667
 
        }, this);
668
 
        
669
 
        oeach(ON_PAGE, function(v, k) {
670
 
           if (v.details) {
671
 
               var m = this.moduleInfo[k],
672
 
                   req = v.details.requires,
673
 
                   mr = m && m.requires;
674
 
               if (m) {
675
 
                   if (!m._inspected && req && mr.length != req.length) {
676
 
                       // console.log('deleting ' + m.name);
677
 
                       delete m.expanded;
678
 
                   }
679
 
               } else {
680
 
                   m = this.addModule(v.details, k);
681
 
               }
682
 
               m._inspected = true;
683
 
           }
684
 
       }, this);
685
 
    },
686
 
    /*
687
 
    * returns true if b is not loaded, and is required directly or by means of modules it supersedes.
688
 
    * @private
689
 
    * @method _requires
690
 
    * @param {String} mod1 The first module to compare
691
 
    * @param {String} mod2 The second module to compare
692
 
    */
693
 
   _requires: function(mod1, mod2) {
694
 
 
695
 
        var i, rm, after_map, s,
696
 
            info = this.moduleInfo,
697
 
            m = info[mod1],
698
 
            other = info[mod2];
699
 
 
700
 
        if (!m || !other) {
701
 
            return false;
702
 
        }
703
 
 
704
 
        rm = m.expanded_map;
705
 
        after_map = m.after_map;
706
 
 
707
 
        // check if this module should be sorted after the other
708
 
        // do this first to short circut circular deps
709
 
        if (after_map && (mod2 in after_map)) {
710
 
            return true;
711
 
        }
712
 
 
713
 
        after_map = other.after_map;
714
 
 
715
 
        // and vis-versa
716
 
        if (after_map && (mod1 in after_map)) {
717
 
            return false;
718
 
        }
719
 
 
720
 
        // check if this module requires one the other supersedes
721
 
        s = info[mod2] && info[mod2].supersedes;
722
 
        if (s) {
723
 
            for (i = 0; i < s.length; i++) {
724
 
                if (this._requires(mod1, s[i])) {
725
 
                    return true;
726
 
                }
727
 
            }
728
 
        }
729
 
 
730
 
        s = info[mod1] && info[mod1].supersedes;
731
 
        if (s) {
732
 
            for (i = 0; i < s.length; i++) {
733
 
                if (this._requires(mod2, s[i])) {
734
 
                    return false;
735
 
                }
736
 
            }
737
 
        }
738
 
 
739
 
        // check if this module requires the other directly
740
 
        // if (r && YArray.indexOf(r, mod2) > -1) {
741
 
        if (rm && (mod2 in rm)) {
742
 
            return true;
743
 
        }
744
 
 
745
 
        // external css files should be sorted below yui css
746
 
        if (m.ext && m.type == CSS && !other.ext && other.type == CSS) {
747
 
            return true;
748
 
        }
749
 
 
750
 
        return false;
751
 
    },
752
 
    /**
753
 
    * Apply a new config to the Loader instance
754
 
    * @method _config
755
 
    * @private
756
 
    * @param {Object} o The new configuration
757
 
    */
758
 
    _config: function(o) {
759
 
        var i, j, val, f, group, groupName, self = this;
760
 
        // apply config values
761
 
        if (o) {
762
 
            for (i in o) {
763
 
                if (o.hasOwnProperty(i)) {
764
 
                    val = o[i];
765
 
                    if (i == 'require') {
766
 
                        self.require(val);
767
 
                    } else if (i == 'skin') {
768
 
                        //If the config.skin is a string, format to the expected object
769
 
                        if (typeof val === 'string') {
770
 
                            self.skin.defaultSkin = o.skin;
771
 
                            val = {
772
 
                                defaultSkin: val
773
 
                            };
774
 
                        }
775
 
 
776
 
                        Y.mix(self.skin, val, true);
777
 
                    } else if (i == 'groups') {
778
 
                        for (j in val) {
779
 
                            if (val.hasOwnProperty(j)) {
780
 
                                // Y.log('group: ' + j);
781
 
                                groupName = j;
782
 
                                group = val[j];
783
 
                                self.addGroup(group, groupName);
784
 
                                if (group.aliases) {
785
 
                                    oeach(group.aliases, self.addAlias, self);
786
 
                                }
787
 
                            }
788
 
                        }
789
 
 
790
 
                    } else if (i == 'modules') {
791
 
                        // add a hash of module definitions
792
 
                        oeach(val, self.addModule, self);
793
 
                    } else if (i === 'aliases') {
794
 
                        oeach(val, self.addAlias, self);
795
 
                    } else if (i == 'gallery') {
796
 
                        this.groups.gallery.update(val, o);
797
 
                    } else if (i == 'yui2' || i == '2in3') {
798
 
                        this.groups.yui2.update(o['2in3'], o.yui2, o);
799
 
                    } else {
800
 
                        self[i] = val;
801
 
                    }
802
 
                }
803
 
            }
804
 
        }
805
 
 
806
 
        // fix filter
807
 
        f = self.filter;
808
 
 
809
 
        if (L.isString(f)) {
810
 
            f = f.toUpperCase();
811
 
            self.filterName = f;
812
 
            self.filter = self.FILTER_DEFS[f];
813
 
            if (f == 'DEBUG') {
814
 
                self.require('yui-log', 'dump');
815
 
            }
816
 
        }
817
 
        
818
 
 
819
 
        if (self.lang) {
820
 
            //Removed this so that when Loader is invoked
821
 
            //it doesn't request what it doesn't need.
822
 
            //self.require('intl-base', 'intl');
823
 
        }
824
 
 
825
 
    },
826
 
 
827
 
    /**
828
 
     * Returns the skin module name for the specified skin name.  If a
829
 
     * module name is supplied, the returned skin module name is
830
 
     * specific to the module passed in.
831
 
     * @method formatSkin
832
 
     * @param {string} skin the name of the skin.
833
 
     * @param {string} mod optional: the name of a module to skin.
834
 
     * @return {string} the full skin module name.
835
 
     */
836
 
    formatSkin: function(skin, mod) {
837
 
        var s = SKIN_PREFIX + skin;
838
 
        if (mod) {
839
 
            s = s + '-' + mod;
840
 
        }
841
 
 
842
 
        return s;
843
 
    },
844
 
 
845
 
    /**
846
 
     * Adds the skin def to the module info
847
 
     * @method _addSkin
848
 
     * @param {string} skin the name of the skin.
849
 
     * @param {string} mod the name of the module.
850
 
     * @param {string} parent parent module if this is a skin of a
851
 
     * submodule or plugin.
852
 
     * @return {string} the module name for the skin.
853
 
     * @private
854
 
     */
855
 
    _addSkin: function(skin, mod, parent) {
856
 
        var mdef, pkg, name, nmod,
857
 
            info = this.moduleInfo,
858
 
            sinf = this.skin,
859
 
            ext = info[mod] && info[mod].ext;
860
 
 
861
 
        // Add a module definition for the module-specific skin css
862
 
        if (mod) {
863
 
            name = this.formatSkin(skin, mod);
864
 
            if (!info[name]) {
865
 
                mdef = info[mod];
866
 
                pkg = mdef.pkg || mod;
867
 
                nmod = {
868
 
                    name: name,
869
 
                    group: mdef.group,
870
 
                    type: 'css',
871
 
                    after: sinf.after,
872
 
                    path: (parent || pkg) + '/' + sinf.base + skin +
873
 
                          '/' + mod + '.css',
874
 
                    ext: ext
875
 
                };
876
 
                if (mdef.base) {
877
 
                    nmod.base = mdef.base;
878
 
                }
879
 
                if (mdef.configFn) {
880
 
                    nmod.configFn = mdef.configFn;
881
 
                }
882
 
                this.addModule(nmod, name);
883
 
 
884
 
                Y.log('Adding skin (' + name + '), ' + parent + ', ' + pkg + ', ' + info[name].path, 'info', 'loader');
885
 
            }
886
 
        }
887
 
 
888
 
        return name;
889
 
    },
890
 
    /**
891
 
    * Adds an alias module to the system
892
 
    * @method addAlias
893
 
    * @param {Array} use An array of modules that makes up this alias
894
 
    * @param {String} name The name of the alias
895
 
    * @example
896
 
    *       var loader = new Y.Loader({});
897
 
    *       loader.addAlias([ 'node', 'yql' ], 'davglass');
898
 
    *       loader.require(['davglass']);
899
 
    *       var out = loader.resolve(true);
900
 
    *
901
 
    *       //out.js will contain Node and YQL modules
902
 
    */
903
 
    addAlias: function(use, name) {
904
 
        YUI.Env.aliases[name] = use;
905
 
        this.addModule({
906
 
            name: name,
907
 
            use: use
908
 
        });
909
 
    },
910
 
    /**
911
 
     * Add a new module group
912
 
     * @method addGroup
913
 
     * @param {Object} config An object containing the group configuration data
914
 
     * @param {String} config.name required, the group name
915
 
     * @param {String} config.base The base directory for this module group
916
 
     * @param {String} config.root The root path to add to each combo resource path
917
 
     * @param {Boolean} config.combine Should the request be combined
918
 
     * @param {String} config.comboBase Combo service base path
919
 
     * @param {Object} config.modules The group of modules
920
 
     * @param {String} name the group name.
921
 
     * @example
922
 
     *      var loader = new Y.Loader({});
923
 
     *      loader.addGroup({
924
 
     *          name: 'davglass',
925
 
     *          combine: true,
926
 
     *          comboBase: '/combo?',
927
 
     *          root: '',
928
 
     *          modules: {
929
 
     *              //Module List here
930
 
     *          }
931
 
     *      }, 'davglass');
932
 
     */
933
 
    addGroup: function(o, name) {
934
 
        var mods = o.modules,
935
 
            self = this;
936
 
        name = name || o.name;
937
 
        o.name = name;
938
 
        self.groups[name] = o;
939
 
 
940
 
        if (o.patterns) {
941
 
            oeach(o.patterns, function(v, k) {
942
 
                v.group = name;
943
 
                self.patterns[k] = v;
944
 
            });
945
 
        }
946
 
 
947
 
        if (mods) {
948
 
            oeach(mods, function(v, k) {
949
 
                if (typeof v === 'string') {
950
 
                    v = { name: k, fullpath: v };
951
 
                }
952
 
                v.group = name;
953
 
                self.addModule(v, k);
954
 
            }, self);
955
 
        }
956
 
    },
957
 
 
958
 
    /**
959
 
     * Add a new module to the component metadata.
960
 
     * @method addModule
961
 
     * @param {Object} config An object containing the module data.
962
 
     * @param {String} config.name Required, the component name
963
 
     * @param {String} config.type Required, the component type (js or css)
964
 
     * @param {String} config.path Required, the path to the script from `base`
965
 
     * @param {Array} config.requires Array of modules required by this component
966
 
     * @param {Array} [config.optional] Array of optional modules for this component
967
 
     * @param {Array} [config.supersedes] Array of the modules this component replaces
968
 
     * @param {Array} [config.after] Array of modules the components which, if present, should be sorted above this one
969
 
     * @param {Object} [config.after_map] Faster alternative to 'after' -- supply a hash instead of an array
970
 
     * @param {Number} [config.rollup] The number of superseded modules required for automatic rollup
971
 
     * @param {String} [config.fullpath] If `fullpath` is specified, this is used instead of the configured `base + path`
972
 
     * @param {Boolean} [config.skinnable] Flag to determine if skin assets should automatically be pulled in
973
 
     * @param {Object} [config.submodules] Hash of submodules
974
 
     * @param {String} [config.group] The group the module belongs to -- this is set automatically when it is added as part of a group configuration.
975
 
     * @param {Array} [config.lang] Array of BCP 47 language tags of languages for which this module has localized resource bundles, e.g., `["en-GB", "zh-Hans-CN"]`
976
 
     * @param {Object} [config.condition] Specifies that the module should be loaded automatically if a condition is met.  This is an object with up to three fields:
977
 
     * @param {String} [config.condition.trigger] The name of a module that can trigger the auto-load
978
 
     * @param {Function} [config.condition.test] A function that returns true when the module is to be loaded.
979
 
     * @param {String} [config.condition.when] Specifies the load order of the conditional module
980
 
     *  with regard to the position of the trigger module.
981
 
     *  This should be one of three values: `before`, `after`, or `instead`.  The default is `after`.
982
 
     * @param {Object} [config.testresults] A hash of test results from `Y.Features.all()`
983
 
     * @param {Function} [config.configFn] A function to exectute when configuring this module
984
 
     * @param {Object} config.configFn.mod The module config, modifying this object will modify it's config. Returning false will delete the module's config.
985
 
     * @param {String} [name] The module name, required if not in the module data.
986
 
     * @return {Object} the module definition or null if the object passed in did not provide all required attributes.
987
 
     */
988
 
    addModule: function(o, name) {
989
 
        name = name || o.name;
990
 
 
991
 
        if (typeof o === 'string') {
992
 
            o = { name: name, fullpath: o };
993
 
        }
994
 
        
995
 
        //Only merge this data if the temp flag is set
996
 
        //from an earlier pass from a pattern or else
997
 
        //an override module (YUI_config) can not be used to
998
 
        //replace a default module.
999
 
        if (this.moduleInfo[name] && this.moduleInfo[name].temp) {
1000
 
            //This catches temp modules loaded via a pattern
1001
 
            // The module will be added twice, once from the pattern and
1002
 
            // Once from the actual add call, this ensures that properties
1003
 
            // that were added to the module the first time around (group: gallery)
1004
 
            // are also added the second time around too.
1005
 
            o = Y.merge(this.moduleInfo[name], o);
1006
 
        }
1007
 
 
1008
 
        o.name = name;
1009
 
 
1010
 
        if (!o || !o.name) {
1011
 
            return null;
1012
 
        }
1013
 
 
1014
 
        if (!o.type) {
1015
 
            //Always assume it's javascript unless the CSS pattern is matched.
1016
 
            o.type = JS;
1017
 
            var p = o.path || o.fullpath;
1018
 
            if (p && this.REGEX_CSS.test(p)) {
1019
 
                Y.log('Auto determined module type as CSS', 'warn', 'loader');
1020
 
                o.type = CSS;
1021
 
            }
1022
 
        }
1023
 
 
1024
 
        if (!o.path && !o.fullpath) {
1025
 
            o.path = _path(name, name, o.type);
1026
 
        }
1027
 
        o.supersedes = o.supersedes || o.use;
1028
 
 
1029
 
        o.ext = ('ext' in o) ? o.ext : (this._internal) ? false : true;
1030
 
 
1031
 
        // Handle submodule logic
1032
 
        var subs = o.submodules, i, l, t, sup, s, smod, plugins, plug,
1033
 
            j, langs, packName, supName, flatSup, flatLang, lang, ret,
1034
 
            overrides, skinname, when,
1035
 
            conditions = this.conditions, trigger;
1036
 
            // , existing = this.moduleInfo[name], newr;
1037
 
        
1038
 
        this.moduleInfo[name] = o;
1039
 
 
1040
 
        o.requires = o.requires || [];
1041
 
 
1042
 
        if (o.skinnable) {
1043
 
            skinname = this._addSkin(this.skin.defaultSkin, name);
1044
 
            o.requires.unshift(skinname);
1045
 
        }
1046
 
 
1047
 
        o.requires = this.filterRequires(o.requires) || [];
1048
 
 
1049
 
        if (!o.langPack && o.lang) {
1050
 
            langs = YArray(o.lang);
1051
 
            for (j = 0; j < langs.length; j++) {
1052
 
                lang = langs[j];
1053
 
                packName = this.getLangPackName(lang, name);
1054
 
                smod = this.moduleInfo[packName];
1055
 
                if (!smod) {
1056
 
                    smod = this._addLangPack(lang, o, packName);
1057
 
                }
1058
 
            }
1059
 
        }
1060
 
 
1061
 
 
1062
 
        if (subs) {
1063
 
            sup = o.supersedes || [];
1064
 
            l = 0;
1065
 
 
1066
 
            for (i in subs) {
1067
 
                if (subs.hasOwnProperty(i)) {
1068
 
                    s = subs[i];
1069
 
 
1070
 
                    s.path = s.path || _path(name, i, o.type);
1071
 
                    s.pkg = name;
1072
 
                    s.group = o.group;
1073
 
 
1074
 
                    if (s.supersedes) {
1075
 
                        sup = sup.concat(s.supersedes);
1076
 
                    }
1077
 
 
1078
 
                    smod = this.addModule(s, i);
1079
 
                    sup.push(i);
1080
 
 
1081
 
                    if (smod.skinnable) {
1082
 
                        o.skinnable = true;
1083
 
                        overrides = this.skin.overrides;
1084
 
                        if (overrides && overrides[i]) {
1085
 
                            for (j = 0; j < overrides[i].length; j++) {
1086
 
                                skinname = this._addSkin(overrides[i][j],
1087
 
                                         i, name);
1088
 
                                sup.push(skinname);
1089
 
                            }
1090
 
                        }
1091
 
                        skinname = this._addSkin(this.skin.defaultSkin,
1092
 
                                        i, name);
1093
 
                        sup.push(skinname);
1094
 
                    }
1095
 
 
1096
 
                    // looks like we are expected to work out the metadata
1097
 
                    // for the parent module language packs from what is
1098
 
                    // specified in the child modules.
1099
 
                    if (s.lang && s.lang.length) {
1100
 
 
1101
 
                        langs = YArray(s.lang);
1102
 
                        for (j = 0; j < langs.length; j++) {
1103
 
                            lang = langs[j];
1104
 
                            packName = this.getLangPackName(lang, name);
1105
 
                            supName = this.getLangPackName(lang, i);
1106
 
                            smod = this.moduleInfo[packName];
1107
 
 
1108
 
                            if (!smod) {
1109
 
                                smod = this._addLangPack(lang, o, packName);
1110
 
                            }
1111
 
 
1112
 
                            flatSup = flatSup || YArray.hash(smod.supersedes);
1113
 
 
1114
 
                            if (!(supName in flatSup)) {
1115
 
                                smod.supersedes.push(supName);
1116
 
                            }
1117
 
 
1118
 
                            o.lang = o.lang || [];
1119
 
 
1120
 
                            flatLang = flatLang || YArray.hash(o.lang);
1121
 
 
1122
 
                            if (!(lang in flatLang)) {
1123
 
                                o.lang.push(lang);
1124
 
                            }
1125
 
 
1126
 
// Y.log('pack ' + packName + ' should supersede ' + supName);
1127
 
// Add rollup file, need to add to supersedes list too
1128
 
 
1129
 
                            // default packages
1130
 
                            packName = this.getLangPackName(ROOT_LANG, name);
1131
 
                            supName = this.getLangPackName(ROOT_LANG, i);
1132
 
 
1133
 
                            smod = this.moduleInfo[packName];
1134
 
 
1135
 
                            if (!smod) {
1136
 
                                smod = this._addLangPack(lang, o, packName);
1137
 
                            }
1138
 
 
1139
 
                            if (!(supName in flatSup)) {
1140
 
                                smod.supersedes.push(supName);
1141
 
                            }
1142
 
 
1143
 
// Y.log('pack ' + packName + ' should supersede ' + supName);
1144
 
// Add rollup file, need to add to supersedes list too
1145
 
 
1146
 
                        }
1147
 
                    }
1148
 
 
1149
 
                    l++;
1150
 
                }
1151
 
            }
1152
 
            //o.supersedes = YObject.keys(YArray.hash(sup));
1153
 
            o.supersedes = YArray.dedupe(sup);
1154
 
            if (this.allowRollup) {
1155
 
                o.rollup = (l < 4) ? l : Math.min(l - 1, 4);
1156
 
            }
1157
 
        }
1158
 
 
1159
 
        plugins = o.plugins;
1160
 
        if (plugins) {
1161
 
            for (i in plugins) {
1162
 
                if (plugins.hasOwnProperty(i)) {
1163
 
                    plug = plugins[i];
1164
 
                    plug.pkg = name;
1165
 
                    plug.path = plug.path || _path(name, i, o.type);
1166
 
                    plug.requires = plug.requires || [];
1167
 
                    plug.group = o.group;
1168
 
                    this.addModule(plug, i);
1169
 
                    if (o.skinnable) {
1170
 
                        this._addSkin(this.skin.defaultSkin, i, name);
1171
 
                    }
1172
 
 
1173
 
                }
1174
 
            }
1175
 
        }
1176
 
 
1177
 
        if (o.condition) {
1178
 
            t = o.condition.trigger;
1179
 
            if (YUI.Env.aliases[t]) {
1180
 
                t = YUI.Env.aliases[t];
1181
 
            }
1182
 
            if (!Y.Lang.isArray(t)) {
1183
 
                t = [t];
1184
 
            }
1185
 
 
1186
 
            for (i = 0; i < t.length; i++) {
1187
 
                trigger = t[i];
1188
 
                when = o.condition.when;
1189
 
                conditions[trigger] = conditions[trigger] || {};
1190
 
                conditions[trigger][name] = o.condition;
1191
 
                // the 'when' attribute can be 'before', 'after', or 'instead'
1192
 
                // the default is after.
1193
 
                if (when && when != 'after') {
1194
 
                    if (when == 'instead') { // replace the trigger
1195
 
                        o.supersedes = o.supersedes || [];
1196
 
                        o.supersedes.push(trigger);
1197
 
                    } else { // before the trigger
1198
 
                        // the trigger requires the conditional mod,
1199
 
                        // so it should appear before the conditional
1200
 
                        // mod if we do not intersede.
1201
 
                    }
1202
 
                } else { // after the trigger
1203
 
                    o.after = o.after || [];
1204
 
                    o.after.push(trigger);
1205
 
                }
1206
 
            }
1207
 
        }
1208
 
 
1209
 
        if (o.supersedes) {
1210
 
            o.supersedes = this.filterRequires(o.supersedes);
1211
 
        }
1212
 
 
1213
 
        if (o.after) {
1214
 
            o.after = this.filterRequires(o.after);
1215
 
            o.after_map = YArray.hash(o.after);
1216
 
        }
1217
 
 
1218
 
        // this.dirty = true;
1219
 
 
1220
 
        if (o.configFn) {
1221
 
            ret = o.configFn(o);
1222
 
            if (ret === false) {
1223
 
                Y.log('Config function returned false for ' + name + ', skipping.', 'info', 'loader');
1224
 
                delete this.moduleInfo[name];
1225
 
                delete GLOBAL_ENV._renderedMods[name];
1226
 
                o = null;
1227
 
            }
1228
 
        }
1229
 
        //Add to global cache
1230
 
        if (o) {
1231
 
            if (!GLOBAL_ENV._renderedMods) {
1232
 
                GLOBAL_ENV._renderedMods = {};
1233
 
            }
1234
 
            GLOBAL_ENV._renderedMods[name] = Y.merge(o);
1235
 
            GLOBAL_ENV._conditions = conditions;
1236
 
        }
1237
 
 
1238
 
        return o;
1239
 
    },
1240
 
 
1241
 
    /**
1242
 
     * Add a requirement for one or more module
1243
 
     * @method require
1244
 
     * @param {string[] | string*} what the modules to load.
1245
 
     */
1246
 
    require: function(what) {
1247
 
        var a = (typeof what === 'string') ? YArray(arguments) : what;
1248
 
        this.dirty = true;
1249
 
        this.required = Y.merge(this.required, YArray.hash(this.filterRequires(a)));
1250
 
 
1251
 
        this._explodeRollups();
1252
 
    },
1253
 
    /**
1254
 
    * Grab all the items that were asked for, check to see if the Loader
1255
 
    * meta-data contains a "use" array. If it doesm remove the asked item and replace it with 
1256
 
    * the content of the "use".
1257
 
    * This will make asking for: "dd"
1258
 
    * Actually ask for: "dd-ddm-base,dd-ddm,dd-ddm-drop,dd-drag,dd-proxy,dd-constrain,dd-drop,dd-scroll,dd-drop-plugin"
1259
 
    * @private
1260
 
    * @method _explodeRollups
1261
 
    */
1262
 
    _explodeRollups: function() {
1263
 
        var self = this, m,
1264
 
        r = self.required;
1265
 
        if (!self.allowRollup) {
1266
 
            oeach(r, function(v, name) {
1267
 
                m = self.getModule(name);
1268
 
                if (m && m.use) {
1269
 
                    //delete r[name];
1270
 
                    YArray.each(m.use, function(v) {
1271
 
                        m = self.getModule(v);
1272
 
                        if (m && m.use) {
1273
 
                            //delete r[v];
1274
 
                            YArray.each(m.use, function(v) {
1275
 
                                r[v] = true;
1276
 
                            });
1277
 
                        } else {
1278
 
                            r[v] = true;
1279
 
                        }
1280
 
                    });
1281
 
                }
1282
 
            });
1283
 
            self.required = r;
1284
 
        }
1285
 
 
1286
 
    },
1287
 
    /**
1288
 
    * Explodes the required array to remove aliases and replace them with real modules
1289
 
    * @method filterRequires
1290
 
    * @param {Array} r The original requires array
1291
 
    * @return {Array} The new array of exploded requirements
1292
 
    */
1293
 
    filterRequires: function(r) {
1294
 
        if (r) {
1295
 
            if (!Y.Lang.isArray(r)) {
1296
 
                r = [r];
1297
 
            }
1298
 
            r = Y.Array(r);
1299
 
            var c = [], i, mod, o, m;
1300
 
 
1301
 
            for (i = 0; i < r.length; i++) {
1302
 
                mod = this.getModule(r[i]);
1303
 
                if (mod && mod.use) {
1304
 
                    for (o = 0; o < mod.use.length; o++) {
1305
 
                        //Must walk the other modules in case a module is a rollup of rollups (datatype)
1306
 
                        m = this.getModule(mod.use[o]);
1307
 
                        if (m && m.use) {
1308
 
                            c = Y.Array.dedupe([].concat(c, this.filterRequires(m.use)));
1309
 
                        } else {
1310
 
                            c.push(mod.use[o]);
1311
 
                        }
1312
 
                    }
1313
 
                } else {
1314
 
                    c.push(r[i]);
1315
 
                }
1316
 
            }
1317
 
            r = c;
1318
 
        }
1319
 
        return r;
1320
 
    },
1321
 
    /**
1322
 
     * Returns an object containing properties for all modules required
1323
 
     * in order to load the requested module
1324
 
     * @method getRequires
1325
 
     * @param {object}  mod The module definition from moduleInfo.
1326
 
     * @return {array} the expanded requirement list.
1327
 
     */
1328
 
    getRequires: function(mod) {
1329
 
 
1330
 
        if (!mod) {
1331
 
            //console.log('returning no reqs for ' + mod.name);
1332
 
            return NO_REQUIREMENTS;
1333
 
        }
1334
 
 
1335
 
        if (mod._parsed) {
1336
 
            //console.log('returning requires for ' + mod.name, mod.requires);
1337
 
            return mod.expanded || NO_REQUIREMENTS;
1338
 
        }
1339
 
 
1340
 
        //TODO add modue cache here out of scope..
1341
 
 
1342
 
        var i, m, j, add, packName, lang, testresults = this.testresults,
1343
 
            name = mod.name, cond,
1344
 
            adddef = ON_PAGE[name] && ON_PAGE[name].details,
1345
 
            d, k, m1,
1346
 
            r, old_mod,
1347
 
            o, skinmod, skindef, skinpar, skinname,
1348
 
            intl = mod.lang || mod.intl,
1349
 
            info = this.moduleInfo,
1350
 
            ftests = Y.Features && Y.Features.tests.load,
1351
 
            hash;
1352
 
 
1353
 
        // console.log(name);
1354
 
 
1355
 
        // pattern match leaves module stub that needs to be filled out
1356
 
        if (mod.temp && adddef) {
1357
 
            old_mod = mod;
1358
 
            mod = this.addModule(adddef, name);
1359
 
            mod.group = old_mod.group;
1360
 
            mod.pkg = old_mod.pkg;
1361
 
            delete mod.expanded;
1362
 
        }
1363
 
 
1364
 
        // console.log('cache: ' + mod.langCache + ' == ' + this.lang);
1365
 
 
1366
 
        // if (mod.expanded && (!mod.langCache || mod.langCache == this.lang)) {
1367
 
        if (mod.expanded && (!this.lang || mod.langCache === this.lang)) {
1368
 
            //Y.log('Already expanded ' + name + ', ' + mod.expanded);
1369
 
            return mod.expanded;
1370
 
        }
1371
 
        
1372
 
 
1373
 
        d = [];
1374
 
        hash = {};
1375
 
        r = this.filterRequires(mod.requires);
1376
 
        if (mod.lang) {
1377
 
            //If a module has a lang attribute, auto add the intl requirement.
1378
 
            d.unshift('intl');
1379
 
            r.unshift('intl');
1380
 
            intl = true;
1381
 
        }
1382
 
        o = this.filterRequires(mod.optional);
1383
 
 
1384
 
        // Y.log("getRequires: " + name + " (dirty:" + this.dirty +
1385
 
        // ", expanded:" + mod.expanded + ")");
1386
 
 
1387
 
        mod._parsed = true;
1388
 
        mod.langCache = this.lang;
1389
 
 
1390
 
        for (i = 0; i < r.length; i++) {
1391
 
            //Y.log(name + ' requiring ' + r[i], 'info', 'loader');
1392
 
            if (!hash[r[i]]) {
1393
 
                d.push(r[i]);
1394
 
                hash[r[i]] = true;
1395
 
                m = this.getModule(r[i]);
1396
 
                if (m) {
1397
 
                    add = this.getRequires(m);
1398
 
                    intl = intl || (m.expanded_map &&
1399
 
                        (INTL in m.expanded_map));
1400
 
                    for (j = 0; j < add.length; j++) {
1401
 
                        d.push(add[j]);
1402
 
                    }
1403
 
                }
1404
 
            }
1405
 
        }
1406
 
 
1407
 
        // get the requirements from superseded modules, if any
1408
 
        r = this.filterRequires(mod.supersedes);
1409
 
        if (r) {
1410
 
            for (i = 0; i < r.length; i++) {
1411
 
                if (!hash[r[i]]) {
1412
 
                    // if this module has submodules, the requirements list is
1413
 
                    // expanded to include the submodules.  This is so we can
1414
 
                    // prevent dups when a submodule is already loaded and the
1415
 
                    // parent is requested.
1416
 
                    if (mod.submodules) {
1417
 
                        d.push(r[i]);
1418
 
                    }
1419
 
 
1420
 
                    hash[r[i]] = true;
1421
 
                    m = this.getModule(r[i]);
1422
 
 
1423
 
                    if (m) {
1424
 
                        add = this.getRequires(m);
1425
 
                        intl = intl || (m.expanded_map &&
1426
 
                            (INTL in m.expanded_map));
1427
 
                        for (j = 0; j < add.length; j++) {
1428
 
                            d.push(add[j]);
1429
 
                        }
1430
 
                    }
1431
 
                }
1432
 
            }
1433
 
        }
1434
 
 
1435
 
        if (o && this.loadOptional) {
1436
 
            for (i = 0; i < o.length; i++) {
1437
 
                if (!hash[o[i]]) {
1438
 
                    d.push(o[i]);
1439
 
                    hash[o[i]] = true;
1440
 
                    m = info[o[i]];
1441
 
                    if (m) {
1442
 
                        add = this.getRequires(m);
1443
 
                        intl = intl || (m.expanded_map &&
1444
 
                            (INTL in m.expanded_map));
1445
 
                        for (j = 0; j < add.length; j++) {
1446
 
                            d.push(add[j]);
1447
 
                        }
1448
 
                    }
1449
 
                }
1450
 
            }
1451
 
        }
1452
 
 
1453
 
        cond = this.conditions[name];
1454
 
 
1455
 
        if (cond) {
1456
 
            //Set the module to not parsed since we have conditionals and this could change the dependency tree.
1457
 
            mod._parsed = false;
1458
 
            if (testresults && ftests) {
1459
 
                oeach(testresults, function(result, id) {
1460
 
                    var condmod = ftests[id].name;
1461
 
                    if (!hash[condmod] && ftests[id].trigger == name) {
1462
 
                        if (result && ftests[id]) {
1463
 
                            hash[condmod] = true;
1464
 
                            d.push(condmod);
1465
 
                        }
1466
 
                    }
1467
 
                });
1468
 
            } else {
1469
 
                oeach(cond, function(def, condmod) {
1470
 
                    if (!hash[condmod]) {
1471
 
                        //first see if they've specfied a ua check
1472
 
                        //then see if they've got a test fn & if it returns true
1473
 
                        //otherwise just having a condition block is enough
1474
 
                        var go = def && ((!def.ua && !def.test) || (def.ua && Y.UA[def.ua]) ||
1475
 
                                    (def.test && def.test(Y, r)));
1476
 
 
1477
 
                        if (go) {
1478
 
                            hash[condmod] = true;
1479
 
                            d.push(condmod);
1480
 
                            m = this.getModule(condmod);
1481
 
                            if (m) {
1482
 
                                add = this.getRequires(m);
1483
 
                                for (j = 0; j < add.length; j++) {
1484
 
                                    d.push(add[j]);
1485
 
                                }
1486
 
 
1487
 
                            }
1488
 
                        }
1489
 
                    }
1490
 
                }, this);
1491
 
            }
1492
 
        }
1493
 
 
1494
 
        // Create skin modules
1495
 
        if (mod.skinnable) {
1496
 
            skindef = this.skin.overrides;
1497
 
            oeach(YUI.Env.aliases, function(o, n) {
1498
 
                if (Y.Array.indexOf(o, name) > -1) {
1499
 
                    skinpar = n;
1500
 
                }
1501
 
            });
1502
 
            if (skindef && (skindef[name] || (skinpar && skindef[skinpar]))) {
1503
 
                skinname = name;
1504
 
                if (skindef[skinpar]) {
1505
 
                    skinname = skinpar;
1506
 
                }
1507
 
                for (i = 0; i < skindef[skinname].length; i++) {
1508
 
                    skinmod = this._addSkin(skindef[skinname][i], name);
1509
 
                    if (!this.isCSSLoaded(skinmod, this._boot)) {
1510
 
                        d.push(skinmod);
1511
 
                    }
1512
 
                }
1513
 
            } else {
1514
 
                skinmod = this._addSkin(this.skin.defaultSkin, name);
1515
 
                if (!this.isCSSLoaded(skinmod, this._boot)) {
1516
 
                    d.push(skinmod);
1517
 
                }
1518
 
            }
1519
 
        }
1520
 
 
1521
 
        mod._parsed = false;
1522
 
 
1523
 
        if (intl) {
1524
 
 
1525
 
            if (mod.lang && !mod.langPack && Y.Intl) {
1526
 
                lang = Y.Intl.lookupBestLang(this.lang || ROOT_LANG, mod.lang);
1527
 
                //Y.log('Best lang: ' + lang + ', this.lang: ' + this.lang + ', mod.lang: ' + mod.lang);
1528
 
                packName = this.getLangPackName(lang, name);
1529
 
                if (packName) {
1530
 
                    d.unshift(packName);
1531
 
                }
1532
 
            }
1533
 
            d.unshift(INTL);
1534
 
        }
1535
 
 
1536
 
        mod.expanded_map = YArray.hash(d);
1537
 
 
1538
 
        mod.expanded = YObject.keys(mod.expanded_map);
1539
 
 
1540
 
        return mod.expanded;
1541
 
    },
1542
 
    /**
1543
 
    * Check to see if named css module is already loaded on the page
1544
 
    * @method isCSSLoaded
1545
 
    * @param {String} name The name of the css file
1546
 
    * @return Boolean
1547
 
    */
1548
 
    isCSSLoaded: function(name, skip) {
1549
 
        //TODO - Make this call a batching call with name being an array
1550
 
        if (!name || !YUI.Env.cssStampEl || (!skip && this.ignoreRegistered)) {
1551
 
            Y.log('isCSSLoaded was skipped for ' + name, 'warn', 'loader');
1552
 
            return false;
1553
 
        }
1554
 
 
1555
 
        var el = YUI.Env.cssStampEl,
1556
 
            ret = false,
1557
 
            style = el.currentStyle; //IE
1558
 
 
1559
 
        //Add the classname to the element
1560
 
        el.className = name;
1561
 
 
1562
 
        if (!style) {
1563
 
            style = Y.config.doc.defaultView.getComputedStyle(el, null);
1564
 
        }
1565
 
 
1566
 
        if (style && style['display'] === 'none') {
1567
 
            ret = true;
1568
 
        }
1569
 
 
1570
 
        Y.log('Has Skin? ' + name + ' : ' + ret, 'info', 'loader');
1571
 
 
1572
 
        el.className = ''; //Reset the classname to ''
1573
 
        return ret;
1574
 
    },
1575
 
 
1576
 
    /**
1577
 
     * Returns a hash of module names the supplied module satisfies.
1578
 
     * @method getProvides
1579
 
     * @param {string} name The name of the module.
1580
 
     * @return {object} what this module provides.
1581
 
     */
1582
 
    getProvides: function(name) {
1583
 
        var m = this.getModule(name), o, s;
1584
 
            // supmap = this.provides;
1585
 
 
1586
 
        if (!m) {
1587
 
            return NOT_FOUND;
1588
 
        }
1589
 
 
1590
 
        if (m && !m.provides) {
1591
 
            o = {};
1592
 
            s = m.supersedes;
1593
 
 
1594
 
            if (s) {
1595
 
                YArray.each(s, function(v) {
1596
 
                    Y.mix(o, this.getProvides(v));
1597
 
                }, this);
1598
 
            }
1599
 
 
1600
 
            o[name] = true;
1601
 
            m.provides = o;
1602
 
 
1603
 
        }
1604
 
 
1605
 
        return m.provides;
1606
 
    },
1607
 
 
1608
 
    /**
1609
 
     * Calculates the dependency tree, the result is stored in the sorted
1610
 
     * property.
1611
 
     * @method calculate
1612
 
     * @param {object} o optional options object.
1613
 
     * @param {string} type optional argument to prune modules.
1614
 
     */
1615
 
    calculate: function(o, type) {
1616
 
        if (o || type || this.dirty) {
1617
 
 
1618
 
            if (o) {
1619
 
                this._config(o);
1620
 
            }
1621
 
 
1622
 
            if (!this._init) {
1623
 
                this._setup();
1624
 
            }
1625
 
 
1626
 
            this._explode();
1627
 
 
1628
 
            if (this.allowRollup) {
1629
 
                this._rollup();
1630
 
            } else {
1631
 
                this._explodeRollups();
1632
 
            }
1633
 
            this._reduce();
1634
 
            this._sort();
1635
 
        }
1636
 
    },
1637
 
    /**
1638
 
    * Creates a "psuedo" package for languages provided in the lang array
1639
 
    * @method _addLangPack
1640
 
    * @private
1641
 
    * @param {String} lang The language to create
1642
 
    * @param {Object} m The module definition to create the language pack around
1643
 
    * @param {String} packName The name of the package (e.g: lang/datatype-date-en-US)
1644
 
    * @return {Object} The module definition
1645
 
    */
1646
 
    _addLangPack: function(lang, m, packName) {
1647
 
        var name = m.name,
1648
 
            packPath, conf,
1649
 
            existing = this.moduleInfo[packName];
1650
 
 
1651
 
        if (!existing) {
1652
 
 
1653
 
            packPath = _path((m.pkg || name), packName, JS, true);
1654
 
 
1655
 
            conf = {
1656
 
                path: packPath,
1657
 
                intl: true,
1658
 
                langPack: true,
1659
 
                ext: m.ext,
1660
 
                group: m.group,
1661
 
                supersedes: []
1662
 
            };
1663
 
 
1664
 
            if (m.configFn) {
1665
 
                conf.configFn = m.configFn;
1666
 
            }
1667
 
 
1668
 
            this.addModule(conf, packName);
1669
 
 
1670
 
            if (lang) {
1671
 
                Y.Env.lang = Y.Env.lang || {};
1672
 
                Y.Env.lang[lang] = Y.Env.lang[lang] || {};
1673
 
                Y.Env.lang[lang][name] = true;
1674
 
            }
1675
 
        }
1676
 
 
1677
 
        return this.moduleInfo[packName];
1678
 
    },
1679
 
 
1680
 
    /**
1681
 
     * Investigates the current YUI configuration on the page.  By default,
1682
 
     * modules already detected will not be loaded again unless a force
1683
 
     * option is encountered.  Called by calculate()
1684
 
     * @method _setup
1685
 
     * @private
1686
 
     */
1687
 
    _setup: function() {
1688
 
        var info = this.moduleInfo, name, i, j, m, l,
1689
 
            packName;
1690
 
 
1691
 
        for (name in info) {
1692
 
            if (info.hasOwnProperty(name)) {
1693
 
                m = info[name];
1694
 
                if (m) {
1695
 
 
1696
 
                    // remove dups
1697
 
                    //m.requires = YObject.keys(YArray.hash(m.requires));
1698
 
                    m.requires = YArray.dedupe(m.requires);
1699
 
 
1700
 
                    // Create lang pack modules
1701
 
                    if (m.lang && m.lang.length) {
1702
 
                        // Setup root package if the module has lang defined,
1703
 
                        // it needs to provide a root language pack
1704
 
                        packName = this.getLangPackName(ROOT_LANG, name);
1705
 
                        this._addLangPack(null, m, packName);
1706
 
                    }
1707
 
 
1708
 
                }
1709
 
            }
1710
 
        }
1711
 
 
1712
 
 
1713
 
        //l = Y.merge(this.inserted);
1714
 
        l = {};
1715
 
 
1716
 
        // available modules
1717
 
        if (!this.ignoreRegistered) {
1718
 
            Y.mix(l, GLOBAL_ENV.mods);
1719
 
        }
1720
 
 
1721
 
        // add the ignore list to the list of loaded packages
1722
 
        if (this.ignore) {
1723
 
            Y.mix(l, YArray.hash(this.ignore));
1724
 
        }
1725
 
 
1726
 
        // expand the list to include superseded modules
1727
 
        for (j in l) {
1728
 
            if (l.hasOwnProperty(j)) {
1729
 
                Y.mix(l, this.getProvides(j));
1730
 
            }
1731
 
        }
1732
 
 
1733
 
        // remove modules on the force list from the loaded list
1734
 
        if (this.force) {
1735
 
            for (i = 0; i < this.force.length; i++) {
1736
 
                if (this.force[i] in l) {
1737
 
                    delete l[this.force[i]];
1738
 
                }
1739
 
            }
1740
 
        }
1741
 
 
1742
 
        Y.mix(this.loaded, l);
1743
 
 
1744
 
        this._init = true;
1745
 
    },
1746
 
 
1747
 
    /**
1748
 
     * Builds a module name for a language pack
1749
 
     * @method getLangPackName
1750
 
     * @param {string} lang the language code.
1751
 
     * @param {string} mname the module to build it for.
1752
 
     * @return {string} the language pack module name.
1753
 
     */
1754
 
    getLangPackName: function(lang, mname) {
1755
 
        return ('lang/' + mname + ((lang) ? '_' + lang : ''));
1756
 
    },
1757
 
    /**
1758
 
     * Inspects the required modules list looking for additional
1759
 
     * dependencies.  Expands the required list to include all
1760
 
     * required modules.  Called by calculate()
1761
 
     * @method _explode
1762
 
     * @private
1763
 
     */
1764
 
    _explode: function() {
1765
 
        //TODO Move done out of scope
1766
 
        var r = this.required, m, reqs, done = {},
1767
 
            self = this;
1768
 
 
1769
 
        // the setup phase is over, all modules have been created
1770
 
        self.dirty = false;
1771
 
 
1772
 
        self._explodeRollups();
1773
 
        r = self.required;
1774
 
        
1775
 
        oeach(r, function(v, name) {
1776
 
            if (!done[name]) {
1777
 
                done[name] = true;
1778
 
                m = self.getModule(name);
1779
 
                if (m) {
1780
 
                    var expound = m.expound;
1781
 
 
1782
 
                    if (expound) {
1783
 
                        r[expound] = self.getModule(expound);
1784
 
                        reqs = self.getRequires(r[expound]);
1785
 
                        Y.mix(r, YArray.hash(reqs));
1786
 
                    }
1787
 
 
1788
 
                    reqs = self.getRequires(m);
1789
 
                    Y.mix(r, YArray.hash(reqs));
1790
 
                }
1791
 
            }
1792
 
        });
1793
 
 
1794
 
        // Y.log('After explode: ' + YObject.keys(r));
1795
 
    },
1796
 
    /**
1797
 
    * Get's the loader meta data for the requested module
1798
 
    * @method getModule
1799
 
    * @param {String} mname The module name to get
1800
 
    * @return {Object} The module metadata
1801
 
    */
1802
 
    getModule: function(mname) {
1803
 
        //TODO: Remove name check - it's a quick hack to fix pattern WIP
1804
 
        if (!mname) {
1805
 
            return null;
1806
 
        }
1807
 
 
1808
 
        var p, found, pname,
1809
 
            m = this.moduleInfo[mname],
1810
 
            patterns = this.patterns;
1811
 
 
1812
 
        // check the patterns library to see if we should automatically add
1813
 
        // the module with defaults
1814
 
        if (!m) {
1815
 
           // Y.log('testing patterns ' + YObject.keys(patterns));
1816
 
            for (pname in patterns) {
1817
 
                if (patterns.hasOwnProperty(pname)) {
1818
 
                    // Y.log('testing pattern ' + i);
1819
 
                    p = patterns[pname];
1820
 
                    
1821
 
                    //There is no test method, create a default one that tests
1822
 
                    // the pattern against the mod name
1823
 
                    if (!p.test) {
1824
 
                        p.test = function(mname, pname) {
1825
 
                            return (mname.indexOf(pname) > -1);
1826
 
                        };
1827
 
                    }
1828
 
 
1829
 
                    if (p.test(mname, pname)) {
1830
 
                        // use the metadata supplied for the pattern
1831
 
                        // as the module definition.
1832
 
                        found = p;
1833
 
                        break;
1834
 
                    }
1835
 
                }
1836
 
            }
1837
 
 
1838
 
            if (found) {
1839
 
                if (p.action) {
1840
 
                    // Y.log('executing pattern action: ' + pname);
1841
 
                    p.action.call(this, mname, pname);
1842
 
                } else {
1843
 
Y.log('Undefined module: ' + mname + ', matched a pattern: ' +
1844
 
    pname, 'info', 'loader');
1845
 
                    // ext true or false?
1846
 
                    m = this.addModule(Y.merge(found), mname);
1847
 
                    m.temp = true;
1848
 
                }
1849
 
            }
1850
 
        }
1851
 
 
1852
 
        return m;
1853
 
    },
1854
 
 
1855
 
    // impl in rollup submodule
1856
 
    _rollup: function() { },
1857
 
 
1858
 
    /**
1859
 
     * Remove superceded modules and loaded modules.  Called by
1860
 
     * calculate() after we have the mega list of all dependencies
1861
 
     * @method _reduce
1862
 
     * @return {object} the reduced dependency hash.
1863
 
     * @private
1864
 
     */
1865
 
    _reduce: function(r) {
1866
 
 
1867
 
        r = r || this.required;
1868
 
 
1869
 
        var i, j, s, m, type = this.loadType,
1870
 
        ignore = this.ignore ? YArray.hash(this.ignore) : false;
1871
 
 
1872
 
        for (i in r) {
1873
 
            if (r.hasOwnProperty(i)) {
1874
 
                m = this.getModule(i);
1875
 
                // remove if already loaded
1876
 
                if (((this.loaded[i] || ON_PAGE[i]) &&
1877
 
                        !this.forceMap[i] && !this.ignoreRegistered) ||
1878
 
                        (type && m && m.type != type)) {
1879
 
                    delete r[i];
1880
 
                }
1881
 
                if (ignore && ignore[i]) {
1882
 
                    delete r[i];
1883
 
                }
1884
 
                // remove anything this module supersedes
1885
 
                s = m && m.supersedes;
1886
 
                if (s) {
1887
 
                    for (j = 0; j < s.length; j++) {
1888
 
                        if (s[j] in r) {
1889
 
                            delete r[s[j]];
1890
 
                        }
1891
 
                    }
1892
 
                }
1893
 
            }
1894
 
        }
1895
 
 
1896
 
        return r;
1897
 
    },
1898
 
    /**
1899
 
    * Handles the queue when a module has been loaded for all cases
1900
 
    * @method _finish
1901
 
    * @private
1902
 
    * @param {String} msg The message from Loader
1903
 
    * @param {Boolean} success A boolean denoting success or failure
1904
 
    */
1905
 
    _finish: function(msg, success) {
1906
 
        Y.log('loader finishing: ' + msg + ', ' + Y.id + ', ' +
1907
 
            this.data, 'info', 'loader');
1908
 
 
1909
 
        _queue.running = false;
1910
 
 
1911
 
        var onEnd = this.onEnd;
1912
 
        if (onEnd) {
1913
 
            onEnd.call(this.context, {
1914
 
                msg: msg,
1915
 
                data: this.data,
1916
 
                success: success
1917
 
            });
1918
 
        }
1919
 
        this._continue();
1920
 
    },
1921
 
    /**
1922
 
    * The default Loader onSuccess handler, calls this.onSuccess with a payload
1923
 
    * @method _onSuccess
1924
 
    * @private
1925
 
    */
1926
 
    _onSuccess: function() {
1927
 
        var self = this, skipped = Y.merge(self.skipped), fn,
1928
 
            failed = [], rreg = self.requireRegistration,
1929
 
            success, msg;
1930
 
 
1931
 
        oeach(skipped, function(k) {
1932
 
            delete self.inserted[k];
1933
 
        });
1934
 
 
1935
 
        self.skipped = {};
1936
 
 
1937
 
        oeach(self.inserted, function(v, k) {
1938
 
            var mod = self.getModule(k);
1939
 
            if (mod && rreg && mod.type == JS && !(k in YUI.Env.mods)) {
1940
 
                failed.push(k);
1941
 
            } else {
1942
 
                Y.mix(self.loaded, self.getProvides(k));
1943
 
            }
1944
 
        });
1945
 
 
1946
 
        fn = self.onSuccess;
1947
 
        msg = (failed.length) ? 'notregistered' : 'success';
1948
 
        success = !(failed.length);
1949
 
        if (fn) {
1950
 
            fn.call(self.context, {
1951
 
                msg: msg,
1952
 
                data: self.data,
1953
 
                success: success,
1954
 
                failed: failed,
1955
 
                skipped: skipped
1956
 
            });
1957
 
        }
1958
 
        self._finish(msg, success);
1959
 
    },
1960
 
    /**
1961
 
    * The default Loader onProgress handler, calls this.onProgress with a payload
1962
 
    * @method _onProgress
1963
 
    * @private
1964
 
    */
1965
 
    _onProgress: function(e) {
1966
 
        var self = this;
1967
 
        if (self.onProgress) {
1968
 
            self.onProgress.call(self.context, {
1969
 
                name: e.url,
1970
 
                data: e.data
1971
 
            });
1972
 
        }
1973
 
    },
1974
 
    /**
1975
 
    * The default Loader onFailure handler, calls this.onFailure with a payload
1976
 
    * @method _onFailure
1977
 
    * @private
1978
 
    */
1979
 
    _onFailure: function(o) {
1980
 
        var f = this.onFailure, msg = [], i = 0, len = o.errors.length;
1981
 
        
1982
 
        for (i; i < len; i++) {
1983
 
            msg.push(o.errors[i].error);
1984
 
        }
1985
 
 
1986
 
        msg = msg.join(',');
1987
 
 
1988
 
        Y.log('load error: ' + msg + ', ' + Y.id, 'error', 'loader');
1989
 
        
1990
 
        if (f) {
1991
 
            f.call(this.context, {
1992
 
                msg: msg,
1993
 
                data: this.data,
1994
 
                success: false
1995
 
            });
1996
 
        }
1997
 
        
1998
 
        this._finish(msg, false);
1999
 
 
2000
 
    },
2001
 
 
2002
 
    /**
2003
 
    * The default Loader onTimeout handler, calls this.onTimeout with a payload
2004
 
    * @method _onTimeout
2005
 
    * @private
2006
 
    */
2007
 
    _onTimeout: function() {
2008
 
        Y.log('loader timeout: ' + Y.id, 'error', 'loader');
2009
 
        var f = this.onTimeout;
2010
 
        if (f) {
2011
 
            f.call(this.context, {
2012
 
                msg: 'timeout',
2013
 
                data: this.data,
2014
 
                success: false
2015
 
            });
2016
 
        }
2017
 
    },
2018
 
 
2019
 
    /**
2020
 
     * Sorts the dependency tree.  The last step of calculate()
2021
 
     * @method _sort
2022
 
     * @private
2023
 
     */
2024
 
    _sort: function() {
2025
 
 
2026
 
        // create an indexed list
2027
 
        var s = YObject.keys(this.required),
2028
 
            // loaded = this.loaded,
2029
 
            //TODO Move this out of scope
2030
 
            done = {},
2031
 
            p = 0, l, a, b, j, k, moved, doneKey;
2032
 
 
2033
 
        // keep going until we make a pass without moving anything
2034
 
        for (;;) {
2035
 
 
2036
 
            l = s.length;
2037
 
            moved = false;
2038
 
 
2039
 
            // start the loop after items that are already sorted
2040
 
            for (j = p; j < l; j++) {
2041
 
 
2042
 
                // check the next module on the list to see if its
2043
 
                // dependencies have been met
2044
 
                a = s[j];
2045
 
 
2046
 
                // check everything below current item and move if we
2047
 
                // find a requirement for the current item
2048
 
                for (k = j + 1; k < l; k++) {
2049
 
                    doneKey = a + s[k];
2050
 
 
2051
 
                    if (!done[doneKey] && this._requires(a, s[k])) {
2052
 
 
2053
 
                        // extract the dependency so we can move it up
2054
 
                        b = s.splice(k, 1);
2055
 
 
2056
 
                        // insert the dependency above the item that
2057
 
                        // requires it
2058
 
                        s.splice(j, 0, b[0]);
2059
 
 
2060
 
                        // only swap two dependencies once to short circut
2061
 
                        // circular dependencies
2062
 
                        done[doneKey] = true;
2063
 
 
2064
 
                        // keep working
2065
 
                        moved = true;
2066
 
 
2067
 
                        break;
2068
 
                    }
2069
 
                }
2070
 
 
2071
 
                // jump out of loop if we moved something
2072
 
                if (moved) {
2073
 
                    break;
2074
 
                // this item is sorted, move our pointer and keep going
2075
 
                } else {
2076
 
                    p++;
2077
 
                }
2078
 
            }
2079
 
 
2080
 
            // when we make it here and moved is false, we are
2081
 
            // finished sorting
2082
 
            if (!moved) {
2083
 
                break;
2084
 
            }
2085
 
 
2086
 
        }
2087
 
 
2088
 
        this.sorted = s;
2089
 
    },
2090
 
 
2091
 
    /**
2092
 
    * Handles the actual insertion of script/link tags
2093
 
    * @method _insert
2094
 
    * @private
2095
 
    * @param {Object} source The YUI instance the request came from
2096
 
    * @param {Object} o The metadata to include
2097
 
    * @param {String} type JS or CSS
2098
 
    * @param {Boolean} [skipcalc=false] Do a Loader.calculate on the meta
2099
 
    */
2100
 
    _insert: function(source, o, type, skipcalc) {
2101
 
 
2102
 
        Y.log('private _insert() ' + (type || '') + ', ' + Y.id, "info", "loader");
2103
 
 
2104
 
        // restore the state at the time of the request
2105
 
        if (source) {
2106
 
            this._config(source);
2107
 
        }
2108
 
 
2109
 
        // build the dependency list
2110
 
        // don't include type so we can process CSS and script in
2111
 
        // one pass when the type is not specified.
2112
 
        if (!skipcalc) {
2113
 
            this.calculate(o);
2114
 
        }
2115
 
 
2116
 
        var modules = this.resolve(),
2117
 
            self = this, comp = 0, actions = 0;
2118
 
 
2119
 
        if (type) {
2120
 
            //Filter out the opposite type and reset the array so the checks later work
2121
 
            modules[((type === JS) ? CSS : JS)] = [];
2122
 
        }
2123
 
        if (modules.js.length) {
2124
 
            comp++;
2125
 
        }
2126
 
        if (modules.css.length) {
2127
 
            comp++;
2128
 
        }
2129
 
 
2130
 
        //console.log('Resolved Modules: ', modules);
2131
 
 
2132
 
        var complete = function(d) {
2133
 
            actions++;
2134
 
            var errs = {}, i = 0, u = '', fn;
2135
 
 
2136
 
            if (d && d.errors) {
2137
 
                for (i = 0; i < d.errors.length; i++) {
2138
 
                    if (d.errors[i].request) {
2139
 
                        u = d.errors[i].request.url;
2140
 
                    } else {
2141
 
                        u = d.errors[i];
2142
 
                    }
2143
 
                    errs[u] = u;
2144
 
                }
2145
 
            }
2146
 
            
2147
 
            if (d && d.data && d.data.length && (d.type === 'success')) {
2148
 
                for (i = 0; i < d.data.length; i++) {
2149
 
                    self.inserted[d.data[i].name] = true;
2150
 
                }
2151
 
            }
2152
 
 
2153
 
            if (actions === comp) {
2154
 
                self._loading = null;
2155
 
                Y.log('Loader actions complete!', 'info', 'loader');
2156
 
                if (d && d.fn) {
2157
 
                    Y.log('Firing final Loader callback!', 'info', 'loader');
2158
 
                    fn = d.fn;
2159
 
                    delete d.fn;
2160
 
                    fn.call(self, d);
2161
 
                }
2162
 
            }
2163
 
        };
2164
 
 
2165
 
        this._loading = true;
2166
 
 
2167
 
        if (!modules.js.length && !modules.css.length) {
2168
 
            Y.log('No modules resolved..', 'warn', 'loader');
2169
 
            actions = -1;
2170
 
            complete({
2171
 
                fn: self._onSuccess
2172
 
            });
2173
 
            return;
2174
 
        }
2175
 
        
2176
 
 
2177
 
        if (modules.css.length) { //Load CSS first
2178
 
            Y.log('Loading CSS modules', 'info', 'loader');
2179
 
            Y.Get.css(modules.css, {
2180
 
                data: modules.cssMods,
2181
 
                attributes: self.cssAttributes,
2182
 
                insertBefore: self.insertBefore,
2183
 
                charset: self.charset,
2184
 
                timeout: self.timeout,
2185
 
                context: self,
2186
 
                onProgress: function(e) {
2187
 
                    self._onProgress.call(self, e);
2188
 
                },
2189
 
                onTimeout: function(d) {
2190
 
                    self._onTimeout.call(self, d);
2191
 
                },
2192
 
                onSuccess: function(d) {
2193
 
                    d.type = 'success';
2194
 
                    d.fn = self._onSuccess;
2195
 
                    complete.call(self, d);
2196
 
                },
2197
 
                onFailure: function(d) {
2198
 
                    d.type = 'failure';
2199
 
                    d.fn = self._onFailure;
2200
 
                    complete.call(self, d);
2201
 
                }
2202
 
            });
2203
 
        }
2204
 
 
2205
 
        if (modules.js.length) {
2206
 
            Y.log('Loading JS modules', 'info', 'loader');
2207
 
            Y.Get.js(modules.js, {
2208
 
                data: modules.jsMods,
2209
 
                insertBefore: self.insertBefore,
2210
 
                attributes: self.jsAttributes,
2211
 
                charset: self.charset,
2212
 
                timeout: self.timeout,
2213
 
                autopurge: false,
2214
 
                context: self,
2215
 
                async: true,
2216
 
                onProgress: function(e) {
2217
 
                    self._onProgress.call(self, e);
2218
 
                },
2219
 
                onTimeout: function(d) {
2220
 
                    self._onTimeout.call(self, d);
2221
 
                },
2222
 
                onSuccess: function(d) {
2223
 
                    d.type = 'success';
2224
 
                    d.fn = self._onSuccess;
2225
 
                    complete.call(self, d);
2226
 
                },
2227
 
                onFailure: function(d) {
2228
 
                    d.type = 'failure';
2229
 
                    d.fn = self._onFailure;
2230
 
                    complete.call(self, d);
2231
 
                }
2232
 
            });
2233
 
        }
2234
 
    },
2235
 
    /**
2236
 
    * Once a loader operation is completely finished, process any additional queued items.
2237
 
    * @method _continue
2238
 
    * @private
2239
 
    */
2240
 
    _continue: function() {
2241
 
        if (!(_queue.running) && _queue.size() > 0) {
2242
 
            _queue.running = true;
2243
 
            _queue.next()();
2244
 
        }
2245
 
    },
2246
 
 
2247
 
    /**
2248
 
     * inserts the requested modules and their dependencies.
2249
 
     * <code>type</code> can be "js" or "css".  Both script and
2250
 
     * css are inserted if type is not provided.
2251
 
     * @method insert
2252
 
     * @param {object} o optional options object.
2253
 
     * @param {string} type the type of dependency to insert.
2254
 
     */
2255
 
    insert: function(o, type, skipsort) {
2256
 
         Y.log('public insert() ' + (type || '') + ', ' +
2257
 
         Y.Object.keys(this.required), "info", "loader");
2258
 
        var self = this, copy = Y.merge(this);
2259
 
        delete copy.require;
2260
 
        delete copy.dirty;
2261
 
        _queue.add(function() {
2262
 
            self._insert(copy, o, type, skipsort);
2263
 
        });
2264
 
        this._continue();
2265
 
    },
2266
 
 
2267
 
    /**
2268
 
     * Executed every time a module is loaded, and if we are in a load
2269
 
     * cycle, we attempt to load the next script.  Public so that it
2270
 
     * is possible to call this if using a method other than
2271
 
     * Y.register to determine when scripts are fully loaded
2272
 
     * @method loadNext
2273
 
     * @deprecated
2274
 
     * @param {string} mname optional the name of the module that has
2275
 
     * been loaded (which is usually why it is time to load the next
2276
 
     * one).
2277
 
     */
2278
 
    loadNext: function(mname) {
2279
 
        Y.log('loadNext was called..', 'error', 'loader');
2280
 
        return;
2281
 
    },
2282
 
 
2283
 
    /**
2284
 
     * Apply filter defined for this instance to a url/path
2285
 
     * @method _filter
2286
 
     * @param {string} u the string to filter.
2287
 
     * @param {string} name the name of the module, if we are processing
2288
 
     * a single module as opposed to a combined url.
2289
 
     * @return {string} the filtered string.
2290
 
     * @private
2291
 
     */
2292
 
    _filter: function(u, name, group) {
2293
 
        var f = this.filter,
2294
 
            hasFilter = name && (name in this.filters),
2295
 
            modFilter = hasFilter && this.filters[name],
2296
 
                groupName = group || (this.moduleInfo[name] ? this.moduleInfo[name].group : null);
2297
 
 
2298
 
            if (groupName && this.groups[groupName] && this.groups[groupName].filter) {         
2299
 
                    modFilter = this.groups[groupName].filter;
2300
 
                    hasFilter = true;           
2301
 
            };
2302
 
 
2303
 
        if (u) {
2304
 
            if (hasFilter) {
2305
 
                f = (L.isString(modFilter)) ?
2306
 
                    this.FILTER_DEFS[modFilter.toUpperCase()] || null :
2307
 
                    modFilter;
2308
 
            }
2309
 
            if (f) {
2310
 
                u = u.replace(new RegExp(f.searchExp, 'g'), f.replaceStr);
2311
 
            }
2312
 
        }
2313
 
 
2314
 
        return u;
2315
 
    },
2316
 
 
2317
 
    /**
2318
 
     * Generates the full url for a module
2319
 
     * @method _url
2320
 
     * @param {string} path the path fragment.
2321
 
     * @param {String} name The name of the module
2322
 
     * @param {String} [base=self.base] The base url to use
2323
 
     * @return {string} the full url.
2324
 
     * @private
2325
 
     */
2326
 
    _url: function(path, name, base) {
2327
 
        return this._filter((base || this.base || '') + path, name);
2328
 
    },
2329
 
    /**
2330
 
    * Returns an Object hash of file arrays built from `loader.sorted` or from an arbitrary list of sorted modules.
2331
 
    * @method resolve
2332
 
    * @param {Boolean} [calc=false] Perform a loader.calculate() before anything else
2333
 
    * @param {Array} [s=loader.sorted] An override for the loader.sorted array
2334
 
    * @return {Object} Object hash (js and css) of two arrays of file lists
2335
 
    * @example This method can be used as an off-line dep calculator
2336
 
    *
2337
 
    *        var Y = YUI();
2338
 
    *        var loader = new Y.Loader({
2339
 
    *            filter: 'debug',
2340
 
    *            base: '../../',
2341
 
    *            root: 'build/',
2342
 
    *            combine: true,
2343
 
    *            require: ['node', 'dd', 'console']
2344
 
    *        });
2345
 
    *        var out = loader.resolve(true);
2346
 
    *
2347
 
    */
2348
 
    resolve: function(calc, s) {
2349
 
 
2350
 
        var len, i, m, url, fn, msg, attr, group, groupName, j, frag,
2351
 
            comboSource, comboSources, mods, comboBase,
2352
 
            base, urls, u = [], tmpBase, baseLen, resCombos = {},
2353
 
            self = this, comboSep, maxURLLength, singles = [],
2354
 
            inserted = (self.ignoreRegistered) ? {} : self.inserted,
2355
 
            resolved = { js: [], jsMods: [], css: [], cssMods: [] },
2356
 
            type = self.loadType || 'js';
2357
 
 
2358
 
        if (calc) {
2359
 
            self.calculate();
2360
 
        }
2361
 
        s = s || self.sorted;
2362
 
 
2363
 
        var addSingle = function(m) {
2364
 
            
2365
 
            if (m) {
2366
 
                group = (m.group && self.groups[m.group]) || NOT_FOUND;
2367
 
                
2368
 
                //Always assume it's async
2369
 
                if (group.async === false) {
2370
 
                    m.async = group.async;
2371
 
                }
2372
 
 
2373
 
                url = (m.fullpath) ? self._filter(m.fullpath, s[i]) :
2374
 
                      self._url(m.path, s[i], group.base || m.base);
2375
 
                
2376
 
                if (m.attributes || m.async === false) {
2377
 
                    url = {
2378
 
                        url: url,
2379
 
                        async: m.async
2380
 
                    };
2381
 
                    if (m.attributes) {
2382
 
                        url.attributes = m.attributes
2383
 
                    }
2384
 
                }
2385
 
                resolved[m.type].push(url);
2386
 
                resolved[m.type + 'Mods'].push(m);
2387
 
            } else {
2388
 
                Y.log('Undefined Module', 'warn', 'loader');
2389
 
            }
2390
 
            
2391
 
        };
2392
 
 
2393
 
        len = s.length;
2394
 
 
2395
 
        // the default combo base
2396
 
        comboBase = self.comboBase;
2397
 
 
2398
 
        url = comboBase;
2399
 
 
2400
 
        comboSources = {};
2401
 
 
2402
 
        for (i = 0; i < len; i++) {
2403
 
            comboSource = comboBase;
2404
 
            m = self.getModule(s[i]);
2405
 
            groupName = m && m.group;
2406
 
            group = self.groups[groupName];
2407
 
            if (groupName && group) {
2408
 
 
2409
 
                if (!group.combine || m.fullpath) {
2410
 
                    //This is not a combo module, skip it and load it singly later.
2411
 
                    //singles.push(s[i]);
2412
 
                    addSingle(m);
2413
 
                    continue;
2414
 
                }
2415
 
                m.combine = true;
2416
 
                if (group.comboBase) {
2417
 
                    comboSource = group.comboBase;
2418
 
                }
2419
 
 
2420
 
                if ("root" in group && L.isValue(group.root)) {
2421
 
                    m.root = group.root;
2422
 
                }
2423
 
                m.comboSep = group.comboSep || self.comboSep;
2424
 
                m.maxURLLength = group.maxURLLength || self.maxURLLength;
2425
 
            } else {
2426
 
                if (!self.combine) {
2427
 
                    //This is not a combo module, skip it and load it singly later.
2428
 
                    //singles.push(s[i]);
2429
 
                    addSingle(m);
2430
 
                    continue;
2431
 
                }
2432
 
            }
2433
 
 
2434
 
            comboSources[comboSource] = comboSources[comboSource] || [];
2435
 
            comboSources[comboSource].push(m);
2436
 
        }
2437
 
 
2438
 
        for (j in comboSources) {
2439
 
            if (comboSources.hasOwnProperty(j)) {
2440
 
                resCombos[j] = resCombos[j] || { js: [], jsMods: [], css: [], cssMods: [] };
2441
 
                url = j;
2442
 
                mods = comboSources[j];
2443
 
                len = mods.length;
2444
 
                
2445
 
                if (len) {
2446
 
                    for (i = 0; i < len; i++) {
2447
 
                        if (inserted[mods[i]]) {
2448
 
                            continue;
2449
 
                        }
2450
 
                        m = mods[i];
2451
 
                        // Do not try to combine non-yui JS unless combo def
2452
 
                        // is found
2453
 
                        if (m && (m.combine || !m.ext)) {
2454
 
                            resCombos[j].comboSep = m.comboSep;
2455
 
                            resCombos[j].group = m.group;
2456
 
                            resCombos[j].maxURLLength = m.maxURLLength;
2457
 
                            frag = ((L.isValue(m.root)) ? m.root : self.root) + (m.path || m.fullpath);
2458
 
                            frag = self._filter(frag, m.name);
2459
 
                            resCombos[j][m.type].push(frag);
2460
 
                            resCombos[j][m.type + 'Mods'].push(m);
2461
 
                        } else {
2462
 
                            //Add them to the next process..
2463
 
                            if (mods[i]) {
2464
 
                                //singles.push(mods[i].name);
2465
 
                                addSingle(mods[i]);
2466
 
                            }
2467
 
                        }
2468
 
 
2469
 
                    }
2470
 
                }
2471
 
            }
2472
 
        }
2473
 
 
2474
 
 
2475
 
        for (j in resCombos) {
2476
 
            base = j;
2477
 
            comboSep = resCombos[base].comboSep || self.comboSep;
2478
 
            maxURLLength = resCombos[base].maxURLLength || self.maxURLLength;
2479
 
            Y.log('Using maxURLLength of ' + maxURLLength, 'info', 'loader');
2480
 
            for (type in resCombos[base]) {
2481
 
                if (type === JS || type === CSS) {
2482
 
                    urls = resCombos[base][type];
2483
 
                    mods = resCombos[base][type + 'Mods'];
2484
 
                    len = urls.length;
2485
 
                    tmpBase = base + urls.join(comboSep);
2486
 
                    baseLen = tmpBase.length;
2487
 
                    if (maxURLLength <= base.length) {
2488
 
                        Y.log('maxURLLength (' + maxURLLength + ') is lower than the comboBase length (' + base.length + '), resetting to default (' + MAX_URL_LENGTH + ')', 'error', 'loader');
2489
 
                        maxURLLength = MAX_URL_LENGTH;
2490
 
                    }
2491
 
                    
2492
 
                    if (len) {
2493
 
                        if (baseLen > maxURLLength) {
2494
 
                            Y.log('Exceeded maxURLLength (' + maxURLLength + ') for ' + type + ', splitting', 'info', 'loader');
2495
 
                            u = [];
2496
 
                            for (s = 0; s < len; s++) {
2497
 
                                u.push(urls[s]);
2498
 
                                tmpBase = base + u.join(comboSep);
2499
 
 
2500
 
                                if (tmpBase.length > maxURLLength) {
2501
 
                                    m = u.pop();
2502
 
                                    tmpBase = base + u.join(comboSep)
2503
 
                                    resolved[type].push(self._filter(tmpBase, null, resCombos[base].group));
2504
 
                                    u = [];
2505
 
                                    if (m) {
2506
 
                                        u.push(m);
2507
 
                                    }
2508
 
                                }
2509
 
                            }
2510
 
                            if (u.length) {
2511
 
                                tmpBase = base + u.join(comboSep);
2512
 
                                resolved[type].push(self._filter(tmpBase, null, resCombos[base].group));
2513
 
                            }
2514
 
                        } else {
2515
 
                            resolved[type].push(self._filter(tmpBase, null, resCombos[base].group));
2516
 
                        }
2517
 
                    }
2518
 
                    resolved[type + 'Mods'] = resolved[type + 'Mods'].concat(mods);
2519
 
                }
2520
 
            }
2521
 
        }
2522
 
 
2523
 
        resCombos = null;
2524
 
 
2525
 
        return resolved;
2526
 
    },
2527
 
    /**
2528
 
    Shortcut to calculate, resolve and load all modules.
2529
 
 
2530
 
        var loader = new Y.Loader({
2531
 
            ignoreRegistered: true,
2532
 
            modules: {
2533
 
                mod: {
2534
 
                    path: 'mod.js'
2535
 
                }
2536
 
            },
2537
 
            requires: [ 'mod' ]
2538
 
        });
2539
 
        loader.load(function() {
2540
 
            console.log('All modules have loaded..');
2541
 
        });
2542
 
 
2543
 
 
2544
 
    @method load
2545
 
    @param {Callback} cb Executed after all load operations are complete
2546
 
    */
2547
 
    load: function(cb) {
2548
 
        if (!cb) {
2549
 
            Y.log('No callback supplied to load()', 'error', 'loader');
2550
 
            return;
2551
 
        }
2552
 
        var self = this,
2553
 
            out = self.resolve(true);
2554
 
        
2555
 
        self.data = out;
2556
 
 
2557
 
        self.onEnd = function() {
2558
 
            cb.apply(self.context || self, arguments);
2559
 
        };
2560
 
 
2561
 
        self.insert();
2562
 
    }
2563
 
};
2564
 
 
2565
 
 
2566
 
 
2567
 
}, '3.5.1' ,{requires:['get', 'features']});