~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/yui-core/yui-core.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.4.1 (build 4118)
3
 
Copyright 2011 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
/**
8
 
 * The YUI module contains the components required for building the YUI seed
9
 
 * file.  This includes the script loading mechanism, a simple queue, and
10
 
 * the core utilities for the library.
11
 
 * @module yui
12
 
 * @submodule yui-base
13
 
 */
14
 
 
15
 
if (typeof YUI != 'undefined') {
16
 
    YUI._YUI = YUI;
17
 
}
18
 
 
19
 
/**
20
 
The YUI global namespace object.  If YUI is already defined, the
21
 
existing YUI object will not be overwritten so that defined
22
 
namespaces are preserved.  It is the constructor for the object
23
 
the end user interacts with.  As indicated below, each instance
24
 
has full custom event support, but only if the event system
25
 
is available.  This is a self-instantiable factory function.  You
26
 
can invoke it directly like this:
27
 
 
28
 
     YUI().use('*', function(Y) {
29
 
         // ready
30
 
     });
31
 
 
32
 
But it also works like this:
33
 
 
34
 
     var Y = YUI();
35
 
 
36
 
@class YUI
37
 
@constructor
38
 
@global
39
 
@uses EventTarget
40
 
@param o* {Object} 0..n optional configuration objects.  these values
41
 
are store in Y.config.  See <a href="config.html">Config</a> for the list of supported
42
 
properties.
43
 
*/
44
 
    /*global YUI*/
45
 
    /*global YUI_config*/
46
 
    var YUI = function() {
47
 
        var i = 0,
48
 
            Y = this,
49
 
            args = arguments,
50
 
            l = args.length,
51
 
            instanceOf = function(o, type) {
52
 
                return (o && o.hasOwnProperty && (o instanceof type));
53
 
            },
54
 
            gconf = (typeof YUI_config !== 'undefined') && YUI_config;
55
 
 
56
 
        if (!(instanceOf(Y, YUI))) {
57
 
            Y = new YUI();
58
 
        } else {
59
 
            // set up the core environment
60
 
            Y._init();
61
 
 
62
 
            /**
63
 
                YUI.GlobalConfig is a master configuration that might span
64
 
                multiple contexts in a non-browser environment.  It is applied
65
 
                first to all instances in all contexts.
66
 
                @property GlobalConfig
67
 
                @type {Object}
68
 
                @global
69
 
                @static
70
 
                @example
71
 
 
72
 
                    
73
 
                    YUI.GlobalConfig = {
74
 
                        filter: 'debug'
75
 
                    };
76
 
 
77
 
                    YUI().use('node', function(Y) {
78
 
                        //debug files used here
79
 
                    });
80
 
 
81
 
                    YUI({
82
 
                        filter: 'min'
83
 
                    }).use('node', function(Y) {
84
 
                        //min files used here
85
 
                    });
86
 
 
87
 
            */
88
 
            if (YUI.GlobalConfig) {
89
 
                Y.applyConfig(YUI.GlobalConfig);
90
 
            }
91
 
            
92
 
            /**
93
 
                YUI_config is a page-level config.  It is applied to all
94
 
                instances created on the page.  This is applied after
95
 
                YUI.GlobalConfig, and before the instance level configuration
96
 
                objects.
97
 
                @global
98
 
                @property YUI_config
99
 
                @type {Object}
100
 
                @example
101
 
 
102
 
                    
103
 
                    //Single global var to include before YUI seed file
104
 
                    YUI_config = {
105
 
                        filter: 'debug'
106
 
                    };
107
 
                    
108
 
                    YUI().use('node', function(Y) {
109
 
                        //debug files used here
110
 
                    });
111
 
 
112
 
                    YUI({
113
 
                        filter: 'min'
114
 
                    }).use('node', function(Y) {
115
 
                        //min files used here
116
 
                    });
117
 
            */
118
 
            if (gconf) {
119
 
                Y.applyConfig(gconf);
120
 
            }
121
 
 
122
 
            // bind the specified additional modules for this instance
123
 
            if (!l) {
124
 
                Y._setup();
125
 
            }
126
 
        }
127
 
 
128
 
        if (l) {
129
 
            // Each instance can accept one or more configuration objects.
130
 
            // These are applied after YUI.GlobalConfig and YUI_Config,
131
 
            // overriding values set in those config files if there is a '
132
 
            // matching property.
133
 
            for (; i < l; i++) {
134
 
                Y.applyConfig(args[i]);
135
 
            }
136
 
 
137
 
            Y._setup();
138
 
        }
139
 
 
140
 
        Y.instanceOf = instanceOf;
141
 
 
142
 
        return Y;
143
 
    };
144
 
 
145
 
