~ted/lazr-js/annoying-debug-message

« back to all changes in this revision

Viewing changes to src-js/lazrjs/yui/yui/yui-base-debug.js

  • Committer: Launchpad Patch Queue Manager
  • Date: 2010-09-09 14:20:30 UTC
  • mfrom: (182.1.3 yui-3.2)
  • Revision ID: launchpad@pqm.canonical.com-20100909142030-13w6vo0ixfysxc15
[r=beuno] Update lazr-js to yui-3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3
3
Code licensed under the BSD License:
4
4
http://developer.yahoo.com/yui/license.html
5
 
version: 3.1.2
6
 
build: 56
 
5
version: 3.2.0
 
6
build: 2676
7
7
*/
8
8
/**
9
9
 * The YUI module contains the components required for building the YUI seed file.
12
12
 * @submodule yui-base
13
13
 */
14
14
 
15
 
if (typeof YUI === 'undefined') {
 
15
if (typeof YUI != 'undefined') {
 
16
    var _YUI = YUI;
 
17
}
16
18
 
17
19
/**
18
20
 * The YUI global namespace object.  If YUI is already defined, the
33
35
    /*global YUI*/
34
36
    /*global YUI_config*/
35
37
    var YUI = function() {
36
 
 
37
 
        var Y = this, a = arguments, i, l = a.length,
38
 
            globalConfig = (typeof YUI_config !== 'undefined') && YUI_config;
39
 
 
40
 
        // Allow instantiation without the new operator
 
38
        var i     = 0, 
 
39
            Y     = this, 
 
40
            args  = arguments, 
 
41
            l     = args.length, 
 
42
            gconf = (typeof YUI_config !== 'undefined') && YUI_config;
 
43
 
41
44
        if (!(Y instanceof YUI)) {
42
45
            Y = new YUI();
43
 
            for (i=0; i<l; i++) {
44
 
                Y._config(a[i]);
45
 
            }
46
 
            return Y; 
47
46
        } else {
48
47
            // set up the core environment
49
48
            Y._init();
50
 
            if (globalConfig) {
51
 
                Y._config(globalConfig);
52
 
            }
53
 
            for (i=0; i<l; i++) {
54
 
                Y._config(a[i]);
 
49
            if (gconf) {
 
50
                Y.applyConfig(gconf);
55
51
            }
56
52
            // bind the specified additional modules for this instance
 
53
            if (!l) {
 
54
                Y._setup();
 
55
            }
 
56
        }
 
57
 
 
58
        if (l) {
 
59
            for (; i<l; i++) {
 
60
                Y.applyConfig(args[i]);
 
61
            }
 
62
 
57
63
            Y._setup();
58
 
            return Y;
59
64
        }
 
65
 
 
66
        return Y;
60
67
    };
61
 
}
62
68
 
63
69
(function() {
64
 
    var p, prop,
65
 
        VERSION       = '3.1.2', 
 
70
    var proto, prop,
 
71
        VERSION       = '3.2.0', 
66
72
        BASE          = 'http://yui.yahooapis.com/',
67
73
        DOC_LABEL     = 'yui3-js-enabled',
68
74
        NOOP          = function() {},
100
106
                            if (hasWin) {
101
107
                                remove(window, 'load', handleLoad);
102
108
                            }
103
 
                        };
 
109
                        },
 
110
        getLoader = function(Y, o) {
 
111
            var loader = Y.Env._loader;
 
112
            if (loader) {
 
113
                loader.ignoreRegistered = false;
 
114
                loader.onEnd            = null;
 
115
                // loader.attaching        = null;
 
116
                loader.data             = null;
 
117
                loader.required         = [];
 
118
                loader.loadType         = null;
 
119
                // loader._inspectPage();
 
120
            } else {
 
121
                loader = new Y.Loader(Y.config);
 
122
                Y.Env._loader = loader;
 
123
            }
 
124
 
 
125
            return loader;
 
126
        },
 
127
        
 
128
        clobber = function(r, s) {
 
129
            for (var i in s) {
 
130
                if (s.hasOwnProperty(i)) {
 
131
                    r[i] = s[i];
 
132
                }
 
133
            }
 
134
        };
104
135
 
105
136
//  Stamp the documentElement (HTML) with a class of "yui-loaded" to 
106
137
//  enable styles that need to key off of JS being enabled.
113
144
}
114
145
 
115
146
if (VERSION.indexOf('@') > -1) {
116
 
    VERSION = '3.0.0'; // dev time hack for cdn test
 
147
    VERSION = '3.2.0pr1'; // dev time hack for cdn test
117
148
}
118
149
        
119
 
