34
36
/*global YUI_config*/
35
37
var YUI = function() {
37
var Y = this, a = arguments, i, l = a.length,
38
globalConfig = (typeof YUI_config !== 'undefined') && YUI_config;
40
// Allow instantiation without the new operator
42
gconf = (typeof YUI_config !== 'undefined') && YUI_config;
41
44
if (!(Y instanceof YUI)) {
48
47
// set up the core environment
51
Y._config(globalConfig);
56
52
// bind the specified additional modules for this instance
60
Y.applyConfig(args[i]);
66
72
BASE = 'http://yui.yahooapis.com/',
67
73
DOC_LABEL = 'yui3-js-enabled',
68
74
NOOP = function() {},
101
107
remove(window, 'load', handleLoad);
110
getLoader = function(Y, o) {
111
var loader = Y.Env._loader;
113
loader.ignoreRegistered = false;
115
// loader.attaching = null;
117
loader.required = [];
118
loader.loadType = null;
119
// loader._inspectPage();
121
loader = new Y.Loader(Y.config);
122
Y.Env._loader = loader;
128
clobber = function(r, s) {
130
if (s.hasOwnProperty(i)) {
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.
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
120
_config: function(o) {
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
160
applyConfig: function(o) {
125
167
config = this.config,
126
168
mods = config.modules,
127
groups = config.groups;
169
groups = config.groups,
171
loader = this.Env._loader;
128
173
for (name in o) {
130
if (mods && name == 'modules') {
131
for (detail in attr) {
132
mods[detail] = attr[detail];
134
} else if (groups && name == 'groups') {
135
for (detail in attr) {
136
groups[detail] = attr[detail];
138
} else if (name == 'win') {
139
config[name] = attr.contentWindow || attr;
140
config.doc = config[name].document;
174
if (o.hasOwnProperty(name)) {
176
if (mods && name == 'modules') {
178
} else if (groups && name == 'groups') {
179
clobber(groups, attr);
180
} else if (rls && name == 'rls') {
182
} else if (name == 'win') {
183
config[name] = attr.contentWindow || attr;
184
config.doc = config[name].document;
185
} else if (name == '_yuid') {
198
_config: function(o) {
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;
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
237
match = src.match(srcPattern);
183
238
b = match && match[1];
185
240
// this is to set up the path to the loader. The file
186
241
// filter for loader should match the yui include.
187
242
filter = match[2];
245
match = filter.indexOf('js');
248
filter = filter.substr(0, match);
188
252
// extract correct path for mixed combo urls
189
253
// http://yuilibrary.com/projects/yui3/ticket/2528423
190
254
match = src.match(comboPattern);
233
Y.config.base = YUI.config.base ||
312
config.base = YUI.config.base ||
234
313
Y.Env.getBase(/^(.*)yui\/yui([\.\-].*)js(\?.*)?$/,
235
314
/^(.*\?)(.*\&)(.*)yui\/yui[\.\-].*js(\?.*)?$/);
237
Y.config.loaderPath = YUI.config.loaderPath ||
316
config.loaderPath = YUI.config.loaderPath ||
238
317
'loader/loader' + (filter || '-min.') + 'js';
243
322
* Finishes the instance setup. Attaches whatever modules were defined
244
323
* when the yui modules was registered.
327
409
add: function(name, fn, version, details) {
328
410
details = details || {};
330
YUI.Env.mods[name] = {
421
env.mods[name] = mod;
422
env.versions[version] = env.versions[version] || {};
423
env.versions[version][name] = mod;
425
for (i in instances) {
426
if (instances.hasOwnProperty(i)) {
427
loader = instances[i].Env._loader;
429
if (!loader.moduleInfo[name]) {
430
loader.addModule(details, name);
346
445
_attach: function(r, fromLoader) {
347
var i, name, mod, details, req, use,
446
var i, name, mod, details, req, use,
348
447
mods = YUI.Env.mods,
349
done = this.Env._attached,
449
done = Y.Env._attached,
352
452
for (i=0; i<len; i++) {
436
547
boot = config.bootstrap,
439
552
fetchCSS = config.fetchCSS,
440
process = function(name) {
442
// add this module to full list of things to attach
445
// only attach a module once
553
process = function(names, skip) {
450
var m = mods[name], req, use;
454
req = m.details.requires;
457
// CSS files don't register themselves, see if it has been loaded
458
if (!G_ENV._loaded[VERSION][name]) {
559
YArray.each(names, function(name) {
561
// add this module to full list of things to attach
566
// only attach a module once
571
var m = mods[name], req, use;
575
req = m.details.requires;
461
used[name] = true; // probably css
465
if (req) { // make sure requirements are attached
466
YArray.each(YArray(req), process);
469
if (use) { // make sure we grab the submodule dependencies too
470
YArray.each(YArray(use), process);
578
// CSS files don't register themselves, see if it has been loaded
579
if (!G_ENV._loaded[VERSION][name]) {
582
used[name] = true; // probably css
586
if (req && req.length) { // make sure requirements are attached
590
if (use && use.length) { // make sure we grab the submodule dependencies too
596
notify = function(response) {
599
callback(Y, response);
601
Y.error('use callback error', e, args);
476
606
handleLoader = function(fromLoader) {
538
675
// YUI().use('*'); // bind everything available
539
676
if (firstArg === "*") {
540
678
args = Y.Object.keys(mods);
543
682
// use loader to expand dependencies and sort the
544
683
// requirements if it is available.
546
loader = new Y.Loader(config);
684
if (boot && !star && Y.Loader && args.length) {
687
loader = getLoader(Y);
547
688
loader.require(args);
548
689
loader.ignoreRegistered = true;
549
690
// loader.allowRollup = false;
550
691
loader.calculate(null, (fetchCSS) ? null : 'js');
551
692
args = loader.sorted;
694
// YUI.Env.loaders[Y.config._sig] = loader;
554
698
// process each requirement and any additional requirements
555
699
// the module metadata specifies
556
YArray.each(args, process);
558
702
len = missing.length;
566
710
if (boot && len && Y.Loader) {
567
711
Y._loading = true;
568
loader = new Y.Loader(config);
712
// loader = new Y.Loader(config);
713
loader = getLoader(Y);
569
714
loader.onEnd = handleLoader;
570
715
loader.context = Y;
571
loader.attaching = args;
716
// loader.attaching = args;
572
717
loader.data = args;
573
718
loader.require((fetchCSS) ? missing : args);
574
719
loader.insert(null, (fetchCSS) ? null : 'js');
720
} else if (len && Y.config.use_rls) {
722
// server side loader service
723
Y.Get.script(Y._rls(args), {
575
730
} else if (boot && len && Y.Get && !Env.bootstrapped) {
577
732
Y._loading = true;
656
814
* @return {YUI} this YUI instance
658
816
error: function(msg, e) {
659
if (this.config.throwFail) {
820
if (Y.config.errorFn) {
821
ret = Y.config.errorFn.apply(Y, arguments);
824
if (Y.config.throwFail && !ret) {
660
825
throw (e || new Error(msg));
662
this.message(msg, "error"); // don't scrub this one
827
Y.message(msg, "error"); // don't scrub this one
687
852
* @return {string} The object's guid or null
689
854
stamp: function(o, readOnly) {
693
var uid = (typeof o === 'string') ? o : o._yuid;
860
// IE generates its own unique ID for dom nodes
861
// The uniqueID property of a document node returns a new ID
862
if (o.uniqueID && o.nodeType && o.nodeType !== 9) {
865
uid = (typeof o === 'string') ? o : o._yuid;
695
869
uid = this.guid();
708
// Give the YUI global the same properties as an instance.
709
// This makes it so that the YUI global can be used like the YAHOO
710
// global was used prior to 3.x. More importantly, the YUI global
711
// provides global metadata, so env needs to be configured.
882
YUI.prototype = proto;
716
884
// inheritance utilities are not available yet
885
for (prop in proto) {
886
if (proto.hasOwnProperty(prop)) {
887
YUI[prop] = proto[prop];
721
891
// set up the environment
747
917
* The config object contains all of the configuration options for
748
918
* the YUI instance. This object is supplied by the implementer
749
919
* when instantiating a YUI instance. Some properties have default
750
* values if they are not supplied by the implementer.
920
* values if they are not supplied by the implementer. This should
921
* not be updated directly because some values are cached. Use
922
* applyConfig() to update the config object on a YUI instance that
923
* has already been configured.
1161
1329
* Alternative console log function for use in environments without
1162
* a supported native console.
1330
* a supported native console. The function is executed in the
1331
* YUI instance context.
1164
1333
* @property logFn
1165
1334
* @type Function
1338
* A callback to execute when Y.error is called. It receives the
1339
* error message and an javascript error object if Y.error was
1340
* executed because a javascript error was caught. The function
1341
* is executed in the YUI instance context.
1349
* The parameter defaults for the remote loader service.
1350
* Requires the rls submodule. The properties that are
1353
* m: comma separated list of module requirements. This
1354
* must be the param name even for custom implemetations.
1355
* v: the version of YUI to load. Defaults to the version
1356
* of YUI that is being used.
1357
* gv: the version of the gallery to load (@see the gallery config)
1358
* env: comma separated list of modules already on the page.
1359
* this must be the param name even for custom implemetations.
1360
* lang: the languages supported on the page (@see the lang config)
1361
* '2in3v': the version of the 2in3 wrapper to use (@see the 2in3 config).
1362
* '2v': the version of yui2 to use in the yui 2in3 wrappers (@see the yui2 config)
1363
* filt: a filter def to apply to the urls (@see the filter config).
1364
* filts: a list of custom filters to apply per module (@see the filters config).
1365
* tests: this is a map of conditional module test function id keys with the values
1366
* of 1 if the test passes, 0 if not. This must be the name of the querystring
1367
* param in custom templates.
1375
* The base path to the remote loader service
1378
* @property rls_base
1382
* The template to use for building the querystring portion
1383
* of the remote loader service url. The default is determined
1384
* by the rls config -- each property that has a value will be
1387
* ex: m={m}&v={v}&env={env}&lang={lang}&filt={filt}&tests={tests}
1391
* @property rls_tmpl
1395
* Configure the instance to use a remote loader service instead of
1396
* the client loader.
1167
1401
YUI.add('yui-base', function(Y) {
1385
1620
return TYPES[typeof o] || TYPES[TOSTRING.call(o)] || (o ? OBJECT : NULL);
1624
* Lightweight version of @see Y.substitute... it uses the same template
1625
* structure as Y.substitute, but doesn't support recursion, auto-object
1626
* coersion, or formats
1630
L.sub = function (s, o) {
1631
return ((s.replace) ? s.replace(SUBREGEX, function (match, key) {
1632
return (!L.isUndefined(o[key])) ? o[key] : match;
1391
1639
* The YUI module contains the components required for building the YUI seed file.
1835
2081
Y.cached = function(source, cache, refetch){
1836
2082
cache = cache || {};
1838
return function(arg1, arg2) {
2084
return function(arg1) {
1840
var k = (arg2) ? Array.prototype.join.call(arguments, DELIMITER) : arg1;
2086
var k = (arguments.length > 1) ?
2087
Array.prototype.join.call(arguments, DELIMITER) : arg1;
1842
2089
if (!(k in cache) || (refetch && cache[k] == refetch)) {
1843
2090
cache[k] = source.apply(source, arguments);
2276
2574
// Mobile browser check
2277
2575
if (/ Mobile\//.test(ua)) {
2278
2576
o.mobile = "Apple"; // iPhone or iPod Touch
2578
m = ua.match(/OS ([^\s]*)/);
2580
m = numberify(m[1].replace('_', '.'));
2582
o.ipad = (navigator.platform == 'iPad') ? m : 0;
2583
o.ipod = (navigator.platform == 'iPod') ? m : 0;
2584
o.iphone = (navigator.platform == 'iPhone') ? m : 0;
2585
o.ios = o.ipad || o.iphone || o.ipod;
2280
2587
m=ua.match(/NokiaN[^\/]*|Android \d\.\d|webOS\/\d\.\d/);
2282
2589
o.mobile = m[0]; // Nokia N-series, Android, webOS, ex: NokiaN95
2591
if (/ Android/.test(ua)) {
2592
o.mobile = 'Android';
2593
m = ua.match(/Android ([^\s]*);/);
2595
o.android = numberify(m[1]);
2286
2601
m=ua.match(/Chrome\/([^\s]*)/);
2559
2876
_next = function(id, loaded) {
2560
var q = queues[id], msg, w, d, h, n, url, s;
2877
var q = queues[id], msg, w, d, h, n, url, s,
2563
2881
// q.timer.cancel();
2620
2938
// add the node to the queue so we can return it to the user supplied callback
2621
2939
q.nodes.push(n);
2623
// add it to the head or insert it before 'insertBefore'
2624
if (q.insertBefore) {
2625
s = _get(q.insertBefore, id);
2941
// add it to the head or insert it before 'insertBefore'. Work around IE
2942
// bug if there is a base tag.
2943
insertBefore = q.insertBefore ||
2944
d.getElementsByTagName('base')[0];
2947
s = _get(insertBefore, id);
2627
2949
s.parentNode.insertBefore(n, s);
2789
3105
_purge = function(tId) {
2790
var n, l, d, h, s, i, node, attr,
3106
var n, l, d, h, s, i, node, attr, insertBefore,
2791
3107
q = queues[tId];
2795
3112
d = q.win.document;
2796
3113
h = d.getElementsByTagName("head")[0];
2798
if (q.insertBefore) {
2799
s = _get(q.insertBefore, tId);
3115
insertBefore = q.insertBefore ||
3116
d.getElementsByTagName('base')[0];
3119
s = _get(insertBefore, tId);
2801
3121
h = s.parentNode;
3370
YUI.add('features', function(Y) {
3374
Y.mix(Y.namespace("Features"), {
3378
add: function(cat, name, o) {
3379
tests[cat] = tests[cat] || {};
3380
tests[cat][name] = o;
3383
all: function(cat, args) {
3384
var cat_o = tests[cat],
3388
Y.Object.each(cat_o, function(v, k) {
3389
// results[k] = Y.Features.test(cat, k, args);
3390
result += k + ':' + (Y.Features.test(cat, k, args) ? 1 : 0) + ';';
3397
test: function(cat, name, args) {
3399
var result, ua, test,
3401
feature = cat_o && cat_o[name];
3406
result = feature.result;
3408
if (Y.Lang.isUndefined(result)) {
3412
result = (Y.UA[ua]);
3415
test = feature.test;
3416
if (test && ((!ua) || result)) {
3417
result = test.apply(Y, args);
3420
feature.result = result;
3428
// Y.Features.add("load", "1", {});
3429
// Y.Features.test("load", "1");
3430
// caps=1:1;2:0;3:1;
3432
/* This file is auto-generated by src/loader/meta_join.py */
3433
var add = Y.Features.add;
3436
"trigger": "dom-style",
3439
// history-hash-ie-test.js
3441
"test": function (Y) {
3442
var docMode = Y.config.doc.documentMode;
3444
return Y.UA.ie && (!('onhashchange' in Y.config.win) ||
3445
!docMode || docMode < 8);
3447
"trigger": "history-hash"
3449
// dd-gestures-test.js
3451
"test": function(Y) {
3452
return (Y.config.win && ('ontouchstart' in Y.config.win && !Y.UA.chrome));
3454
"trigger": "dd-drag"
3458
}, '3.2.0' ,{requires:['yui-base']});
3459
YUI.add('rls', function(Y) {
3462
* Implentation for building the remote loader service url.
3464
* @param what {Array} the requested modules
3467
Y._rls = function(what) {
3469
var config = Y.config,
3471
// the configuration
3472
rls = config.rls || {
3473
m: 1, // required in the template
3476
env: 1, // required in the template
3478
'2in3v': config['2in3'],
3480
filt: config.filter,
3481
filts: config.filters,
3482
tests: 1 // required in the template
3485
// The rls base path
3486
rls_base = config.rls_base || 'load?',
3489
rls_tmpl = config.rls_tmpl || function() {
3491
for (param in rls) {
3492
if (param in rls && rls[param]) {
3493
s += param + '={' + param + '}&';
3496
// console.log('rls_tmpl: ' + s);
3502
// update the request
3504
rls.env = Y.Object.keys(YUI.Env.mods);
3505
rls.tests = Y.Features.all('load', [Y]);
3507
url = Y.Lang.sub(rls_base + rls_tmpl, rls);
3510
config.rls_tmpl = rls_tmpl;
3512
// console.log(url);
3518
}, '3.2.0' ,{requires:['yui-base','get','features']});
3048
3519
YUI.add('intl-base', function(Y) {
3170
3640
INSTANCE.log = function(msg, cat, src, silent) {
3171
3641
var bail, excl, incl, m, f,
3644
publisher = (Y.fire) ? Y : YUI.Env.globalEvents;
3174
3645
// suppress log message if the config is off or the event stack
3175
3646
// or the event call stack contains a consumer of the yui:log event
3272
3743
later = function(when, o, fn, data, periodic) {
3273
3744
when = when || 0;
3275
var m=fn, d=Y.Array(data), f, r;
3277
if (L.isString(fn)) {
3748
if (o && L.isString(fn)) {
3752
f = !L.isUndefined(data) ? function() {
3753
m.apply(o, Y.Array(data));
3288
r = (periodic) ? setInterval(f, when) : setTimeout(f, when);
3758
id = (periodic) ? setInterval(f, when) : setTimeout(f, when);
3292
3762
interval: periodic,
3293
3763
cancel: function() {
3294
3764
if (this.interval) {
3359
}, '3.1.2' ,{requires:['yui-base']});
3362
YUI.add('yui', function(Y){}, '3.1.2' ,{use:['yui-base','get','intl-base','yui-log','yui-later','yui-throttle']});
3829
}, '3.2.0' ,{requires:['yui-base']});
3832
YUI.add('yui', function(Y){}, '3.2.0' ,{use:['yui-base','get','features','rls','intl-base','yui-log','yui-later','yui-throttle']});