(function() {
146
 
 
147
 
    var proto, prop,
148
 
        VERSION = '3.4.1',
149
 
        PERIOD = '.',
150
 
        BASE = 'http://yui.yahooapis.com/',
151
 
        DOC_LABEL = 'yui3-js-enabled',
152
 
        NOOP = function() {},
153
 
        SLICE = Array.prototype.slice,
154
 
        APPLY_TO_AUTH = { 'io.xdrReady': 1,   // the functions applyTo
155
 
                          'io.xdrResponse': 1,   // can call. this should
156
 
                          'SWF.eventHandler': 1 }, // be done at build time
157
 
        hasWin = (typeof window != 'undefined'),
158
 
        win = (hasWin) ? window : null,
159
 
        doc = (hasWin) ? win.document : null,
160
 
        docEl = doc && doc.documentElement,
161
 
        docClass = docEl && docEl.className,
162
 
        instances = {},
163
 
        time = new Date().getTime(),
164
 
        add = function(el, type, fn, capture) {
165
 
            if (el && el.addEventListener) {
166
 
                el.addEventListener(type, fn, capture);
167
 
            } else if (el && el.attachEvent) {
168
 
                el.attachEvent('on' + type, fn);
169
 
            }
170
 
        },
171
 
        remove = function(el, type, fn, capture) {
172
 
            if (el && el.removeEventListener) {
173
 
                // this can throw an uncaught exception in FF
174
 
                try {
175
 
                    el.removeEventListener(type, fn, capture);
176
 
                } catch (ex) {}
177
 
            } else if (el && el.detachEvent) {
178
 
                el.detachEvent('on' + type, fn);
179
 
            }
180
 
        },
181
 
        handleLoad = function() {
182
 
            YUI.Env.windowLoaded = true;
183
 
            YUI.Env.DOMReady = true;
184
 
            if (hasWin) {
185
 
                remove(window, 'load', handleLoad);
186
 
            }
187
 
        },
188
 
        getLoader = function(Y, o) {
189
 
            var loader = Y.Env._loader;
190
 
            if (loader) {
191
 
                //loader._config(Y.config);
192
 
                loader.ignoreRegistered = false;
193
 
                loader.onEnd = null;
194
 
                loader.data = null;
195
 
                loader.required = [];
196
 
                loader.loadType = null;
197
 
            } else {
198
 
                loader = new Y.Loader(Y.config);
199
 
                Y.Env._loader = loader;
200
 
            }
201
 
            YUI.Env.core = Y.Array.dedupe([].concat(YUI.Env.core, [ 'loader-base', 'loader-rollup', 'loader-yui3' ]));
202
 
 
203
 
            return loader;
204
 
        },
205
 
 
206
 
        clobber = function(r, s) {
207
 
            for (var i in s) {
208
 
                if (s.hasOwnProperty(i)) {
209
 
                    r[i] = s[i];
210
 
                }
211
 
            }
212
 
        },
213
 
 
214
 
        ALREADY_DONE = { success: true };
215
 
 
216
 
//  Stamp the documentElement (HTML) with a class of "yui-loaded" to
217
 
//  enable styles that need to key off of JS being enabled.
218
 
if (docEl && docClass.indexOf(DOC_LABEL) == -1) {
219
 
    if (docClass) {
220
 
        docClass += ' ';
221
 
    }
222
 
    docClass += DOC_LABEL;
223
 
    docEl.className = docClass;
224
 
}
225
 
 
226
 
if (VERSION.indexOf('@') > -1) {
227
 
    VERSION = '3.3.0'; // dev time hack for cdn test
228
 
}
229
 
 
230
 
proto = {
231
 
    /**
232
 
     * Applies a new configuration object to the YUI instance config.
233
 
     * This will merge new group/module definitions, and will also
234
 
     * update the loader cache if necessary.  Updating Y.config directly
235
 
     * will not update the cache.
236
 
     * @method applyConfig
237
 
     * @param {Object} o the configuration object.
238
 
     * @since 3.2.0
239
 
     */
240
 
    applyConfig: function(o) {
241
 
 
242
 
        o = o || NOOP;
243
 
 
244
 
        var attr,
245
 
            name,
246
 
            // detail,
247
 
            config = this.config,
248
 
            mods = config.modules,
249
 
            groups = config.groups,
250
 
            rls = config.rls,
251
 
            loader = this.Env._loader;
252
 
 
253
 
        for (name in o) {
254
 
            if (o.hasOwnProperty(name)) {
255
 
                attr = o[name];
256
 
                if (mods && name == 'modules') {
257
 
                    clobber(mods, attr);
258
 
                } else if (groups && name == 'groups') {
259
 
                    clobber(groups, attr);
260
 
                } else if (rls && name == 'rls') {
261
 
                    clobber(rls, attr);
262
 
                } else if (name == 'win') {
263
 
                    config[name] = attr.contentWindow || attr;
264
 
                    config.doc = config[name].document;
265
 
                } else if (name == '_yuid') {
266
 
                    // preserve the guid
267
 
                } else {
268
 
                    config[name] = attr;
269
 
                }
270
 
            }
271
 
        }
272
 
 
273
 
        if (loader) {
274
 
            loader._config(o);
275
 
        }
276
 
    },
277
 
    /**
278
 
    * Old way to apply a config to the instance (calls `applyConfig` under the hood)
279
 
    * @private
280
 
    * @method _config
281
 
    * @param {Object} o The config to apply
282
 
    */
283
 
    _config: function(o) {
284
 
        this.applyConfig(o);
285
 
    },
286
 
 
287
 
    /**
288
 
     * Initialize this YUI instance
289
 
     * @private
290
 
     * @method _init
291
 
     */
292
 
    _init: function() {
293
 
        var filter,
294
 
            Y = this,
295
 
            G_ENV = YUI.Env,
296
 
            Env = Y.Env,
297
 
            prop;
298
 
 
299
 
        /**
300
 
         * The version number of the YUI instance.
301
 
         * @property version
302
 
         * @type string
303
 
         */
304
 
        Y.version = VERSION;
305
 
 
306
 
        if (!Env) {
307
 
            Y.Env = {
308
 
                core: ['get','intl-base'],
309
 
                mods: {}, // flat module map
310
 
                versions: {}, // version module map
311
 
                base: BASE,
312
 
                cdn: BASE + VERSION + '/build/',
313
 
                // bootstrapped: false,
314
 
                _idx: 0,
315
 
                _used: {},
316
 
                _attached: {},
317
 
                _missed: [],
318
 
                _yidx: 0,
319
 
                _uidx: 0,
320
 
                _guidp: 'y',
321
 
                _loaded: {},
322
 
                // serviced: {},
323
 
                // Regex in English:
324
 
                // I'll start at the \b(simpleyui).
325
 
                // 1. Look in the test string for "simpleyui" or "yui" or
326
 
                //    "yui-base" or "yui-rls" or "yui-foobar" that comes after a word break.  That is, it
327
 
                //    can't match "foyui" or "i_heart_simpleyui". This can be anywhere in the string.
328
 
                // 2. After #1 must come a forward slash followed by the string matched in #1, so
329
 
                //    "yui-base/yui-base" or "simpleyui/simpleyui" or "yui-pants/yui-pants".
330
 
                // 3. The second occurence of the #1 token can optionally be followed by "-debug" or "-min",
331
 
                //    so "yui/yui-min", "yui/yui-debug", "yui-base/yui-base-debug". NOT "yui/yui-tshirt".
332
 
                // 4. This is followed by ".js", so "yui/yui.js", "simpleyui/simpleyui-min.js"
333
 
                // 0. Going back to the beginning, now. If all that stuff in 1-4 comes after a "?" in the string,
334
 
                //    then capture the junk between the LAST "&" and the string in 1-4.  So
335
 
                //    "blah?foo/yui/yui.js" will capture "foo/" and "blah?some/thing.js&3.3.0/build/yui-rls/yui-rls.js"
336
 
                //    will capture "3.3.0/build/"
337
 
                //
338
 
                // Regex Exploded:
339
 
                // (?:\?             Find a ?
340
 
                //   (?:[^&]*&)      followed by 0..n characters followed by an &
341
 
                //   *               in fact, find as many sets of characters followed by a & as you can
342
 
                //   ([^&]*)         capture the stuff after the last & in \1
343
 
                // )?                but it's ok if all this ?junk&more_junk stuff isn't even there
344
 
                // \b(simpleyui|     after a word break find either the string "simpleyui" or
345
 
                //    yui(?:-\w+)?   the string "yui" optionally followed by a -, then more characters
346
 
                // )                 and store the simpleyui or yui-* string in \2
347
 
                // \/\2              then comes a / followed by the simpleyui or yui-* string in \2
348
 
                // (?:-(min|debug))? optionally followed by "-min" or "-debug"
349
 
                // .js               and ending in ".js"
350
 
                _BASE_RE: /(?:\?(?:[^&]*&)*([^&]*))?\b(simpleyui|yui(?:-\w+)?)\/\2(?:-(min|debug))?\.js/,
351
 
                parseBasePath: function(src, pattern) {
352
 
                    var match = src.match(pattern),
353
 
                        path, filter;
354
 
 
355
 
                    if (match) {
356
 
                        path = RegExp.leftContext || src.slice(0, src.indexOf(match[0]));
357
 
 
358
 
                        // this is to set up the path to the loader.  The file
359
 
                        // filter for loader should match the yui include.
360
 
                        filter = match[3];
361
 
 
362
 
                        // extract correct path for mixed combo urls
363
 
                        // http://yuilibrary.com/projects/yui3/ticket/2528423
364
 
                        if (match[1]) {
365
 
                            path += '?' + match[1];
366
 
                        }
367
 
                        path = {
368
 
                            filter: filter,
369
 
                            path: path
370
 
                        }
371
 
                    }
372
 
                    return path;
373
 
                },
374
 
                getBase: G_ENV && G_ENV.getBase ||
375
 
                        function(pattern) {
376
 
                            var nodes = (doc && doc.getElementsByTagName('script')) || [],
377
 
                                path = Env.cdn, parsed,
378
 
                                i, len, src;
379
 
 
380
 
                            for (i = 0, len = nodes.length; i < len; ++i) {
381
 
                                src = nodes[i].src;
382
 
                                if (src) {
383
 
                                    parsed = Y.Env.parseBasePath(src, pattern);
384
 
                                    if (parsed) {
385
 
                                        filter = parsed.filter;
386
 
                                        path = parsed.path;
387
 
                                        break;
388
 
                                    }
389
 
                                }
390
 
                            }
391
 
 
392
 
                            // use CDN default
393
 
                            return path;
394
 
                        }
395
 
 
396
 
            };
397
 
 
398
 
            Env = Y.Env;
399
 
 
400
 
            Env._loaded[VERSION] = {};
401
 
 
402
 
            if (G_ENV && Y !== YUI) {
403
 
                Env._yidx = ++G_ENV._yidx;
404
 
                Env._guidp = ('yui_' + VERSION + '_' +
405
 
                             Env._yidx + '_' + time).replace(/\./g, '_');
406
 
            } else if (YUI._YUI) {
407
 
 
408
 
                G_ENV = YUI._YUI.Env;
409
 
                Env._yidx += G_ENV._yidx;
410
 
                Env._uidx += G_ENV._uidx;
411
 
 
412
 
                for (prop in G_ENV) {
413
 
                    if (!(prop in Env)) {
414
 
                        Env[prop] = G_ENV[prop];
415
 
                    }
416
 
                }
417
 
 
418
 
                delete YUI._YUI;
419
 
            }
420
 
 
421
 
            Y.id = Y.stamp(Y);
422
 
            instances[Y.id] = Y;
423
 
 
424
 
        }
425
 
 
426
 
        Y.constructor = YUI;
427
 
 
428
 
        // configuration defaults
429
 
        Y.config = Y.config || {
430
 
            win: win,
431
 
            doc: doc,
432
 
            debug: true,
433
 
            useBrowserConsole: true,
434
 
            throwFail: true,
435
 
            bootstrap: true,
436
 
            cacheUse: true,
437
 
            fetchCSS: true,
438
 
            use_rls: false,
439
 
            rls_timeout: 2000
440
 
        };
441
 
 
442
 
        if (YUI.Env.rls_disabled) {
443
 
            Y.config.use_rls = false;
444
 
        }
445
 
 
446
 
        Y.config.lang = Y.config.lang || 'en-US';
447
 
 
448
 
        Y.config.base = YUI.config.base || Y.Env.getBase(Y.Env._BASE_RE);
449
 
        
450
 
        if (!filter || (!('mindebug').indexOf(filter))) {
451
 
            filter = 'min';
452
 
        }
453
 
        filter = (filter) ? '-' + filter : filter;
454
 
        Y.config.loaderPath = YUI.config.loaderPath || 'loader/loader' + filter + '.js';
455
 
 
456
 
    },
457
 
 
458
 
    /**
459
 
     * Finishes the instance setup. Attaches whatever modules were defined
460
 
     * when the yui modules was registered.
461
 
     * @method _setup
462
 
     * @private
463
 
     */
464
 
    _setup: function(o) {
465
 
        var i, Y = this,
466
 
            core = [],
467
 
            mods = YUI.Env.mods,
468
 
            //extras = Y.config.core || ['get','intl-base'];
469
 
            extras = Y.config.core || [].concat(YUI.Env.core); //Clone it..
470
 
 
471
 
        for (i = 0; i < extras.length; i++) {
472
 
            if (mods[extras[i]]) {
473
 
                core.push(extras[i]);
474
 
            }
475
 
        }
476
 
 
477
 
        Y._attach(['yui-base']);
478
 
        Y._attach(core);
479
 
 
480
 
        if (Y.Loader) {
481
 
            getLoader(Y);
482
 
        }
483
 
 
484
 
    },
485
 
 
486
 
    /**
487
 
     * Executes a method on a YUI instance with
488
 
     * the specified id if the specified method is whitelisted.
489
 
     * @method applyTo
490
 
     * @param id {String} the YUI instance id.
491
 
     * @param method {String} the name of the method to exectute.
492
 
     * Ex: 'Object.keys'.
493
 
     * @param args {Array} the arguments to apply to the method.
494
 
     * @return {Object} the return value from the applied method or null.
495
 
     */
496
 
    applyTo: function(id, method, args) {
497
 
        if (!(method in APPLY_TO_AUTH)) {
498
 
            this.log(method + ': applyTo not allowed', 'warn', 'yui');
499
 
            return null;
500
 
        }
501
 
 
502
 
        var instance = instances[id], nest, m, i;
503
 
        if (instance) {
504
 
            nest = method.split('.');
505
 
            m = instance;
506
 
            for (i = 0; i < nest.length; i = i + 1) {
507
 
                m = m[nest[i]];
508
 
                if (!m) {
509
 
                    this.log('applyTo not found: ' + method, 'warn', 'yui');
510
 
                }
511
 
            }
512
 
            return m.apply(instance, args);
513
 
        }
514
 
 
515
 
        return null;
516
 
    },
517
 
 
518
 
/**
519
 
Registers a module with the YUI global.  The easiest way to create a
520
 
first-class YUI module is to use the YUI component build tool.
521
 
 
522
 
http://yuilibrary.com/projects/builder
523
 
 
524
 
The build system will produce the `YUI.add` wrapper for you module, along
525
 
with any configuration info required for the module.
526
 
@method add
527
 
@param name {String} module name.
528
 
@param fn {Function} entry point into the module that is used to bind module to the YUI instance.
529
 
@param {YUI} fn.Y The YUI instance this module is executed in.
530
 
@param {String} fn.name The name of the module
531
 
@param version {String} version string.
532
 
@param details {Object} optional config data:
533
 
@param details.requires {Array} features that must be present before this module can be attached.
534
 
@param details.optional {Array} optional features that should be present if loadOptional
535
 
 is defined.  Note: modules are not often loaded this way in YUI 3,
536
 
 but this field is still useful to inform the user that certain
537
 
 features in the component will require additional dependencies.
538
 
@param details.use {Array} features that are included within this module which need to
539
 
 be attached automatically when this module is attached.  This
540
 
 supports the YUI 3 rollup system -- a module with submodules
541
 
 defined will need to have the submodules listed in the 'use'
542
 
 config.  The YUI component build tool does this for you.
543
 
@return {YUI} the YUI instance.
544
 
@example
545
 
 
546
 
    YUI.add('davglass', function(Y, name) {
547
 
        Y.davglass = function() {
548
 
            alert('Dav was here!');
549
 
        };
550
 
    }, '3.4.0', { requires: ['yui-base', 'harley-davidson', 'mt-dew'] });
551
 
 
552
 
*/
553
 
    add: function(name, fn, version, details) {
554
 
        details = details || {};
555
 
        var env = YUI.Env,
556
 
            mod = {
557
 
                name: name,
558
 
                fn: fn,
559
 
                version: version,
560
 
                details: details
561
 
            },
562
 
            loader,
563
 
            i, versions = env.versions;
564
 
 
565
 
        env.mods[name] = mod;
566
 
        versions[version] = versions[version] || {};
567
 
        versions[version][name] = mod;
568
 
 
569
 
        for (i in instances) {
570
 
            if (instances.hasOwnProperty(i)) {
571
 
                loader = instances[i].Env._loader;
572
 
                if (loader) {
573
 
                    if (!loader.moduleInfo[name]) {
574
 
                        loader.addModule(details, name);
575
 
                    }
576
 
                }
577
 
            }
578
 
        }
579
 
 
580
 
        return this;
581
 
    },
582
 
 
583
 
    /**
584
 
     * Executes the function associated with each required
585
 
     * module, binding the module to the YUI instance.
586
 
     * @param {Array} r The array of modules to attach
587
 
     * @param {Boolean} [moot=false] Don't throw a warning if the module is not attached
588
 
     * @method _attach
589
 
     * @private
590
 
     */
591
 
    _attach: function(r, moot) {
592
 
        var i, name, mod, details, req, use, after,
593
 
            mods = YUI.Env.mods,
594
 
            aliases = YUI.Env.aliases,
595
 
            Y = this, j,
596
 
            loader = Y.Env._loader,
597
 
            done = Y.Env._attached,
598
 
            len = r.length, loader,
599
 
            c = [];
600
 
 
601
 
        //Check for conditional modules (in a second+ instance) and add their requirements
602
 
        //TODO I hate this entire method, it needs to be fixed ASAP (3.5.0) ^davglass
603
 
        for (i = 0; i < len; i++) {
604
 
            name = r[i];
605
 
            mod = mods[name];
606
 
            c.push(name);
607
 
            if (loader && loader.conditions[name]) {
608
 
                Y.Object.each(loader.conditions[name], function(def) {
609
 
                    var go = def && ((def.ua && Y.UA[def.ua]) || (def.test && def.test(Y)));
610
 
                    if (go) {
611
 
                        c.push(def.name);
612
 
                    }
613
 
                });
614
 
            }
615
 
        }
616
 
        r = c;
617
 
        len = r.length;
618
 
 
619
 
        for (i = 0; i < len; i++) {
620
 
            if (!done[r[i]]) {
621
 
                name = r[i];
622
 
                mod = mods[name];
623
 
 
624
 
                if (aliases && aliases[name]) {
625
 
                    Y._attach(aliases[name]);
626
 
                    continue;
627
 
                }
628
 
                if (!mod) {
629
 
                    if (loader && loader.moduleInfo[name]) {
630
 
                        mod = loader.moduleInfo[name];
631
 
                        moot = true;
632
 
                    }
633
 
 
634
 
 
635
 
                    //if (!loader || !loader.moduleInfo[name]) {
636
 
                    //if ((!loader || !loader.moduleInfo[name]) && !moot) {
637
 
                    if (!moot) {
638
 
                        if ((name.indexOf('skin-') === -1) && (name.indexOf('css') === -1)) {
639
 
                            Y.Env._missed.push(name);
640
 
                            Y.Env._missed = Y.Array.dedupe(Y.Env._missed);
641
 
                            Y.message('NOT loaded: ' + name, 'warn', 'yui');
642
 
                        }
643
 
                    }
644
 
                } else {
645
 
                    done[name] = true;
646
 
                    //Don't like this, but in case a mod was asked for once, then we fetch it
647
 
                    //We need to remove it from the missed list ^davglass
648
 
                    for (j = 0; j < Y.Env._missed.length; j++) {
649
 
                        if (Y.Env._missed[j] === name) {
650
 
                            Y.message('Found: ' + name + ' (was reported as missing earlier)', 'warn', 'yui');
651
 
                            Y.Env._missed.splice(j, 1);
652
 
                        }
653
 
                    }
654
 
                    details = mod.details;
655
 
                    req = details.requires;
656
 
                    use = details.use;
657
 
                    after = details.after;
658
 
 
659
 
                    if (req) {
660
 
                        for (j = 0; j < req.length; j++) {
661
 
                            if (!done[req[j]]) {
662
 
                                if (!Y._attach(req)) {
663
 
                                    return false;
664
 
                                }
665
 
                                break;
666
 
                            }
667
 
                        }
668
 
                    }
669
 
 
670
 
                    if (after) {
671
 
                        for (j = 0; j < after.length; j++) {
672
 
                            if (!done[after[j]]) {
673
 
                                if (!Y._attach(after, true)) {
674
 
                                    return false;
675
 
                                }
676
 
                                break;
677
 
                            }
678
 
                        }
679
 
                    }
680
 
 
681
 
                    if (mod.fn) {
682
 
                        try {
683
 
                            mod.fn(Y, name);
684
 
                        } catch (e) {
685
 
                            Y.error('Attach error: ' + name, e, name);
686
 
                            return false;
687
 
                        }
688
 
                    }
689
 
 
690
 
                    if (use) {
691
 
                        for (j = 0; j < use.length; j++) {
692
 
                            if (!done[use[j]]) {
693
 
                                if (!Y._attach(use)) {
694
 
                                    return false;
695
 
                                }
696
 
                                break;
697
 
                            }
698
 
                        }
699
 
                    }
700
 
 
701
 
 
702
 
 
703
 
                }
704
 
            }
705
 
        }
706
 
 
707
 
        return true;
708
 
    },
709
 
 
710
 
    /**
711
 
     * Attaches one or more modules to the YUI instance.  When this
712
 
     * is executed, the requirements are analyzed, and one of
713
 
     * several things can happen:
714
 
     *
715
 
     *  * All requirements are available on the page --  The modules
716
 
     *   are attached to the instance.  If supplied, the use callback
717
 
     *   is executed synchronously.
718
 
     *
719
 
     *  * Modules are missing, the Get utility is not available OR
720
 
     *   the 'bootstrap' config is false -- A warning is issued about
721
 
     *   the missing modules and all available modules are attached.
722
 
     *
723
 
     *  * Modules are missing, the Loader is not available but the Get
724
 
     *   utility is and boostrap is not false -- The loader is bootstrapped
725
 
     *   before doing the following....
726
 
     *
727
 
     *  * Modules are missing and the Loader is available -- The loader
728
 
     *   expands the dependency tree and fetches missing modules.  When
729
 
     *   the loader is finshed the callback supplied to use is executed
730
 
     *   asynchronously.
731
 
     *
732
 
     * @method use
733
 
     * @param modules* {String} 1-n modules to bind (uses arguments array).
734
 
     * @param *callback {Function} callback function executed when
735
 
     * the instance has the required functionality.  If included, it
736
 
     * must be the last parameter.
737
 
     *
738
 
     * @example
739
 
     *      // loads and attaches dd and its dependencies
740
 
     *      YUI().use('dd', function(Y) {});
741
 
     *
742
 
     *      // loads and attaches dd and node as well as all of their dependencies (since 3.4.0)
743
 
     *      YUI().use(['dd', 'node'], function(Y) {});
744
 
     *
745
 
     *      // attaches all modules that are available on the page
746
 
     *      YUI().use('*', function(Y) {});
747
 
     *
748
 
     *      // intrinsic YUI gallery support (since 3.1.0)
749
 
     *      YUI().use('gallery-yql', function(Y) {});
750
 
     *
751
 
     *      // intrinsic YUI 2in3 support (since 3.1.0)
752
 
     *      YUI().use('yui2-datatable', function(Y) {});
753
 
     *
754
 
     * @return {YUI} the YUI instance.
755
 
     */
756
 
    use: function() {
757
 
        var args = SLICE.call(arguments, 0),
758
 
            callback = args[args.length - 1],
759
 
            Y = this,
760
 
            i = 0,
761
 
            name,
762
 
            Env = Y.Env,
763
 
            provisioned = true;
764
 
 
765
 
        // The last argument supplied to use can be a load complete callback
766
 
        if (Y.Lang.isFunction(callback)) {
767
 
            args.pop();
768
 
        } else {
769
 
            callback = null;
770
 
        }
771
 
        if (Y.Lang.isArray(args[0])) {
772
 
            args = args[0];
773
 
        }
774
 
 
775
 
        if (Y.config.cacheUse) {
776
 
            while ((name = args[i++])) {
777
 
                if (!Env._attached[name]) {
778
 
                    provisioned = false;
779
 
                    break;
780
 
                }
781
 
            }
782
 
 
783
 
            if (provisioned) {
784
 
                if (args.length) {
785
 
                }
786
 
                Y._notify(callback, ALREADY_DONE, args);
787
 
                return Y;
788
 
            }
789
 
        }
790
 
 
791
 
        if (Y._loading) {
792
 
            Y._useQueue = Y._useQueue || new Y.Queue();
793
 
            Y._useQueue.add([args, callback]);
794
 
        } else {
795
 
            Y._use(args, function(Y, response) {
796
 
                Y._notify(callback, response, args);
797
 
            });
798
 
        }
799
 
 
800
 
        return Y;
801
 
    },
802
 
    /**
803
 
    * Notify handler from Loader for attachment/load errors
804
 
    * @method _notify
805
 
    * @param callback {Function} The callback to pass to the `Y.config.loadErrorFn`
806
 
    * @param response {Object} The response returned from Loader
807
 
    * @param args {Array} The aruments passed from Loader
808
 
    * @private
809
 
    */
810
 
    _notify: function(callback, response, args) {
811
 
        if (!response.success && this.config.loadErrorFn) {
812
 
            this.config.loadErrorFn.call(this, this, callback, response, args);
813
 
        } else if (callback) {
814
 
            try {
815
 
                callback(this, response);
816
 
            } catch (e) {
817
 
                this.error('use callback error', e, args);
818
 
            }
819
 
        }
820
 
    },
821
 
    
822
 
    /**
823
 
    * This private method is called from the `use` method queue. To ensure that only one set of loading
824
 
    * logic is performed at a time.
825
 
    * @method _use
826
 
    * @private
827
 
    * @param args* {String} 1-n modules to bind (uses arguments array).
828
 
    * @param *callback {Function} callback function executed when
829
 
    * the instance has the required functionality.  If included, it
830
 
    * must be the last parameter.
831
 
    */
832
 
    _use: function(args, callback) {
833
 
 
834
 
        if (!this.Array) {
835
 
            this._attach(['yui-base']);
836
 
        }
837
 
 
838
 
        var len, loader, handleBoot, handleRLS,
839
 
            Y = this,
840
 
            G_ENV = YUI.Env,
841
 
            mods = G_ENV.mods,
842
 
            Env = Y.Env,
843
 
            used = Env._used,
844
 
            queue = G_ENV._loaderQueue,
845
 
            firstArg = args[0],
846
 
            YArray = Y.Array,
847
 
            config = Y.config,
848
 
            boot = config.bootstrap,
849
 
            missing = [],
850
 
            r = [],
851
 
            ret = true,
852
 
            fetchCSS = config.fetchCSS,
853
 
            process = function(names, skip) {
854
 
 
855
 
                if (!names.length) {
856
 
                    return;
857
 
                }
858
 
 
859
 
                YArray.each(names, function(name) {
860
 
 
861
 
                    // add this module to full list of things to attach
862
 
                    if (!skip) {
863
 
                        r.push(name);
864
 
                    }
865
 
 
866
 
                    // only attach a module once
867
 
                    if (used[name]) {
868
 
                        return;
869
 
                    }
870
 
 
871
 
                    var m = mods[name], req, use;
872
 
 
873
 
                    if (m) {
874
 
                        used[name] = true;
875
 
                        req = m.details.requires;
876
 
                        use = m.details.use;
877
 
                    } else {
878
 
                        // CSS files don't register themselves, see if it has
879
 
                        // been loaded
880
 
                        if (!G_ENV._loaded[VERSION][name]) {
881
 
                            missing.push(name);
882
 
                        } else {
883
 
                            used[name] = true; // probably css
884
 
                        }
885
 
                    }
886
 
 
887
 
                    // make sure requirements are attached
888
 
                    if (req && req.length) {
889
 
                        process(req);
890
 
                    }
891
 
 
892
 
                    // make sure we grab the submodule dependencies too
893
 
                    if (use && use.length) {
894
 
                        process(use, 1);
895
 
                    }
896
 
                });
897
 
            },
898
 
 
899
 
            handleLoader = function(fromLoader) {
900
 
                var response = fromLoader || {
901
 
                        success: true,
902
 
                        msg: 'not dynamic'
903
 
                    },
904
 
                    redo, origMissing,
905
 
                    ret = true,
906
 
                    data = response.data;
907
 
 
908
 
 
909
 
                Y._loading = false;
910
 
 
911
 
                if (data) {
912
 
                    origMissing = missing;
913
 
                    missing = [];
914
 
                    r = [];
915
 
                    process(data);
916
 
                    redo = missing.length;
917
 
                    if (redo) {
918
 
                        if (missing.sort().join() ==
919
 
                                origMissing.sort().join()) {
920
 
                            redo = false;
921
 
                        }
922
 
                    }
923
 
                }
924
 
 
925
 
                if (redo && data) {
926
 
                    Y._loading = false;
927
 
                    Y._use(args, function() {
928
 
                        if (Y._attach(data)) {
929
 
                            Y._notify(callback, response, data);
930
 
                        }
931
 
                    });
932
 
                } else {
933
 
                    if (data) {
934
 
                        ret = Y._attach(data);
935
 
                    }
936
 
                    if (ret) {
937
 
                        Y._notify(callback, response, args);
938
 
                    }
939
 
                }
940
 
 
941
 
                if (Y._useQueue && Y._useQueue.size() && !Y._loading) {
942
 
                    Y._use.apply(Y, Y._useQueue.next());
943
 
                }
944
 
 
945
 
            };
946
 
 
947
 
 
948
 
        // YUI().use('*'); // bind everything available
949
 
        if (firstArg === '*') {
950
 
            ret = Y._attach(Y.Object.keys(mods));
951
 
            if (ret) {
952
 
                handleLoader();
953
 
            }
954
 
            return Y;
955
 
        }
956
 
 
957
 
 
958
 
        // use loader to expand dependencies and sort the
959
 
        // requirements if it is available.
960
 
        if (boot && Y.Loader && args.length) {
961
 
            loader = getLoader(Y);
962
 
            loader.require(args);
963
 
            loader.ignoreRegistered = true;
964
 
            loader.calculate(null, (fetchCSS) ? null : 'js');
965
 
            args = loader.sorted;
966
 
        }
967
 
 
968
 
        // process each requirement and any additional requirements
969
 
        // the module metadata specifies
970
 
        process(args);
971
 
 
972
 
        len = missing.length;
973
 
 
974
 
        if (len) {
975
 
            missing = Y.Object.keys(YArray.hash(missing));
976
 
            len = missing.length;
977
 
        }
978
 
 
979
 
 
980
 
        // dynamic load
981
 
        if (boot && len && Y.Loader) {
982
 
            Y._loading = true;
983
 
            loader = getLoader(Y);
984
 
            loader.onEnd = handleLoader;
985
 
            loader.context = Y;
986
 
            loader.data = args;
987
 
            loader.ignoreRegistered = false;
988
 
            loader.require(args);
989
 
            loader.insert(null, (fetchCSS) ? null : 'js');
990
 
            // loader.partial(missing, (fetchCSS) ? null : 'js');
991
 
 
992
 
        } else if (len && Y.config.use_rls && !YUI.Env.rls_enabled) {
993
 
 
994
 
            G_ENV._rls_queue = G_ENV._rls_queue || new Y.Queue();
995
 
 
996
 
            // server side loader service
997
 
            handleRLS = function(instance, argz) {
998
 
 
999
 
                var rls_end = function(o) {
1000
 
                    handleLoader(o);
1001
 
                    instance.rls_advance();
1002
 
                },
1003
 
                rls_url = instance._rls(argz);
1004
 
 
1005
 
                if (rls_url) {
1006
 
                    instance.rls_oncomplete(function(o) {
1007
 
                        rls_end(o);
1008
 
                    });
1009
 
                    instance.Get.script(rls_url, {
1010
 
                        data: argz,
1011
 
                        timeout: instance.config.rls_timeout,
1012
 
                        onFailure: instance.rls_handleFailure,
1013
 
                        onTimeout: instance.rls_handleTimeout
1014
 
                    });
1015
 
                } else {
1016
 
                    rls_end({
1017
 
                        success: true,
1018
 
                        data: argz
1019
 
                    });
1020
 
                }
1021
 
            };
1022
 
 
1023
 
            G_ENV._rls_queue.add(function() {
1024
 
                G_ENV._rls_in_progress = true;
1025
 
                Y.rls_callback = callback;
1026
 
                Y.rls_locals(Y, args, handleRLS);
1027
 
            });
1028
 
 
1029
 
            if (!G_ENV._rls_in_progress && G_ENV._rls_queue.size()) {
1030
 
                G_ENV._rls_queue.next()();
1031
 
            }
1032
 
 
1033
 
        } else if (boot && len && Y.Get && !Env.bootstrapped) {
1034
 
 
1035
 
            Y._loading = true;
1036
 
 
1037
 
            handleBoot = function() {
1038
 
                Y._loading = false;
1039
 
                queue.running = false;
1040
 
                Env.bootstrapped = true;
1041
 
                G_ENV._bootstrapping = false;
1042
 
                if (Y._attach(['loader'])) {
1043
 
                    Y._use(args, callback);
1044
 
                }
1045
 
            };
1046
 
 
1047
 
            if (G_ENV._bootstrapping) {
1048
 
                queue.add(handleBoot);
1049
 
            } else {
1050
 
                G_ENV._bootstrapping = true;
1051
 
                Y.Get.script(config.base + config.loaderPath, {
1052
 
                    onEnd: handleBoot
1053
 
                });
1054
 
            }
1055
 
 
1056
 
        } else {
1057
 
            ret = Y._attach(args);
1058
 
            if (ret) {
1059
 
                handleLoader();
1060
 
            }
1061
 
        }
1062
 
 
1063
 
        return Y;
1064
 
    },
1065
 
 
1066
 
 
1067
 
    /**
1068
 
    Adds a namespace object onto the YUI global if called statically.
1069
 
 
1070
 
        // creates YUI.your.namespace.here as nested objects
1071
 
        YUI.namespace("your.namespace.here");
1072
 
 
1073
 
    If called as a method on a YUI <em>instance</em>, it creates the
1074
 
    namespace on the instance.
1075
 
 
1076
 
         // creates Y.property.package
1077
 
         Y.namespace("property.package");
1078
 
    
1079
 
    Dots in the input string cause `namespace` to create nested objects for
1080
 
    each token. If any part of the requested namespace already exists, the
1081
 
    current object will be left in place.  This allows multiple calls to
1082
 
    `namespace` to preserve existing namespaced properties.
1083
 
    
1084
 
    If the first token in the namespace string is "YAHOO", the token is
1085
 
    discarded.
1086
 
 
1087
 
    Be careful with namespace tokens. Reserved words may work in some browsers
1088
 
    and not others. For instance, the following will fail in some browsers
1089
 
    because the supported version of JavaScript reserves the word "long":
1090
 
    
1091
 
         Y.namespace("really.long.nested.namespace");
1092
 
    
1093
 
    @method namespace
1094
 
    @param  {String} namespace* namespaces to create.
1095
 
    @return {Object}  A reference to the last namespace object created.
1096
 
    **/
1097
 
    namespace: function() {
1098
 
        var a = arguments, o = this, i = 0, j, d, arg;
1099
 
        for (; i < a.length; i++) {
1100
 
            // d = ('' + a[i]).split('.');
1101
 
            arg = a[i];
1102
 
            if (arg.indexOf(PERIOD)) {
1103
 
                d = arg.split(PERIOD);
1104
 
                for (j = (d[0] == 'YAHOO') ? 1 : 0; j < d.length; j++) {
1105
 
                    o[d[j]] = o[d[j]] || {};
1106
 
                    o = o[d[j]];
1107
 
                }
1108
 
            } else {
1109
 
                o[arg] = o[arg] || {};
1110
 
            }
1111
 
        }
1112
 
        return o;
1113
 
    },
1114
 
 
1115
 
    // this is replaced if the log module is included
1116
 
    log: NOOP,
1117
 
    message: NOOP,
1118
 
    // this is replaced if the dump module is included
1119
 
    dump: function (o) { return ''+o; },
1120
 
 
1121
 
    /**
1122
 
     * Report an error.  The reporting mechanism is controled by
1123
 
     * the `throwFail` configuration attribute.  If throwFail is
1124
 
     * not specified, the message is written to the Logger, otherwise
1125
 
     * a JS error is thrown
1126
 
     * @method error
1127
 
     * @param msg {String} the error message.
1128
 
     * @param e {Error|String} Optional JS error that was caught, or an error string.
1129
 
     * @param data Optional additional info
1130
 
     * and `throwFail` is specified, this error will be re-thrown.
1131
 
     * @return {YUI} this YUI instance.
1132
 
     */
1133
 
    error: function(msg, e, data) {
1134
 
 
1135
 
        var Y = this, ret;
1136
 
 
1137
 
        if (Y.config.errorFn) {
1138
 
            ret = Y.config.errorFn.apply(Y, arguments);
1139
 
        }
1140
 
 
1141
 
        if (Y.config.throwFail && !ret) {
1142
 
            throw (e || new Error(msg));
1143
 
        } else {
1144
 
            Y.message(msg, 'error'); // don't scrub this one
1145
 
        }
1146
 
 
1147
 
        return Y;
1148
 
    },
1149
 
 
1150
 
    /**
1151
 
     * Generate an id that is unique among all YUI instances
1152
 
     * @method guid
1153
 
     * @param pre {String} optional guid prefix.
1154
 
     * @return {String} the guid.
1155
 
     */
1156
 
    guid: function(pre) {
1157
 
        var id = this.Env._guidp + '_' + (++this.Env._uidx);
1158
 
        return (pre) ? (pre + id) : id;
1159
 
    },
1160
 
 
1161
 
    /**
1162
 
     * Returns a `guid` associated with an object.  If the object
1163
 
     * does not have one, a new one is created unless `readOnly`
1164
 
     * is specified.
1165
 
     * @method stamp
1166
 
     * @param o {Object} The object to stamp.
1167
 
     * @param readOnly {Boolean} if `true`, a valid guid will only
1168
 
     * be returned if the object has one assigned to it.
1169
 
     * @return {String} The object's guid or null.
1170
 
     */
1171
 
    stamp: function(o, readOnly) {
1172
 
        var uid;
1173
 
        if (!o) {
1174
 
            return o;
1175
 
        }
1176
 
 
1177
 
        // IE generates its own unique ID for dom nodes
1178
 
        // The uniqueID property of a document node returns a new ID
1179
 
        if (o.uniqueID && o.nodeType && o.nodeType !== 9) {
1180
 
            uid = o.uniqueID;
1181
 
        } else {
1182
 
            uid = (typeof o === 'string') ? o : o._yuid;
1183
 
        }
1184
 
 
1185
 
        if (!uid) {
1186
 
            uid = this.guid();
1187
 
            if (!readOnly) {
1188
 
                try {
1189
 
                    o._yuid = uid;
1190
 
                } catch (e) {
1191
 
                    uid = null;
1192
 
                }
1193
 
            }
1194
 
        }
1195
 
        return uid;
1196
 
    },
1197
 
 
1198
 
    /**
1199
 
     * Destroys the YUI instance
1200
 
     * @method destroy
1201
 
     * @since 3.3.0
1202
 
     */
1203
 
    destroy: function() {
1204
 
        var Y = this;
1205
 
        if (Y.Event) {
1206
 
            Y.Event._unload();
1207
 
        }
1208
 
        delete instances[Y.id];
1209
 
        delete Y.Env;
1210
 
        delete Y.config;
1211
 
    }
1212
 
 
1213
 
    /**
1214
 
     * instanceof check for objects that works around
1215
 
     * memory leak in IE when the item tested is
1216
 
     * window/document
1217
 
     * @method instanceOf
1218
 
     * @since 3.3.0
1219
 
     */
1220
 
};
1221
 
 
1222
 
 
1223
 
 
1224
 
    YUI.prototype = proto;
1225
 
 
1226
 
    // inheritance utilities are not available yet
1227
 
    for (prop in proto) {
1228
 
        if (proto.hasOwnProperty(prop)) {
1229
 
            YUI[prop] = proto[prop];
1230
 
        }
1231
 
    }
1232
 
 
1233
 
    // set up the environment
1234
 
    YUI._init();
1235
 
 
1236
 
    if (hasWin) {
1237
 
        // add a window load event at load time so we can capture
1238
 
        // the case where it fires before dynamic loading is
1239
 
        // complete.
1240
 
        add(window, 'load', handleLoad);
1241
 
    } else {
1242
 
        handleLoad();
1243
 
    }
1244
 
 
1245
 
    YUI.Env.add = add;
1246
 
    YUI.Env.remove = remove;
1247
 
 
1248
 
    /*global exports*/
1249
 
    // Support the CommonJS method for exporting our single global
1250
 
    if (typeof exports == 'object') {
1251
 
        exports.YUI = YUI;
1252
 
    }
1253
 
 
1254
 
}());
1255
 
 
1256
 
 
1257
 