YUI.prototype = {
120
 
    _config: function(o) {
121
 
        o = o || {};
 
150
proto = {
 
151
    /**
 
152
     * Applies a new configuration object to the YUI instance config.
 
153
     * This will merge new group/module definitions, and will also
 
154
     * update the loader cache if necessary.  Updating Y.config directly
 
155
     * will not update the cache.
 
156
     * @method applyConfig
 
157
     * @param the configuration object
 
158
     * @since 3.2.0
 
159
     */
 
160
    applyConfig: function(o) {
 
161
 
 
162
        o = o || NOOP;
 
163
        
122
164
        var attr,
123
165
            name, 
124
 
            detail,
 
166
            // detail,
125
167
            config = this.config, 
126
168
            mods   = config.modules,
127
 
            groups = config.groups;
 
169
            groups = config.groups,
 
170
            rls    = config.rls,
 
171
            loader = this.Env._loader;
 
172
 
128
173
        for (name in o) {
129
 
            attr = o[name];
130
 
            if (mods && name == 'modules') {
131
 
                for (detail in attr) {
132
 
                    mods[detail] = attr[detail];
133
 
                }
134
 
            } else if (groups && name == 'groups') {
135
 
                for (detail in attr) {
136
 
                    groups[detail] = attr[detail];
137
 
                }
138
 
            } else if (name == 'win') {
139
 
                config[name] = attr.contentWindow || attr;
140
 
                config.doc = config[name].document;
141
 
            } else {
142
 
                config[name] = attr;
 
174
            if (o.hasOwnProperty(name)) {
 
175
                attr = o[name];
 
176
                if (mods && name == 'modules') {
 
177
                    clobber(mods, attr);
 
178
                } else if (groups && name == 'groups') {
 
179
                    clobber(groups, attr);
 
180
                } else if (rls && name == 'rls') {
 
181
                    clobber(rls, attr);
 
182
                } else if (name == 'win') {
 
183
                    config[name] = attr.contentWindow || attr;
 
184
                    config.doc = config[name].document;
 
185
                } else if (name == '_yuid') {
 
186
                    // preserve the guid
 
187
                } else {
 
188
                    config[name] = attr;
 
189
                }
143
190
            }
144
191
        }
 
192
 
 
193
        if (loader) {
 
194
            loader._config(o);
 
195
        }
 
196
    },
 
197
 
 
198
    _config: function(o) {
 
199
        this.applyConfig(o);
145
200
    },
146
201
 
147
202
    /**
150
205
     */
151
206
    _init: function() {
152
207
        var filter,
153
 
            Y     = this, 
154
 
            G_ENV = YUI.Env,
155
 
            Env   = Y.Env;
 
208
            Y       = this, 
 
209
            G_ENV   = YUI.Env,
 
210
            Env     = Y.Env,
 
211
            prop, config;
156
212
 
157
213
        Y.version = VERSION;
158
214
 
159
215
        if (!Env) {
160
216
            Y.Env = {
161
 
                mods:         {},
 
217
                mods:         {}, // flat module map
 
218
                versions:     {}, // version module map
162
219
                base:         BASE,
163
220
                cdn:          BASE + VERSION + '/build/',
164
 
                bootstrapped: false,
 
221
                // bootstrapped: false,
165
222
                _idx:         0,
166
223
                _used:        {},
167
224
                _attached:    {},
169
226
                _uidx:        0,
170
227
                _guidp:       'y',
171
228
                _loaded:      {},
172
 
                getBase: function(srcPattern, comboPattern) {
 
229
                getBase: G_ENV && G_ENV.getBase || function(srcPattern, comboPattern) {
173
230
                    var b, nodes, i, src, match;
174
231
                    // get from querystring
175
232
                    nodes = (doc && doc.getElementsByTagName('script')) || [];
176
233
                    for (i=0; i<nodes.length; i=i+1) {
177
234
                        src = nodes[i].src;
178
235
                        if (src) {
179
 
                            //src = "http://yui.yahooapis.com/combo?2.8.0r4/b
180
 
                            //uild/yuiloader-dom-event/yuiloader-dom-event.js
181
 
                            //&3.0.0/build/yui/yui-min.js"; // debug url
182
 
                            //Y.log('src) ' + src);
 
236
 
183
237
                            match = src.match(srcPattern);
184
238
                            b = match && match[1];
185
239
                            if (b) {
186
240
                                // this is to set up the path to the loader.  The file 
187
241
                                // filter for loader should match the yui include.
188
242
                                filter = match[2];
 
243
 
 
244
                                if (filter) {
 
245
                                    match = filter.indexOf('js');
 
246
 
 
247
                                    if (match > -1) {
 
248
                                        filter = filter.substr(0, match);
 
249
                                    }
 
250
                                }
 
251
 
189
252
                                // extract correct path for mixed combo urls
190
253
                                // http://yuilibrary.com/projects/yui3/ticket/2528423
191
254
                                match = src.match(comboPattern);
211
274
                Env._yidx  = ++G_ENV._yidx;
212
275
                Env._guidp = ('yui_' + VERSION + '_' + 
213
276
                             Env._yidx + '_' + time).replace(/\./g, '_');
 
277
            } else if (typeof _YUI != 'undefined') {
 
278
 
 
279
                G_ENV = _YUI.Env;
 
280
                Env._yidx += G_ENV._yidx;
 
281
                Env._uidx += G_ENV._uidx;
 
282
                
 
283
                for (prop in G_ENV) {
 
284
                    if (!(prop in Env)) {
 
285
                        Env[prop] = G_ENV[prop];
 
286
                    }
 
287
                }
214
288
            }
215
289
 
216
290
            Y.id = Y.stamp(Y);
222
296
 
223
297
        // configuration defaults
224
298
        Y.config = Y.config || {
 
299
            // _sig:              '',
225
300
            win:               win,
226
301
            doc:               doc,
227
302
            debug:             true,
231
306
            fetchCSS:          true
232
307
        };
233
308
 
234
 
        Y.config.base = YUI.config.base || 
 
309
        config = Y.config;
 
310
 
 
311
 
 
312
        config.base = YUI.config.base || 
235
313
            Y.Env.getBase(/^(.*)yui\/yui([\.\-].*)js(\?.*)?$/, 
236
314
                          /^(.*\?)(.*\&)(.*)yui\/yui[\.\-].*js(\?.*)?$/);
237
315
 
238
 
        Y.config.loaderPath = YUI.config.loaderPath || 
 
316
        config.loaderPath = YUI.config.loaderPath || 
239
317
            'loader/loader' + (filter || '-min.') + 'js';
240
318
 
241
319
    },
242
 
    
 
320
 
243
321
    /**
244
322
     * Finishes the instance setup. Attaches whatever modules were defined
245
323
     * when the yui modules was registered.
247
325
     * @private
248
326
     */
249
327
    _setup: function(o) {
250
 
 
251
328
        var i, Y = this,
252
329
            core = [],
253
330
            mods = YUI.Env.mods,
254
 
            extras = Y.config.core || ['get', 'intl-base', 'loader', 'yui-log', 'yui-later', 'yui-throttle'];
255
 
 
 
331
            extras = Y.config.core || [ 'get', 
 
332
                                        'rls', 
 
333
                                        'intl-base', 
 
334
                                        'loader', 
 
335
                                        'yui-log', 
 
336
                                        'yui-later', 
 
337
                                        'yui-throttle' ];
256
338
 
257
339
        for (i=0; i<extras.length; i++) {
258
340
            if (mods[extras[i]]) {
260
342
            }
261
343
        }
262
344
 
263
 
        Y.use('yui-base');
264
 
        Y.use.apply(Y, core);
 
345
        Y._attach(['yui-base']);
 
346
        Y._attach(core);
265
347
 
266
348
        // Y.log(Y.id + ' initialized', 'info', 'yui');
267
349
    },
277
359
     * @return {object} the return value from the applied method or null
278
360
     */
279
361
    applyTo: function(id, method, args) {
280
 
 
281
362
        if (!(method in APPLY_TO_AUTH)) {
282
363
            this.log(method + ': applyTo not allowed', 'warn', 'yui');
283
364
            return null;
328
409
     */
329
410
    add: function(name, fn, version, details) {
330
411
        details = details || {};
331
 
 
332
 
        YUI.Env.mods[name] = {
333
 
            name: name, 
334
 
            fn: fn,
335
 
            version: version,
336
 
            details: details
337
 
        };
 
412
        var env = YUI.Env,
 
413
            mod  = {
 
414
                name: name, 
 
415
                fn: fn,
 
416
                version: version,
 
417
                details: details
 
418
            },
 
419
            loader,
 
420
            i;
 
421
 
 
422
        env.mods[name] = mod;
 
423
        env.versions[version] = env.versions[version] || {};
 
424
        env.versions[version][name] = mod;
 
425
 
 
426
        for (i in instances) {
 
427
            if (instances.hasOwnProperty(i)) {
 
428
                loader = instances[i].Env._loader;
 
429
                if (loader) {
 
430
                    if (!loader.moduleInfo[name]) {
 
431
                        loader.addModule(details, name);
 
432
                    }
 
433
                }
 
434
            }
 
435
        }
338
436
 
339
437
        return this;
340
438
    },
346
444
     * @private
347
445
     */
348
446
    _attach: function(r, fromLoader) {
349
 
        var i, name, mod, details, req, use,
 
447
        var i, name, mod, details, req, use, 
350
448
            mods = YUI.Env.mods,
351
 
            done = this.Env._attached,
 
449
            Y    = this,
 
450
            done = Y.Env._attached,
352
451
            len  = r.length;
353
452
 
354
453
        for (i=0; i<len; i++) {
362
461
                use        = details.use;
363
462
 
364
463
                if (req && req.length) {
365
 
                    this._attach(this.Array(req));
 
464
                    if (!Y._attach(req)) {
 
465
                        return false;
 
466
                    }
366
467
                }
367
468
 
368
 
                // this.log('attaching ' + name, 'info', 'yui');
 
469
                // Y.log('attaching ' + name, 'info', 'yui');
369
470
 
370
471
                if (mod.fn) {
371
 
                    mod.fn(this, name);
 
472
                    try {
 
473
                        mod.fn(Y, name);
 
474
                    } catch (e) {
 
475
                        Y.error('Attach error: ' + name, e, name);
 
476
                        return false;
 
477
                    }
372
478
                }
373
479
 
374
480
                if (use && use.length) {
375
 
                    this._attach(this.Array(use));
 
481
                    if (!Y._attach(use)) {
 
482
                        return false;
 
483
                    }
376
484
                }
377
485
            }
378
486
        }
 
487
 
 
488
        return true;
379
489
    },
380
490
 
381
491
    /**
421
531
 
422
532
        if (!this.Array) {
423
533
            this._attach(['yui-base']);
 
534
            // this._attach( this.config.core || ['yui-base', 'get', 'intl-base', 'loader', 'yui-log', 'yui-later', 'yui-throttle']);
424
535
        }
425
536
 
426
537
        var len, loader, handleBoot,
438
549
            boot     = config.bootstrap,
439
550
            missing  = [], 
440
551
            r        = [], 
 
552
            star,
 
553
            ret      = true,
441
554
            fetchCSS = config.fetchCSS,
442
 
            process  = function(name) {
443
 
 
444
 
                // add this module to full list of things to attach
445
 
                r.push(name);
446
 
 
447
 
                // only attach a module once
448
 
                if (used[name]) {
 
555
            process  = function(names, skip) {
 
556
 
 
557
                if (!names.length) {
449
558
                    return;
450
559
                }
451
560
 
452
 
                var m = mods[name], req, use;
453
 
 
454
 
                if (m) {
455
 
                    used[name] = true;
456
 
                    req = m.details.requires;
457
 
                    use = m.details.use;
458
 
                } else {
459
 
                    // CSS files don't register themselves, see if it has been loaded
460
 
                    if (!G_ENV._loaded[VERSION][name]) {
461
 
                        missing.push(name);
 
561
                YArray.each(names, function(name) {
 
562
 
 
563
                    // add this module to full list of things to attach
 
564
                    if (!skip) {
 
565
                        r.push(name);
 
566
                    }
 
567
 
 
568
                    // only attach a module once
 
569
                    if (used[name]) {
 
570
                        return;
 
571
                    }
 
572
 
 
573
                    var m = mods[name], req, use;
 
574
 
 
575
                    if (m) {
 
576
                        used[name] = true;
 
577
                        req = m.details.requires;
 
578
                        use = m.details.use;
462
579
                    } else {
463
 
                        used[name] = true; // probably css
464
 
                    }
465
 
                }
466
 
 
467
 
                if (req) { // make sure requirements are attached
468
 
                    YArray.each(YArray(req), process);
469
 
                }
470
 
 
471
 
                if (use) { // make sure we grab the submodule dependencies too
472
 
                    YArray.each(YArray(use), process);
473
 
                }
474
 
 
475
 
 
 
580
                        // CSS files don't register themselves, see if it has been loaded
 
581
                        if (!G_ENV._loaded[VERSION][name]) {
 
582
                            missing.push(name);
 
583
                        } else {
 
584
                            used[name] = true; // probably css
 
585
                        }
 
586
                    }
 
587
 
 
588
                    if (req && req.length) { // make sure requirements are attached
 
589
                        process(req);
 
590
                    }
 
591
 
 
592
                    if (use && use.length) { // make sure we grab the submodule dependencies too
 
593
                        process(use, 1);
 
594
                    }
 
595
                });
 
596
            },
 
597
 
 
598
            notify = function(response) {
 
599
                if (callback) {
 
600
                    try {
 
601
                        callback(Y, response);
 
602
                    } catch (e) {
 
603
                        Y.error('use callback error', e, args);
 
604
                    }
 
605
                }
476
606
            },
477
607
 
478
608
            handleLoader = function(fromLoader) {
480
610
                        success: true,
481
611
                        msg: 'not dynamic'
482
612
                    }, 
483
 
                    newData, redo, origMissing,
 
613
                    newData, redo, origMissing, 
 
614
                    ret = true,
484
615
                    data = response.data;
485
616
 
486
617
                Y._loading = false;
490
621
                if (data) {
491
622
                    origMissing = missing.concat();
492
623
                    missing = [];
493
 
                    Y.Array.each(data, process);
 
624
                    r = [];
 
625
                    process(data);
494
626
                    redo = missing.length;
495
627
                    if (redo) {
496
628
                        if (missing.sort().join() == origMissing.sort().join()) {
500
632
                }
501
633
 
502
634
                if (redo && data) {
503
 
                    // Y.log('redo: ' + r);
504
 
                    // Y.log('redo: ' + missing);
505
 
                    // Y.log('redo: ' + args);
506
 
                    newData = data.concat();
 
635
                    // Y.log('redo r: ' + r);
 
636
                    // Y.log('redo data: ' + data);
 
637
                    // Y.log('redo missing: ' + missing);
 
638
                    Y.log('redo args: ' + args);
 
639
                    
 
640
                    // newData = data.concat();
 
641
                    // newData = args.concat();
 
642
                    newData = args.concat();
 
643
 
 
644
                    // newData = missing.concat();
 
645
 
507
646
                    newData.push(function() {
508
647
                        Y.log('Nested USE callback: ' + data, 'info', 'yui');
509
 
                        Y._attach(data);
510
 
                        if (callback) {
511
 
                            callback(Y, response);
 
648
                        if (Y._attach(data)) {
 
649
                            notify(response);
512
650
                        }
513
651
                    });
514
652
                    Y._loading  = false;
515
653
                    Y.use.apply(Y, newData);
516
654
                } else {
517
655
                    if (data) {
518
 
                        Y._attach(data);
 
656
                        ret = Y._attach(data);
519
657
                    }
520
 
                    if (callback) {
521
 
                        callback(Y, response);
 
658
                    if (ret) {
 
659
                        notify(response);
522
660
                    }
523
661
                }
524
662
 
545
683
 
546
684
        // YUI().use('*'); // bind everything available
547
685
        if (firstArg === "*") {
 
686
            star = true;
548
687
            args = Y.Object.keys(mods);
549
688
        }
 
689
 
 
690
        // Y.log('before loader requirements: ' + args, 'info', 'yui');
550
691
        
551
692
        // use loader to expand dependencies and sort the 
552
693
        // requirements if it is available.
553
 
        if (Y.Loader) {
554
 
            loader = new Y.Loader(config);
 
694
        if (boot && !star && Y.Loader && args.length) {
 
695
 
 
696
            // Y.log('checking dependences with loader', 'info', 'yui');
 
697
 
 
698
            loader = getLoader(Y);
555
699
            loader.require(args);
556
700
            loader.ignoreRegistered = true;
557
701
            // loader.allowRollup = false;
558
702
            loader.calculate(null, (fetchCSS) ? null : 'js');
559
703
            args = loader.sorted;
 
704
 
 
705
            // YUI.Env.loaders[Y.config._sig] = loader;
560
706
        }
561
707
 
 
708
        // Y.log('after loader requirements: ' + args, 'info', 'yui');
 
709
 
562
710
        // process each requirement and any additional requirements 
563
711
        // the module metadata specifies
564
 
        YArray.each(args, process);
 
712
        process(args);
565
713
 
566
 
        Y.log('Module requirements: ' + args, 'info', 'yui');
 
714
        // Y.log('args: ' + args , 'info', 'yui');
 
715
        // Y.log('requires: ' + r, 'info', 'yui');
567
716
        len = missing.length;
568
717
 
569
718
        if (len) {
577
726
            // Y.log('Using loader to fetch missing dependencies: ' + missing, 'info', 'yui');
578
727
            Y.log('Using Loader', 'info', 'yui');
579
728
            Y._loading = true;
580
 
            loader = new Y.Loader(config);
 
729
            // loader = new Y.Loader(config);
 
730
            loader = getLoader(Y);
581
731
            loader.onEnd = handleLoader;
582
732
            loader.context = Y;
583
 
            loader.attaching = args;
 
733
            // loader.attaching = args;
584
734
            loader.data = args;
585
735
            loader.require((fetchCSS) ? missing : args);
586
736
            loader.insert(null, (fetchCSS) ? null : 'js');
 
737
        } else if (len && Y.config.use_rls) {
 
738
 
 
739
            // server side loader service
 
740
            Y.Get.script(Y._rls(args), {
 
741
                onEnd: function(o) {
 
742
                    handleLoader(o);
 
743
                }, 
 
744
                data: args
 
745
            });
 
746
            
587
747
        } else if (boot && len && Y.Get && !Env.bootstrapped) {
588
748
 
589
749
            Y._loading = true;
593
753
                Y._loading = false;
594
754
                queue.running = false;
595
755
                Env.bootstrapped = true;
596
 
                Y._attach(['loader']);
597
 
                Y.use.apply(Y, args);
 
756
                if (Y._attach(['loader'])) {
 
757
                    Y.use.apply(Y, args);
 
758
                }
598
759
            };
599
760
 
600
761
            if (G_ENV._bootstrapping) {
614
775
Y.log('This instance is not provisioned to fetch missing modules: ' + missing, 'log', 'yui');
615
776
            }
616
777
            Y.log('Attaching available dependencies.', 'info', 'yui');
617
 
            Y._attach(r);
618
 
            handleLoader();
 
778
            ret = Y._attach(args);
 
779
            if (ret) {
 
780
                handleLoader();
 
781
            }
619
782
        }
620
783
 
621
784
        return Y;
672
835
     * @return {YUI} this YUI instance
673
836
     */
674
837
    error: function(msg, e) {
675
 
        if (this.config.throwFail) {
 
838
 
 
839
        var Y = this, ret;
 
840
        
 
841
        if (Y.config.errorFn) {
 
842
            ret = Y.config.errorFn.apply(Y, arguments);
 
843
        }
 
844
 
 
845
        if (Y.config.throwFail && !ret) {
676
846
            throw (e || new Error(msg)); 
677
847
        } else {
678
 
            this.message(msg, "error"); // don't scrub this one
 
848
            Y.message(msg, "error"); // don't scrub this one
679
849
        }
680
850
 
681
 
        return this;
 
851
        return Y;
682
852
    },
683
853
 
684
854
    /**
703
873
     * @return {string} The object's guid or null
704
874
     */
705
875
    stamp: function(o, readOnly) {
 
876
        var uid;
706
877
        if (!o) {
707
878
            return o;
708
879
        }
709
 
        var uid = (typeof o === 'string') ? o : o._yuid;
 
880
        
 
881
        // IE generates its own unique ID for dom nodes
 
882
        // The uniqueID property of a document node returns a new ID
 
883
        if (o.uniqueID && o.nodeType && o.nodeType !== 9) {
 
884
            uid = o.uniqueID;
 
885
        } else {
 
886
            uid = (typeof o === 'string') ? o : o._yuid;
 
887
        }
 
888
 
710
889
        if (!uid) {
711
890
            uid = this.guid();
712
891
            if (!readOnly) {
721
900
    }
722
901
};
723
902
 
724
 
// Give the YUI global the same properties as an instance.
725
 
// This makes it so that the YUI global can be used like the YAHOO
726
 
// global was used prior to 3.x.  More importantly, the YUI global
727
 
// provides global metadata, so env needs to be configured.
728
 
// @TODO review
729
 
 
730
 
    p = YUI.prototype;
 
903
    YUI.prototype = proto;
731
904
 
732
905
    // inheritance utilities are not available yet
733
 
    for (prop in p) {
734
 
        YUI[prop] = p[prop];
 
906
    for (prop in proto) {
 
907
        if (proto.hasOwnProperty(prop)) {
 
908
            YUI[prop] = proto[prop];
 
909
        }
735
910
    }
736
911
 
737
912
    // set up the environment
763
938
 * The config object contains all of the configuration options for
764
939
 * the YUI instance.  This object is supplied by the implementer 
765
940
 * when instantiating a YUI instance.  Some properties have default
766
 
 * values if they are not supplied by the implementer.
 
941
 * values if they are not supplied by the implementer.  This should
 
942
 * not be updated directly because some values are cached.  Use
 
943
 * applyConfig() to update the config object on a YUI instance that
 
944
 * has already been configured.
767
945
 *
768
946
 * @class config
769
947
 * @static
795
973
 */
796
974
 
797
975
/**
798
 
 * A hash of log sources that should be not be logged.  If specified, all sources are logged if not on this list.
 
976
 * A hash of log sources that should be not be logged.  If specified, 
 
977
 * all sources are logged if not on this list.
799
978
 *
800
979
 * @property logExclude
801
980
 * @type object
812
991
 */
813
992
 
814
993
/**
815
 
 * If throwFail is set, Y.fail will generate or re-throw a JS Error.  Otherwise the failure is logged.
 
994
 * If throwFail is set, Y.error will generate or re-throw a JS Error.  
 
995
 * Otherwise the failure is logged.
816
996
 *
817
997
 * @property throwFail
818
998
 * @type boolean
1022
1202
 */
1023
1203
 
1024
1204
/**
1025
 
 * charset for dynamic nodes
1026
 
 * @property charset
1027
 
 * @type string
1028
 
 * @deprecated use jsAttributes cssAttributes
1029
 
 */
1030
 
 
1031
 
/**
1032
1205
 * Object literal containing attributes to add to dynamically loaded script nodes.
1033
1206
 * @property jsAttributes
1034
1207
 * @type string
1065
1238
 * name, and the value is an object literal specifying the metdata
1066
1239
 * for the module.  * See Loader.addModule for the supported module
1067
1240
 * metadata fields.  Also @see groups, which provides a way to
1068
 
 * configure the base and combo spec for a 
 
1241
 * configure the base and combo spec for a set of modules.
1069
1242
 * <code>
1070
1243
 * modules: {
1071
1244
 * &nbsp; mymod1: {
1158
1331
 * @since 3.1.0
1159
1332
 * @property yui2 
1160
1333
 * @type string
1161
 
 * @default 2.8.0
 
1334
 * @default 2.8.1
1162
1335
 */
1163
1336
 
1164
1337
/**
1175
1348
 
1176
1349
/**
1177
1350
 * Alternative console log function for use in environments without
1178
 
 * a supported native console.
 
1351
 * a supported native console.  The function is executed in the
 
1352
 * YUI instance context.
1179
1353
 * @since 3.1.0
1180
1354
 * @property logFn
1181
1355
 * @type Function
1182
1356
 */
 
1357
 
 
1358
/**
 
1359
 * A callback to execute when Y.error is called.  It receives the
 
1360
 * error message and an javascript error object if Y.error was
 
1361
 * executed because a javascript error was caught.  The function
 
1362
 * is executed in the YUI instance context.
 
1363
 *
 
1364
 * @since 3.2.0
 
1365
 * @property errorFn
 
1366
 * @type Function
 
1367
 */
 
1368
 
 
1369
/**
 
1370
 * The parameter defaults for the remote loader service.
 
1371
 * Requires the rls submodule.  The properties that are
 
1372
 * supported:
 
1373
 * <pre>
 
1374
 * m: comma separated list of module requirements.  This 
 
1375
 *    must be the param name even for custom implemetations.
 
1376
 * v: the version of YUI to load.  Defaults to the version
 
1377
 *    of YUI that is being used.
 
1378
 * gv: the version of the gallery to load (@see the gallery config)
 
1379
 * env: comma separated list of modules already on the page.
 
1380
 *      this must be the param name even for custom implemetations.
 
1381
 * lang: the languages supported on the page (@see the lang config)
 
1382
 * '2in3v':  the version of the 2in3 wrapper to use (@see the 2in3 config).
 
1383
 * '2v': the version of yui2 to use in the yui 2in3 wrappers (@see the yui2 config)
 
1384
 * filt: a filter def to apply to the urls (@see the filter config).
 
1385
 * filts: a list of custom filters to apply per module (@see the filters config).
 
1386
 * tests: this is a map of conditional module test function id keys with the values
 
1387
 * of 1 if the test passes, 0 if not.  This must be the name of the querystring
 
1388
 * param in custom templates.
 
1389
 *</pre>
 
1390
 *
 
1391
 * @since 3.2.0
 
1392
 * @property rls
 
1393
 */
 
1394
 
 
1395
/**
 
1396
 * The base path to the remote loader service
 
1397
 *
 
1398
 * @since 3.2.0
 
1399
 * @property rls_base
 
1400
 */
 
1401
 
 
1402
/**
 
1403
 * The template to use for building the querystring portion
 
1404
 * of the remote loader service url.  The default is determined
 
1405
 * by the rls config -- each property that has a value will be
 
1406
 * represented.
 
1407
 *
 
1408
 * ex: m={m}&v={v}&env={env}&lang={lang}&filt={filt}&tests={tests}
 
1409
 *
 
1410
 *
 
1411
 * @since 3.2.0
 
1412
 * @property rls_tmpl
 
1413
 */
 
1414
 
 
1415
/**
 
1416
 * Configure the instance to use a remote loader service instead of
 
1417
 * the client loader.
 
1418
 *
 
1419
 * @since 3.2.0
 
1420
 * @property use_rls
 
1421
 */
1183
1422
YUI.add('yui-base', function(Y) {
1184
1423
 
1185
1424
/*
1193
1432
 * @module yui
1194
1433
 * @submodule yui-base
1195
1434
 */
1196
 
(function() {
 
1435
// (function() {
1197
1436
/**
1198
1437
 * Provides the language utilites and extensions used by the library
1199
1438
 * @class Lang
1229
1468
},
1230
1469
 
1231
1470
TRIMREGEX = /^\s+|\s+$/g,
1232
 
EMPTYSTRING = '';
 
1471
EMPTYSTRING = '',
 
1472
SUBREGEX  = /\{\s*([^\|\}]+?)\s*(?:\|([^\}]*))?\s*\}/g;
1233
1473
 
1234
1474
/**
1235
1475
 * Determines whether or not the provided item is an array.
1401
1641
    return  TYPES[typeof o] || TYPES[TOSTRING.call(o)] || (o ? OBJECT : NULL);
1402
1642
};
1403
1643
 
1404
 
})();
 
1644
/**
 
1645
 * Lightweight version of @see Y.substitute... it uses the same template
 
1646
 * structure as Y.substitute, but doesn't support recursion, auto-object
 
1647
 * coersion, or formats
 
1648
 * @method sub
 
1649
 * @since 3.2.0
 
1650
 */
 
1651
L.sub = function (s, o) {
 
1652
    return ((s.replace) ? s.replace(SUBREGEX, function (match, key) {
 
1653
        return (!L.isUndefined(o[key])) ? o[key] : match;
 
1654
    }) : s);
 
1655
};
 
1656
 
 
1657
// })();
1405
1658
 
1406
1659
/**
1407
1660
 * The YUI module contains the components required for building the YUI seed file.
1533
1786
YArray.hash = function(k, v) {
1534
1787
    var o = {}, l = k.length, vl = v && v.length, i;
1535
1788
    for (i=0; i<l; i=i+1) {
1536
 
        if (k[i]) {
1537
 
            o[k[i]] = (vl && vl > i) ? v[i] : true;
1538
 
        }
 
1789
        o[k[i]] = (vl && vl > i) ? v[i] : true;
1539
1790
    }
1540
1791
 
1541
1792
    return o;
1851
2102
Y.cached = function(source, cache, refetch){
1852
2103
    cache = cache || {};
1853
2104
 
1854
 
    return function(arg1, arg2) {
 
2105
    return function(arg1) {
1855
2106
 
1856
 
        var k = (arg2) ? Array.prototype.join.call(arguments, DELIMITER) : arg1;
 
2107
        var k = (arguments.length > 1) ? 
 
2108
            Array.prototype.join.call(arguments, DELIMITER) : arg1;
1857
2109
 
1858
2110
        if (!(k in cache) || (refetch && cache[k] == refetch)) {
1859
2111
            cache[k] = source.apply(source, arguments);
1897
2149
 
1898
2150
owns = function(o, k) {
1899
2151
    return o && o.hasOwnProperty && o.hasOwnProperty(k);
 
2152
    // return Object.prototype.hasOwnProperty.call(o, k);
1900
2153
},
1901
2154
 
1902
 
UNDEFINED = undefined,
 
2155
UNDEFINED,
1903
2156
 
1904
2157
/**
1905
2158
 * Extracts the keys, values, or size from an object
2000
2253
/**
2001
2254
 * Executes a function on each item. The function
2002
2255
 * receives the value, the key, and the object
2003
 
 * as paramters (in that order).
 
2256
 * as parameters (in that order).
2004
2257
 * @method each
2005
2258
 * @static
2006
2259
 * @param o the object to iterate
2021
2274
    return Y;
2022
2275
};
2023
2276
 
2024
 
/*
 
2277
/**
2025
2278
 * Executes a function on each item, but halts if the
2026
2279
 * function returns true.  The function
2027
2280
 * receives the value, the key, and the object
2110
2363
    return o;
2111
2364
};
2112
2365
 
 
2366
/**
 
2367
 * Returns true if the object has no properties of its own
 
2368
 * @method isEmpty
 
2369
 * @return {boolean} true if the object is empty
 
2370
 * @since 3.2.0
 
2371
 */
 
2372
O.isEmpty = function(o) {
 
2373
    for (var i in o) {
 
2374
        if (owns(o, i)) {
 
2375
            return false;
 
2376
        }
 
2377
    }
 
2378
    return true;
 
2379
};
 
2380
 
2113
2381
})();
2114
2382
 
2115
2383
/**
2132
2400
 * @class UA
2133
2401
 * @static
2134
2402
 */
2135
 
Y.UA = function() {
 
2403
Y.UA = YUI.Env.UA || function() {
2136
2404
 
2137
2405
    var numberify = function(s) {
2138
2406
            var c = 0;
2234
2502
         * @type float
2235
2503
         */
2236
2504
        air: 0,
 
2505
        /**
 
2506
         * Detects Apple iPad's OS version
 
2507
         * @property ipad
 
2508
         * @type float
 
2509
         * @static
 
2510
         */
 
2511
        ipad: 0,
 
2512
        /**
 
2513
         * Detects Apple iPhone's OS version
 
2514
         * @property iphone
 
2515
         * @type float
 
2516
         * @static
 
2517
         */
 
2518
        iphone: 0,
 
2519
        /**
 
2520
         * Detects Apples iPod's OS version
 
2521
         * @property ipod
 
2522
         * @type float
 
2523
         * @static
 
2524
         */
 
2525
        ipod: 0,
 
2526
        /**
 
2527
         * General truthy check for iPad, iPhone or iPod
 
2528
         * @property ios
 
2529
         * @type float
 
2530
         * @static
 
2531
         */
 
2532
        ios: null,
 
2533
        /**
 
2534
         * Detects Googles Android OS version
 
2535
         * @property android 
 
2536
         * @type float
 
2537
         * @static
 
2538
         */
 
2539
        android: 0,
2237
2540
 
2238
2541
        /**
2239
2542
         * Google Caja version number or 0.
2292
2595
            // Mobile browser check
2293
2596
            if (/ Mobile\//.test(ua)) {
2294
2597
                o.mobile = "Apple"; // iPhone or iPod Touch
 
2598
 
 
2599
                m = ua.match(/OS ([^\s]*)/);
 
2600
                if (m && m[1]) {
 
2601
                    m = numberify(m[1].replace('_', '.'));
 
2602
                }
 
2603
                o.ipad = (navigator.platform == 'iPad') ? m : 0;
 
2604
                o.ipod = (navigator.platform == 'iPod') ? m : 0;
 
2605
                o.iphone = (navigator.platform == 'iPhone') ? m : 0;
 
2606
                o.ios = o.ipad || o.iphone || o.ipod;
2295
2607
            } else {
2296
2608
                m=ua.match(/NokiaN[^\/]*|Android \d\.\d|webOS\/\d\.\d/);
2297
2609
                if (m) {
2298
2610
                    o.mobile = m[0]; // Nokia N-series, Android, webOS, ex: NokiaN95
2299
2611
                }
 
2612
                if (/ Android/.test(ua)) {
 
2613
                    o.mobile = 'Android';
 
2614
                    m = ua.match(/Android ([^\s]*);/);
 
2615
                    if (m && m[1]) {
 
2616
                        o.android = numberify(m[1]);
 
2617
                    }
 
2618
 
 
2619
                }
2300
2620
            }
2301
2621
 
2302
2622
            m=ua.match(/Chrome\/([^\s]*)/);
2336
2656
            }
2337
2657
        }
2338
2658
    }
 
2659
 
 
2660
    YUI.Env.UA = o;
2339
2661
    
2340
2662
    return o;
2341
2663
}();
2342
2664
 
2343
2665
 
2344
 
}, '3.1.2' );
 
2666
}, '3.2.0' );