/**
1258
 
 * The config object contains all of the configuration options for
1259
 
 * the `YUI` instance.  This object is supplied by the implementer
1260
 
 * when instantiating a `YUI` instance.  Some properties have default
1261
 
 * values if they are not supplied by the implementer.  This should
1262
 
 * not be updated directly because some values are cached.  Use
1263
 
 * `applyConfig()` to update the config object on a YUI instance that
1264
 
 * has already been configured.
1265
 
 *
1266
 
 * @class config
1267
 
 * @static
1268
 
 */
1269
 
 
1270
 
/**
1271
 
 * Allows the YUI seed file to fetch the loader component and library
1272
 
 * metadata to dynamically load additional dependencies.
1273
 
 *
1274
 
 * @property bootstrap
1275
 
 * @type boolean
1276
 
 * @default true
1277
 
 */
1278
 
 
1279
 
/**
1280
 
 * Log to the browser console if debug is on and the browser has a
1281
 
 * supported console.
1282
 
 *
1283
 
 * @property useBrowserConsole
1284
 
 * @type boolean
1285
 
 * @default true
1286
 
 */
1287
 
 
1288
 
/**
1289
 
 * A hash of log sources that should be logged.  If specified, only
1290
 
 * log messages from these sources will be logged.
1291
 
 *
1292
 
 * @property logInclude
1293
 
 * @type object
1294
 
 */
1295
 
 
1296
 
/**
1297
 
 * A hash of log sources that should be not be logged.  If specified,
1298
 
 * all sources are logged if not on this list.
1299
 
 *
1300
 
 * @property logExclude
1301
 
 * @type object
1302
 
 */
1303
 
 
1304
 
/**
1305
 
 * Set to true if the yui seed file was dynamically loaded in
1306
 
 * order to bootstrap components relying on the window load event
1307
 
 * and the `domready` custom event.
1308
 
 *
1309
 
 * @property injected
1310
 
 * @type boolean
1311
 
 * @default false
1312
 
 */
1313
 
 
1314
 
/**
1315
 
 * If `throwFail` is set, `Y.error` will generate or re-throw a JS Error.
1316
 
 * Otherwise the failure is logged.
1317
 
 *
1318
 
 * @property throwFail
1319
 
 * @type boolean
1320
 
 * @default true
1321
 
 */
1322
 
 
1323
 
/**
1324
 
 * The window/frame that this instance should operate in.
1325
 
 *
1326
 
 * @property win
1327
 
 * @type Window
1328
 
 * @default the window hosting YUI
1329
 
 */
1330
 
 
1331
 
/**
1332
 
 * The document associated with the 'win' configuration.
1333
 
 *
1334
 
 * @property doc
1335
 
 * @type Document
1336
 
 * @default the document hosting YUI
1337
 
 */
1338
 
 
1339
 
/**
1340
 
 * A list of modules that defines the YUI core (overrides the default).
1341
 
 *
1342
 
 * @property core
1343
 
 * @type string[]
1344
 
 */
1345
 
 
1346
 
/**
1347
 
 * A list of languages in order of preference. This list is matched against
1348
 
 * the list of available languages in modules that the YUI instance uses to
1349
 
 * determine the best possible localization of language sensitive modules.
1350
 
 * Languages are represented using BCP 47 language tags, such as "en-GB" for
1351
 
 * English as used in the United Kingdom, or "zh-Hans-CN" for simplified
1352
 
 * Chinese as used in China. The list can be provided as a comma-separated
1353
 
 * list or as an array.
1354
 
 *
1355
 
 * @property lang
1356
 
 * @type string|string[]
1357
 
 */
1358
 
 
1359
 
/**
1360
 
 * The default date format
1361
 
 * @property dateFormat
1362
 
 * @type string
1363
 
 * @deprecated use configuration in `DataType.Date.format()` instead.
1364
 
 */
1365
 
 
1366
 
/**
1367
 
 * The default locale
1368
 
 * @property locale
1369
 
 * @type string
1370
 
 * @deprecated use `config.lang` instead.
1371
 
 */
1372
 
 
1373
 
/**
1374
 
 * The default interval when polling in milliseconds.
1375
 
 * @property pollInterval
1376
 
 * @type int
1377
 
 * @default 20
1378
 
 */
1379
 
 
1380
 
/**
1381
 
 * The number of dynamic nodes to insert by default before
1382
 
 * automatically removing them.  This applies to script nodes
1383
 
 * because removing the node will not make the evaluated script
1384
 
 * unavailable.  Dynamic CSS is not auto purged, because removing
1385
 
 * a linked style sheet will also remove the style definitions.
1386
 
 * @property purgethreshold
1387
 
 * @type int
1388
 
 * @default 20
1389
 
 */
1390
 
 
1391
 
/**
1392
 
 * The default interval when polling in milliseconds.
1393
 
 * @property windowResizeDelay
1394
 
 * @type int
1395
 
 * @default 40
1396
 
 */
1397
 
 
1398
 
/**
1399
 
 * Base directory for dynamic loading
1400
 
 * @property base
1401
 
 * @type string
1402
 
 */
1403
 
 
1404
 
/*
1405
 
 * The secure base dir (not implemented)
1406
 
 * For dynamic loading.
1407
 
 * @property secureBase
1408
 
 * @type string
1409
 
 */
1410
 
 
1411
 
/**
1412
 
 * The YUI combo service base dir. Ex: `http://yui.yahooapis.com/combo?`
1413
 
 * For dynamic loading.
1414
 
 * @property comboBase
1415
 
 * @type string
1416
 
 */
1417
 
 
1418
 
/**
1419
 
 * The root path to prepend to module path for the combo service.
1420
 
 * Ex: 3.0.0b1/build/
1421
 
 * For dynamic loading.
1422
 
 * @property root
1423
 
 * @type string
1424
 
 */
1425
 
 
1426
 
/**
1427
 
 * A filter to apply to result urls.  This filter will modify the default
1428
 
 * path for all modules.  The default path for the YUI library is the
1429
 
 * minified version of the files (e.g., event-min.js).  The filter property
1430
 
 * can be a predefined filter or a custom filter.  The valid predefined
1431
 
 * filters are:
1432
 
 * <dl>
1433
 
 *  <dt>DEBUG</dt>
1434
 
 *  <dd>Selects the debug versions of the library (e.g., event-debug.js).
1435
 
 *      This option will automatically include the Logger widget</dd>
1436
 
 *  <dt>RAW</dt>
1437
 
 *  <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
1438
 
 * </dl>
1439
 
 * You can also define a custom filter, which must be an object literal
1440
 
 * containing a search expression and a replace string:
1441
 
 * 
1442
 
 *      myFilter: {
1443
 
 *          'searchExp': "-min\\.js",
1444
 
 *          'replaceStr': "-debug.js"
1445
 
 *      }
1446
 
 *
1447
 
 * For dynamic loading.
1448
 
 *
1449
 
 * @property filter
1450
 
 * @type string|object
1451
 
 */
1452
 
 
1453
 
/**
1454
 
 * The `skin` config let's you configure application level skin
1455
 
 * customizations.  It contains the following attributes which
1456
 
 * can be specified to override the defaults:
1457
 
 *
1458
 
 *      // The default skin, which is automatically applied if not
1459
 
 *      // overriden by a component-specific skin definition.
1460
 
 *      // Change this in to apply a different skin globally
1461
 
 *      defaultSkin: 'sam',
1462
 
 *
1463
 
 *      // This is combined with the loader base property to get
1464
 
 *      // the default root directory for a skin.
1465
 
 *      base: 'assets/skins/',
1466
 
 *
1467
 
 *      // Any component-specific overrides can be specified here,
1468
 
 *      // making it possible to load different skins for different
1469
 
 *      // components.  It is possible to load more than one skin
1470
 
 *      // for a given component as well.
1471
 
 *      overrides: {
1472
 
 *          slider: ['capsule', 'round']
1473
 
 *      }
1474
 
 *
1475
 
 * For dynamic loading.
1476
 
 *
1477
 
 *  @property skin
1478
 
 */
1479
 
 
1480
 
/**
1481
 
 * Hash of per-component filter specification.  If specified for a given
1482
 
 * component, this overrides the filter config.
1483
 
 *
1484
 
 * For dynamic loading.
1485
 
 *
1486
 
 * @property filters
1487
 
 */
1488
 
 
1489
 
/**
1490
 
 * Use the YUI combo service to reduce the number of http connections
1491
 
 * required to load your dependencies.  Turning this off will
1492
 
 * disable combo handling for YUI and all module groups configured
1493
 
 * with a combo service.
1494
 
 *
1495
 
 * For dynamic loading.
1496
 
 *
1497
 
 * @property combine
1498
 
 * @type boolean
1499
 
 * @default true if 'base' is not supplied, false if it is.
1500
 
 */
1501
 
 
1502
 
/**
1503
 
 * A list of modules that should never be dynamically loaded
1504
 
 *
1505
 
 * @property ignore
1506
 
 * @type string[]
1507
 
 */
1508
 
 
1509
 
/**
1510
 
 * A list of modules that should always be loaded when required, even if already
1511
 
 * present on the page.
1512
 
 *
1513
 
 * @property force
1514
 
 * @type string[]
1515
 
 */
1516
 
 
1517
 
/**
1518
 
 * Node or id for a node that should be used as the insertion point for new
1519
 
 * nodes.  For dynamic loading.
1520
 
 *
1521
 
 * @property insertBefore
1522
 
 * @type string
1523
 
 */
1524
 
 
1525
 
/**
1526
 
 * Object literal containing attributes to add to dynamically loaded script
1527
 
 * nodes.
1528
 
 * @property jsAttributes
1529
 
 * @type string
1530
 
 */
1531
 
 
1532
 
/**
1533
 
 * Object literal containing attributes to add to dynamically loaded link
1534
 
 * nodes.
1535
 
 * @property cssAttributes
1536
 
 * @type string
1537
 
 */
1538
 
 
1539
 
/**
1540
 
 * Number of milliseconds before a timeout occurs when dynamically
1541
 
 * loading nodes. If not set, there is no timeout.
1542
 
 * @property timeout
1543
 
 * @type int
1544
 
 */
1545
 
 
1546
 
/**
1547
 
 * Callback for the 'CSSComplete' event.  When dynamically loading YUI
1548
 
 * components with CSS, this property fires when the CSS is finished
1549
 
 * loading but script loading is still ongoing.  This provides an
1550
 
 * opportunity to enhance the presentation of a loading page a little
1551
 
 * bit before the entire loading process is done.
1552
 
 *
1553
 
 * @property onCSS
1554
 
 * @type function
1555
 
 */
1556
 
 
1557
 
/**
1558
 
 * A hash of module definitions to add to the list of YUI components.
1559
 
 * These components can then be dynamically loaded side by side with
1560
 
 * YUI via the `use()` method. This is a hash, the key is the module
1561
 
 * name, and the value is an object literal specifying the metdata
1562
 
 * for the module.  See `Loader.addModule` for the supported module
1563
 
 * metadata fields.  Also see groups, which provides a way to
1564
 
 * configure the base and combo spec for a set of modules.
1565
 
 * 
1566
 
 *      modules: {
1567
 
 *          mymod1: {
1568
 
 *              requires: ['node'],
1569
 
 *              fullpath: 'http://myserver.mydomain.com/mymod1/mymod1.js'
1570
 
 *          },
1571
 
 *          mymod2: {
1572
 
 *              requires: ['mymod1'],
1573
 
 *              fullpath: 'http://myserver.mydomain.com/mymod2/mymod2.js'
1574
 
 *          }
1575
 
 *      }
1576
 
 *
1577
 
 * @property modules
1578
 
 * @type object
1579
 
 */
1580
 
 
1581
 
/**
1582
 
 * A hash of module group definitions.  It for each group you
1583
 
 * can specify a list of modules and the base path and
1584
 
 * combo spec to use when dynamically loading the modules.
1585
 
 * 
1586
 
 *      groups: {
1587
 
 *          yui2: {
1588
 
 *              // specify whether or not this group has a combo service
1589
 
 *              combine: true,
1590
 
 * 
1591
 
 *              // the base path for non-combo paths
1592
 
 *              base: 'http://yui.yahooapis.com/2.8.0r4/build/',
1593
 
 * 
1594
 
 *              // the path to the combo service
1595
 
 *              comboBase: 'http://yui.yahooapis.com/combo?',
1596
 
 * 
1597
 
 *              // a fragment to prepend to the path attribute when
1598
 
 *              // when building combo urls
1599
 
 *              root: '2.8.0r4/build/',
1600
 
 * 
1601
 
 *              // the module definitions
1602
 
 *              modules:  {
1603
 
 *                  yui2_yde: {
1604
 
 *                      path: "yahoo-dom-event/yahoo-dom-event.js"
1605
 
 *                  },
1606
 
 *                  yui2_anim: {
1607
 
 *                      path: "animation/animation.js",
1608
 
 *                      requires: ['yui2_yde']
1609
 
 *                  }
1610
 
 *              }
1611
 
 *          }
1612
 
 *      }
1613
 
 * 
1614
 
 * @property groups
1615
 
 * @type object
1616
 
 */
1617
 
 
1618
 
/**
1619
 
 * The loader 'path' attribute to the loader itself.  This is combined
1620
 
 * with the 'base' attribute to dynamically load the loader component
1621
 
 * when boostrapping with the get utility alone.
1622
 
 *
1623
 
 * @property loaderPath
1624
 
 * @type string
1625
 
 * @default loader/loader-min.js
1626
 
 */
1627
 
 
1628
 
/**
1629
 
 * Specifies whether or not YUI().use(...) will attempt to load CSS
1630
 
 * resources at all.  Any truthy value will cause CSS dependencies
1631
 
 * to load when fetching script.  The special value 'force' will
1632
 
 * cause CSS dependencies to be loaded even if no script is needed.
1633
 
 *
1634
 
 * @property fetchCSS
1635
 
 * @type boolean|string
1636
 
 * @default true
1637
 
 */
1638
 
 
1639
 
/**
1640
 
 * The default gallery version to build gallery module urls
1641
 
 * @property gallery
1642
 
 * @type string
1643
 
 * @since 3.1.0
1644
 
 */
1645
 
 
1646
 
/**
1647
 
 * The default YUI 2 version to build yui2 module urls.  This is for
1648
 
 * intrinsic YUI 2 support via the 2in3 project.  Also see the '2in3'
1649
 
 * config for pulling different revisions of the wrapped YUI 2
1650
 
 * modules.
1651
 
 * @since 3.1.0
1652
 
 * @property yui2
1653
 
 * @type string
1654
 
 * @default 2.8.1
1655
 
 */
1656
 
 
1657
 
/**
1658
 
 * The 2in3 project is a deployment of the various versions of YUI 2
1659
 
 * deployed as first-class YUI 3 modules.  Eventually, the wrapper
1660
 
 * for the modules will change (but the underlying YUI 2 code will
1661
 
 * be the same), and you can select a particular version of
1662
 
 * the wrapper modules via this config.
1663
 
 * @since 3.1.0
1664
 
 * @property 2in3
1665
 
 * @type string
1666
 
 * @default 1
1667
 
 */
1668
 
 
1669
 
/**
1670
 
 * Alternative console log function for use in environments without
1671
 
 * a supported native console.  The function is executed in the
1672
 
 * YUI instance context.
1673
 
 * @since 3.1.0
1674
 
 * @property logFn
1675
 
 * @type Function
1676
 
 */
1677
 
 
1678
 
/**
1679
 
 * A callback to execute when Y.error is called.  It receives the
1680
 
 * error message and an javascript error object if Y.error was
1681
 
 * executed because a javascript error was caught.  The function
1682
 
 * is executed in the YUI instance context.
1683
 
 *
1684
 
 * @since 3.2.0
1685
 
 * @property errorFn
1686
 
 * @type Function
1687
 
 */
1688
 
 
1689
 
/**
1690
 
 * A callback to execute when the loader fails to load one or
1691
 
 * more resource.  This could be because of a script load
1692
 
 * failure.  It can also fail if a javascript module fails
1693
 
 * to register itself, but only when the 'requireRegistration'
1694
 
 * is true.  If this function is defined, the use() callback will
1695
 
 * only be called when the loader succeeds, otherwise it always
1696
 
 * executes unless there was a javascript error when attaching
1697
 
 * a module.
1698
 
 *
1699
 
 * @since 3.3.0
1700
 
 * @property loadErrorFn
1701
 
 * @type Function
1702
 
 */
1703
 
 
1704
 
/**
1705
 
 * When set to true, the YUI loader will expect that all modules
1706
 
 * it is responsible for loading will be first-class YUI modules
1707
 
 * that register themselves with the YUI global.  If this is
1708
 
 * set to true, loader will fail if the module registration fails
1709
 
 * to happen after the script is loaded.
1710
 
 *
1711
 
 * @since 3.3.0
1712
 
 * @property requireRegistration
1713
 
 * @type boolean
1714
 
 * @default false
1715
 
 */
1716
 
 
1717
 
/**
1718
 
 * Cache serviced use() requests.
1719
 
 * @since 3.3.0
1720
 
 * @property cacheUse
1721
 
 * @type boolean
1722
 
 * @default true
1723
 
 * @deprecated no longer used
1724
 
 */
1725
 
 
1726
 
/**
1727
 
 * The parameter defaults for the remote loader service. **Requires the rls seed file.** The properties that are supported:
1728
 
 * 
1729
 
 *  * `m`: comma separated list of module requirements.  This
1730
 
 *    must be the param name even for custom implemetations.
1731
 
 *  * `v`: the version of YUI to load.  Defaults to the version
1732
 
 *    of YUI that is being used.
1733
 
 *  * `gv`: the version of the gallery to load (see the gallery config)
1734
 
 *  * `env`: comma separated list of modules already on the page.
1735
 
 *      this must be the param name even for custom implemetations.
1736
 
 *  * `lang`: the languages supported on the page (see the lang config)
1737
 
 *  * `'2in3v'`:  the version of the 2in3 wrapper to use (see the 2in3 config).
1738
 
 *  * `'2v'`: the version of yui2 to use in the yui 2in3 wrappers
1739
 
 *  * `filt`: a filter def to apply to the urls (see the filter config).
1740
 
 *  * `filts`: a list of custom filters to apply per module
1741
 
 *  * `tests`: this is a map of conditional module test function id keys
1742
 
 * with the values of 1 if the test passes, 0 if not.  This must be
1743
 
 * the name of the querystring param in custom templates.
1744
 
 *
1745
 
 * @since 3.2.0
1746
 
 * @property rls
1747
 
 * @type {Object}
1748
 
 */
1749
 
 
1750
 
/**
1751
 
 * The base path to the remote loader service. **Requires the rls seed file.**
1752
 
 *
1753
 
 * @since 3.2.0
1754
 
 * @property rls_base
1755
 
 * @type {String}
1756
 
 */
1757
 
 
1758
 
/**
1759
 
 * The template to use for building the querystring portion
1760
 
 * of the remote loader service url.  The default is determined
1761
 
 * by the rls config -- each property that has a value will be
1762
 
 * represented. **Requires the rls seed file.**
1763
 
 * 
1764
 
 * @since 3.2.0
1765
 
 * @property rls_tmpl
1766
 
 * @type {String}
1767
 
 * @example
1768
 
 *      m={m}&v={v}&env={env}&lang={lang}&filt={filt}&tests={tests}
1769
 
 *
1770
 
 */
1771
 
 
1772
 
/**
1773
 
 * Configure the instance to use a remote loader service instead of
1774
 
 * the client loader. **Requires the rls seed file.**
1775
 
 *
1776
 
 * @since 3.2.0
1777
 
 * @property use_rls
1778
 
 * @type {Boolean}
1779
 
 */
1780
 
YUI.add('yui-base', function(Y) {
1781
 
 
1782
 
/*
1783
 
 * YUI stub
1784
 
 * @module yui
1785
 
 * @submodule yui-base
1786
 
 */
1787
 
/**
1788
 
 * The YUI module contains the components required for building the YUI
1789
 
 * seed file.  This includes the script loading mechanism, a simple queue,
1790
 
 * and the core utilities for the library.
1791
 
 * @module yui
1792
 
 * @submodule yui-base
1793
 
 */
1794
 
 
1795
 
/**
1796
 
 * Provides core language utilites and extensions used throughout YUI.
1797
 
 *
1798
 
 * @class Lang
1799
 
 * @static
1800
 
 */
1801
 
 
1802
 
var L = Y.Lang || (Y.Lang = {}),
1803
 
 
1804
 
STRING_PROTO = String.prototype,
1805
 
TOSTRING     = Object.prototype.toString,
1806
 
 
1807
 
TYPES = {
1808
 
    'undefined'        : 'undefined',
1809
 
    'number'           : 'number',
1810
 
    'boolean'          : 'boolean',
1811
 
    'string'           : 'string',
1812
 
    '[object Function]': 'function',
1813
 
    '[object RegExp]'  : 'regexp',
1814
 
    '[object Array]'   : 'array',
1815
 
    '[object Date]'    : 'date',
1816
 
    '[object Error]'   : 'error'
1817
 
},
1818
 
 
1819
 
SUBREGEX  = /\{\s*([^|}]+?)\s*(?:\|([^}]*))?\s*\}/g,
1820
 
TRIMREGEX = /^\s+|\s+$/g,
1821
 
 
1822
 
// If either MooTools or Prototype is on the page, then there's a chance that we
1823
 
// can't trust "native" language features to actually be native. When this is
1824
 
// the case, we take the safe route and fall back to our own non-native
1825
 
// implementation.
1826
 
win           = Y.config.win,
1827
 
unsafeNatives = win && !!(win.MooTools || win.Prototype);
1828
 
 
1829
 
/**
1830
 
 * Determines whether or not the provided item is an array.
1831
 
 *
1832
 
 * Returns `false` for array-like collections such as the function `arguments`
1833
 
 * collection or `HTMLElement` collections. Use `Y.Array.test()` if you want to
1834
 
 * test for an array-like collection.
1835
 
 *
1836
 
 * @method isArray
1837
 
 * @param o The object to test.
1838
 
 * @return {boolean} true if o is an array.
1839
 
 * @static
1840
 
 */
1841
 
L.isArray = (!unsafeNatives && Array.isArray) || function (o) {
1842
 
    return L.type(o) === 'array';
1843
 
};
1844
 
 
1845
 
/**
1846
 
 * Determines whether or not the provided item is a boolean.
1847
 
 * @method isBoolean
1848
 
 * @static
1849
 
 * @param o The object to test.
1850
 
 * @return {boolean} true if o is a boolean.
1851
 
 */
1852
 
L.isBoolean = function(o) {
1853
 
    return typeof o === 'boolean';
1854
 
};
1855
 
 
1856
 
/**
1857
 
 * <p>
1858
 
 * Determines whether or not the provided item is a function.
1859
 
 * Note: Internet Explorer thinks certain functions are objects:
1860
 
 * </p>
1861
 
 *
1862
 
 * <pre>
1863
 
 * var obj = document.createElement("object");
1864
 
 * Y.Lang.isFunction(obj.getAttribute) // reports false in IE
1865
 
 * &nbsp;
1866
 
 * var input = document.createElement("input"); // append to body
1867
 
 * Y.Lang.isFunction(input.focus) // reports false in IE
1868
 
 * </pre>
1869
 
 *
1870
 
 * <p>
1871
 
 * You will have to implement additional tests if these functions
1872
 
 * matter to you.
1873
 
 * </p>
1874
 
 *
1875
 
 * @method isFunction
1876
 
 * @static
1877
 
 * @param o The object to test.
1878
 
 * @return {boolean} true if o is a function.
1879
 
 */
1880
 
L.isFunction = function(o) {
1881
 
    return L.type(o) === 'function';
1882
 
};
1883
 
 
1884
 
/**
1885
 
 * Determines whether or not the supplied item is a date instance.
1886
 
 * @method isDate
1887
 
 * @static
1888
 
 * @param o The object to test.
1889
 
 * @return {boolean} true if o is a date.
1890
 
 */
1891
 
L.isDate = function(o) {
1892
 
    return L.type(o) === 'date' && o.toString() !== 'Invalid Date' && !isNaN(o);
1893
 
};
1894
 
 
1895
 
/**
1896
 
 * Determines whether or not the provided item is null.
1897
 
 * @method isNull
1898
 
 * @static
1899
 
 * @param o The object to test.
1900
 
 * @return {boolean} true if o is null.
1901
 
 */
1902
 
L.isNull = function(o) {
1903
 
    return o === null;
1904
 
};
1905
 
 
1906
 
/**
1907
 
 * Determines whether or not the provided item is a legal number.
1908
 
 * @method isNumber
1909
 
 * @static
1910
 
 * @param o The object to test.
1911
 
 * @return {boolean} true if o is a number.
1912
 
 */
1913
 
L.isNumber = function(o) {
1914
 
    return typeof o === 'number' && isFinite(o);
1915
 
};
1916
 
 
1917
 
/**
1918
 
 * Determines whether or not the provided item is of type object
1919
 
 * or function. Note that arrays are also objects, so
1920
 
 * <code>Y.Lang.isObject([]) === true</code>.
1921
 
 * @method isObject
1922
 
 * @static
1923
 
 * @param o The object to test.
1924
 
 * @param failfn {boolean} fail if the input is a function.
1925
 
 * @return {boolean} true if o is an object.
1926
 
 * @see isPlainObject
1927
 
 */
1928
 
L.isObject = function(o, failfn) {
1929
 
    var t = typeof o;
1930
 
    return (o && (t === 'object' ||
1931
 
        (!failfn && (t === 'function' || L.isFunction(o))))) || false;
1932
 
};
1933
 
 
1934
 
/**
1935
 
 * Determines whether or not the provided item is a string.
1936
 
 * @method isString
1937
 
 * @static
1938
 
 * @param o The object to test.
1939
 
 * @return {boolean} true if o is a string.
1940
 
 */
1941
 
L.isString = function(o) {
1942
 
    return typeof o === 'string';
1943
 
};
1944
 
 
1945
 
/**
1946
 
 * Determines whether or not the provided item is undefined.
1947
 
 * @method isUndefined
1948
 
 * @static
1949
 
 * @param o The object to test.
1950
 
 * @return {boolean} true if o is undefined.
1951
 
 */
1952
 
L.isUndefined = function(o) {
1953
 
    return typeof o === 'undefined';
1954
 
};
1955
 
 
1956
 
/**
1957
 
 * Returns a string without any leading or trailing whitespace.  If
1958
 
 * the input is not a string, the input will be returned untouched.
1959
 
 * @method trim
1960
 
 * @static
1961
 
 * @param s {string} the string to trim.
1962
 
 * @return {string} the trimmed string.
1963
 
 */
1964
 
L.trim = STRING_PROTO.trim ? function(s) {
1965
 
    return s && s.trim ? s.trim() : s;
1966
 
} : function (s) {
1967
 
    try {
1968
 
        return s.replace(TRIMREGEX, '');
1969
 
    } catch (e) {
1970
 
        return s;
1971
 
    }
1972
 
};
1973
 
 
1974
 
/**
1975
 
 * Returns a string without any leading whitespace.
1976
 
 * @method trimLeft
1977
 
 * @static
1978
 
 * @param s {string} the string to trim.
1979
 
 * @return {string} the trimmed string.
1980
 
 */
1981
 
L.trimLeft = STRING_PROTO.trimLeft ? function (s) {
1982
 
    return s.trimLeft();
1983
 
} : function (s) {
1984
 
    return s.replace(/^\s+/, '');
1985
 
};
1986
 
 
1987
 
/**
1988
 
 * Returns a string without any trailing whitespace.
1989
 
 * @method trimRight
1990
 
 * @static
1991
 
 * @param s {string} the string to trim.
1992
 
 * @return {string} the trimmed string.
1993
 
 */
1994
 
L.trimRight = STRING_PROTO.trimRight ? function (s) {
1995
 
    return s.trimRight();
1996
 
} : function (s) {
1997
 
    return s.replace(/\s+$/, '');
1998
 
};
1999
 
 
2000
 
/**
2001
 
 * A convenience method for detecting a legitimate non-null value.
2002
 
 * Returns false for null/undefined/NaN, true for other values,
2003
 
 * including 0/false/''
2004
 
 * @method isValue
2005
 
 * @static
2006
 
 * @param o The item to test.
2007
 
 * @return {boolean} true if it is not null/undefined/NaN || false.
2008
 
 */
2009
 
L.isValue = function(o) {
2010
 
    var t = L.type(o);
2011
 
 
2012
 
    switch (t) {
2013
 
        case 'number':
2014
 
            return isFinite(o);
2015
 
 
2016
 
        case 'null': // fallthru
2017
 
        case 'undefined':
2018
 
            return false;
2019
 
 
2020
 
        default:
2021
 
            return !!t;
2022
 
    }
2023
 
};
2024
 
 
2025
 
/**
2026
 
 * <p>
2027
 
 * Returns a string representing the type of the item passed in.
2028
 
 * </p>
2029
 
 *
2030
 
 * <p>
2031
 
 * Known issues:
2032
 
 * </p>
2033
 
 *
2034
 
 * <ul>
2035
 
 *   <li>
2036
 
 *     <code>typeof HTMLElementCollection</code> returns function in Safari, but
2037
 
 *     <code>Y.type()</code> reports object, which could be a good thing --
2038
 
 *     but it actually caused the logic in <code>Y.Lang.isObject</code> to fail.
2039
 
 *   </li>
2040
 
 * </ul>
2041
 
 *
2042
 
 * @method type
2043
 
 * @param o the item to test.
2044
 
 * @return {string} the detected type.
2045
 
 * @static
2046
 
 */
2047
 
L.type = function(o) {
2048
 
    return TYPES[typeof o] || TYPES[TOSTRING.call(o)] || (o ? 'object' : 'null');
2049
 
};
2050
 
 
2051
 
/**
2052
 
 * Lightweight version of <code>Y.substitute</code>. Uses the same template
2053
 
 * structure as <code>Y.substitute</code>, but doesn't support recursion,
2054
 
 * auto-object coersion, or formats.
2055
 
 * @method sub
2056
 
 * @param {string} s String to be modified.
2057
 
 * @param {object} o Object containing replacement values.
2058
 
 * @return {string} the substitute result.
2059
 
 * @static
2060
 
 * @since 3.2.0
2061
 
 */
2062
 
L.sub = function(s, o) {
2063
 
    return s.replace ? s.replace(SUBREGEX, function (match, key) {
2064
 
        return L.isUndefined(o[key]) ? match : o[key];
2065
 
    }) : s;
2066
 
};
2067
 
 
2068
 
/**
2069
 
 * Returns the current time in milliseconds.
2070
 
 *
2071
 
 * @method now
2072
 
 * @return {Number} Current time in milliseconds.
2073
 
 * @static
2074
 
 * @since 3.3.0
2075
 
 */
2076
 
L.now = Date.now || function () {
2077
 
    return new Date().getTime();
2078
 
};
2079
 
/**
2080
 
@module yui
2081
 
@submodule yui-base
2082
 
*/
2083
 
 
2084
 
var Lang   = Y.Lang,
2085
 
    Native = Array.prototype,
2086
 
 
2087
 
    hasOwn = Object.prototype.hasOwnProperty;
2088
 
 
2089
 
/**
2090
 
Provides utility methods for working with arrays. Additional array helpers can
2091
 
be found in the `collection` and `array-extras` modules.
2092
 
 
2093
 
`Y.Array(thing)` returns a native array created from _thing_. Depending on
2094
 
_thing_'s type, one of the following will happen:
2095
 
 
2096
 
  * Arrays are returned unmodified unless a non-zero _startIndex_ is
2097
 
    specified.
2098
 
  * Array-like collections (see `Array.test()`) are converted to arrays.
2099
 
  * For everything else, a new array is created with _thing_ as the sole
2100
 
    item.
2101
 
 
2102
 
Note: elements that are also collections, such as `<form>` and `<select>`
2103
 
elements, are not automatically converted to arrays. To force a conversion,
2104
 
pass `true` as the value of the _force_ parameter.
2105
 
 
2106
 
@class Array
2107
 
@constructor
2108
 
@param {Any} thing The thing to arrayify.
2109
 
@param {Number} [startIndex=0] If non-zero and _thing_ is an array or array-like
2110
 
  collection, a subset of items starting at the specified index will be
2111
 
  returned.
2112
 
@param {Boolean} [force=false] If `true`, _thing_ will be treated as an
2113
 
  array-like collection no matter what.
2114
 
@return {Array} A native array created from _thing_, according to the rules
2115
 
  described above.
2116
 
**/
2117
 
function YArray(thing, startIndex, force) {
2118
 
    var len, result;
2119
 
 
2120
 
    startIndex || (startIndex = 0);
2121
 
 
2122
 
    if (force || YArray.test(thing)) {
2123
 
        // IE throws when trying to slice HTMLElement collections.
2124
 
        try {
2125
 
            return Native.slice.call(thing, startIndex);
2126
 
        } catch (ex) {
2127
 
            result = [];
2128
 
 
2129
 
            for (len = thing.length; startIndex < len; ++startIndex) {
2130
 
                result.push(thing[startIndex]);
2131
 
            }
2132
 
 
2133
 
            return result;
2134
 
        }
2135
 
    }
2136
 
 
2137
 
    return [thing];
2138
 
}
2139
 
 
2140
 
Y.Array = YArray;
2141
 
 
2142
 
/**
2143
 
Dedupes an array of strings, returning an array that's guaranteed to contain
2144
 
only one copy of a given string.
2145
 
 
2146
 
This method differs from `Array.unique()` in that it's optimized for use only
2147
 
with strings, whereas `unique` may be used with other types (but is slower).
2148
 
Using `dedupe()` with non-string values may result in unexpected behavior.
2149
 
 
2150
 
@method dedupe
2151
 
@param {String[]} array Array of strings to dedupe.
2152
 
@return {Array} Deduped copy of _array_.
2153
 
@static
2154
 
@since 3.4.0
2155
 
**/
2156
 
YArray.dedupe = function (array) {
2157
 
    var hash    = {},
2158
 
        results = [],
2159
 
        i, item, len;
2160
 
 
2161
 
    for (i = 0, len = array.length; i < len; ++i) {
2162
 
        item = array[i];
2163
 
 
2164
 
        if (!hasOwn.call(hash, item)) {
2165
 
            hash[item] = 1;
2166
 
            results.push(item);
2167
 
        }
2168
 
    }
2169
 
 
2170
 
    return results;
2171
 
};
2172
 
 
2173
 
/**
2174
 
Executes the supplied function on each item in the array. This method wraps
2175
 
the native ES5 `Array.forEach()` method if available.
2176
 
 
2177
 
@method each
2178
 
@param {Array} array Array to iterate.
2179
 
@param {Function} fn Function to execute on each item in the array. The function
2180
 
  will receive the following arguments:
2181
 
    @param {Any} fn.item Current array item.
2182
 
    @param {Number} fn.index Current array index.
2183
 
    @param {Array} fn.array Array being iterated.
2184
 
@param {Object} [thisObj] `this` object to use when calling _fn_.
2185
 
@return {YUI} The YUI instance.
2186
 
@static
2187
 
**/
2188
 
YArray.each = YArray.forEach = Native.forEach ? function (array, fn, thisObj) {
2189
 
    Native.forEach.call(array || [], fn, thisObj || Y);
2190
 
    return Y;
2191
 
} : function (array, fn, thisObj) {
2192
 
    for (var i = 0, len = (array && array.length) || 0; i < len; ++i) {
2193
 
        if (i in array) {
2194
 
            fn.call(thisObj || Y, array[i], i, array);
2195
 
        }
2196
 
    }
2197
 
 
2198
 
    return Y;
2199
 
};
2200
 
 
2201
 
/**
2202
 
Alias for `each()`.
2203
 
 
2204
 
@method forEach
2205
 
@static
2206
 
**/
2207
 
 
2208
 
/**
2209
 
Returns an object using the first array as keys and the second as values. If
2210
 
the second array is not provided, or if it doesn't contain the same number of
2211
 
values as the first array, then `true` will be used in place of the missing
2212
 
values.
2213
 
 
2214
 
@example
2215
 
 
2216
 
    Y.Array.hash(['a', 'b', 'c'], ['foo', 'bar']);
2217
 
    // => {a: 'foo', b: 'bar', c: true}
2218
 
 
2219
 
@method hash
2220
 
@param {String[]} keys Array of strings to use as keys.
2221
 
@param {Array} [values] Array to use as values.
2222
 
@return {Object} Hash using the first array as keys and the second as values.
2223
 
@static
2224
 
**/
2225
 
YArray.hash = function (keys, values) {
2226
 
    var hash = {},
2227
 
        vlen = (values && values.length) || 0,
2228
 
        i, len;
2229
 
 
2230
 
    for (i = 0, len = keys.length; i < len; ++i) {
2231
 
        if (i in keys) {
2232
 
            hash[keys[i]] = vlen > i && i in values ? values[i] : true;
2233
 
        }
2234
 
    }
2235
 
 
2236
 
    return hash;
2237
 
};
2238
 
 
2239
 
/**
2240
 
Returns the index of the first item in the array that's equal (using a strict
2241
 
equality check) to the specified _value_, or `-1` if the value isn't found.
2242
 
 
2243
 
This method wraps the native ES5 `Array.indexOf()` method if available.
2244
 
 
2245
 
@method indexOf
2246
 
@param {Array} array Array to search.
2247
 
@param {Any} value Value to search for.
2248
 
@return {Number} Index of the item strictly equal to _value_, or `-1` if not
2249
 
  found.
2250
 
@static
2251
 
**/
2252
 
YArray.indexOf = Native.indexOf ? function (array, value) {
2253
 
    // TODO: support fromIndex
2254
 
    return Native.indexOf.call(array, value);
2255
 
} : function (array, value) {
2256
 
    for (var i = 0, len = array.length; i < len; ++i) {
2257
 
        if (i in array && array[i] === value) {
2258
 
            return i;
2259
 
        }
2260
 
    }
2261
 
 
2262
 
    return -1;
2263
 
};
2264
 
 
2265
 
/**
2266
 
Numeric sort convenience function.
2267
 
 
2268
 
The native `Array.prototype.sort()` function converts values to strings and
2269
 
sorts them in lexicographic order, which is unsuitable for sorting numeric
2270
 
values. Provide `Array.numericSort` as a custom sort function when you want
2271
 
to sort values in numeric order.
2272
 
 
2273
 
@example
2274
 
 
2275
 
    [42, 23, 8, 16, 4, 15].sort(Y.Array.numericSort);
2276
 
    // => [4, 8, 15, 16, 23, 42]
2277
 
 
2278
 
@method numericSort
2279
 
@param {Number} a First value to compare.
2280
 
@param {Number} b Second value to compare.
2281
 
@return {Number} Difference between _a_ and _b_.
2282
 
@static
2283
 
**/
2284
 
YArray.numericSort = function (a, b) {
2285
 
    return a - b;
2286
 
};
2287
 
 
2288
 
/**
2289
 
Executes the supplied function on each item in the array. Returning a truthy
2290
 
value from the function will stop the processing of remaining items.
2291
 
 
2292
 
@method some
2293
 
@param {Array} array Array to iterate over.
2294
 
@param {Function} fn Function to execute on each item. The function will receive
2295
 
  the following arguments:
2296
 
    @param {Any} fn.value Current array item.
2297
 
    @param {Number} fn.index Current array index.
2298
 
    @param {Array} fn.array Array being iterated over.
2299
 
@param {Object} [thisObj] `this` object to use when calling _fn_.
2300
 
@return {Boolean} `true` if the function returns a truthy value on any of the
2301
 
  items in the array; `false` otherwise.
2302
 
@static
2303
 
**/
2304
 
YArray.some = Native.some ? function (array, fn, thisObj) {
2305
 
    return Native.some.call(array, fn, thisObj);
2306
 
} : function (array, fn, thisObj) {
2307
 
    for (var i = 0, len = array.length; i < len; ++i) {
2308
 
        if (i in array && fn.call(thisObj, array[i], i, array)) {
2309
 
            return true;
2310
 
        }
2311
 
    }
2312
 
 
2313
 
    return false;
2314
 
};
2315
 
 
2316
 
/**
2317
 
Evaluates _obj_ to determine if it's an array, an array-like collection, or
2318
 
something else. This is useful when working with the function `arguments`
2319
 
collection and `HTMLElement` collections.
2320
 
 
2321
 
Note: This implementation doesn't consider elements that are also
2322
 
collections, such as `<form>` and `<select>`, to be array-like.
2323
 
 
2324
 
@method test
2325
 
@param {Object} obj Object to test.
2326
 
@return {Number} A number indicating the results of the test:
2327
 
 
2328
 
  * 0: Neither an array nor an array-like collection.
2329
 
  * 1: Real array.
2330
 
  * 2: Array-like collection.
2331
 
 
2332
 
@static
2333
 
**/
2334
 
YArray.test = function (obj) {
2335
 
    var result = 0;
2336
 
 
2337
 
    if (Lang.isArray(obj)) {
2338
 
        result = 1;
2339
 
    } else if (Lang.isObject(obj)) {
2340
 
        try {
2341
 
            // indexed, but no tagName (element) or alert (window),
2342
 
            // or functions without apply/call (Safari
2343
 
            // HTMLElementCollection bug).
2344
 
            if ('length' in obj && !obj.tagName && !obj.alert && !obj.apply) {
2345
 
                result = 2;
2346
 
            }
2347
 
        } catch (ex) {}
2348
 
    }
2349
 
 
2350
 
    return result;
2351
 
};
2352
 
/**
2353
 
 * The YUI module contains the components required for building the YUI
2354
 
 * seed file.  This includes the script loading mechanism, a simple queue,
2355
 
 * and the core utilities for the library.
2356
 
 * @module yui
2357
 
 * @submodule yui-base
2358
 
 */
2359
 
 
2360
 
/**
2361
 
 * A simple FIFO queue.  Items are added to the Queue with add(1..n items) and
2362
 
 * removed using next().
2363
 
 *
2364
 
 * @class Queue
2365
 
 * @constructor
2366
 
 * @param {MIXED} item* 0..n items to seed the queue.
2367
 
 */
2368
 
function Queue() {
2369
 
    this._init();
2370
 
    this.add.apply(this, arguments);
2371
 
}
2372
 
 
2373
 
Queue.prototype = {
2374
 
    /**
2375
 
     * Initialize the queue
2376
 
     *
2377
 
     * @method _init
2378
 
     * @protected
2379
 
     */
2380
 
    _init: function() {
2381
 
        /**
2382
 
         * The collection of enqueued items
2383
 
         *
2384
 
         * @property _q
2385
 
         * @type Array
2386
 
         * @protected
2387
 
         */
2388
 
        this._q = [];
2389
 
    },
2390
 
 
2391
 
    /**
2392
 
     * Get the next item in the queue. FIFO support
2393
 
     *
2394
 
     * @method next
2395
 
     * @return {MIXED} the next item in the queue.
2396
 
     */
2397
 
    next: function() {
2398
 
        return this._q.shift();
2399
 
    },
2400
 
 
2401
 
    /**
2402
 
     * Get the last in the queue. LIFO support.
2403
 
     *
2404
 
     * @method last
2405
 
     * @return {MIXED} the last item in the queue.
2406
 
     */
2407
 
    last: function() {
2408
 
        return this._q.pop();
2409
 
    },
2410
 
 
2411
 
    /**
2412
 
     * Add 0..n items to the end of the queue.
2413
 
     *
2414
 
     * @method add
2415
 
     * @param {MIXED} item* 0..n items.
2416
 
     * @return {object} this queue.
2417
 
     */
2418
 
    add: function() {
2419
 
        this._q.push.apply(this._q, arguments);
2420
 
 
2421
 
        return this;
2422
 
    },
2423
 
 
2424
 
    /**
2425
 
     * Returns the current number of queued items.
2426
 
     *
2427
 
     * @method size
2428
 
     * @return {Number} The size.
2429
 
     */
2430
 
    size: function() {
2431
 
        return this._q.length;
2432
 
    }
2433
 
};
2434
 
 
2435
 
Y.Queue = Queue;
2436
 
 
2437
 
YUI.Env._loaderQueue = YUI.Env._loaderQueue || new Queue();
2438
 
 
2439
 
/**
2440
 
The YUI module contains the components required for building the YUI seed file.
2441
 
This includes the script loading mechanism, a simple queue, and the core
2442
 
utilities for the library.
2443
 
 
2444
 
@module yui
2445
 
@submodule yui-base
2446
 
**/
2447
 
 
2448
 
var CACHED_DELIMITER = '__',
2449
 
 
2450
 
    hasOwn   = Object.prototype.hasOwnProperty,
2451
 
    isObject = Y.Lang.isObject;
2452
 
 
2453
 
/**
2454
 
Returns a wrapper for a function which caches the return value of that function,
2455
 
keyed off of the combined string representation of the argument values provided
2456
 
when the wrapper is called.
2457
 
 
2458
 
Calling this function again with the same arguments will return the cached value
2459
 
rather than executing the wrapped function.
2460
 
 
2461
 
Note that since the cache is keyed off of the string representation of arguments
2462
 
passed to the wrapper function, arguments that aren't strings and don't provide
2463
 
a meaningful `toString()` method may result in unexpected caching behavior. For
2464
 
example, the objects `{}` and `{foo: 'bar'}` would both be converted to the
2465
 
string `[object Object]` when used as a cache key.
2466
 
 
2467
 
@method cached
2468
 
@param {Function} source The function to memoize.
2469
 
@param {Object} [cache={}] Object in which to store cached values. You may seed
2470
 
  this object with pre-existing cached values if desired.
2471
 
@param {any} [refetch] If supplied, this value is compared with the cached value
2472
 
  using a `==` comparison. If the values are equal, the wrapped function is
2473
 
  executed again even though a cached value exists.
2474
 
@return {Function} Wrapped function.
2475
 
@for YUI
2476
 
**/
2477
 
Y.cached = function (source, cache, refetch) {
2478
 
    cache || (cache = {});
2479
 
 
2480
 
    return function (arg) {
2481
 
        var key = arguments.length > 1 ?
2482
 
                Array.prototype.join.call(arguments, CACHED_DELIMITER) :
2483
 
                String(arg);
2484
 
 
2485
 
        if (!(key in cache) || (refetch && cache[key] == refetch)) {
2486
 
            cache[key] = source.apply(source, arguments);
2487
 
        }
2488
 
 
2489
 
        return cache[key];
2490
 
    };
2491
 
};
2492
 
 
2493
 
/**
2494
 
Returns a new object containing all of the properties of all the supplied
2495
 
objects. The properties from later objects will overwrite those in earlier
2496
 
objects.
2497
 
 
2498
 
Passing in a single object will create a shallow copy of it. For a deep copy,
2499
 
use `clone()`.
2500
 
 
2501
 
@method merge
2502
 
@param {Object} objects* One or more objects to merge.
2503
 
@return {Object} A new merged object.
2504
 
**/
2505
 
Y.merge = function () {
2506
 
    var args   = arguments,
2507
 
        i      = 0,
2508
 
        len    = args.length,
2509
 
        result = {};
2510
 
 
2511
 
    for (; i < len; ++i) {
2512
 
        Y.mix(result, args[i], true);
2513
 
    }
2514
 
 
2515
 
    return result;
2516
 
};
2517
 
 
2518
 
/**
2519
 
Mixes _supplier_'s properties into _receiver_.
2520
 
 
2521
 
Properties on _receiver_ or _receiver_'s prototype will not be overwritten or
2522
 
shadowed unless the _overwrite_ parameter is `true`, and will not be merged
2523
 
unless the _merge_ parameter is `true`.
2524
 
 
2525
 
In the default mode (0), only properties the supplier owns are copied (prototype
2526
 
properties are not copied). The following copying modes are available:
2527
 
 
2528
 
  * `0`: _Default_. Object to object.
2529
 
  * `1`: Prototype to prototype.
2530
 
  * `2`: Prototype to prototype and object to object.
2531
 
  * `3`: Prototype to object.
2532
 
  * `4`: Object to prototype.
2533
 
 
2534
 
@method mix
2535
 
@param {Function|Object} receiver The object or function to receive the mixed
2536
 
  properties.
2537
 
@param {Function|Object} supplier The object or function supplying the
2538
 
  properties to be mixed.
2539
 
@param {Boolean} [overwrite=false] If `true`, properties that already exist
2540
 
  on the receiver will be overwritten with properties from the supplier.
2541
 
@param {String[]} [whitelist] An array of property names to copy. If
2542
 
  specified, only the whitelisted properties will be copied, and all others
2543
 
  will be ignored.
2544
 
@param {Number} [mode=0] Mix mode to use. See above for available modes.
2545
 
@param {Boolean} [merge=false] If `true`, objects and arrays that already
2546
 
  exist on the receiver will have the corresponding object/array from the
2547
 
  supplier merged into them, rather than being skipped or overwritten. When
2548
 
  both _overwrite_ and _merge_ are `true`, _merge_ takes precedence.
2549
 
@return {Function|Object|YUI} The receiver, or the YUI instance if the
2550
 
  specified receiver is falsy.
2551
 
**/
2552
 
Y.mix = function(receiver, supplier, overwrite, whitelist, mode, merge) {
2553
 
    var alwaysOverwrite, exists, from, i, key, len, to;
2554
 
 
2555
 
    // If no supplier is given, we return the receiver. If no receiver is given,
2556
 
    // we return Y. Returning Y doesn't make much sense to me, but it's
2557
 
    // grandfathered in for backcompat reasons.
2558
 
    if (!receiver || !supplier) {
2559
 
        return receiver || Y;
2560
 
    }
2561
 
 
2562
 
    if (mode) {
2563
 
        // In mode 2 (prototype to prototype and object to object), we recurse
2564
 
        // once to do the proto to proto mix. The object to object mix will be
2565
 
        // handled later on.
2566
 
        if (mode === 2) {
2567
 
            Y.mix(receiver.prototype, supplier.prototype, overwrite,
2568
 
                    whitelist, 0, merge);
2569
 
        }
2570
 
 
2571
 
        // Depending on which mode is specified, we may be copying from or to
2572
 
        // the prototypes of the supplier and receiver.
2573
 
        from = mode === 1 || mode === 3 ? supplier.prototype : supplier;
2574
 
        to   = mode === 1 || mode === 4 ? receiver.prototype : receiver;
2575
 
 
2576
 
        // If either the supplier or receiver doesn't actually have a
2577
 
        // prototype property, then we could end up with an undefined `from`
2578
 
        // or `to`. If that happens, we abort and return the receiver.
2579
 
        if (!from || !to) {
2580
 
            return receiver;
2581
 
        }
2582
 
    } else {
2583
 
        from = supplier;
2584
 
        to   = receiver;
2585
 
    }
2586
 
 
2587
 
    // If `overwrite` is truthy and `merge` is falsy, then we can skip a
2588
 
    // property existence check on each iteration and save some time.
2589
 
    alwaysOverwrite = overwrite && !merge;
2590
 
 
2591
 
    if (whitelist) {
2592
 
        for (i = 0, len = whitelist.length; i < len; ++i) {
2593
 
            key = whitelist[i];
2594
 
 
2595
 
            // We call `Object.prototype.hasOwnProperty` instead of calling
2596
 
            // `hasOwnProperty` on the object itself, since the object's
2597
 
            // `hasOwnProperty` method may have been overridden or removed.
2598
 
            // Also, some native objects don't implement a `hasOwnProperty`
2599
 
            // method.
2600
 
            if (!hasOwn.call(from, key)) {
2601
 
                continue;
2602
 
            }
2603
 
 
2604
 
            // The `key in to` check here is (sadly) intentional for backwards
2605
 
            // compatibility reasons. It prevents undesired shadowing of
2606
 
            // prototype members on `to`.
2607
 
            exists = alwaysOverwrite ? false : key in to;
2608
 
 
2609
 
            if (merge && exists && isObject(to[key], true)
2610
 
                    && isObject(from[key], true)) {
2611
 
                // If we're in merge mode, and the key is present on both
2612
 
                // objects, and the value on both objects is either an object or
2613
 
                // an array (but not a function), then we recurse to merge the
2614
 
                // `from` value into the `to` value instead of overwriting it.
2615
 
                //
2616
 
                // Note: It's intentional that the whitelist isn't passed to the
2617
 
                // recursive call here. This is legacy behavior that lots of
2618
 
                // code still depends on.
2619
 
                Y.mix(to[key], from[key], overwrite, null, 0, merge);
2620
 
            } else if (overwrite || !exists) {
2621
 
                // We're not in merge mode, so we'll only copy the `from` value
2622
 
                // to the `to` value if we're in overwrite mode or if the
2623
 
                // current key doesn't exist on the `to` object.
2624
 
                to[key] = from[key];
2625
 
            }
2626
 
        }
2627
 
    } else {
2628
 
        for (key in from) {
2629
 
            // The code duplication here is for runtime performance reasons.
2630
 
            // Combining whitelist and non-whitelist operations into a single
2631
 
            // loop or breaking the shared logic out into a function both result
2632
 
            // in worse performance, and Y.mix is critical enough that the byte
2633
 
            // tradeoff is worth it.
2634
 
            if (!hasOwn.call(from, key)) {
2635
 
                continue;
2636
 
            }
2637
 
 
2638
 
            // The `key in to` check here is (sadly) intentional for backwards
2639
 
            // compatibility reasons. It prevents undesired shadowing of
2640
 
            // prototype members on `to`.
2641
 
            exists = alwaysOverwrite ? false : key in to;
2642
 
 
2643
 
            if (merge && exists && isObject(to[key], true)
2644
 
                    && isObject(from[key], true)) {
2645
 
                Y.mix(to[key], from[key], overwrite, null, 0, merge);
2646
 
            } else if (overwrite || !exists) {
2647
 
                to[key] = from[key];
2648
 
            }
2649
 
        }
2650
 
 
2651
 
        // If this is an IE browser with the JScript enumeration bug, force
2652
 
        // enumeration of the buggy properties by making a recursive call with
2653
 
        // the buggy properties as the whitelist.
2654
 
        if (Y.Object._hasEnumBug) {
2655
 
            Y.mix(to, from, overwrite, Y.Object._forceEnum, mode, merge);
2656
 
        }
2657
 
    }
2658
 
 
2659
 
    return receiver;
2660
 
};
2661
 
/**
2662
 
 * The YUI module contains the components required for building the YUI
2663
 
 * seed file.  This includes the script loading mechanism, a simple queue,
2664
 
 * and the core utilities for the library.
2665
 
 * @module yui
2666
 
 * @submodule yui-base
2667
 
 */
2668
 
 
2669
 
/**
2670
 
 * Adds utilities to the YUI instance for working with objects.
2671
 
 *
2672
 
 * @class Object
2673
 
 */
2674
 
 
2675
 
var hasOwn = Object.prototype.hasOwnProperty,
2676
 
 
2677
 
// If either MooTools or Prototype is on the page, then there's a chance that we
2678
 
// can't trust "native" language features to actually be native. When this is
2679
 
// the case, we take the safe route and fall back to our own non-native
2680
 
// implementations.
2681
 
win           = Y.config.win,
2682
 
unsafeNatives = win && !!(win.MooTools || win.Prototype),
2683
 
 
2684
 
UNDEFINED, // <-- Note the comma. We're still declaring vars.
2685
 
 
2686
 
/**
2687
 
 * Returns a new object that uses _obj_ as its prototype. This method wraps the
2688
 
 * native ES5 `Object.create()` method if available, but doesn't currently
2689
 
 * pass through `Object.create()`'s second argument (properties) in order to
2690
 
 * ensure compatibility with older browsers.
2691
 
 *
2692
 
 * @method ()
2693
 
 * @param {Object} obj Prototype object.
2694
 
 * @return {Object} New object using _obj_ as its prototype.
2695
 
 * @static
2696
 
 */
2697
 
O = Y.Object = (!unsafeNatives && Object.create) ? function (obj) {
2698
 
    // We currently wrap the native Object.create instead of simply aliasing it
2699
 
    // to ensure consistency with our fallback shim, which currently doesn't
2700
 
    // support Object.create()'s second argument (properties). Once we have a
2701
 
    // safe fallback for the properties arg, we can stop wrapping
2702
 
    // Object.create().
2703
 
    return Object.create(obj);
2704
 
} : (function () {
2705
 
    // Reusable constructor function for the Object.create() shim.
2706
 
    function F() {}
2707
 
 
2708
 
    // The actual shim.
2709
 
    return function (obj) {
2710
 
        F.prototype = obj;
2711
 
        return new F();
2712
 
    };
2713
 
}()),
2714
 
 
2715
 
/**
2716
 
 * Property names that IE doesn't enumerate in for..in loops, even when they
2717
 
 * should be enumerable. When `_hasEnumBug` is `true`, it's necessary to
2718
 
 * manually enumerate these properties.
2719
 
 *
2720
 
 * @property _forceEnum
2721
 
 * @type String[]
2722
 
 * @protected
2723
 
 * @static
2724
 
 */
2725
 
forceEnum = O._forceEnum = [
2726
 
    'hasOwnProperty',
2727
 
    'isPrototypeOf',
2728
 
    'propertyIsEnumerable',
2729
 
    'toString',
2730
 
    'toLocaleString',
2731
 
    'valueOf'
2732
 
],
2733
 
 
2734
 
/**
2735
 
 * `true` if this browser has the JScript enumeration bug that prevents
2736
 
 * enumeration of the properties named in the `_forceEnum` array, `false`
2737
 
 * otherwise.
2738
 
 *
2739
 
 * See:
2740
 
 *   - <https://developer.mozilla.org/en/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug>
2741
 
 *   - <http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation>
2742
 
 *
2743
 
 * @property _hasEnumBug
2744
 
 * @type Boolean
2745
 
 * @protected
2746
 
 * @static
2747
 
 */
2748
 
hasEnumBug = O._hasEnumBug = !{valueOf: 0}.propertyIsEnumerable('valueOf'),
2749
 
 
2750
 
/**
2751
 
 * `true` if this browser incorrectly considers the `prototype` property of
2752
 
 * functions to be enumerable. Currently known to affect Opera 11.50.
2753
 
 *
2754
 
 * @property _hasProtoEnumBug
2755
 
 * @type Boolean
2756
 
 * @protected
2757
 
 * @static
2758
 
 */
2759
 
hasProtoEnumBug = O._hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'),
2760
 
 
2761
 
/**
2762
 
 * Returns `true` if _key_ exists on _obj_, `false` if _key_ doesn't exist or
2763
 
 * exists only on _obj_'s prototype. This is essentially a safer version of
2764
 
 * `obj.hasOwnProperty()`.
2765
 
 *
2766
 
 * @method owns
2767
 
 * @param {Object} obj Object to test.
2768
 
 * @param {String} key Property name to look for.
2769
 
 * @return {Boolean} `true` if _key_ exists on _obj_, `false` otherwise.
2770
 
 * @static
2771
 
 */
2772
 
owns = O.owns = function (obj, key) {
2773
 
    return !!obj && hasOwn.call(obj, key);
2774
 
}; // <-- End of var declarations.
2775
 
 
2776
 
/**
2777
 
 * Alias for `owns()`.
2778
 
 *
2779
 
 * @method hasKey
2780
 
 * @param {Object} obj Object to test.
2781
 
 * @param {String} key Property name to look for.
2782
 
 * @return {Boolean} `true` if _key_ exists on _obj_, `false` otherwise.
2783
 
 * @static
2784
 
 */
2785
 
O.hasKey = owns;
2786
 
 
2787
 
/**
2788
 
 * Returns an array containing the object's enumerable keys. Does not include
2789
 
 * prototype keys or non-enumerable keys.
2790
 
 *
2791
 
 * Note that keys are returned in enumeration order (that is, in the same order
2792
 
 * that they would be enumerated by a `for-in` loop), which may not be the same
2793
 
 * as the order in which they were defined.
2794
 
 *
2795
 
 * This method is an alias for the native ES5 `Object.keys()` method if
2796
 
 * available.
2797
 
 *
2798
 
 * @example
2799
 
 *
2800
 
 *     Y.Object.keys({a: 'foo', b: 'bar', c: 'baz'});
2801
 
 *     // => ['a', 'b', 'c']
2802
 
 *
2803
 
 * @method keys
2804
 
 * @param {Object} obj An object.
2805
 
 * @return {String[]} Array of keys.
2806
 
 * @static
2807
 
 */
2808
 
O.keys = (!unsafeNatives && Object.keys) || function (obj) {
2809
 
    if (!Y.Lang.isObject(obj)) {
2810
 
        throw new TypeError('Object.keys called on a non-object');
2811
 
    }
2812
 
 
2813
 
    var keys = [],
2814
 
        i, key, len;
2815
 
 
2816
 
    if (hasProtoEnumBug && typeof obj === 'function') {
2817
 
        for (key in obj) {
2818
 
            if (owns(obj, key) && key !== 'prototype') {
2819
 
                keys.push(key);
2820
 
            }
2821
 
        }
2822
 
    } else {
2823
 
        for (key in obj) {
2824
 
            if (owns(obj, key)) {
2825
 
                keys.push(key);
2826
 
            }
2827
 
        }
2828
 
    }
2829
 
 
2830
 
    if (hasEnumBug) {
2831
 
        for (i = 0, len = forceEnum.length; i < len; ++i) {
2832
 
            key = forceEnum[i];
2833
 
 
2834
 
            if (owns(obj, key)) {
2835
 
                keys.push(key);
2836
 
            }
2837
 
        }
2838
 
    }
2839
 
 
2840
 
    return keys;
2841
 
};
2842
 
 
2843
 
/**
2844
 
 * Returns an array containing the values of the object's enumerable keys.
2845
 
 *
2846
 
 * Note that values are returned in enumeration order (that is, in the same
2847
 
 * order that they would be enumerated by a `for-in` loop), which may not be the
2848
 
 * same as the order in which they were defined.
2849
 
 *
2850
 
 * @example
2851
 
 *
2852
 
 *     Y.Object.values({a: 'foo', b: 'bar', c: 'baz'});
2853
 
 *     // => ['foo', 'bar', 'baz']
2854
 
 *
2855
 
 * @method values
2856
 
 * @param {Object} obj An object.
2857
 
 * @return {Array} Array of values.
2858
 
 * @static
2859
 
 */
2860
 
O.values = function (obj) {
2861
 
    var keys   = O.keys(obj),
2862
 
        i      = 0,
2863
 
        len    = keys.length,
2864
 
        values = [];
2865
 
 
2866
 
    for (; i < len; ++i) {
2867
 
        values.push(obj[keys[i]]);
2868
 
    }
2869
 
 
2870
 
    return values;
2871
 
};
2872
 
 
2873
 
/**
2874
 
 * Returns the number of enumerable keys owned by an object.
2875
 
 *
2876
 
 * @method size
2877
 
 * @param {Object} obj An object.
2878
 
 * @return {Number} The object's size.
2879
 
 * @static
2880
 
 */
2881
 
O.size = function (obj) {
2882
 
    try {
2883
 
        return O.keys(obj).length;
2884
 
    } catch (ex) {
2885
 
        return 0; // Legacy behavior for non-objects.
2886
 
    }
2887
 
};
2888
 
 
2889
 
/**
2890
 
 * Returns `true` if the object owns an enumerable property with the specified
2891
 
 * value.
2892
 
 *
2893
 
 * @method hasValue
2894
 
 * @param {Object} obj An object.
2895
 
 * @param {any} value The value to search for.
2896
 
 * @return {Boolean} `true` if _obj_ contains _value_, `false` otherwise.
2897
 
 * @static
2898
 
 */
2899
 
O.hasValue = function (obj, value) {
2900
 
    return Y.Array.indexOf(O.values(obj), value) > -1;
2901
 
};
2902
 
 
2903
 
/**
2904
 
 * Executes a function on each enumerable property in _obj_. The function
2905
 
 * receives the value, the key, and the object itself as parameters (in that
2906
 
 * order).
2907
 
 *
2908
 
 * By default, only properties owned by _obj_ are enumerated. To include
2909
 
 * prototype properties, set the _proto_ parameter to `true`.
2910
 
 *
2911
 
 * @method each
2912
 
 * @param {Object} obj Object to enumerate.
2913
 
 * @param {Function} fn Function to execute on each enumerable property.
2914
 
 *   @param {mixed} fn.value Value of the current property.
2915
 
 *   @param {String} fn.key Key of the current property.
2916
 
 *   @param {Object} fn.obj Object being enumerated.
2917
 
 * @param {Object} [thisObj] `this` object to use when calling _fn_.
2918
 
 * @param {Boolean} [proto=false] Include prototype properties.
2919
 
 * @return {YUI} the YUI instance.
2920
 
 * @chainable
2921
 
 * @static
2922
 
 */
2923
 
O.each = function (obj, fn, thisObj, proto) {
2924
 
    var key;
2925
 
 
2926
 
    for (key in obj) {
2927
 
        if (proto || owns(obj, key)) {
2928
 
            fn.call(thisObj || Y, obj[key], key, obj);
2929
 
        }
2930
 
    }
2931
 
 
2932
 
    return Y;
2933
 
};
2934
 
 
2935
 
/**
2936
 
 * Executes a function on each enumerable property in _obj_, but halts if the
2937
 
 * function returns a truthy value. The function receives the value, the key,
2938
 
 * and the object itself as paramters (in that order).
2939
 
 *
2940
 
 * By default, only properties owned by _obj_ are enumerated. To include
2941
 
 * prototype properties, set the _proto_ parameter to `true`.
2942
 
 *
2943
 
 * @method some
2944
 
 * @param {Object} obj Object to enumerate.
2945
 
 * @param {Function} fn Function to execute on each enumerable property.
2946
 
 *   @param {mixed} fn.value Value of the current property.
2947
 
 *   @param {String} fn.key Key of the current property.
2948
 
 *   @param {Object} fn.obj Object being enumerated.
2949
 
 * @param {Object} [thisObj] `this` object to use when calling _fn_.
2950
 
 * @param {Boolean} [proto=false] Include prototype properties.
2951
 
 * @return {Boolean} `true` if any execution of _fn_ returns a truthy value,
2952
 
 *   `false` otherwise.
2953
 
 * @static
2954
 
 */
2955
 
O.some = function (obj, fn, thisObj, proto) {
2956
 
    var key;
2957
 
 
2958
 
    for (key in obj) {
2959
 
        if (proto || owns(obj, key)) {
2960
 
            if (fn.call(thisObj || Y, obj[key], key, obj)) {
2961
 
                return true;
2962
 
            }
2963
 
        }
2964
 
    }
2965
 
 
2966
 
    return false;
2967
 
};
2968
 
 
2969
 
/**
2970
 
 * Retrieves the sub value at the provided path,
2971
 
 * from the value object provided.
2972
 
 *
2973
 
 * @method getValue
2974
 
 * @static
2975
 
 * @param o The object from which to extract the property value.
2976
 
 * @param path {Array} A path array, specifying the object traversal path
2977
 
 * from which to obtain the sub value.
2978
 
 * @return {Any} The value stored in the path, undefined if not found,
2979
 
 * undefined if the source is not an object.  Returns the source object
2980
 
 * if an empty path is provided.
2981
 
 */
2982
 
O.getValue = function(o, path) {
2983
 
    if (!Y.Lang.isObject(o)) {
2984
 
        return UNDEFINED;
2985
 
    }
2986
 
 
2987
 
    var i,
2988
 
        p = Y.Array(path),
2989
 
        l = p.length;
2990
 
 
2991
 
    for (i = 0; o !== UNDEFINED && i < l; i++) {
2992
 
        o = o[p[i]];
2993
 
    }
2994
 
 
2995
 
    return o;
2996
 
};
2997
 
 
2998
 
/**
2999
 
 * Sets the sub-attribute value at the provided path on the
3000
 
 * value object.  Returns the modified value object, or
3001
 
 * undefined if the path is invalid.
3002
 
 *
3003
 
 * @method setValue
3004
 
 * @static
3005
 
 * @param o             The object on which to set the sub value.
3006
 
 * @param path {Array}  A path array, specifying the object traversal path
3007
 
 *                      at which to set the sub value.
3008
 
 * @param val {Any}     The new value for the sub-attribute.
3009
 
 * @return {Object}     The modified object, with the new sub value set, or
3010
 
 *                      undefined, if the path was invalid.
3011
 
 */
3012
 
O.setValue = function(o, path, val) {
3013
 
    var i,
3014
 
        p = Y.Array(path),
3015
 
        leafIdx = p.length - 1,
3016
 
        ref = o;
3017
 
 
3018
 
    if (leafIdx >= 0) {
3019
 
        for (i = 0; ref !== UNDEFINED && i < leafIdx; i++) {
3020
 
            ref = ref[p[i]];
3021
 
        }
3022
 
 
3023
 
        if (ref !== UNDEFINED) {
3024
 
            ref[p[i]] = val;
3025
 
        } else {
3026
 
            return UNDEFINED;
3027
 
        }
3028
 
    }
3029
 
 
3030
 
    return o;
3031
 
};
3032
 
 
3033
 
/**
3034
 
 * Returns `true` if the object has no enumerable properties of its own.
3035
 
 *
3036
 
 * @method isEmpty
3037
 
 * @param {Object} obj An object.
3038
 
 * @return {Boolean} `true` if the object is empty.
3039
 
 * @static
3040
 
 * @since 3.2.0
3041
 
 */
3042
 
O.isEmpty = function (obj) {
3043
 
    return !O.keys(obj).length;
3044
 
};
3045
 
/**
3046
 
 * The YUI module contains the components required for building the YUI seed
3047
 
 * file.  This includes the script loading mechanism, a simple queue, and the
3048
 
 * core utilities for the library.
3049
 
 * @module yui
3050
 
 * @submodule yui-base
3051
 
 */
3052
 
 
3053
 
/**
3054
 
 * YUI user agent detection.
3055
 
 * Do not fork for a browser if it can be avoided.  Use feature detection when
3056
 
 * you can.  Use the user agent as a last resort.  For all fields listed
3057
 
 * as @type float, UA stores a version number for the browser engine,
3058
 
 * 0 otherwise.  This value may or may not map to the version number of
3059
 
 * the browser using the engine.  The value is presented as a float so
3060
 
 * that it can easily be used for boolean evaluation as well as for
3061
 
 * looking for a particular range of versions.  Because of this,
3062
 
 * some of the granularity of the version info may be lost.  The fields that
3063
 
 * are @type string default to null.  The API docs list the values that
3064
 
 * these fields can have.
3065
 
 * @class UA
3066
 
 * @static
3067
 
 */
3068
 
 
3069
 
/**
3070
 
* Static method on `YUI.Env` for parsing a UA string.  Called at instantiation
3071
 
* to populate `Y.UA`.
3072
 
*
3073
 
* @static
3074
 
* @method parseUA
3075
 
* @param {String} [subUA=navigator.userAgent] UA string to parse
3076
 
* @returns {Object} The Y.UA object
3077
 
*/
3078
 
YUI.Env.parseUA = function(subUA) {
3079
 
 
3080
 
    var numberify = function(s) {
3081
 
            var c = 0;
3082
 
            return parseFloat(s.replace(/\./g, function() {
3083
 
                return (c++ == 1) ? '' : '.';
3084
 
            }));
3085
 
        },
3086
 
 
3087
 
        win = Y.config.win,
3088
 
 
3089
 
        nav = win && win.navigator,
3090
 
 
3091
 
        o = {
3092
 
 
3093
 
        /**
3094
 
         * Internet Explorer version number or 0.  Example: 6
3095
 
         * @property ie
3096
 
         * @type float
3097
 
         * @static
3098
 
         */
3099
 
        ie: 0,
3100
 
 
3101
 
        /**
3102
 
         * Opera version number or 0.  Example: 9.2
3103
 
         * @property opera
3104
 
         * @type float
3105
 
         * @static
3106
 
         */
3107
 
        opera: 0,
3108
 
 
3109
 
        /**
3110
 
         * Gecko engine revision number.  Will evaluate to 1 if Gecko
3111
 
         * is detected but the revision could not be found. Other browsers
3112
 
         * will be 0.  Example: 1.8
3113
 
         * <pre>
3114
 
         * Firefox 1.0.0.4: 1.7.8   <-- Reports 1.7
3115
 
         * Firefox 1.5.0.9: 1.8.0.9 <-- 1.8
3116
 
         * Firefox 2.0.0.3: 1.8.1.3 <-- 1.81
3117
 
         * Firefox 3.0   <-- 1.9
3118
 
         * Firefox 3.5   <-- 1.91
3119
 
         * </pre>
3120
 
         * @property gecko
3121
 
         * @type float
3122
 
         * @static
3123
 
         */
3124
 
        gecko: 0,
3125
 
 
3126
 
        /**
3127
 
         * AppleWebKit version.  KHTML browsers that are not WebKit browsers
3128
 
         * will evaluate to 1, other browsers 0.  Example: 418.9
3129
 
         * <pre>
3130
 
         * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
3131
 
         *                                   latest available for Mac OSX 10.3.
3132
 
         * Safari 2.0.2:         416     <-- hasOwnProperty introduced
3133
 
         * Safari 2.0.4:         418     <-- preventDefault fixed
3134
 
         * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
3135
 
         *                                   different versions of webkit
3136
 
         * Safari 2.0.4 (419.3): 419     <-- Tiger installations that have been
3137
 
         *                                   updated, but not updated
3138
 
         *                                   to the latest patch.
3139
 
         * Webkit 212 nightly:   522+    <-- Safari 3.0 precursor (with native
3140
 
         * SVG and many major issues fixed).
3141
 
         * Safari 3.0.4 (523.12) 523.12  <-- First Tiger release - automatic
3142
 
         * update from 2.x via the 10.4.11 OS patch.
3143
 
         * Webkit nightly 1/2008:525+    <-- Supports DOMContentLoaded event.
3144
 
         *                                   yahoo.com user agent hack removed.
3145
 
         * </pre>
3146
 
         * http://en.wikipedia.org/wiki/Safari_version_history
3147
 
         * @property webkit
3148
 
         * @type float
3149
 
         * @static
3150
 
         */
3151
 
        webkit: 0,
3152
 
 
3153
 
        /**
3154
 
         * Safari will be detected as webkit, but this property will also
3155
 
         * be populated with the Safari version number
3156
 
         * @property safari
3157
 
         * @type float
3158
 
         * @static
3159
 
         */
3160
 
        safari: 0,
3161
 
 
3162
 
        /**
3163
 
         * Chrome will be detected as webkit, but this property will also
3164
 
         * be populated with the Chrome version number
3165
 
         * @property chrome
3166
 
         * @type float
3167
 
         * @static
3168
 
         */
3169
 
        chrome: 0,
3170
 
 
3171
 
        /**
3172
 
         * The mobile property will be set to a string containing any relevant
3173
 
         * user agent information when a modern mobile browser is detected.
3174
 
         * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series
3175
 
         * devices with the WebKit-based browser, and Opera Mini.
3176
 
         * @property mobile
3177
 
         * @type string
3178
 
         * @default null
3179
 
         * @static
3180
 
         */
3181
 
        mobile: null,
3182
 
 
3183
 
        /**
3184
 
         * Adobe AIR version number or 0.  Only populated if webkit is detected.
3185
 
         * Example: 1.0
3186
 
         * @property air
3187
 
         * @type float
3188
 
         */
3189
 
        air: 0,
3190
 
        /**
3191
 
         * Detects Apple iPad's OS version
3192
 
         * @property ipad
3193
 
         * @type float
3194
 
         * @static
3195
 
         */
3196
 
        ipad: 0,
3197
 
        /**
3198
 
         * Detects Apple iPhone's OS version
3199
 
         * @property iphone
3200
 
         * @type float
3201
 
         * @static
3202
 
         */
3203
 
        iphone: 0,
3204
 
        /**
3205
 
         * Detects Apples iPod's OS version
3206
 
         * @property ipod
3207
 
         * @type float
3208
 
         * @static
3209
 
         */
3210
 
        ipod: 0,
3211
 
        /**
3212
 
         * General truthy check for iPad, iPhone or iPod
3213
 
         * @property ios
3214
 
         * @type float
3215
 
         * @default null
3216
 
         * @static
3217
 
         */
3218
 
        ios: null,
3219
 
        /**
3220
 
         * Detects Googles Android OS version
3221
 
         * @property android
3222
 
         * @type float
3223
 
         * @static
3224
 
         */
3225
 
        android: 0,
3226
 
        /**
3227
 
         * Detects Palms WebOS version
3228
 
         * @property webos
3229
 
         * @type float
3230
 
         * @static
3231
 
         */
3232
 
        webos: 0,
3233
 
 
3234
 
        /**
3235
 
         * Google Caja version number or 0.
3236
 
         * @property caja
3237
 
         * @type float
3238
 
         */
3239
 
        caja: nav && nav.cajaVersion,
3240
 
 
3241
 
        /**
3242
 
         * Set to true if the page appears to be in SSL
3243
 
         * @property secure
3244
 
         * @type boolean
3245
 
         * @static
3246
 
         */
3247
 
        secure: false,
3248
 
 
3249
 
        /**
3250
 
         * The operating system.  Currently only detecting windows or macintosh
3251
 
         * @property os
3252
 
         * @type string
3253
 
         * @default null
3254
 
         * @static
3255
 
         */
3256
 
        os: null
3257
 
 
3258
 
    },
3259
 
 
3260
 
    ua = subUA || nav && nav.userAgent,
3261
 
 
3262
 
    loc = win && win.location,
3263
 
 
3264
 
    href = loc && loc.href,
3265
 
 
3266
 
    m;
3267
 
 
3268
 
    /**
3269
 
    * The User Agent string that was parsed
3270
 
    * @property userAgent
3271
 
    * @type String
3272
 
    * @static
3273
 
    */
3274
 
    o.userAgent = ua;
3275
 
 
3276
 
 
3277
 
    o.secure = href && (href.toLowerCase().indexOf('https') === 0);
3278
 
 
3279
 
    if (ua) {
3280
 
 
3281
 
        if ((/windows|win32/i).test(ua)) {
3282
 
            o.os = 'windows';
3283
 
        } else if ((/macintosh/i).test(ua)) {
3284
 
            o.os = 'macintosh';
3285
 
        } else if ((/rhino/i).test(ua)) {
3286
 
            o.os = 'rhino';
3287
 
        }
3288
 
 
3289
 
        // Modern KHTML browsers should qualify as Safari X-Grade
3290
 
        if ((/KHTML/).test(ua)) {
3291
 
            o.webkit = 1;
3292
 
        }
3293
 
        // Modern WebKit browsers are at least X-Grade
3294
 
        m = ua.match(/AppleWebKit\/([^\s]*)/);
3295
 
        if (m && m[1]) {
3296
 
            o.webkit = numberify(m[1]);
3297
 
            o.safari = o.webkit;
3298
 
 
3299
 
            // Mobile browser check
3300
 
            if (/ Mobile\//.test(ua)) {
3301
 
                o.mobile = 'Apple'; // iPhone or iPod Touch
3302
 
 
3303
 
                m = ua.match(/OS ([^\s]*)/);
3304
 
                if (m && m[1]) {
3305
 
                    m = numberify(m[1].replace('_', '.'));
3306
 
                }
3307
 
                o.ios = m;
3308
 
                o.ipad = o.ipod = o.iphone = 0;
3309
 
 
3310
 
                m = ua.match(/iPad|iPod|iPhone/);
3311
 
                if (m && m[0]) {
3312
 
                    o[m[0].toLowerCase()] = o.ios;
3313
 
                }
3314
 
            } else {
3315
 
                m = ua.match(/NokiaN[^\/]*|webOS\/\d\.\d/);
3316
 
                if (m) {
3317
 
                    // Nokia N-series, webOS, ex: NokiaN95
3318
 
                    o.mobile = m[0];
3319
 
                }
3320
 
                if (/webOS/.test(ua)) {
3321
 
                    o.mobile = 'WebOS';
3322
 
                    m = ua.match(/webOS\/([^\s]*);/);
3323
 
                    if (m && m[1]) {
3324
 
                        o.webos = numberify(m[1]);
3325
 
                    }
3326
 
                }
3327
 
                if (/ Android/.test(ua)) {
3328
 
                    if (/Mobile/.test(ua)) {
3329
 
                        o.mobile = 'Android';
3330
 
                    }
3331
 
                    m = ua.match(/Android ([^\s]*);/);
3332
 
                    if (m && m[1]) {
3333
 
                        o.android = numberify(m[1]);
3334
 
                    }
3335
 
 
3336
 
                }
3337
 
            }
3338
 
 
3339
 
            m = ua.match(/Chrome\/([^\s]*)/);
3340
 
            if (m && m[1]) {
3341
 
                o.chrome = numberify(m[1]); // Chrome
3342
 
                o.safari = 0; //Reset safari back to 0
3343
 
            } else {
3344
 
                m = ua.match(/AdobeAIR\/([^\s]*)/);
3345
 
                if (m) {
3346
 
                    o.air = m[0]; // Adobe AIR 1.0 or better
3347
 
                }
3348
 
            }
3349
 
        }
3350
 
 
3351
 
        if (!o.webkit) { // not webkit
3352
 
// @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
3353
 
            m = ua.match(/Opera[\s\/]([^\s]*)/);
3354
 
            if (m && m[1]) {
3355
 
                o.opera = numberify(m[1]);
3356
 
                m = ua.match(/Version\/([^\s]*)/);
3357
 
                if (m && m[1]) {
3358
 
                    o.opera = numberify(m[1]); // opera 10+
3359
 
                }
3360
 
 
3361
 
                m = ua.match(/Opera Mini[^;]*/);
3362
 
 
3363
 
                if (m) {
3364
 
                    o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
3365
 
                }
3366
 
            } else { // not opera or webkit
3367
 
                m = ua.match(/MSIE\s([^;]*)/);
3368
 
                if (m && m[1]) {
3369
 
                    o.ie = numberify(m[1]);
3370
 
                } else { // not opera, webkit, or ie
3371
 
                    m = ua.match(/Gecko\/([^\s]*)/);
3372
 
                    if (m) {
3373
 
                        o.gecko = 1; // Gecko detected, look for revision
3374
 
                        m = ua.match(/rv:([^\s\)]*)/);
3375
 
                        if (m && m[1]) {
3376
 
                            o.gecko = numberify(m[1]);
3377
 
                        }
3378
 
                    }
3379
 
                }
3380
 
            }
3381
 
        }
3382
 
    }
3383
 
 
3384
 
    //It was a parsed UA, do not assign the global value.
3385
 
    if (!subUA) {
3386
 
        YUI.Env.UA = o;
3387
 
    }
3388
 
 
3389
 
    return o;
3390
 
};
3391
 
 
3392
 
 
3393
 
Y.UA = YUI.Env.UA || YUI.Env.parseUA();
3394
 
YUI.Env.aliases = {
3395
 
    "anim": ["anim-base","anim-color","anim-curve","anim-easing","anim-node-plugin","anim-scroll","anim-xy"],
3396
 
    "app": ["controller","model","model-list","view"],
3397
 
    "attribute": ["attribute-base","attribute-complex"],
3398
 
    "autocomplete": ["autocomplete-base","autocomplete-sources","autocomplete-list","autocomplete-plugin"],
3399
 
    "base": ["base-base","base-pluginhost","base-build"],
3400
 
    "cache": ["cache-base","cache-offline","cache-plugin"],
3401
 
    "collection": ["array-extras","arraylist","arraylist-add","arraylist-filter","array-invoke"],
3402
 
    "dataschema": ["dataschema-base","dataschema-json","dataschema-xml","dataschema-array","dataschema-text"],
3403
 
    "datasource": ["datasource-local","datasource-io","datasource-get","datasource-function","datasource-cache","datasource-jsonschema","datasource-xmlschema","datasource-arrayschema","datasource-textschema","datasource-polling"],
3404
 
    "datatable": ["datatable-base","datatable-datasource","datatable-sort","datatable-scroll"],
3405
 
    "datatype": ["datatype-number","datatype-date","datatype-xml"],
3406
 
    "datatype-date": ["datatype-date-parse","datatype-date-format"],
3407
 
    "datatype-number": ["datatype-number-parse","datatype-number-format"],
3408
 
    "datatype-xml": ["datatype-xml-parse","datatype-xml-format"],
3409
 
    "dd": ["dd-ddm-base","dd-ddm","dd-ddm-drop","dd-drag","dd-proxy","dd-constrain","dd-drop","dd-scroll","dd-delegate"],
3410
 
    "dom": ["dom-base","dom-screen","dom-style","selector-native","selector"],
3411
 
    "editor": ["frame","selection","exec-command","editor-base","editor-para","editor-br","editor-bidi","editor-tab","createlink-base"],
3412
 
    "event": ["event-base","event-delegate","event-synthetic","event-mousewheel","event-mouseenter","event-key","event-focus","event-resize","event-hover","event-outside"],
3413
 
    "event-custom": ["event-custom-base","event-custom-complex"],
3414
 
    "event-gestures": ["event-flick","event-move"],
3415
 
    "highlight": ["highlight-base","highlight-accentfold"],
3416
 
    "history": ["history-base","history-hash","history-hash-ie","history-html5"],
3417
 
    "io": ["io-base","io-xdr","io-form","io-upload-iframe","io-queue"],
3418
 
    "json": ["json-parse","json-stringify"],
3419
 
    "loader": ["loader-base","loader-rollup","loader-yui3"],
3420
 
    "node": ["node-base","node-event-delegate","node-pluginhost","node-screen","node-style"],
3421
 
    "pluginhost": ["pluginhost-base","pluginhost-config"],
3422
 
    "querystring": ["querystring-parse","querystring-stringify"],
3423
 
    "recordset": ["recordset-base","recordset-sort","recordset-filter","recordset-indexer"],
3424
 
    "resize": ["resize-base","resize-proxy","resize-constrain"],
3425
 
    "slider": ["slider-base","slider-value-range","clickable-rail","range-slider"],
3426
 
    "text": ["text-accentfold","text-wordbreak"],
3427
 
    "widget": ["widget-base","widget-htmlparser","widget-uievents","widget-skin"]
3428
 
};
3429
 
 
3430
 
 
3431
 
}, '3.4.1' );