3
Copyright 2012 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
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.
15
if (typeof YUI != 'undefined') {
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:
28
YUI().use('*', function(Y) {
32
But it also works like this:
36
Configuring the YUI object:
41
}).use('node', function(Y) {
42
//Node is ready to use
45
See the API docs for the <a href="config.html">Config</a> class
46
for the complete list of supported configuration properties accepted
47
by the YUI constuctor.
53
@param [o]* {Object} 0..n optional configuration objects. these values
54
are store in Y.config. See <a href="config.html">Config</a> for the list of supported
59
var YUI = function() {
64
instanceOf = function(o, type) {
65
return (o && o.hasOwnProperty && (o instanceof type));
67
gconf = (typeof YUI_config !== 'undefined') && YUI_config;
69
if (!(instanceOf(Y, YUI))) {
72
// set up the core environment
76
YUI.GlobalConfig is a master configuration that might span
77
multiple contexts in a non-browser environment. It is applied
78
first to all instances in all contexts.
79
@property GlobalConfig
90
YUI().use('node', function(Y) {
91
//debug files used here
96
}).use('node', function(Y) {
101
if (YUI.GlobalConfig) {
102
Y.applyConfig(YUI.GlobalConfig);
106
YUI_config is a page-level config. It is applied to all
107
instances created on the page. This is applied after
108
YUI.GlobalConfig, and before the instance level configuration
116
//Single global var to include before YUI seed file
121
YUI().use('node', function(Y) {
122
//debug files used here
127
}).use('node', function(Y) {
128
//min files used here
132
Y.applyConfig(gconf);
135
// bind the specified additional modules for this instance
142
// Each instance can accept one or more configuration objects.
143
// These are applied after YUI.GlobalConfig and YUI_Config,
144
// overriding values set in those config files if there is a '
145
// matching property.
147
Y.applyConfig(args[i]);
153
Y.instanceOf = instanceOf;
163
BASE = 'http://yui.yahooapis.com/',
164
DOC_LABEL = 'yui3-js-enabled',
165
CSS_STAMP_EL = 'yui3-css-stamp',
166
NOOP = function() {},
167
SLICE = Array.prototype.slice,
168
APPLY_TO_AUTH = { 'io.xdrReady': 1, // the functions applyTo
169
'io.xdrResponse': 1, // can call. this should
170
'SWF.eventHandler': 1 }, // be done at build time
171
hasWin = (typeof window != 'undefined'),
172
win = (hasWin) ? window : null,
173
doc = (hasWin) ? win.document : null,
174
docEl = doc && doc.documentElement,
175
docClass = docEl && docEl.className,
177
time = new Date().getTime(),
178
add = function(el, type, fn, capture) {
179
if (el && el.addEventListener) {
180
el.addEventListener(type, fn, capture);
181
} else if (el && el.attachEvent) {
182
el.attachEvent('on' + type, fn);
185
remove = function(el, type, fn, capture) {
186
if (el && el.removeEventListener) {
187
// this can throw an uncaught exception in FF
189
el.removeEventListener(type, fn, capture);
191
} else if (el && el.detachEvent) {
192
el.detachEvent('on' + type, fn);
195
handleLoad = function() {
196
YUI.Env.windowLoaded = true;
197
YUI.Env.DOMReady = true;
199
remove(window, 'load', handleLoad);
202
getLoader = function(Y, o) {
203
var loader = Y.Env._loader;
205
//loader._config(Y.config);
206
loader.ignoreRegistered = false;
209
loader.required = [];
210
loader.loadType = null;
212
loader = new Y.Loader(Y.config);
213
Y.Env._loader = loader;
215
YUI.Env.core = Y.Array.dedupe([].concat(YUI.Env.core, [ 'loader-base', 'loader-rollup', 'loader-yui3' ]));
220
clobber = function(r, s) {
222
if (s.hasOwnProperty(i)) {
228
ALREADY_DONE = { success: true };
230
// Stamp the documentElement (HTML) with a class of "yui-loaded" to
231
// enable styles that need to key off of JS being enabled.
232
if (docEl && docClass.indexOf(DOC_LABEL) == -1) {
236
docClass += DOC_LABEL;
237
docEl.className = docClass;
240
if (VERSION.indexOf('@') > -1) {
241
VERSION = '3.3.0'; // dev time hack for cdn test
246
* Applies a new configuration object to the YUI instance config.
247
* This will merge new group/module definitions, and will also
248
* update the loader cache if necessary. Updating Y.config directly
249
* will not update the cache.
250
* @method applyConfig
251
* @param {Object} o the configuration object.
254
applyConfig: function(o) {
261
config = this.config,
262
mods = config.modules,
263
groups = config.groups,
264
aliases = config.aliases,
265
loader = this.Env._loader;
268
if (o.hasOwnProperty(name)) {
270
if (mods && name == 'modules') {
272
} else if (aliases && name == 'aliases') {
273
clobber(aliases, attr);
274
} else if (groups && name == 'groups') {
275
clobber(groups, attr);
276
} else if (name == 'win') {
277
config[name] = (attr && attr.contentWindow) || attr;
278
config.doc = config[name] ? config[name].document : null;
279
} else if (name == '_yuid') {
293
* Old way to apply a config to the instance (calls `applyConfig` under the hood)
296
* @param {Object} o The config to apply
298
_config: function(o) {
303
* Initialize this YUI instance
315
* The version number of the YUI instance.
323
core: ['get','features','intl-base','yui-log', 'yui-log-nodejs', 'yui-later','loader-base', 'loader-rollup', 'loader-yui3'],
324
mods: {}, // flat module map
325
versions: {}, // version module map
327
cdn: BASE + VERSION + '/build/',
328
// bootstrapped: false,
339
// I'll start at the \b(simpleyui).
340
// 1. Look in the test string for "simpleyui" or "yui" or
341
// "yui-base" or "yui-davglass" or "yui-foobar" that comes after a word break. That is, it
342
// can't match "foyui" or "i_heart_simpleyui". This can be anywhere in the string.
343
// 2. After #1 must come a forward slash followed by the string matched in #1, so
344
// "yui-base/yui-base" or "simpleyui/simpleyui" or "yui-pants/yui-pants".
345
// 3. The second occurence of the #1 token can optionally be followed by "-debug" or "-min",
346
// so "yui/yui-min", "yui/yui-debug", "yui-base/yui-base-debug". NOT "yui/yui-tshirt".
347
// 4. This is followed by ".js", so "yui/yui.js", "simpleyui/simpleyui-min.js"
348
// 0. Going back to the beginning, now. If all that stuff in 1-4 comes after a "?" in the string,
349
// then capture the junk between the LAST "&" and the string in 1-4. So
350
// "blah?foo/yui/yui.js" will capture "foo/" and "blah?some/thing.js&3.3.0/build/yui-davglass/yui-davglass.js"
351
// will capture "3.3.0/build/"
355
// (?:[^&]*&) followed by 0..n characters followed by an &
356
// * in fact, find as many sets of characters followed by a & as you can
357
// ([^&]*) capture the stuff after the last & in \1
358
// )? but it's ok if all this ?junk&more_junk stuff isn't even there
359
// \b(simpleyui| after a word break find either the string "simpleyui" or
360
// yui(?:-\w+)? the string "yui" optionally followed by a -, then more characters
361
// ) and store the simpleyui or yui-* string in \2
362
// \/\2 then comes a / followed by the simpleyui or yui-* string in \2
363
// (?:-(min|debug))? optionally followed by "-min" or "-debug"
364
// .js and ending in ".js"
365
_BASE_RE: /(?:\?(?:[^&]*&)*([^&]*))?\b(simpleyui|yui(?:-\w+)?)\/\2(?:-(min|debug))?\.js/,
366
parseBasePath: function(src, pattern) {
367
var match = src.match(pattern),
371
path = RegExp.leftContext || src.slice(0, src.indexOf(match[0]));
373
// this is to set up the path to the loader. The file
374
// filter for loader should match the yui include.
377
// extract correct path for mixed combo urls
378
// http://yuilibrary.com/projects/yui3/ticket/2528423
380
path += '?' + match[1];
389
getBase: G_ENV && G_ENV.getBase ||
391
var nodes = (doc && doc.getElementsByTagName('script')) || [],
392
path = Env.cdn, parsed,
395
for (i = 0, len = nodes.length; i < len; ++i) {
398
parsed = Y.Env.parseBasePath(src, pattern);
400
filter = parsed.filter;
415
Env._loaded[VERSION] = {};
417
if (G_ENV && Y !== YUI) {
418
Env._yidx = ++G_ENV._yidx;
419
Env._guidp = ('yui_' + VERSION + '_' +
420
Env._yidx + '_' + time).replace(/\./g, '_');
421
} else if (YUI._YUI) {
423
G_ENV = YUI._YUI.Env;
424
Env._yidx += G_ENV._yidx;
425
Env._uidx += G_ENV._uidx;
427
for (prop in G_ENV) {
428
if (!(prop in Env)) {
429
Env[prop] = G_ENV[prop];
443
// configuration defaults
444
Y.config = Y.config || {
451
useBrowserConsole: true,
456
//Register the CSS stamp element
457
if (doc && !doc.getElementById(CSS_STAMP_EL)) {
458
el = doc.createElement('div');
459
el.innerHTML = '<div id="' + CSS_STAMP_EL + '" style="position: absolute !important; visibility: hidden !important"></div>';
460
YUI.Env.cssStampEl = el.firstChild;
461
docEl.insertBefore(YUI.Env.cssStampEl, docEl.firstChild);
464
Y.config.lang = Y.config.lang || 'en-US';
466
Y.config.base = YUI.config.base || Y.Env.getBase(Y.Env._BASE_RE);
468
if (!filter || (!('mindebug').indexOf(filter))) {
471
filter = (filter) ? '-' + filter : filter;
472
Y.config.loaderPath = YUI.config.loaderPath || 'loader/loader' + filter + '.js';
477
* Finishes the instance setup. Attaches whatever modules were defined
478
* when the yui modules was registered.
482
_setup: function(o) {
486
//extras = Y.config.core || ['get','features','intl-base','yui-log', 'yui-log-nodejs', 'yui-later','loader-base', 'loader-rollup', 'loader-yui3'];
487
extras = Y.config.core || [].concat(YUI.Env.core); //Clone it..
489
for (i = 0; i < extras.length; i++) {
490
if (mods[extras[i]]) {
491
core.push(extras[i]);
495
Y._attach(['yui-base']);
502
// Y.log(Y.id + ' initialized', 'info', 'yui');
506
* Executes a method on a YUI instance with
507
* the specified id if the specified method is whitelisted.
509
* @param id {String} the YUI instance id.
510
* @param method {String} the name of the method to exectute.
512
* @param args {Array} the arguments to apply to the method.
513
* @return {Object} the return value from the applied method or null.
515
applyTo: function(id, method, args) {
516
if (!(method in APPLY_TO_AUTH)) {
517
this.log(method + ': applyTo not allowed', 'warn', 'yui');
521
var instance = instances[id], nest, m, i;
523
nest = method.split('.');
525
for (i = 0; i < nest.length; i = i + 1) {
528
this.log('applyTo not found: ' + method, 'warn', 'yui');
531
return m && m.apply(instance, args);
538
Registers a module with the YUI global. The easiest way to create a
539
first-class YUI module is to use the YUI component build tool.
541
http://yuilibrary.com/projects/builder
543
The build system will produce the `YUI.add` wrapper for you module, along
544
with any configuration info required for the module.
546
@param name {String} module name.
547
@param fn {Function} entry point into the module that is used to bind module to the YUI instance.
548
@param {YUI} fn.Y The YUI instance this module is executed in.
549
@param {String} fn.name The name of the module
550
@param version {String} version string.
551
@param details {Object} optional config data:
552
@param details.requires {Array} features that must be present before this module can be attached.
553
@param details.optional {Array} optional features that should be present if loadOptional
554
is defined. Note: modules are not often loaded this way in YUI 3,
555
but this field is still useful to inform the user that certain
556
features in the component will require additional dependencies.
557
@param details.use {Array} features that are included within this module which need to
558
be attached automatically when this module is attached. This
559
supports the YUI 3 rollup system -- a module with submodules
560
defined will need to have the submodules listed in the 'use'
561
config. The YUI component build tool does this for you.
562
@return {YUI} the YUI instance.
565
YUI.add('davglass', function(Y, name) {
566
Y.davglass = function() {
567
alert('Dav was here!');
569
}, '3.4.0', { requires: ['yui-base', 'harley-davidson', 'mt-dew'] });
572
add: function(name, fn, version, details) {
573
details = details || {};
582
i, versions = env.versions;
584
env.mods[name] = mod;
585
versions[version] = versions[version] || {};
586
versions[version][name] = mod;
588
for (i in instances) {
589
if (instances.hasOwnProperty(i)) {
590
loader = instances[i].Env._loader;
592
if (!loader.moduleInfo[name] || loader.moduleInfo[name].temp) {
593
loader.addModule(details, name);
603
* Executes the function associated with each required
604
* module, binding the module to the YUI instance.
605
* @param {Array} r The array of modules to attach
606
* @param {Boolean} [moot=false] Don't throw a warning if the module is not attached
610
_attach: function(r, moot) {
611
var i, name, mod, details, req, use, after,
613
aliases = YUI.Env.aliases,
615
loader = Y.Env._loader,
616
done = Y.Env._attached,
617
len = r.length, loader,
620
//Check for conditional modules (in a second+ instance) and add their requirements
621
//TODO I hate this entire method, it needs to be fixed ASAP (3.5.0) ^davglass
622
for (i = 0; i < len; i++) {
626
if (loader && loader.conditions[name]) {
627
Y.Object.each(loader.conditions[name], function(def) {
628
var go = def && ((def.ua && Y.UA[def.ua]) || (def.test && def.test(Y)));
638
for (i = 0; i < len; i++) {
643
if (aliases && aliases[name]) {
644
Y._attach(aliases[name]);
648
if (loader && loader.moduleInfo[name]) {
649
mod = loader.moduleInfo[name];
653
// Y.log('no js def for: ' + name, 'info', 'yui');
655
//if (!loader || !loader.moduleInfo[name]) {
656
//if ((!loader || !loader.moduleInfo[name]) && !moot) {
658
if ((name.indexOf('skin-') === -1) && (name.indexOf('css') === -1)) {
659
Y.Env._missed.push(name);
660
Y.Env._missed = Y.Array.dedupe(Y.Env._missed);
661
Y.message('NOT loaded: ' + name, 'warn', 'yui');
666
//Don't like this, but in case a mod was asked for once, then we fetch it
667
//We need to remove it from the missed list ^davglass
668
for (j = 0; j < Y.Env._missed.length; j++) {
669
if (Y.Env._missed[j] === name) {
670
Y.message('Found: ' + name + ' (was reported as missing earlier)', 'warn', 'yui');
671
Y.Env._missed.splice(j, 1);
674
details = mod.details;
675
req = details.requires;
677
after = details.after;
680
for (j = 0; j < req.length; j++) {
682
if (!Y._attach(req)) {
691
for (j = 0; j < after.length; j++) {
692
if (!done[after[j]]) {
693
if (!Y._attach(after, true)) {
705
Y.error('Attach error: ' + name, e, name);
711
for (j = 0; j < use.length; j++) {
713
if (!Y._attach(use)) {
731
* Attaches one or more modules to the YUI instance. When this
732
* is executed, the requirements are analyzed, and one of
733
* several things can happen:
735
* * All requirements are available on the page -- The modules
736
* are attached to the instance. If supplied, the use callback
737
* is executed synchronously.
739
* * Modules are missing, the Get utility is not available OR
740
* the 'bootstrap' config is false -- A warning is issued about
741
* the missing modules and all available modules are attached.
743
* * Modules are missing, the Loader is not available but the Get
744
* utility is and boostrap is not false -- The loader is bootstrapped
745
* before doing the following....
747
* * Modules are missing and the Loader is available -- The loader
748
* expands the dependency tree and fetches missing modules. When
749
* the loader is finshed the callback supplied to use is executed
753
* @param modules* {String|Array} 1-n modules to bind (uses arguments array).
754
* @param [callback] {Function} callback function executed when
755
* the instance has the required functionality. If included, it
756
* must be the last parameter.
757
* @param callback.Y {YUI} The `YUI` instance created for this sandbox
758
* @param callback.data {Object} Object data returned from `Loader`.
761
* // loads and attaches dd and its dependencies
762
* YUI().use('dd', function(Y) {});
764
* // loads and attaches dd and node as well as all of their dependencies (since 3.4.0)
765
* YUI().use(['dd', 'node'], function(Y) {});
767
* // attaches all modules that are available on the page
768
* YUI().use('*', function(Y) {});
770
* // intrinsic YUI gallery support (since 3.1.0)
771
* YUI().use('gallery-yql', function(Y) {});
773
* // intrinsic YUI 2in3 support (since 3.1.0)
774
* YUI().use('yui2-datatable', function(Y) {});
776
* @return {YUI} the YUI instance.
779
var args = SLICE.call(arguments, 0),
780
callback = args[args.length - 1],
788
// The last argument supplied to use can be a load complete callback
789
if (Y.Lang.isFunction(callback)) {
794
if (Y.Lang.isArray(args[0])) {
798
if (Y.config.cacheUse) {
799
while ((name = args[i++])) {
800
if (!Env._attached[name]) {
808
Y.log('already provisioned: ' + args, 'info', 'yui');
810
Y._notify(callback, ALREADY_DONE, args);
816
Y._useQueue = Y._useQueue || new Y.Queue();
817
Y._useQueue.add([args, callback]);
819
Y._use(args, function(Y, response) {
820
Y._notify(callback, response, args);
827
* Notify handler from Loader for attachment/load errors
829
* @param callback {Function} The callback to pass to the `Y.config.loadErrorFn`
830
* @param response {Object} The response returned from Loader
831
* @param args {Array} The aruments passed from Loader
834
_notify: function(callback, response, args) {
835
if (!response.success && this.config.loadErrorFn) {
836
this.config.loadErrorFn.call(this, this, callback, response, args);
837
} else if (callback) {
839
callback(this, response);
841
this.error('use callback error', e, args);
847
* This private method is called from the `use` method queue. To ensure that only one set of loading
848
* logic is performed at a time.
851
* @param args* {String} 1-n modules to bind (uses arguments array).
852
* @param *callback {Function} callback function executed when
853
* the instance has the required functionality. If included, it
854
* must be the last parameter.
856
_use: function(args, callback) {
859
this._attach(['yui-base']);
862
var len, loader, handleBoot, handleRLS,
868
aliases = G_ENV.aliases,
869
queue = G_ENV._loaderQueue,
873
boot = config.bootstrap,
877
fetchCSS = config.fetchCSS,
878
process = function(names, skip) {
887
for (i = 0; i < names.length; i++) {
888
if (aliases[names[i]]) {
889
a = [].concat(a, aliases[names[i]]);
897
YArray.each(names, function(name) {
899
// add this module to full list of things to attach
904
// only attach a module once
909
var m = mods[name], req, use;
913
req = m.details.requires;
916
// CSS files don't register themselves, see if it has
918
if (!G_ENV._loaded[VERSION][name]) {
921
used[name] = true; // probably css
925
// make sure requirements are attached
926
if (req && req.length) {
930
// make sure we grab the submodule dependencies too
931
if (use && use.length) {
937
handleLoader = function(fromLoader) {
938
var response = fromLoader || {
944
data = response.data;
949
origMissing = missing;
953
redo = missing.length;
955
if (missing.sort().join() ==
956
origMissing.sort().join()) {
964
Y._use(missing, function() {
965
Y.log('Nested use callback: ' + data, 'info', 'yui');
966
if (Y._attach(data)) {
967
Y._notify(callback, response, data);
972
// Y.log('attaching from loader: ' + data, 'info', 'yui');
973
ret = Y._attach(data);
976
Y._notify(callback, response, args);
980
if (Y._useQueue && Y._useQueue.size() && !Y._loading) {
981
Y._use.apply(Y, Y._useQueue.next());
986
// Y.log(Y.id + ': use called: ' + a + ' :: ' + callback, 'info', 'yui');
988
// YUI().use('*'); // bind everything available
989
if (firstArg === '*') {
990
ret = Y._attach(Y.Object.keys(mods));
997
if (mods['loader'] && !Y.Loader) {
998
Y.log('Loader was found in meta, but it is not attached. Attaching..', 'info', 'yui');
999
Y._attach(['loader']);
1002
// Y.log('before loader requirements: ' + args, 'info', 'yui');
1004
// use loader to expand dependencies and sort the
1005
// requirements if it is available.
1006
if (boot && Y.Loader && args.length) {
1007
loader = getLoader(Y);
1008
loader.require(args);
1009
loader.ignoreRegistered = true;
1010
loader._boot = true;
1011
loader.calculate(null, (fetchCSS) ? null : 'js');
1012
args = loader.sorted;
1013
loader._boot = false;
1016
// process each requirement and any additional requirements
1017
// the module metadata specifies
1020
len = missing.length;
1023
missing = Y.Object.keys(YArray.hash(missing));
1024
len = missing.length;
1025
Y.log('Modules missing: ' + missing + ', ' + missing.length, 'info', 'yui');
1030
if (boot && len && Y.Loader) {
1031
// Y.log('Using loader to fetch missing deps: ' + missing, 'info', 'yui');
1032
Y.log('Using Loader', 'info', 'yui');
1034
loader = getLoader(Y);
1035
loader.onEnd = handleLoader;
1038
loader.ignoreRegistered = false;
1039
loader.require(args);
1040
loader.insert(null, (fetchCSS) ? null : 'js');
1042
} else if (boot && len && Y.Get && !Env.bootstrapped) {
1046
handleBoot = function() {
1048
queue.running = false;
1049
Env.bootstrapped = true;
1050
G_ENV._bootstrapping = false;
1051
if (Y._attach(['loader'])) {
1052
Y._use(args, callback);
1056
if (G_ENV._bootstrapping) {
1057
Y.log('Waiting for loader', 'info', 'yui');
1058
queue.add(handleBoot);
1060
G_ENV._bootstrapping = true;
1061
Y.log('Fetching loader: ' + config.base + config.loaderPath, 'info', 'yui');
1062
Y.Get.script(config.base + config.loaderPath, {
1068
Y.log('Attaching available dependencies: ' + args, 'info', 'yui');
1069
ret = Y._attach(args);
1080
Adds a namespace object onto the YUI global if called statically.
1082
// creates YUI.your.namespace.here as nested objects
1083
YUI.namespace("your.namespace.here");
1085
If called as a method on a YUI <em>instance</em>, it creates the
1086
namespace on the instance.
1088
// creates Y.property.package
1089
Y.namespace("property.package");
1091
Dots in the input string cause `namespace` to create nested objects for
1092
each token. If any part of the requested namespace already exists, the
1093
current object will be left in place. This allows multiple calls to
1094
`namespace` to preserve existing namespaced properties.
1096
If the first token in the namespace string is "YAHOO", the token is
1099
Be careful with namespace tokens. Reserved words may work in some browsers
1100
and not others. For instance, the following will fail in some browsers
1101
because the supported version of JavaScript reserves the word "long":
1103
Y.namespace("really.long.nested.namespace");
1105
<em>Note: If you pass multiple arguments to create multiple namespaces, only
1106
the last one created is returned from this function.</em>
1109
@param {String} namespace* namespaces to create.
1110
@return {Object} A reference to the last namespace object created.
1112
namespace: function() {
1113
var a = arguments, o, i = 0, j, d, arg;
1115
for (; i < a.length; i++) {
1116
o = this; //Reset base object per argument or it will get reused from the last
1118
if (arg.indexOf(PERIOD) > -1) { //Skip this if no "." is present
1119
d = arg.split(PERIOD);
1120
for (j = (d[0] == 'YAHOO') ? 1 : 0; j < d.length; j++) {
1121
o[d[j]] = o[d[j]] || {};
1125
o[arg] = o[arg] || {};
1126
o = o[arg]; //Reset base object to the new object so it's returned
1132
// this is replaced if the log module is included
1135
// this is replaced if the dump module is included
1136
dump: function (o) { return ''+o; },
1139
* Report an error. The reporting mechanism is controlled by
1140
* the `throwFail` configuration attribute. If throwFail is
1141
* not specified, the message is written to the Logger, otherwise
1142
* a JS error is thrown. If an `errorFn` is specified in the config
1143
* it must return `true` to keep the error from being thrown.
1145
* @param msg {String} the error message.
1146
* @param e {Error|String} Optional JS error that was caught, or an error string.
1147
* @param src Optional additional info (passed to `Y.config.errorFn` and `Y.message`)
1148
* and `throwFail` is specified, this error will be re-thrown.
1149
* @return {YUI} this YUI instance.
1151
error: function(msg, e, src) {
1152
//TODO Add check for window.onerror here
1156
if (Y.config.errorFn) {
1157
ret = Y.config.errorFn.apply(Y, arguments);
1160
if (Y.config.throwFail && !ret) {
1161
throw (e || new Error(msg));
1163
Y.message(msg, 'error', ''+src); // don't scrub this one
1170
* Generate an id that is unique among all YUI instances
1172
* @param pre {String} optional guid prefix.
1173
* @return {String} the guid.
1175
guid: function(pre) {
1176
var id = this.Env._guidp + '_' + (++this.Env._uidx);
1177
return (pre) ? (pre + id) : id;
1181
* Returns a `guid` associated with an object. If the object
1182
* does not have one, a new one is created unless `readOnly`
1185
* @param o {Object} The object to stamp.
1186
* @param readOnly {Boolean} if `true`, a valid guid will only
1187
* be returned if the object has one assigned to it.
1188
* @return {String} The object's guid or null.
1190
stamp: function(o, readOnly) {
1196
// IE generates its own unique ID for dom nodes
1197
// The uniqueID property of a document node returns a new ID
1198
if (o.uniqueID && o.nodeType && o.nodeType !== 9) {
1201
uid = (typeof o === 'string') ? o : o._yuid;
1218
* Destroys the YUI instance
1222
destroy: function() {
1227
delete instances[Y.id];
1233
* instanceof check for objects that works around
1234
* memory leak in IE when the item tested is
1236
* @method instanceOf
1237
* @param o {Object} The object to check.
1238
* @param type {Object} The class to check against.
1243
YUI.prototype = proto;
1245
// inheritance utilities are not available yet
1246
for (prop in proto) {
1247
if (proto.hasOwnProperty(prop)) {
1248
YUI[prop] = proto[prop];
1253
Static method on the Global YUI object to apply a config to all YUI instances.
1254
It's main use case is "mashups" where several third party scripts are trying to write to
1255
a global YUI config at the same time. This way they can all call `YUI.applyConfig({})` instead of
1256
overwriting other scripts configs.
1260
@param {Object} o the configuration object.
1266
fullpath: './davglass.js'
1274
fullpath: './foo.js'
1279
YUI().use('davglass', function(Y) {
1280
//Module davglass will be available here..
1284
YUI.applyConfig = function(o) {
1288
//If there is a GlobalConfig, apply it first to set the defaults
1289
if (YUI.GlobalConfig) {
1290
this.prototype.applyConfig.call(this, YUI.GlobalConfig);
1292
//Apply this config to it
1293
this.prototype.applyConfig.call(this, o);
1294
//Reset GlobalConfig to the combined config
1295
YUI.GlobalConfig = this.config;
1298
// set up the environment
1302
// add a window load event at load time so we can capture
1303
// the case where it fires before dynamic loading is
1305
add(window, 'load', handleLoad);
1311
YUI.Env.remove = remove;
1314
// Support the CommonJS method for exporting our single global
1315
if (typeof exports == 'object') {
1323
* The config object contains all of the configuration options for
1324
* the `YUI` instance. This object is supplied by the implementer
1325
* when instantiating a `YUI` instance. Some properties have default
1326
* values if they are not supplied by the implementer. This should
1327
* not be updated directly because some values are cached. Use
1328
* `applyConfig()` to update the config object on a YUI instance that
1329
* has already been configured.
1336
* Allows the YUI seed file to fetch the loader component and library
1337
* metadata to dynamically load additional dependencies.
1339
* @property bootstrap
1345
* Turns on writing Ylog messages to the browser console.
1353
* Log to the browser console if debug is on and the browser has a
1354
* supported console.
1356
* @property useBrowserConsole
1362
* A hash of log sources that should be logged. If specified, only
1363
* log messages from these sources will be logged.
1365
* @property logInclude
1370
* A hash of log sources that should be not be logged. If specified,
1371
* all sources are logged if not on this list.
1373
* @property logExclude
1378
* Set to true if the yui seed file was dynamically loaded in
1379
* order to bootstrap components relying on the window load event
1380
* and the `domready` custom event.
1382
* @property injected
1388
* If `throwFail` is set, `Y.error` will generate or re-throw a JS Error.
1389
* Otherwise the failure is logged.
1391
* @property throwFail
1397
* The window/frame that this instance should operate in.
1401
* @default the window hosting YUI
1405
* The document associated with the 'win' configuration.
1409
* @default the document hosting YUI
1413
* A list of modules that defines the YUI core (overrides the default list).
1417
* @default [ get,features,intl-base,yui-log,yui-later,loader-base, loader-rollup, loader-yui3 ]
1421
* A list of languages in order of preference. This list is matched against
1422
* the list of available languages in modules that the YUI instance uses to
1423
* determine the best possible localization of language sensitive modules.
1424
* Languages are represented using BCP 47 language tags, such as "en-GB" for
1425
* English as used in the United Kingdom, or "zh-Hans-CN" for simplified
1426
* Chinese as used in China. The list can be provided as a comma-separated
1427
* list or as an array.
1430
* @type string|string[]
1434
* The default date format
1435
* @property dateFormat
1437
* @deprecated use configuration in `DataType.Date.format()` instead.
1441
* The default locale
1444
* @deprecated use `config.lang` instead.
1448
* The default interval when polling in milliseconds.
1449
* @property pollInterval
1455
* The number of dynamic nodes to insert by default before
1456
* automatically removing them. This applies to script nodes
1457
* because removing the node will not make the evaluated script
1458
* unavailable. Dynamic CSS is not auto purged, because removing
1459
* a linked style sheet will also remove the style definitions.
1460
* @property purgethreshold
1466
* The default interval when polling in milliseconds.
1467
* @property windowResizeDelay
1473
* Base directory for dynamic loading
1479
* The secure base dir (not implemented)
1480
* For dynamic loading.
1481
* @property secureBase
1486
* The YUI combo service base dir. Ex: `http://yui.yahooapis.com/combo?`
1487
* For dynamic loading.
1488
* @property comboBase
1493
* The root path to prepend to module path for the combo service.
1494
* Ex: 3.0.0b1/build/
1495
* For dynamic loading.
1501
* A filter to apply to result urls. This filter will modify the default
1502
* path for all modules. The default path for the YUI library is the
1503
* minified version of the files (e.g., event-min.js). The filter property
1504
* can be a predefined filter or a custom filter. The valid predefined
1508
* <dd>Selects the debug versions of the library (e.g., event-debug.js).
1509
* This option will automatically include the Logger widget</dd>
1511
* <dd>Selects the non-minified version of the library (e.g., event.js).</dd>
1513
* You can also define a custom filter, which must be an object literal
1514
* containing a search expression and a replace string:
1517
* 'searchExp': "-min\\.js",
1518
* 'replaceStr': "-debug.js"
1521
* For dynamic loading.
1524
* @type string|object
1528
* The `skin` config let's you configure application level skin
1529
* customizations. It contains the following attributes which
1530
* can be specified to override the defaults:
1532
* // The default skin, which is automatically applied if not
1533
* // overriden by a component-specific skin definition.
1534
* // Change this in to apply a different skin globally
1535
* defaultSkin: 'sam',
1537
* // This is combined with the loader base property to get
1538
* // the default root directory for a skin.
1539
* base: 'assets/skins/',
1541
* // Any component-specific overrides can be specified here,
1542
* // making it possible to load different skins for different
1543
* // components. It is possible to load more than one skin
1544
* // for a given component as well.
1546
* slider: ['capsule', 'round']
1549
* For dynamic loading.
1555
* Hash of per-component filter specification. If specified for a given
1556
* component, this overrides the filter config.
1558
* For dynamic loading.
1564
* Use the YUI combo service to reduce the number of http connections
1565
* required to load your dependencies. Turning this off will
1566
* disable combo handling for YUI and all module groups configured
1567
* with a combo service.
1569
* For dynamic loading.
1573
* @default true if 'base' is not supplied, false if it is.
1577
* A list of modules that should never be dynamically loaded
1584
* A list of modules that should always be loaded when required, even if already
1585
* present on the page.
1592
* Node or id for a node that should be used as the insertion point for new
1593
* nodes. For dynamic loading.
1595
* @property insertBefore
1600
* Object literal containing attributes to add to dynamically loaded script
1602
* @property jsAttributes
1607
* Object literal containing attributes to add to dynamically loaded link
1609
* @property cssAttributes
1614
* Number of milliseconds before a timeout occurs when dynamically
1615
* loading nodes. If not set, there is no timeout.
1621
* Callback for the 'CSSComplete' event. When dynamically loading YUI
1622
* components with CSS, this property fires when the CSS is finished
1623
* loading but script loading is still ongoing. This provides an
1624
* opportunity to enhance the presentation of a loading page a little
1625
* bit before the entire loading process is done.
1632
* A hash of module definitions to add to the list of YUI components.
1633
* These components can then be dynamically loaded side by side with
1634
* YUI via the `use()` method. This is a hash, the key is the module
1635
* name, and the value is an object literal specifying the metdata
1636
* for the module. See `Loader.addModule` for the supported module
1637
* metadata fields. Also see groups, which provides a way to
1638
* configure the base and combo spec for a set of modules.
1642
* requires: ['node'],
1643
* fullpath: '/mymod1/mymod1.js'
1646
* requires: ['mymod1'],
1647
* fullpath: '/mymod2/mymod2.js'
1649
* mymod3: '/js/mymod3.js',
1650
* mycssmod: '/css/mycssmod.css'
1659
* Aliases are dynamic groups of modules that can be used as
1664
* davglass: [ 'node', 'yql', 'dd' ],
1665
* mine: [ 'davglass', 'autocomplete']
1667
* }).use('mine', function(Y) {
1668
* //Node, YQL, DD & AutoComplete available here..
1676
* A hash of module group definitions. It for each group you
1677
* can specify a list of modules and the base path and
1678
* combo spec to use when dynamically loading the modules.
1682
* // specify whether or not this group has a combo service
1685
* // The comboSeperator to use with this group's combo handler
1688
* // The maxURLLength for this server
1689
* maxURLLength: 500,
1691
* // the base path for non-combo paths
1692
* base: 'http://yui.yahooapis.com/2.8.0r4/build/',
1694
* // the path to the combo service
1695
* comboBase: 'http://yui.yahooapis.com/combo?',
1697
* // a fragment to prepend to the path attribute when
1698
* // when building combo urls
1699
* root: '2.8.0r4/build/',
1701
* // the module definitions
1704
* path: "yahoo-dom-event/yahoo-dom-event.js"
1707
* path: "animation/animation.js",
1708
* requires: ['yui2_yde']
1719
* The loader 'path' attribute to the loader itself. This is combined
1720
* with the 'base' attribute to dynamically load the loader component
1721
* when boostrapping with the get utility alone.
1723
* @property loaderPath
1725
* @default loader/loader-min.js
1729
* Specifies whether or not YUI().use(...) will attempt to load CSS
1730
* resources at all. Any truthy value will cause CSS dependencies
1731
* to load when fetching script. The special value 'force' will
1732
* cause CSS dependencies to be loaded even if no script is needed.
1734
* @property fetchCSS
1735
* @type boolean|string
1740
* The default gallery version to build gallery module urls
1747
* The default YUI 2 version to build yui2 module urls. This is for
1748
* intrinsic YUI 2 support via the 2in3 project. Also see the '2in3'
1749
* config for pulling different revisions of the wrapped YUI 2
1758
* The 2in3 project is a deployment of the various versions of YUI 2
1759
* deployed as first-class YUI 3 modules. Eventually, the wrapper
1760
* for the modules will change (but the underlying YUI 2 code will
1761
* be the same), and you can select a particular version of
1762
* the wrapper modules via this config.
1770
* Alternative console log function for use in environments without
1771
* a supported native console. The function is executed in the
1772
* YUI instance context.
1779
* A callback to execute when Y.error is called. It receives the
1780
* error message and an javascript error object if Y.error was
1781
* executed because a javascript error was caught. The function
1782
* is executed in the YUI instance context. Returning `true` from this
1783
* function will stop the Error from being thrown.
1791
* A callback to execute when the loader fails to load one or
1792
* more resource. This could be because of a script load
1793
* failure. It can also fail if a javascript module fails
1794
* to register itself, but only when the 'requireRegistration'
1795
* is true. If this function is defined, the use() callback will
1796
* only be called when the loader succeeds, otherwise it always
1797
* executes unless there was a javascript error when attaching
1801
* @property loadErrorFn
1806
* When set to true, the YUI loader will expect that all modules
1807
* it is responsible for loading will be first-class YUI modules
1808
* that register themselves with the YUI global. If this is
1809
* set to true, loader will fail if the module registration fails
1810
* to happen after the script is loaded.
1813
* @property requireRegistration
1819
* Cache serviced use() requests.
1821
* @property cacheUse
1824
* @deprecated no longer used
1828
* Whether or not YUI should use native ES5 functionality when available for
1829
* features like `Y.Array.each()`, `Y.Object()`, etc. When `false`, YUI will
1830
* always use its own fallback implementations instead of relying on ES5
1831
* functionality, even when it's available.
1833
* @method useNativeES5
1838
YUI.add('yui-base', function(Y) {
1843
* @submodule yui-base
1846
* The YUI module contains the components required for building the YUI
1847
* seed file. This includes the script loading mechanism, a simple queue,
1848
* and the core utilities for the library.
1850
* @submodule yui-base
1854
* Provides core language utilites and extensions used throughout YUI.
1860
var L = Y.Lang || (Y.Lang = {}),
1862
STRING_PROTO = String.prototype,
1863
TOSTRING = Object.prototype.toString,
1866
'undefined' : 'undefined',
1867
'number' : 'number',
1868
'boolean' : 'boolean',
1869
'string' : 'string',
1870
'[object Function]': 'function',
1871
'[object RegExp]' : 'regexp',
1872
'[object Array]' : 'array',
1873
'[object Date]' : 'date',
1874
'[object Error]' : 'error'
1877
SUBREGEX = /\{\s*([^|}]+?)\s*(?:\|([^}]*))?\s*\}/g,
1878
TRIMREGEX = /^\s+|\s+$/g,
1879
NATIVE_FN_REGEX = /\{\s*\[(?:native code|function)\]\s*\}/i;
1881
// -- Protected Methods --------------------------------------------------------
1884
Returns `true` if the given function appears to be implemented in native code,
1885
`false` otherwise. Will always return `false` -- even in ES5-capable browsers --
1886
if the `useNativeES5` YUI config option is set to `false`.
1888
This isn't guaranteed to be 100% accurate and won't work for anything other than
1889
functions, but it can be useful for determining whether a function like
1890
`Array.prototype.forEach` is native or a JS shim provided by another library.
1892
There's a great article by @kangax discussing certain flaws with this technique:
1893
<http://perfectionkills.com/detecting-built-in-host-methods/>
1895
While his points are valid, it's still possible to benefit from this function
1896
as long as it's used carefully and sparingly, and in such a way that false
1897
negatives have minimal consequences. It's used internally to avoid using
1898
potentially broken non-native ES5 shims that have been added to the page by
1902
@param {Function} fn Function to test.
1903
@return {Boolean} `true` if _fn_ appears to be native, `false` otherwise.
1908
L._isNative = function (fn) {
1909
return !!(Y.config.useNativeES5 && fn && NATIVE_FN_REGEX.test(fn));
1912
// -- Public Methods -----------------------------------------------------------
1915
* Determines whether or not the provided item is an array.
1917
* Returns `false` for array-like collections such as the function `arguments`
1918
* collection or `HTMLElement` collections. Use `Y.Array.test()` if you want to
1919
* test for an array-like collection.
1922
* @param o The object to test.
1923
* @return {boolean} true if o is an array.
1926
L.isArray = L._isNative(Array.isArray) ? Array.isArray : function (o) {
1927
return L.type(o) === 'array';
1931
* Determines whether or not the provided item is a boolean.
1934
* @param o The object to test.
1935
* @return {boolean} true if o is a boolean.
1937
L.isBoolean = function(o) {
1938
return typeof o === 'boolean';
1942
* Determines whether or not the supplied item is a date instance.
1945
* @param o The object to test.
1946
* @return {boolean} true if o is a date.
1948
L.isDate = function(o) {
1949
return L.type(o) === 'date' && o.toString() !== 'Invalid Date' && !isNaN(o);
1954
* Determines whether or not the provided item is a function.
1955
* Note: Internet Explorer thinks certain functions are objects:
1959
* var obj = document.createElement("object");
1960
* Y.Lang.isFunction(obj.getAttribute) // reports false in IE
1962
* var input = document.createElement("input"); // append to body
1963
* Y.Lang.isFunction(input.focus) // reports false in IE
1967
* You will have to implement additional tests if these functions
1971
* @method isFunction
1973
* @param o The object to test.
1974
* @return {boolean} true if o is a function.
1976
L.isFunction = function(o) {
1977
return L.type(o) === 'function';
1981
* Determines whether or not the provided item is null.
1984
* @param o The object to test.
1985
* @return {boolean} true if o is null.
1987
L.isNull = function(o) {
1992
* Determines whether or not the provided item is a legal number.
1995
* @param o The object to test.
1996
* @return {boolean} true if o is a number.
1998
L.isNumber = function(o) {
1999
return typeof o === 'number' && isFinite(o);
2003
* Determines whether or not the provided item is of type object
2004
* or function. Note that arrays are also objects, so
2005
* <code>Y.Lang.isObject([]) === true</code>.
2008
* @param o The object to test.
2009
* @param failfn {boolean} fail if the input is a function.
2010
* @return {boolean} true if o is an object.
2011
* @see isPlainObject
2013
L.isObject = function(o, failfn) {
2015
return (o && (t === 'object' ||
2016
(!failfn && (t === 'function' || L.isFunction(o))))) || false;
2020
* Determines whether or not the provided item is a string.
2023
* @param o The object to test.
2024
* @return {boolean} true if o is a string.
2026
L.isString = function(o) {
2027
return typeof o === 'string';
2031
* Determines whether or not the provided item is undefined.
2032
* @method isUndefined
2034
* @param o The object to test.
2035
* @return {boolean} true if o is undefined.
2037
L.isUndefined = function(o) {
2038
return typeof o === 'undefined';
2042
* A convenience method for detecting a legitimate non-null value.
2043
* Returns false for null/undefined/NaN, true for other values,
2044
* including 0/false/''
2047
* @param o The item to test.
2048
* @return {boolean} true if it is not null/undefined/NaN || false.
2050
L.isValue = function(o) {
2057
case 'null': // fallthru
2067
* Returns the current time in milliseconds.
2070
* @return {Number} Current time in milliseconds.
2074
L.now = Date.now || function () {
2075
return new Date().getTime();
2079
* Lightweight version of <code>Y.substitute</code>. Uses the same template
2080
* structure as <code>Y.substitute</code>, but doesn't support recursion,
2081
* auto-object coersion, or formats.
2083
* @param {string} s String to be modified.
2084
* @param {object} o Object containing replacement values.
2085
* @return {string} the substitute result.
2089
L.sub = function(s, o) {
2090
return s.replace ? s.replace(SUBREGEX, function (match, key) {
2091
return L.isUndefined(o[key]) ? match : o[key];
2096
* Returns a string without any leading or trailing whitespace. If
2097
* the input is not a string, the input will be returned untouched.
2100
* @param s {string} the string to trim.
2101
* @return {string} the trimmed string.
2103
L.trim = STRING_PROTO.trim ? function(s) {
2104
return s && s.trim ? s.trim() : s;
2107
return s.replace(TRIMREGEX, '');
2114
* Returns a string without any leading whitespace.
2117
* @param s {string} the string to trim.
2118
* @return {string} the trimmed string.
2120
L.trimLeft = STRING_PROTO.trimLeft ? function (s) {
2121
return s.trimLeft();
2123
return s.replace(/^\s+/, '');
2127
* Returns a string without any trailing whitespace.
2130
* @param s {string} the string to trim.
2131
* @return {string} the trimmed string.
2133
L.trimRight = STRING_PROTO.trimRight ? function (s) {
2134
return s.trimRight();
2136
return s.replace(/\s+$/, '');
2140
Returns one of the following strings, representing the type of the item passed
2157
* `typeof HTMLElementCollection` returns function in Safari, but
2158
`Y.Lang.type()` reports "object", which could be a good thing --
2159
but it actually caused the logic in <code>Y.Lang.isObject</code> to fail.
2162
@param o the item to test.
2163
@return {string} the detected type.
2166
L.type = function(o) {
2167
return TYPES[typeof o] || TYPES[TOSTRING.call(o)] || (o ? 'object' : 'null');
2175
Native = Array.prototype,
2177
hasOwn = Object.prototype.hasOwnProperty;
2180
Provides utility methods for working with arrays. Additional array helpers can
2181
be found in the `collection` and `array-extras` modules.
2183
`Y.Array(thing)` returns a native array created from _thing_. Depending on
2184
_thing_'s type, one of the following will happen:
2186
* Arrays are returned unmodified unless a non-zero _startIndex_ is
2188
* Array-like collections (see `Array.test()`) are converted to arrays.
2189
* For everything else, a new array is created with _thing_ as the sole
2192
Note: elements that are also collections, such as `<form>` and `<select>`
2193
elements, are not automatically converted to arrays. To force a conversion,
2194
pass `true` as the value of the _force_ parameter.
2198
@param {Any} thing The thing to arrayify.
2199
@param {Number} [startIndex=0] If non-zero and _thing_ is an array or array-like
2200
collection, a subset of items starting at the specified index will be
2202
@param {Boolean} [force=false] If `true`, _thing_ will be treated as an
2203
array-like collection no matter what.
2204
@return {Array} A native array created from _thing_, according to the rules
2207
function YArray(thing, startIndex, force) {
2210
startIndex || (startIndex = 0);
2212
if (force || YArray.test(thing)) {
2213
// IE throws when trying to slice HTMLElement collections.
2215
return Native.slice.call(thing, startIndex);
2219
for (len = thing.length; startIndex < len; ++startIndex) {
2220
result.push(thing[startIndex]);
2233
Dedupes an array of strings, returning an array that's guaranteed to contain
2234
only one copy of a given string.
2236
This method differs from `Array.unique()` in that it's optimized for use only
2237
with strings, whereas `unique` may be used with other types (but is slower).
2238
Using `dedupe()` with non-string values may result in unexpected behavior.
2241
@param {String[]} array Array of strings to dedupe.
2242
@return {Array} Deduped copy of _array_.
2246
YArray.dedupe = function (array) {
2251
for (i = 0, len = array.length; i < len; ++i) {
2254
if (!hasOwn.call(hash, item)) {
2264
Executes the supplied function on each item in the array. This method wraps
2265
the native ES5 `Array.forEach()` method if available.
2268
@param {Array} array Array to iterate.
2269
@param {Function} fn Function to execute on each item in the array. The function
2270
will receive the following arguments:
2271
@param {Any} fn.item Current array item.
2272
@param {Number} fn.index Current array index.
2273
@param {Array} fn.array Array being iterated.
2274
@param {Object} [thisObj] `this` object to use when calling _fn_.
2275
@return {YUI} The YUI instance.
2278
YArray.each = YArray.forEach = Lang._isNative(Native.forEach) ? function (array, fn, thisObj) {
2279
Native.forEach.call(array || [], fn, thisObj || Y);
2281
} : function (array, fn, thisObj) {
2282
for (var i = 0, len = (array && array.length) || 0; i < len; ++i) {
2284
fn.call(thisObj || Y, array[i], i, array);
2299
Returns an object using the first array as keys and the second as values. If
2300
the second array is not provided, or if it doesn't contain the same number of
2301
values as the first array, then `true` will be used in place of the missing
2306
Y.Array.hash(['a', 'b', 'c'], ['foo', 'bar']);
2307
// => {a: 'foo', b: 'bar', c: true}
2310
@param {String[]} keys Array of strings to use as keys.
2311
@param {Array} [values] Array to use as values.
2312
@return {Object} Hash using the first array as keys and the second as values.
2315
YArray.hash = function (keys, values) {
2317
vlen = (values && values.length) || 0,
2320
for (i = 0, len = keys.length; i < len; ++i) {
2322
hash[keys[i]] = vlen > i && i in values ? values[i] : true;
2330
Returns the index of the first item in the array that's equal (using a strict
2331
equality check) to the specified _value_, or `-1` if the value isn't found.
2333
This method wraps the native ES5 `Array.indexOf()` method if available.
2336
@param {Array} array Array to search.
2337
@param {Any} value Value to search for.
2338
@param {Number} [from=0] The index at which to begin the search.
2339
@return {Number} Index of the item strictly equal to _value_, or `-1` if not
2343
YArray.indexOf = Lang._isNative(Native.indexOf) ? function (array, value, from) {
2344
return Native.indexOf.call(array, value, from);
2345
} : function (array, value, from) {
2346
// http://es5.github.com/#x15.4.4.14
2347
var len = array.length;
2350
from = (from > 0 || -1) * Math.floor(Math.abs(from));
2360
for (; from < len; ++from) {
2361
if (from in array && array[from] === value) {
2370
Numeric sort convenience function.
2372
The native `Array.prototype.sort()` function converts values to strings and
2373
sorts them in lexicographic order, which is unsuitable for sorting numeric
2374
values. Provide `Array.numericSort` as a custom sort function when you want
2375
to sort values in numeric order.
2379
[42, 23, 8, 16, 4, 15].sort(Y.Array.numericSort);
2380
// => [4, 8, 15, 16, 23, 42]
2383
@param {Number} a First value to compare.
2384
@param {Number} b Second value to compare.
2385
@return {Number} Difference between _a_ and _b_.
2388
YArray.numericSort = function (a, b) {
2393
Executes the supplied function on each item in the array. Returning a truthy
2394
value from the function will stop the processing of remaining items.
2397
@param {Array} array Array to iterate over.
2398
@param {Function} fn Function to execute on each item. The function will receive
2399
the following arguments:
2400
@param {Any} fn.value Current array item.
2401
@param {Number} fn.index Current array index.
2402
@param {Array} fn.array Array being iterated over.
2403
@param {Object} [thisObj] `this` object to use when calling _fn_.
2404
@return {Boolean} `true` if the function returns a truthy value on any of the
2405
items in the array; `false` otherwise.
2408
YArray.some = Lang._isNative(Native.some) ? function (array, fn, thisObj) {
2409
return Native.some.call(array, fn, thisObj);
2410
} : function (array, fn, thisObj) {
2411
for (var i = 0, len = array.length; i < len; ++i) {
2412
if (i in array && fn.call(thisObj, array[i], i, array)) {
2421
Evaluates _obj_ to determine if it's an array, an array-like collection, or
2422
something else. This is useful when working with the function `arguments`
2423
collection and `HTMLElement` collections.
2425
Note: This implementation doesn't consider elements that are also
2426
collections, such as `<form>` and `<select>`, to be array-like.
2429
@param {Object} obj Object to test.
2430
@return {Number} A number indicating the results of the test:
2432
* 0: Neither an array nor an array-like collection.
2434
* 2: Array-like collection.
2438
YArray.test = function (obj) {
2441
if (Lang.isArray(obj)) {
2443
} else if (Lang.isObject(obj)) {
2445
// indexed, but no tagName (element) or alert (window),
2446
// or functions without apply/call (Safari
2447
// HTMLElementCollection bug).
2448
if ('length' in obj && !obj.tagName && !obj.alert && !obj.apply) {
2457
* The YUI module contains the components required for building the YUI
2458
* seed file. This includes the script loading mechanism, a simple queue,
2459
* and the core utilities for the library.
2461
* @submodule yui-base
2465
* A simple FIFO queue. Items are added to the Queue with add(1..n items) and
2466
* removed using next().
2470
* @param {MIXED} item* 0..n items to seed the queue.
2474
this.add.apply(this, arguments);
2479
* Initialize the queue
2486
* The collection of enqueued items
2496
* Get the next item in the queue. FIFO support
2499
* @return {MIXED} the next item in the queue.
2502
return this._q.shift();
2506
* Get the last in the queue. LIFO support.
2509
* @return {MIXED} the last item in the queue.
2512
return this._q.pop();
2516
* Add 0..n items to the end of the queue.
2519
* @param {MIXED} item* 0..n items.
2520
* @return {object} this queue.
2523
this._q.push.apply(this._q, arguments);
2529
* Returns the current number of queued items.
2532
* @return {Number} The size.
2535
return this._q.length;
2541
YUI.Env._loaderQueue = YUI.Env._loaderQueue || new Queue();
2544
The YUI module contains the components required for building the YUI seed file.
2545
This includes the script loading mechanism, a simple queue, and the core
2546
utilities for the library.
2552
var CACHED_DELIMITER = '__',
2554
hasOwn = Object.prototype.hasOwnProperty,
2555
isObject = Y.Lang.isObject;
2558
Returns a wrapper for a function which caches the return value of that function,
2559
keyed off of the combined string representation of the argument values provided
2560
when the wrapper is called.
2562
Calling this function again with the same arguments will return the cached value
2563
rather than executing the wrapped function.
2565
Note that since the cache is keyed off of the string representation of arguments
2566
passed to the wrapper function, arguments that aren't strings and don't provide
2567
a meaningful `toString()` method may result in unexpected caching behavior. For
2568
example, the objects `{}` and `{foo: 'bar'}` would both be converted to the
2569
string `[object Object]` when used as a cache key.
2572
@param {Function} source The function to memoize.
2573
@param {Object} [cache={}] Object in which to store cached values. You may seed
2574
this object with pre-existing cached values if desired.
2575
@param {any} [refetch] If supplied, this value is compared with the cached value
2576
using a `==` comparison. If the values are equal, the wrapped function is
2577
executed again even though a cached value exists.
2578
@return {Function} Wrapped function.
2581
Y.cached = function (source, cache, refetch) {
2582
cache || (cache = {});
2584
return function (arg) {
2585
var key = arguments.length > 1 ?
2586
Array.prototype.join.call(arguments, CACHED_DELIMITER) :
2589
if (!(key in cache) || (refetch && cache[key] == refetch)) {
2590
cache[key] = source.apply(source, arguments);
2598
Returns the `location` object from the window/frame in which this YUI instance
2599
operates, or `undefined` when executing in a non-browser environment
2602
It is _not_ recommended to hold references to the `window.location` object
2603
outside of the scope of a function in which its properties are being accessed or
2604
its methods are being called. This is because of a nasty bug/issue that exists
2605
in both Safari and MobileSafari browsers:
2606
[WebKit Bug 34679](https://bugs.webkit.org/show_bug.cgi?id=34679).
2609
@return {location} The `location` object from the window/frame in which this YUI
2613
Y.getLocation = function () {
2614
// It is safer to look this up every time because yui-base is attached to a
2615
// YUI instance before a user's config is applied; i.e. `Y.config.win` does
2616
// not point the correct window object when this file is loaded.
2617
var win = Y.config.win;
2619
// It is not safe to hold a reference to the `location` object outside the
2620
// scope in which it is being used. The WebKit engine used in Safari and
2621
// MobileSafari will "disconnect" the `location` object from the `window`
2622
// when a page is restored from back/forward history cache.
2623
return win && win.location;
2627
Returns a new object containing all of the properties of all the supplied
2628
objects. The properties from later objects will overwrite those in earlier
2631
Passing in a single object will create a shallow copy of it. For a deep copy,
2635
@param {Object} objects* One or more objects to merge.
2636
@return {Object} A new merged object.
2638
Y.merge = function () {
2639
var args = arguments,
2644
for (; i < len; ++i) {
2645
Y.mix(result, args[i], true);
2652
Mixes _supplier_'s properties into _receiver_.
2654
Properties on _receiver_ or _receiver_'s prototype will not be overwritten or
2655
shadowed unless the _overwrite_ parameter is `true`, and will not be merged
2656
unless the _merge_ parameter is `true`.
2658
In the default mode (0), only properties the supplier owns are copied (prototype
2659
properties are not copied). The following copying modes are available:
2661
* `0`: _Default_. Object to object.
2662
* `1`: Prototype to prototype.
2663
* `2`: Prototype to prototype and object to object.
2664
* `3`: Prototype to object.
2665
* `4`: Object to prototype.
2668
@param {Function|Object} receiver The object or function to receive the mixed
2670
@param {Function|Object} supplier The object or function supplying the
2671
properties to be mixed.
2672
@param {Boolean} [overwrite=false] If `true`, properties that already exist
2673
on the receiver will be overwritten with properties from the supplier.
2674
@param {String[]} [whitelist] An array of property names to copy. If
2675
specified, only the whitelisted properties will be copied, and all others
2677
@param {Number} [mode=0] Mix mode to use. See above for available modes.
2678
@param {Boolean} [merge=false] If `true`, objects and arrays that already
2679
exist on the receiver will have the corresponding object/array from the
2680
supplier merged into them, rather than being skipped or overwritten. When
2681
both _overwrite_ and _merge_ are `true`, _merge_ takes precedence.
2682
@return {Function|Object|YUI} The receiver, or the YUI instance if the
2683
specified receiver is falsy.
2685
Y.mix = function(receiver, supplier, overwrite, whitelist, mode, merge) {
2686
var alwaysOverwrite, exists, from, i, key, len, to;
2688
// If no supplier is given, we return the receiver. If no receiver is given,
2689
// we return Y. Returning Y doesn't make much sense to me, but it's
2690
// grandfathered in for backcompat reasons.
2691
if (!receiver || !supplier) {
2692
return receiver || Y;
2696
// In mode 2 (prototype to prototype and object to object), we recurse
2697
// once to do the proto to proto mix. The object to object mix will be
2698
// handled later on.
2700
Y.mix(receiver.prototype, supplier.prototype, overwrite,
2701
whitelist, 0, merge);
2704
// Depending on which mode is specified, we may be copying from or to
2705
// the prototypes of the supplier and receiver.
2706
from = mode === 1 || mode === 3 ? supplier.prototype : supplier;
2707
to = mode === 1 || mode === 4 ? receiver.prototype : receiver;
2709
// If either the supplier or receiver doesn't actually have a
2710
// prototype property, then we could end up with an undefined `from`
2711
// or `to`. If that happens, we abort and return the receiver.
2720
// If `overwrite` is truthy and `merge` is falsy, then we can skip a
2721
// property existence check on each iteration and save some time.
2722
alwaysOverwrite = overwrite && !merge;
2725
for (i = 0, len = whitelist.length; i < len; ++i) {
2728
// We call `Object.prototype.hasOwnProperty` instead of calling
2729
// `hasOwnProperty` on the object itself, since the object's
2730
// `hasOwnProperty` method may have been overridden or removed.
2731
// Also, some native objects don't implement a `hasOwnProperty`
2733
if (!hasOwn.call(from, key)) {
2737
// The `key in to` check here is (sadly) intentional for backwards
2738
// compatibility reasons. It prevents undesired shadowing of
2739
// prototype members on `to`.
2740
exists = alwaysOverwrite ? false : key in to;
2742
if (merge && exists && isObject(to[key], true)
2743
&& isObject(from[key], true)) {
2744
// If we're in merge mode, and the key is present on both
2745
// objects, and the value on both objects is either an object or
2746
// an array (but not a function), then we recurse to merge the
2747
// `from` value into the `to` value instead of overwriting it.
2749
// Note: It's intentional that the whitelist isn't passed to the
2750
// recursive call here. This is legacy behavior that lots of
2751
// code still depends on.
2752
Y.mix(to[key], from[key], overwrite, null, 0, merge);
2753
} else if (overwrite || !exists) {
2754
// We're not in merge mode, so we'll only copy the `from` value
2755
// to the `to` value if we're in overwrite mode or if the
2756
// current key doesn't exist on the `to` object.
2757
to[key] = from[key];
2762
// The code duplication here is for runtime performance reasons.
2763
// Combining whitelist and non-whitelist operations into a single
2764
// loop or breaking the shared logic out into a function both result
2765
// in worse performance, and Y.mix is critical enough that the byte
2766
// tradeoff is worth it.
2767
if (!hasOwn.call(from, key)) {
2771
// The `key in to` check here is (sadly) intentional for backwards
2772
// compatibility reasons. It prevents undesired shadowing of
2773
// prototype members on `to`.
2774
exists = alwaysOverwrite ? false : key in to;
2776
if (merge && exists && isObject(to[key], true)
2777
&& isObject(from[key], true)) {
2778
Y.mix(to[key], from[key], overwrite, null, 0, merge);
2779
} else if (overwrite || !exists) {
2780
to[key] = from[key];
2784
// If this is an IE browser with the JScript enumeration bug, force
2785
// enumeration of the buggy properties by making a recursive call with
2786
// the buggy properties as the whitelist.
2787
if (Y.Object._hasEnumBug) {
2788
Y.mix(to, from, overwrite, Y.Object._forceEnum, mode, merge);
2795
* The YUI module contains the components required for building the YUI
2796
* seed file. This includes the script loading mechanism, a simple queue,
2797
* and the core utilities for the library.
2799
* @submodule yui-base
2803
* Adds utilities to the YUI instance for working with objects.
2809
hasOwn = Object.prototype.hasOwnProperty,
2811
UNDEFINED, // <-- Note the comma. We're still declaring vars.
2814
* Returns a new object that uses _obj_ as its prototype. This method wraps the
2815
* native ES5 `Object.create()` method if available, but doesn't currently
2816
* pass through `Object.create()`'s second argument (properties) in order to
2817
* ensure compatibility with older browsers.
2820
* @param {Object} obj Prototype object.
2821
* @return {Object} New object using _obj_ as its prototype.
2824
O = Y.Object = Lang._isNative(Object.create) ? function (obj) {
2825
// We currently wrap the native Object.create instead of simply aliasing it
2826
// to ensure consistency with our fallback shim, which currently doesn't
2827
// support Object.create()'s second argument (properties). Once we have a
2828
// safe fallback for the properties arg, we can stop wrapping
2830
return Object.create(obj);
2832
// Reusable constructor function for the Object.create() shim.
2836
return function (obj) {
2843
* Property names that IE doesn't enumerate in for..in loops, even when they
2844
* should be enumerable. When `_hasEnumBug` is `true`, it's necessary to
2845
* manually enumerate these properties.
2847
* @property _forceEnum
2852
forceEnum = O._forceEnum = [
2855
'propertyIsEnumerable',
2862
* `true` if this browser has the JScript enumeration bug that prevents
2863
* enumeration of the properties named in the `_forceEnum` array, `false`
2867
* - <https://developer.mozilla.org/en/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug>
2868
* - <http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation>
2870
* @property _hasEnumBug
2875
hasEnumBug = O._hasEnumBug = !{valueOf: 0}.propertyIsEnumerable('valueOf'),
2878
* `true` if this browser incorrectly considers the `prototype` property of
2879
* functions to be enumerable. Currently known to affect Opera 11.50.
2881
* @property _hasProtoEnumBug
2886
hasProtoEnumBug = O._hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'),
2889
* Returns `true` if _key_ exists on _obj_, `false` if _key_ doesn't exist or
2890
* exists only on _obj_'s prototype. This is essentially a safer version of
2891
* `obj.hasOwnProperty()`.
2894
* @param {Object} obj Object to test.
2895
* @param {String} key Property name to look for.
2896
* @return {Boolean} `true` if _key_ exists on _obj_, `false` otherwise.
2899
owns = O.owns = function (obj, key) {
2900
return !!obj && hasOwn.call(obj, key);
2901
}; // <-- End of var declarations.
2904
* Alias for `owns()`.
2907
* @param {Object} obj Object to test.
2908
* @param {String} key Property name to look for.
2909
* @return {Boolean} `true` if _key_ exists on _obj_, `false` otherwise.
2915
* Returns an array containing the object's enumerable keys. Does not include
2916
* prototype keys or non-enumerable keys.
2918
* Note that keys are returned in enumeration order (that is, in the same order
2919
* that they would be enumerated by a `for-in` loop), which may not be the same
2920
* as the order in which they were defined.
2922
* This method is an alias for the native ES5 `Object.keys()` method if
2927
* Y.Object.keys({a: 'foo', b: 'bar', c: 'baz'});
2928
* // => ['a', 'b', 'c']
2931
* @param {Object} obj An object.
2932
* @return {String[]} Array of keys.
2935
O.keys = Lang._isNative(Object.keys) ? Object.keys : function (obj) {
2936
if (!Lang.isObject(obj)) {
2937
throw new TypeError('Object.keys called on a non-object');
2943
if (hasProtoEnumBug && typeof obj === 'function') {
2945
if (owns(obj, key) && key !== 'prototype') {
2951
if (owns(obj, key)) {
2958
for (i = 0, len = forceEnum.length; i < len; ++i) {
2961
if (owns(obj, key)) {
2971
* Returns an array containing the values of the object's enumerable keys.
2973
* Note that values are returned in enumeration order (that is, in the same
2974
* order that they would be enumerated by a `for-in` loop), which may not be the
2975
* same as the order in which they were defined.
2979
* Y.Object.values({a: 'foo', b: 'bar', c: 'baz'});
2980
* // => ['foo', 'bar', 'baz']
2983
* @param {Object} obj An object.
2984
* @return {Array} Array of values.
2987
O.values = function (obj) {
2988
var keys = O.keys(obj),
2993
for (; i < len; ++i) {
2994
values.push(obj[keys[i]]);
3001
* Returns the number of enumerable keys owned by an object.
3004
* @param {Object} obj An object.
3005
* @return {Number} The object's size.
3008
O.size = function (obj) {
3010
return O.keys(obj).length;
3012
return 0; // Legacy behavior for non-objects.
3017
* Returns `true` if the object owns an enumerable property with the specified
3021
* @param {Object} obj An object.
3022
* @param {any} value The value to search for.
3023
* @return {Boolean} `true` if _obj_ contains _value_, `false` otherwise.
3026
O.hasValue = function (obj, value) {
3027
return Y.Array.indexOf(O.values(obj), value) > -1;
3031
* Executes a function on each enumerable property in _obj_. The function
3032
* receives the value, the key, and the object itself as parameters (in that
3035
* By default, only properties owned by _obj_ are enumerated. To include
3036
* prototype properties, set the _proto_ parameter to `true`.
3039
* @param {Object} obj Object to enumerate.
3040
* @param {Function} fn Function to execute on each enumerable property.
3041
* @param {mixed} fn.value Value of the current property.
3042
* @param {String} fn.key Key of the current property.
3043
* @param {Object} fn.obj Object being enumerated.
3044
* @param {Object} [thisObj] `this` object to use when calling _fn_.
3045
* @param {Boolean} [proto=false] Include prototype properties.
3046
* @return {YUI} the YUI instance.
3050
O.each = function (obj, fn, thisObj, proto) {
3054
if (proto || owns(obj, key)) {
3055
fn.call(thisObj || Y, obj[key], key, obj);
3063
* Executes a function on each enumerable property in _obj_, but halts if the
3064
* function returns a truthy value. The function receives the value, the key,
3065
* and the object itself as paramters (in that order).
3067
* By default, only properties owned by _obj_ are enumerated. To include
3068
* prototype properties, set the _proto_ parameter to `true`.
3071
* @param {Object} obj Object to enumerate.
3072
* @param {Function} fn Function to execute on each enumerable property.
3073
* @param {mixed} fn.value Value of the current property.
3074
* @param {String} fn.key Key of the current property.
3075
* @param {Object} fn.obj Object being enumerated.
3076
* @param {Object} [thisObj] `this` object to use when calling _fn_.
3077
* @param {Boolean} [proto=false] Include prototype properties.
3078
* @return {Boolean} `true` if any execution of _fn_ returns a truthy value,
3079
* `false` otherwise.
3082
O.some = function (obj, fn, thisObj, proto) {
3086
if (proto || owns(obj, key)) {
3087
if (fn.call(thisObj || Y, obj[key], key, obj)) {
3097
* Retrieves the sub value at the provided path,
3098
* from the value object provided.
3102
* @param o The object from which to extract the property value.
3103
* @param path {Array} A path array, specifying the object traversal path
3104
* from which to obtain the sub value.
3105
* @return {Any} The value stored in the path, undefined if not found,
3106
* undefined if the source is not an object. Returns the source object
3107
* if an empty path is provided.
3109
O.getValue = function(o, path) {
3110
if (!Lang.isObject(o)) {
3118
for (i = 0; o !== UNDEFINED && i < l; i++) {
3126
* Sets the sub-attribute value at the provided path on the
3127
* value object. Returns the modified value object, or
3128
* undefined if the path is invalid.
3132
* @param o The object on which to set the sub value.
3133
* @param path {Array} A path array, specifying the object traversal path
3134
* at which to set the sub value.
3135
* @param val {Any} The new value for the sub-attribute.
3136
* @return {Object} The modified object, with the new sub value set, or
3137
* undefined, if the path was invalid.
3139
O.setValue = function(o, path, val) {
3142
leafIdx = p.length - 1,
3146
for (i = 0; ref !== UNDEFINED && i < leafIdx; i++) {
3150
if (ref !== UNDEFINED) {
3161
* Returns `true` if the object has no enumerable properties of its own.
3164
* @param {Object} obj An object.
3165
* @return {Boolean} `true` if the object is empty.
3169
O.isEmpty = function (obj) {
3170
return !O.keys(Object(obj)).length;
3173
* The YUI module contains the components required for building the YUI seed
3174
* file. This includes the script loading mechanism, a simple queue, and the
3175
* core utilities for the library.
3177
* @submodule yui-base
3181
* YUI user agent detection.
3182
* Do not fork for a browser if it can be avoided. Use feature detection when
3183
* you can. Use the user agent as a last resort. For all fields listed
3184
* as @type float, UA stores a version number for the browser engine,
3185
* 0 otherwise. This value may or may not map to the version number of
3186
* the browser using the engine. The value is presented as a float so
3187
* that it can easily be used for boolean evaluation as well as for
3188
* looking for a particular range of versions. Because of this,
3189
* some of the granularity of the version info may be lost. The fields that
3190
* are @type string default to null. The API docs list the values that
3191
* these fields can have.
3197
* Static method on `YUI.Env` for parsing a UA string. Called at instantiation
3198
* to populate `Y.UA`.
3202
* @param {String} [subUA=navigator.userAgent] UA string to parse
3203
* @return {Object} The Y.UA object
3205
YUI.Env.parseUA = function(subUA) {
3207
var numberify = function(s) {
3209
return parseFloat(s.replace(/\./g, function() {
3210
return (c++ == 1) ? '' : '.';
3216
nav = win && win.navigator,
3221
* Internet Explorer version number or 0. Example: 6
3229
* Opera version number or 0. Example: 9.2
3237
* Gecko engine revision number. Will evaluate to 1 if Gecko
3238
* is detected but the revision could not be found. Other browsers
3239
* will be 0. Example: 1.8
3241
* Firefox 1.0.0.4: 1.7.8 <-- Reports 1.7
3242
* Firefox 1.5.0.9: 1.8.0.9 <-- 1.8
3243
* Firefox 2.0.0.3: 1.8.1.3 <-- 1.81
3244
* Firefox 3.0 <-- 1.9
3245
* Firefox 3.5 <-- 1.91
3254
* AppleWebKit version. KHTML browsers that are not WebKit browsers
3255
* will evaluate to 1, other browsers 0. Example: 418.9
3257
* Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
3258
* latest available for Mac OSX 10.3.
3259
* Safari 2.0.2: 416 <-- hasOwnProperty introduced
3260
* Safari 2.0.4: 418 <-- preventDefault fixed
3261
* Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
3262
* different versions of webkit
3263
* Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been
3264
* updated, but not updated
3265
* to the latest patch.
3266
* Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native
3267
* SVG and many major issues fixed).
3268
* Safari 3.0.4 (523.12) 523.12 <-- First Tiger release - automatic
3269
* update from 2.x via the 10.4.11 OS patch.
3270
* Webkit nightly 1/2008:525+ <-- Supports DOMContentLoaded event.
3271
* yahoo.com user agent hack removed.
3273
* http://en.wikipedia.org/wiki/Safari_version_history
3281
* Safari will be detected as webkit, but this property will also
3282
* be populated with the Safari version number
3290
* Chrome will be detected as webkit, but this property will also
3291
* be populated with the Chrome version number
3299
* The mobile property will be set to a string containing any relevant
3300
* user agent information when a modern mobile browser is detected.
3301
* Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series
3302
* devices with the WebKit-based browser, and Opera Mini.
3311
* Adobe AIR version number or 0. Only populated if webkit is detected.
3318
* Detects Apple iPad's OS version
3325
* Detects Apple iPhone's OS version
3332
* Detects Apples iPod's OS version
3339
* General truthy check for iPad, iPhone or iPod
3347
* Detects Googles Android OS version
3354
* Detects Kindle Silk
3361
* Detects Kindle Silk Acceleration
3368
* Detects Palms WebOS version
3376
* Google Caja version number or 0.
3380
caja: nav && nav.cajaVersion,
3383
* Set to true if the page appears to be in SSL
3391
* The operating system. Currently only detecting windows or macintosh
3400
* The Nodejs Version
3409
ua = subUA || nav && nav.userAgent,
3411
loc = win && win.location,
3413
href = loc && loc.href,
3418
* The User Agent string that was parsed
3419
* @property userAgent
3426
o.secure = href && (href.toLowerCase().indexOf('https') === 0);
3430
if ((/windows|win32/i).test(ua)) {
3432
} else if ((/macintosh|mac_powerpc/i).test(ua)) {
3434
} else if ((/android/i).test(ua)) {
3436
} else if ((/symbos/i).test(ua)) {
3438
} else if ((/linux/i).test(ua)) {
3440
} else if ((/rhino/i).test(ua)) {
3444
// Modern KHTML browsers should qualify as Safari X-Grade
3445
if ((/KHTML/).test(ua)) {
3448
if ((/IEMobile|XBLWP7/).test(ua)) {
3449
o.mobile = 'windows';
3451
if ((/Fennec/).test(ua)) {
3454
// Modern WebKit browsers are at least X-Grade
3455
m = ua.match(/AppleWebKit\/([^\s]*)/);
3457
o.webkit = numberify(m[1]);
3458
o.safari = o.webkit;
3460
// Mobile browser check
3461
if (/ Mobile\//.test(ua) || (/iPad|iPod|iPhone/).test(ua)) {
3462
o.mobile = 'Apple'; // iPhone or iPod Touch
3464
m = ua.match(/OS ([^\s]*)/);
3466
m = numberify(m[1].replace('_', '.'));
3470
o.ipad = o.ipod = o.iphone = 0;
3472
m = ua.match(/iPad|iPod|iPhone/);
3474
o[m[0].toLowerCase()] = o.ios;
3477
m = ua.match(/NokiaN[^\/]*|webOS\/\d\.\d/);
3479
// Nokia N-series, webOS, ex: NokiaN95
3482
if (/webOS/.test(ua)) {
3484
m = ua.match(/webOS\/([^\s]*);/);
3486
o.webos = numberify(m[1]);
3489
if (/ Android/.test(ua)) {
3490
if (/Mobile/.test(ua)) {
3491
o.mobile = 'Android';
3493
m = ua.match(/Android ([^\s]*);/);
3495
o.android = numberify(m[1]);
3499
if (/Silk/.test(ua)) {
3500
m = ua.match(/Silk\/([^\s]*)\)/);
3502
o.silk = numberify(m[1]);
3505
o.android = 2.34; //Hack for desktop mode in Kindle
3508
if (/Accelerated=true/.test(ua)) {
3514
m = ua.match(/(Chrome|CrMo)\/([^\s]*)/);
3515
if (m && m[1] && m[2]) {
3516
o.chrome = numberify(m[2]); // Chrome
3517
o.safari = 0; //Reset safari back to 0
3518
if (m[1] === 'CrMo') {
3519
o.mobile = 'chrome';
3522
m = ua.match(/AdobeAIR\/([^\s]*)/);
3524
o.air = m[0]; // Adobe AIR 1.0 or better
3529
if (!o.webkit) { // not webkit
3530
// @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)
3531
if (/Opera/.test(ua)) {
3532
m = ua.match(/Opera[\s\/]([^\s]*)/);
3534
o.opera = numberify(m[1]);
3536
m = ua.match(/Version\/([^\s]*)/);
3538
o.opera = numberify(m[1]); // opera 10+
3541
if (/Opera Mobi/.test(ua)) {
3543
m = ua.replace('Opera Mobi', '').match(/Opera ([^\s]*)/);
3545
o.opera = numberify(m[1]);
3548
m = ua.match(/Opera Mini[^;]*/);
3551
o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
3553
} else { // not opera or webkit
3554
m = ua.match(/MSIE\s([^;]*)/);
3556
o.ie = numberify(m[1]);
3557
} else { // not opera, webkit, or ie
3558
m = ua.match(/Gecko\/([^\s]*)/);
3560
o.gecko = 1; // Gecko detected, look for revision
3561
m = ua.match(/rv:([^\s\)]*)/);
3563
o.gecko = numberify(m[1]);
3571
//It was a parsed UA, do not assign the global value.
3574
if (typeof process == 'object') {
3576
if (process.versions && process.versions.node) {
3578
o.os = process.platform;
3579
o.nodejs = process.versions.node;
3591
Y.UA = YUI.Env.UA || YUI.Env.parseUA();
3594
Performs a simple comparison between two version numbers, accounting for
3595
standard versioning logic such as the fact that "535.8" is a lower version than
3596
"535.24", even though a simple numerical comparison would indicate that it's
3597
greater. Also accounts for cases such as "1.1" vs. "1.1.0", which are
3598
considered equivalent.
3600
Returns -1 if version _a_ is lower than version _b_, 0 if they're equivalent,
3601
1 if _a_ is higher than _b_.
3603
Versions may be numbers or strings containing numbers and dots. For example,
3604
both `535` and `"535.8.10"` are acceptable. A version string containing
3605
non-numeric characters, like `"535.8.beta"`, may produce unexpected results.
3607
@method compareVersions
3608
@param {Number|String} a First version number to compare.
3609
@param {Number|String} b Second version number to compare.
3610
@return -1 if _a_ is lower than _b_, 0 if they're equivalent, 1 if _a_ is
3613
Y.UA.compareVersions = function (a, b) {
3614
var aPart, aParts, bPart, bParts, i, len;
3620
aParts = (a + '').split('.');
3621
bParts = (b + '').split('.');
3623
for (i = 0, len = Math.max(aParts.length, bParts.length); i < len; ++i) {
3624
aPart = parseInt(aParts[i], 10);
3625
bPart = parseInt(bParts[i], 10);
3627
isNaN(aPart) && (aPart = 0);
3628
isNaN(bPart) && (bPart = 0);
3630
if (aPart < bPart) {
3634
if (aPart > bPart) {
3642
"anim": ["anim-base","anim-color","anim-curve","anim-easing","anim-node-plugin","anim-scroll","anim-xy"],
3643
"app": ["app-base","app-transitions","model","model-list","router","view"],
3644
"attribute": ["attribute-base","attribute-complex"],
3645
"autocomplete": ["autocomplete-base","autocomplete-sources","autocomplete-list","autocomplete-plugin"],
3646
"base": ["base-base","base-pluginhost","base-build"],
3647
"cache": ["cache-base","cache-offline","cache-plugin"],
3648
"collection": ["array-extras","arraylist","arraylist-add","arraylist-filter","array-invoke"],
3649
"controller": ["router"],
3650
"dataschema": ["dataschema-base","dataschema-json","dataschema-xml","dataschema-array","dataschema-text"],
3651
"datasource": ["datasource-local","datasource-io","datasource-get","datasource-function","datasource-cache","datasource-jsonschema","datasource-xmlschema","datasource-arrayschema","datasource-textschema","datasource-polling"],
3652
"datatable": ["datatable-core","datatable-head","datatable-body","datatable-base","datatable-column-widths","datatable-message","datatable-mutable","datatable-sort","datatable-datasource"],
3653
"datatable-deprecated": ["datatable-base-deprecated","datatable-datasource-deprecated","datatable-sort-deprecated","datatable-scroll-deprecated"],
3654
"datatype": ["datatype-number","datatype-date","datatype-xml"],
3655
"datatype-date": ["datatype-date-parse","datatype-date-format"],
3656
"datatype-number": ["datatype-number-parse","datatype-number-format"],
3657
"datatype-xml": ["datatype-xml-parse","datatype-xml-format"],
3658
"dd": ["dd-ddm-base","dd-ddm","dd-ddm-drop","dd-drag","dd-proxy","dd-constrain","dd-drop","dd-scroll","dd-delegate"],
3659
"dom": ["dom-base","dom-screen","dom-style","selector-native","selector"],
3660
"editor": ["frame","editor-selection","exec-command","editor-base","editor-para","editor-br","editor-bidi","editor-tab","createlink-base"],
3661
"event": ["event-base","event-delegate","event-synthetic","event-mousewheel","event-mouseenter","event-key","event-focus","event-resize","event-hover","event-outside","event-touch","event-move","event-flick","event-valuechange"],
3662
"event-custom": ["event-custom-base","event-custom-complex"],
3663
"event-gestures": ["event-flick","event-move"],
3664
"handlebars": ["handlebars-compiler"],
3665
"highlight": ["highlight-base","highlight-accentfold"],
3666
"history": ["history-base","history-hash","history-hash-ie","history-html5"],
3667
"io": ["io-base","io-xdr","io-form","io-upload-iframe","io-queue"],
3668
"json": ["json-parse","json-stringify"],
3669
"loader": ["loader-base","loader-rollup","loader-yui3"],
3670
"node": ["node-base","node-event-delegate","node-pluginhost","node-screen","node-style"],
3671
"pluginhost": ["pluginhost-base","pluginhost-config"],
3672
"querystring": ["querystring-parse","querystring-stringify"],
3673
"recordset": ["recordset-base","recordset-sort","recordset-filter","recordset-indexer"],
3674
"resize": ["resize-base","resize-proxy","resize-constrain"],
3675
"slider": ["slider-base","slider-value-range","clickable-rail","range-slider"],
3676
"text": ["text-accentfold","text-wordbreak"],
3677
"widget": ["widget-base","widget-htmlparser","widget-skin","widget-uievents"]
3682
YUI.add('get', function(Y) {
3685
* NodeJS specific Get module used to load remote resources. It contains the same signature as the default Get module so there is no code change needed.
3686
* @module get-nodejs
3690
var path = require('path'),
3693
request = require('request');
3696
Y.Get = function() {
3699
//Setup the default config base path
3700
Y.config.base = path.join(__dirname, '../');
3702
YUI.require = require;
3703
YUI.process = process;
3706
* Escape the path for Windows, they need to be double encoded when used as `__dirname` or `__filename`
3707
* @method escapeWinPath
3709
* @param {String} p The path to modify
3710
* @return {String} The encoded path
3712
var escapeWinPath = function(p) {
3713
return p.replace(/\\/g, '\\\\');
3717
* Takes the raw JS files and wraps them to be executed in the YUI context so they can be loaded
3718
* into the YUI object
3721
* @param {String} data The JS to execute
3722
* @param {String} url The path to the file that was parsed
3723
* @param {Callback} cb The callback to execute when this is completed
3724
* @param {Error} cb.err=null Error object
3725
* @param {String} cb.url The URL that was just parsed
3728
Y.Get._exec = function(data, url, cb) {
3729
var dirName = escapeWinPath(path.dirname(url));
3730
var fileName = escapeWinPath(url);
3732
if (dirName.match(/^https?:\/\//)) {
3734
fileName = 'remoteResource';
3737
var mod = "(function(YUI) { var __dirname = '" + dirName + "'; "+
3738
"var __filename = '" + fileName + "'; " +
3739
"var process = YUI.process;" +
3740
"var require = function(file) {" +
3741
" if (file.indexOf('./') === 0) {" +
3742
" file = __dirname + file.replace('./', '/'); }" +
3743
" return YUI.require(file); }; " +
3744
data + " ;return YUI; })";
3746
//var mod = "(function(YUI) { " + data + ";return YUI; })";
3747
var script = vm.createScript(mod, url);
3748
var fn = script.runInThisContext(mod);
3754
* Fetches the content from a remote URL or a file from disc and passes the content
3755
* off to `_exec` for parsing
3758
* @param {String} url The URL/File path to fetch the content from
3759
* @param {Callback} cb The callback to fire once the content has been executed via `_exec`
3761
Y.Get._include = function(url, cb) {
3764
if (url.match(/^https?:\/\//)) {
3767
timeout: self.timeout
3769
request(cfg, function (err, response, body) {
3771
Y.log(err, 'error', 'get');
3774
Y.Get._exec(body, url, cb);
3778
if (Y.config.useSync) {
3779
//Needs to be in useSync
3780
if (path.existsSync(url)) {
3781
var mod = fs.readFileSync(url,'utf8');
3782
Y.Get._exec(mod, url, cb);
3784
cb('Path does not exist: ' + url, url);
3787
fs.readFile(url, 'utf8', function(err, mod) {
3791
Y.Get._exec(mod, url, cb);
3800
var end = function(cb, msg, result) {
3801
//Y.log('Get end: ' + cb.onEnd);
3802
if (Y.Lang.isFunction(cb.onEnd)) {
3803
cb.onEnd.call(Y, msg, result);
3805
}, pass = function(cb) {
3806
//Y.log('Get pass: ' + cb.onSuccess);
3807
if (Y.Lang.isFunction(cb.onSuccess)) {
3808
cb.onSuccess.call(Y, cb);
3810
end(cb, 'success', 'success');
3811
}, fail = function(cb, er) {
3812
//Y.log('Get fail: ' + er);
3813
if (Y.Lang.isFunction(cb.onFailure)) {
3814
cb.onFailure.call(Y, er, cb);
3816
end(cb, er, 'fail');
3821
* Override for Get.script for loading local or remote YUI modules.
3823
* @param {Array|String} s The URL's to load into this context
3824
* @param {Object} options Transaction options
3826
Y.Get.js = function(s, options) {
3829
urls = A(s), url, i, l = urls.length, c= 0,
3830
check = function() {
3838
for (i=0; i<l; i++) {
3840
if (Y.Lang.isObject(url)) {
3844
url = url.replace(/'/g, '%27');
3845
Y.log('URL: ' + url, 'info', 'get');
3846
Y.Get._include(url, function(err, url) {
3852
if (options.onProgress) {
3853
options.onProgress.call(options.context || Y, url);
3855
Y.log('After Load: ' + url, 'info', 'get');
3858
Y.log('----------------------------------------------------------', 'error', 'get');
3859
Y.log(err, 'error', 'get');
3860
Y.log('----------------------------------------------------------', 'error', 'get');
3870
* Alias for `Y.Get.js`
3873
Y.Get.script = Y.Get.js;
3875
//Place holder for SS Dom access
3876
Y.Get.css = function(s, cb) {
3877
Y.log('Y.Get.css is not supported, just reporting that it has loaded but not fetching.', 'warn', 'get');
3883
}, '3.5.1' ,{requires:['yui-base']});
3884
YUI.add('features', function(Y) {
3886
var feature_tests = {};
3889
Contains the core of YUI's feature test architecture.
3899
Y.mix(Y.namespace('Features'), {
3902
* Object hash of all registered feature tests
3906
tests: feature_tests,
3909
* Add a test to the system
3912
* Y.Features.add("load", "1", {});
3916
* @param {String} cat The category, right now only 'load' is supported
3917
* @param {String} name The number sequence of the test, how it's reported in the URL or config: 1, 2, 3
3918
* @param {Object} o Object containing test properties
3919
* @param {String} o.name The name of the test
3920
* @param {Function} o.test The test function to execute, the only argument to the function is the `Y` instance
3921
* @param {String} o.trigger The module that triggers this test.
3923
add: function(cat, name, o) {
3924
feature_tests[cat] = feature_tests[cat] || {};
3925
feature_tests[cat][name] = o;
3928
* Execute all tests of a given category and return the serialized results
3934
* @param {String} cat The category to execute
3935
* @param {Array} args The arguments to pass to the test function
3936
* @return {String} A semi-colon separated string of tests and their success/failure: 1:1;2:1;3:0
3938
all: function(cat, args) {
3939
var cat_o = feature_tests[cat],
3943
Y.Object.each(cat_o, function(v, k) {
3944
result.push(k + ':' + (Y.Features.test(cat, k, args) ? 1 : 0));
3948
return (result.length) ? result.join(';') : '';
3951
* Run a sepecific test and return a Boolean response.
3954
* Y.Features.test("load", "1");
3958
* @param {String} cat The category of the test to run
3959
* @param {String} name The name of the test to run
3960
* @param {Array} args The arguments to pass to the test function
3961
* @return {Boolean} True or false if the test passed/failed.
3963
test: function(cat, name, args) {
3965
var result, ua, test,
3966
cat_o = feature_tests[cat],
3967
feature = cat_o && cat_o[name];
3970
Y.log('Feature test ' + cat + ', ' + name + ' not found');
3973
result = feature.result;
3975
if (Y.Lang.isUndefined(result)) {
3979
result = (Y.UA[ua]);
3982
test = feature.test;
3983
if (test && ((!ua) || result)) {
3984
result = test.apply(Y, args);
3987
feature.result = result;
3995
// Y.Features.add("load", "1", {});
3996
// Y.Features.test("load", "1");
3997
// caps=1:1;2:0;3:1;
3999
/* This file is auto-generated by src/loader/scripts/meta_join.py */
4000
var add = Y.Features.add;
4003
"name": "io-nodejs",
4004
"trigger": "io-base",
4007
// graphics-canvas-default
4009
"name": "graphics-canvas-default",
4010
"test": function(Y) {
4011
var DOCUMENT = Y.config.doc,
4012
useCanvas = Y.config.defaultGraphicEngine && Y.config.defaultGraphicEngine == "canvas",
4013
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
4014
svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
4015
return (!svg || useCanvas) && (canvas && canvas.getContext && canvas.getContext("2d"));
4017
"trigger": "graphics"
4019
// autocomplete-list-keys
4021
"name": "autocomplete-list-keys",
4022
"test": function (Y) {
4023
// Only add keyboard support to autocomplete-list if this doesn't appear to
4024
// be an iOS or Android-based mobile device.
4026
// There's currently no feasible way to actually detect whether a device has
4027
// a hardware keyboard, so this sniff will have to do. It can easily be
4028
// overridden by manually loading the autocomplete-list-keys module.
4030
// Worth noting: even though iOS supports bluetooth keyboards, Mobile Safari
4031
// doesn't fire the keyboard events used by AutoCompleteList, so there's
4032
// no point loading the -keys module even when a bluetooth keyboard may be
4034
return !(Y.UA.ios || Y.UA.android);
4036
"trigger": "autocomplete-list"
4040
"name": "graphics-svg",
4041
"test": function(Y) {
4042
var DOCUMENT = Y.config.doc,
4043
useSVG = !Y.config.defaultGraphicEngine || Y.config.defaultGraphicEngine != "canvas",
4044
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
4045
svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
4047
return svg && (useSVG || !canvas);
4049
"trigger": "graphics"
4053
"name": "editor-para-ie",
4054
"trigger": "editor-para",
4058
// graphics-vml-default
4060
"name": "graphics-vml-default",
4061
"test": function(Y) {
4062
var DOCUMENT = Y.config.doc,
4063
canvas = DOCUMENT && DOCUMENT.createElement("canvas");
4064
return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d")));
4066
"trigger": "graphics"
4068
// graphics-svg-default
4070
"name": "graphics-svg-default",
4071
"test": function(Y) {
4072
var DOCUMENT = Y.config.doc,
4073
useSVG = !Y.config.defaultGraphicEngine || Y.config.defaultGraphicEngine != "canvas",
4074
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
4075
svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
4077
return svg && (useSVG || !canvas);
4079
"trigger": "graphics"
4083
"name": "history-hash-ie",
4084
"test": function (Y) {
4085
var docMode = Y.config.doc && Y.config.doc.documentMode;
4087
return Y.UA.ie && (!('onhashchange' in Y.config.win) ||
4088
!docMode || docMode < 8);
4090
"trigger": "history-hash"
4094
"name": "transition-timer",
4095
"test": function (Y) {
4096
var DOCUMENT = Y.config.doc,
4097
node = (DOCUMENT) ? DOCUMENT.documentElement: null,
4100
if (node && node.style) {
4101
ret = !('MozTransition' in node.style || 'WebkitTransition' in node.style);
4106
"trigger": "transition"
4110
"name": "dom-style-ie",
4111
"test": function (Y) {
4113
var testFeature = Y.Features.test,
4114
addFeature = Y.Features.add,
4115
WINDOW = Y.config.win,
4116
DOCUMENT = Y.config.doc,
4117
DOCUMENT_ELEMENT = 'documentElement',
4120
addFeature('style', 'computedStyle', {
4122
return WINDOW && 'getComputedStyle' in WINDOW;
4126
addFeature('style', 'opacity', {
4128
return DOCUMENT && 'opacity' in DOCUMENT[DOCUMENT_ELEMENT].style;
4132
ret = (!testFeature('style', 'opacity') &&
4133
!testFeature('style', 'computedStyle'));
4137
"trigger": "dom-style"
4141
"name": "selector-css2",
4142
"test": function (Y) {
4143
var DOCUMENT = Y.config.doc,
4144
ret = DOCUMENT && !('querySelectorAll' in DOCUMENT);
4148
"trigger": "selector"
4152
"name": "widget-base-ie",
4153
"trigger": "widget-base",
4158
"name": "event-base-ie",
4159
"test": function(Y) {
4160
var imp = Y.config.doc && Y.config.doc.implementation;
4161
return (imp && (!imp.hasFeature('Events', '2.0')));
4163
"trigger": "node-base"
4167
"name": "dd-gestures",
4168
"test": function(Y) {
4169
return ((Y.config.win && ("ontouchstart" in Y.config.win)) && !(Y.UA.chrome && Y.UA.chrome < 6));
4171
"trigger": "dd-drag"
4173
// scrollview-base-ie
4175
"name": "scrollview-base-ie",
4176
"trigger": "scrollview-base",
4179
// app-transitions-native
4181
"name": "app-transitions-native",
4182
"test": function (Y) {
4183
var doc = Y.config.doc,
4184
node = doc ? doc.documentElement : null;
4186
if (node && node.style) {
4187
return ('MozTransition' in node.style || 'WebkitTransition' in node.style);
4192
"trigger": "app-transitions"
4196
"name": "graphics-canvas",
4197
"test": function(Y) {
4198
var DOCUMENT = Y.config.doc,
4199
useCanvas = Y.config.defaultGraphicEngine && Y.config.defaultGraphicEngine == "canvas",
4200
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
4201
svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
4202
return (!svg || useCanvas) && (canvas && canvas.getContext && canvas.getContext("2d"));
4204
"trigger": "graphics"
4208
"name": "graphics-vml",
4209
"test": function(Y) {
4210
var DOCUMENT = Y.config.doc,
4211
canvas = DOCUMENT && DOCUMENT.createElement("canvas");
4212
return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d")));
4214
"trigger": "graphics"
4218
}, '3.5.1' ,{requires:['yui-base']});
4219
YUI.add('intl-base', function(Y) {
4222
* The Intl utility provides a central location for managing sets of
4223
* localized resources (strings and formatting patterns).
4230
var SPLIT_REGEX = /[, ]/;
4232
Y.mix(Y.namespace('Intl'), {
4235
* Returns the language among those available that
4236
* best matches the preferred language list, using the Lookup
4237
* algorithm of BCP 47.
4238
* If none of the available languages meets the user's preferences,
4239
* then "" is returned.
4240
* Extended language ranges are not supported.
4242
* @method lookupBestLang
4243
* @param {String[] | String} preferredLanguages The list of preferred
4244
* languages in descending preference order, represented as BCP 47
4245
* language tags. A string array or a comma-separated list.
4246
* @param {String[]} availableLanguages The list of languages
4247
* that the application supports, represented as BCP 47 language
4250
* @return {String} The available language that best matches the
4251
* preferred language list, or "".
4254
lookupBestLang: function(preferredLanguages, availableLanguages) {
4256
var i, language, result, index;
4258
// check whether the list of available languages contains language;
4260
function scan(language) {
4262
for (i = 0; i < availableLanguages.length; i += 1) {
4263
if (language.toLowerCase() ===
4264
availableLanguages[i].toLowerCase()) {
4265
return availableLanguages[i];
4270
if (Y.Lang.isString(preferredLanguages)) {
4271
preferredLanguages = preferredLanguages.split(SPLIT_REGEX);
4274
for (i = 0; i < preferredLanguages.length; i += 1) {
4275
language = preferredLanguages[i];
4276
if (!language || language === '*') {
4279
// check the fallback sequence for one language
4280
while (language.length > 0) {
4281
result = scan(language);
4285
index = language.lastIndexOf('-');
4287
language = language.substring(0, index);
4288
// one-character subtags get cut along with the
4290
if (index >= 2 && language.charAt(index - 2) === '-') {
4291
language = language.substring(0, index - 2);
4294
// nothing available for this language
4306
}, '3.5.1' ,{requires:['yui-base']});
4307
YUI.add('yui-log', function(Y) {
4310
* Provides console log capability and exposes a custom event for
4311
* console implementations. This module is a `core` YUI module, <a href="../classes/YUI.html#method_log">it's documentation is located under the YUI class</a>.
4314
* @submodule yui-log
4318
LOGEVENT = 'yui:log',
4319
UNDEFINED = 'undefined',
4320
LEVELS = { debug: 1,
4326
* If the 'debug' config is true, a 'yui:log' event will be
4327
* dispatched, which the Console widget and anything else
4328
* can consume. If the 'useBrowserConsole' config is true, it will
4329
* write to the browser console if available. YUI-specific log
4330
* messages will only be present in the -debug versions of the
4331
* JS files. The build system is supposed to remove log statements
4332
* from the raw and minified versions of the files.
4336
* @param {String} msg The message to log.
4337
* @param {String} cat The log category for the message. Default
4338
* categories are "info", "warn", "error", time".
4339
* Custom categories can be used as well. (opt).
4340
* @param {String} src The source of the the message (opt).
4341
* @param {boolean} silent If true, the log event won't fire.
4342
* @return {YUI} YUI instance.
4344
INSTANCE.log = function(msg, cat, src, silent) {
4345
var bail, excl, incl, m, f,
4348
publisher = (Y.fire) ? Y : YUI.Env.globalEvents;
4349
// suppress log message if the config is off or the event stack
4350
// or the event call stack contains a consumer of the yui:log event
4352
// apply source filters
4354
excl = c.logExclude;
4355
incl = c.logInclude;
4356
if (incl && !(src in incl)) {
4358
} else if (incl && (src in incl)) {
4360
} else if (excl && (src in excl)) {
4365
if (c.useBrowserConsole) {
4366
m = (src) ? src + ': ' + msg : msg;
4367
if (Y.Lang.isFunction(c.logFn)) {
4368
c.logFn.call(Y, msg, cat, src);
4369
} else if (typeof console != UNDEFINED && console.log) {
4370
f = (cat && console[cat] && (cat in LEVELS)) ? cat : 'log';
4372
} else if (typeof opera != UNDEFINED) {
4377
if (publisher && !silent) {
4379
if (publisher == Y && (!publisher.getEvent(LOGEVENT))) {
4380
publisher.publish(LOGEVENT, {
4385
publisher.fire(LOGEVENT, {
4398
* Write a system message. This message will be preserved in the
4399
* minified and raw versions of the YUI files, unlike log statements.
4402
* @param {String} msg The message to log.
4403
* @param {String} cat The log category for the message. Default
4404
* categories are "info", "warn", "error", time".
4405
* Custom categories can be used as well. (opt).
4406
* @param {String} src The source of the the message (opt).
4407
* @param {boolean} silent If true, the log event won't fire.
4408
* @return {YUI} YUI instance.
4410
INSTANCE.message = function() {
4411
return INSTANCE.log.apply(INSTANCE, arguments);
4415
}, '3.5.1' ,{requires:['yui-base']});
4416
YUI.add('yui-log-nodejs', function(Y) {
4418
var sys = require(process.binding('natives').util ? 'util' : 'sys'),
4422
var stdio = require("stdio");
4423
hasColor = stdio.isStderrATTY();
4428
Y.config.useColor = hasColor;
4430
Y.consoleColor = function(str, num) {
4431
if (!this.config.useColor) {
4437
return "\033[" + num +"m" + str + "\033[0m"
4441
var logFn = function(str, t, m) {
4444
id = '[' + this.id + ']:';
4447
m = (m) ? this.consoleColor(' (' + m.toLowerCase() + '):', 35) : '';
4453
if ((typeof str === 'object') || str instanceof Array) {
4455
//Should we use this?
4456
if (str.tagName || str._yuid || str._query) {
4457
str = str.toString();
4459
str = sys.inspect(str);
4466
var lvl = '37;40', mLvl = ((str) ? '' : 31);
4467
t = t+''; //Force to a string..
4468
switch (t.toLowerCase()) {
4479
if (typeof str === 'string') {
4480
if (str && str.indexOf("\n") !== -1) {
4485
// output log messages to stderr
4486
sys.error(this.consoleColor(t.toLowerCase() + ':', lvl) + m + ' ' + this.consoleColor(str, mLvl));
4489
if (!Y.config.logFn) {
4490
Y.config.logFn = logFn;
4495
}, '3.5.1' ,{requires:['yui-log']});
4496
YUI.add('yui-later', function(Y) {
4499
* Provides a setTimeout/setInterval wrapper. This module is a `core` YUI module, <a href="../classes/YUI.html#method_later">it's documentation is located under the YUI class</a>.
4502
* @submodule yui-later
4508
* Executes the supplied function in the context of the supplied
4509
* object 'when' milliseconds later. Executes the function a
4510
* single time unless periodic is set to true.
4513
* @param when {int} the number of milliseconds to wait until the fn
4515
* @param o the context object.
4516
* @param fn {Function|String} the function to execute or the name of
4517
* the method in the 'o' object to execute.
4518
* @param data [Array] data that is provided to the function. This
4519
* accepts either a single item or an array. If an array is provided,
4520
* the function is executed with one parameter for each array item.
4521
* If you need to pass a single array parameter, it needs to be wrapped
4522
* in an array [myarray].
4524
* Note: native methods in IE may not have the call and apply methods.
4525
* In this case, it will work, but you are limited to four arguments.
4527
* @param periodic {boolean} if true, executes continuously at supplied
4528
* interval until canceled.
4529
* @return {object} a timer object. Call the cancel() method on this
4530
* object to stop the timer.
4532
Y.later = function(when, o, fn, data, periodic) {
4534
data = (!Y.Lang.isUndefined(data)) ? Y.Array(data) : NO_ARGS;
4535
o = o || Y.config.win || Y;
4537
var cancelled = false,
4538
method = (o && Y.Lang.isString(fn)) ? o[fn] : fn,
4539
wrapper = function() {
4540
// IE 8- may execute a setInterval callback one last time
4541
// after clearInterval was called, so in order to preserve
4542
// the cancel() === no more runny-run, we have to jump through
4545
if (!method.apply) {
4546
method(data[0], data[1], data[2], data[3]);
4548
method.apply(o, data || NO_ARGS);
4552
id = (periodic) ? setInterval(wrapper, when) : setTimeout(wrapper, when);
4557
cancel: function() {
4559
if (this.interval) {
4568
Y.Lang.later = Y.later;
4572
}, '3.5.1' ,{requires:['yui-base']});
4573
YUI.add('loader-base', function(Y) {
4576
* The YUI loader core
4578
* @submodule loader-base
4581
if (!YUI.Env[Y.version]) {
4584
var VERSION = Y.version,
4586
ROOT = VERSION + BUILD,
4587
CDN_BASE = Y.Env.base,
4588
GALLERY_VERSION = '${loader.gallery}',
4590
TNT_VERSION = '${loader.tnt}',
4591
YUI2_VERSION = '${loader.yui2}',
4592
COMBO_BASE = CDN_BASE + 'combo?',
4593
META = { version: VERSION,
4596
comboBase: COMBO_BASE,
4597
skin: { defaultSkin: 'sam',
4598
base: 'assets/skins/',
4605
'cssfonts-context']},
4608
groups = META.groups,
4609
yui2Update = function(tnt, yui2, config) {
4611
var root = TNT + '.' +
4612
(tnt || TNT_VERSION) + '/' +
4613
(yui2 || YUI2_VERSION) + BUILD,
4614
base = (config && config.base) ? config.base : CDN_BASE,
4615
combo = (config && config.comboBase) ? config.comboBase : COMBO_BASE;
4617
groups.yui2.base = base + root;
4618
groups.yui2.root = root;
4619
groups.yui2.comboBase = combo;
4621
galleryUpdate = function(tag, config) {
4622
var root = (tag || GALLERY_VERSION) + BUILD,
4623
base = (config && config.base) ? config.base : CDN_BASE,
4624
combo = (config && config.comboBase) ? config.comboBase : COMBO_BASE;
4626
groups.gallery.base = base + root;
4627
groups.gallery.root = root;
4628
groups.gallery.comboBase = combo;
4632
groups[VERSION] = {};
4637
comboBase: COMBO_BASE,
4638
update: galleryUpdate,
4639
patterns: { 'gallery-': { },
4640
'lang/gallery-': {},
4641
'gallerycss-': { type: 'css' } }
4647
comboBase: COMBO_BASE,
4651
configFn: function(me) {
4652
if (/-skin|reset|fonts|grids|base/.test(me.name)) {
4654
me.path = me.path.replace(/\.js/, '.css');
4655
// this makes skins in builds earlier than
4656
// 2.6.0 work as long as combine is false
4657
me.path = me.path.replace(/\/yui2-skin/,
4658
'/assets/skins/sam/yui2-skin');
4668
YUI.Env[VERSION] = META;
4674
* Loader dynamically loads script and css files. It includes the dependency
4675
* information for the version of the library in use, and will automatically pull in
4676
* dependencies for the modules requested. It can also load the
4677
* files from the Yahoo! CDN, and it can utilize the combo service provided on
4678
* this network to reduce the number of http connections required to download
4683
* @submodule loader-base
4687
NO_REQUIREMENTS = [],
4688
MAX_URL_LENGTH = 1024,
4689
GLOBAL_ENV = YUI.Env,
4690
GLOBAL_LOADED = GLOBAL_ENV._loaded,
4694
VERSION = Y.version,
4697
oeach = YObject.each,
4699
_queue = GLOBAL_ENV._loaderQueue,
4700
META = GLOBAL_ENV[VERSION],
4701
SKIN_PREFIX = 'skin-',
4703
ON_PAGE = GLOBAL_ENV.mods,
4706
_path = function(dir, file, type, nomin) {
4707
var path = dir + '/' + file;
4711
path += '.' + (type || CSS);
4717
* The component metadata is stored in Y.Env.meta.
4718
* Part of the loader module.
4725
* Loader dynamically loads script and css files. It includes the dependency
4726
* info for the version of the library in use, and will automatically pull in
4727
* dependencies for the modules requested. It can load the
4728
* files from the Yahoo! CDN, and it can utilize the combo service provided on
4729
* this network to reduce the number of http connections required to download
4730
* YUI files. You can also specify an external, custom combo service to host
4731
* your modules as well.
4734
var loader = new Y.Loader({
4739
require: ['node', 'dd', 'console']
4741
var out = loader.resolve(true);
4745
* @param {Object} config an optional set of configuration options.
4746
* @param {String} config.base The base dir which to fetch this module from
4747
* @param {String} config.comboBase The Combo service base path. Ex: `http://yui.yahooapis.com/combo?`
4748
* @param {String} config.root The root path to prepend to module names for the combo service. Ex: `2.5.2/build/`
4749
* @param {String|Object} config.filter A filter to apply to result urls. <a href="#property_filter">See filter property</a>
4750
* @param {Object} config.filters Per-component filter specification. If specified for a given component, this overrides the filter config.
4751
* @param {Boolean} config.combine Use a combo service to reduce the number of http connections required to load your dependencies
4752
* @param {Array} config.ignore: A list of modules that should never be dynamically loaded
4753
* @param {Array} config.force A list of modules that should always be loaded when required, even if already present on the page
4754
* @param {HTMLElement|String} config.insertBefore Node or id for a node that should be used as the insertion point for new nodes
4755
* @param {Object} config.jsAttributes Object literal containing attributes to add to script nodes
4756
* @param {Object} config.cssAttributes Object literal containing attributes to add to link nodes
4757
* @param {Number} config.timeout The number of milliseconds before a timeout occurs when dynamically loading nodes. If not set, there is no timeout
4758
* @param {Object} config.context Execution context for all callbacks
4759
* @param {Function} config.onSuccess Callback for the 'success' event
4760
* @param {Function} config.onFailure Callback for the 'failure' event
4761
* @param {Function} config.onCSS Callback for the 'CSSComplete' event. When loading YUI components with CSS the CSS is loaded first, then the script. This provides a moment you can tie into to improve the presentation of the page while the script is loading.
4762
* @param {Function} config.onTimeout Callback for the 'timeout' event
4763
* @param {Function} config.onProgress Callback executed each time a script or css file is loaded
4764
* @param {Object} config.modules A list of module definitions. See <a href="#method_addModule">Loader.addModule</a> for the supported module metadata
4765
* @param {Object} config.groups A list of group definitions. Each group can contain specific definitions for `base`, `comboBase`, `combine`, and accepts a list of `modules`.
4766
* @param {String} config.2in3 The version of the YUI 2 in 3 wrapper to use. The intrinsic support for YUI 2 modules in YUI 3 relies on versions of the YUI 2 components inside YUI 3 module wrappers. These wrappers change over time to accomodate the issues that arise from running YUI 2 in a YUI 3 sandbox.
4767
* @param {String} config.yui2 When using the 2in3 project, you can select the version of YUI 2 to use. Valid values are `2.2.2`, `2.3.1`, `2.4.1`, `2.5.2`, `2.6.0`, `2.7.0`, `2.8.0`, `2.8.1` and `2.9.0` [default] -- plus all versions of YUI 2 going forward.
4769
Y.Loader = function(o) {
4771
var defaults = META.modules,
4774
//Catch no config passed.
4777
modulekey = META.md5;
4780
* Internal callback to handle multiple internal insert() calls
4781
* so that css is inserted prior to js
4782
* @property _internalCallback
4785
// self._internalCallback = null;
4788
* Callback that will be executed when the loader is finished
4793
// self.onSuccess = null;
4796
* Callback that will be executed if there is a failure
4800
// self.onFailure = null;
4803
* Callback for the 'CSSComplete' event. When loading YUI components
4804
* with CSS the CSS is loaded first, then the script. This provides
4805
* a moment you can tie into to improve the presentation of the page
4806
* while the script is loading.
4810
// self.onCSS = null;
4813
* Callback executed each time a script or css file is loaded
4814
* @method onProgress
4817
// self.onProgress = null;
4820
* Callback that will be executed if a timeout occurs
4824
// self.onTimeout = null;
4827
* The execution context for all callbacks
4829
* @default {YUI} the YUI instance
4834
* Data that is passed to all callbacks
4837
// self.data = null;
4840
* Node reference or id where new nodes should be inserted before
4841
* @property insertBefore
4842
* @type string|HTMLElement
4844
// self.insertBefore = null;
4847
* The charset attribute for inserted nodes
4850
* @deprecated , use cssAttributes or jsAttributes.
4852
// self.charset = null;
4855
* An object literal containing attributes to add to link nodes
4856
* @property cssAttributes
4859
// self.cssAttributes = null;
4862
* An object literal containing attributes to add to script nodes
4863
* @property jsAttributes
4866
// self.jsAttributes = null;
4869
* The base directory.
4872
* @default http://yui.yahooapis.com/[YUI VERSION]/build/
4874
self.base = Y.Env.meta.base + Y.Env.meta.root;
4877
* Base path for the combo service
4878
* @property comboBase
4880
* @default http://yui.yahooapis.com/combo?
4882
self.comboBase = Y.Env.meta.comboBase;
4885
* Base path for language packs.
4887
// self.langBase = Y.Env.meta.langBase;
4891
* If configured, the loader will attempt to use the combo
4892
* service for YUI resources and configured external resources.
4895
* @default true if a base dir isn't in the config
4897
self.combine = o.base &&
4898
(o.base.indexOf(self.comboBase.substr(0, 20)) > -1);
4901
* The default seperator to use between files in a combo URL
4902
* @property comboSep
4904
* @default Ampersand
4906
self.comboSep = '&';
4908
* Max url length for combo urls. The default is 2048. This is the URL
4909
* limit for the Yahoo! hosted combo servers. If consuming
4910
* a different combo service that has a different URL limit
4911
* it is possible to override this default by supplying
4912
* the maxURLLength config option. The config option will
4913
* only take effect if lower than the default.
4915
* @property maxURLLength
4918
self.maxURLLength = MAX_URL_LENGTH;
4921
* Ignore modules registered on the YUI global
4922
* @property ignoreRegistered
4925
//self.ignoreRegistered = false;
4928
* Root path to prepend to module path for the combo
4932
* @default [YUI VERSION]/build/
4934
self.root = Y.Env.meta.root;
4937
* Timeout value in milliseconds. If set, self value will be used by
4938
* the get utility. the timeout event will fire if
4946
* A list of modules that should not be loaded, even if
4947
* they turn up in the dependency tree
4951
// self.ignore = null;
4954
* A list of modules that should always be loaded, even
4955
* if they have already been inserted into the page.
4959
// self.force = null;
4964
* Should we allow rollups
4965
* @property allowRollup
4969
self.allowRollup = false;
4972
* A filter to apply to result urls. This filter will modify the default
4973
* path for all modules. The default path for the YUI library is the
4974
* minified version of the files (e.g., event-min.js). The filter property
4975
* can be a predefined filter or a custom filter. The valid predefined
4979
* <dd>Selects the debug versions of the library (e.g., event-debug.js).
4980
* This option will automatically include the Logger widget</dd>
4982
* <dd>Selects the non-minified version of the library (e.g., event.js).
4985
* You can also define a custom filter, which must be an object literal
4986
* containing a search expression and a replace string:
4989
* 'searchExp': "-min\\.js",
4990
* 'replaceStr': "-debug.js"
4994
* @type string| {searchExp: string, replaceStr: string}
4996
// self.filter = null;
4999
* per-component filter specification. If specified for a given
5000
* component, this overrides the filter config.
5007
* The list of requested modules
5008
* @property required
5009
* @type {string: boolean}
5014
* If a module name is predefined when requested, it is checked againsts
5015
* the patterns provided in this property. If there is a match, the
5016
* module is added with the default configuration.
5018
* At the moment only supporting module prefixes, but anticipate
5019
* supporting at least regular expressions.
5020
* @property patterns
5023
// self.patterns = Y.merge(Y.Env.meta.patterns);
5027
* The library metadata
5028
* @property moduleInfo
5030
// self.moduleInfo = Y.merge(Y.Env.meta.moduleInfo);
5031
self.moduleInfo = {};
5033
self.groups = Y.merge(Y.Env.meta.groups);
5036
* Provides the information used to skin the skinnable components.
5037
* The following skin definition would result in 'skin1' and 'skin2'
5038
* being loaded for calendar (if calendar was requested), and
5039
* 'sam' for all other skinnable components:
5042
* // The default skin, which is automatically applied if not
5043
* // overriden by a component-specific skin definition.
5044
* // Change this in to apply a different skin globally
5045
* defaultSkin: 'sam',
5047
* // This is combined with the loader base property to get
5048
* // the default root directory for a skin. ex:
5049
* // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/
5050
* base: 'assets/skins/',
5052
* // Any component-specific overrides can be specified here,
5053
* // making it possible to load different skins for different
5054
* // components. It is possible to load more than one skin
5055
* // for a given component as well.
5057
* calendar: ['skin1', 'skin2']
5063
self.skin = Y.merge(Y.Env.meta.skin);
5066
* Map of conditional modules
5069
self.conditions = {};
5071
// map of modules with a hash of modules that meet the requirement
5072
// self.provides = {};
5075
self._internal = true;
5078
cache = GLOBAL_ENV._renderedMods;
5081
oeach(cache, function modCache(v, k) {
5082
self.moduleInfo[k] = Y.merge(v);
5085
cache = GLOBAL_ENV._conditions;
5087
oeach(cache, function condCache(v, k) {
5088
self.conditions[k] = Y.merge(v);
5092
oeach(defaults, self.addModule, self);
5097
* Set when beginning to compute the dependency tree.
5098
* Composed of what YUI reports to be loaded combined
5099
* with what has been loaded by any instance on the page
5100
* with the version number specified in the metadata.
5102
* @type {string: boolean}
5104
self.loaded = GLOBAL_LOADED[VERSION];
5107
self._inspectPage();
5109
self._internal = false;
5113
self.forceMap = (self.force) ? Y.Array.hash(self.force) : {};
5115
self.testresults = null;
5117
if (Y.config.tests) {
5118
self.testresults = Y.config.tests;
5122
* List of rollup files found in the library metadata
5125
// self.rollups = null;
5128
* Whether or not to load optional dependencies for
5129
* the requested modules
5130
* @property loadOptional
5134
// self.loadOptional = false;
5137
* All of the derived dependencies in sorted order, which
5138
* will be populated when either calculate() or insert()
5146
* A list of modules to attach to the YUI instance when complete.
5147
* If not supplied, the sorted list of dependencies are applied.
5148
* @property attaching
5150
// self.attaching = null;
5153
* Flag to indicate the dependency tree needs to be recomputed
5154
* if insert is called again.
5162
* List of modules inserted by the utility
5163
* @property inserted
5164
* @type {string: boolean}
5169
* List of skipped modules during insert() because the module
5175
// Y.on('yui:load', self.loadNext, self);
5180
* Cached sorted calculate results
5184
//self.results = {};
5188
Y.Loader.prototype = {
5190
Regex that matches a CSS URL. Used to guess the file type when it's not
5199
REGEX_CSS: /\.css(?:[?;].*)?$/i,
5202
* Default filters for raw and debug
5203
* @property FILTER_DEFS
5210
'searchExp': '-min\\.js',
5214
'searchExp': '-min\\.js',
5215
'replaceStr': '-debug.js'
5219
* Check the pages meta-data and cache the result.
5220
* @method _inspectPage
5223
_inspectPage: function() {
5225
//Inspect the page for CSS only modules and mark them as loaded.
5226
oeach(this.moduleInfo, function(v, k) {
5227
if (v.type && v.type === CSS) {
5228
if (this.isCSSLoaded(v.name)) {
5229
Y.log('Found CSS module on page: ' + v.name, 'info', 'loader');
5230
this.loaded[k] = true;
5235
oeach(ON_PAGE, function(v, k) {
5237
var m = this.moduleInfo[k],
5238
req = v.details.requires,
5239
mr = m && m.requires;
5241
if (!m._inspected && req && mr.length != req.length) {
5242
// console.log('deleting ' + m.name);
5246
m = this.addModule(v.details, k);
5248
m._inspected = true;
5253
* returns true if b is not loaded, and is required directly or by means of modules it supersedes.
5256
* @param {String} mod1 The first module to compare
5257
* @param {String} mod2 The second module to compare
5259
_requires: function(mod1, mod2) {
5261
var i, rm, after_map, s,
5262
info = this.moduleInfo,
5270
rm = m.expanded_map;
5271
after_map = m.after_map;
5273
// check if this module should be sorted after the other
5274
// do this first to short circut circular deps
5275
if (after_map && (mod2 in after_map)) {
5279
after_map = other.after_map;
5282
if (after_map && (mod1 in after_map)) {
5286
// check if this module requires one the other supersedes
5287
s = info[mod2] && info[mod2].supersedes;
5289
for (i = 0; i < s.length; i++) {
5290
if (this._requires(mod1, s[i])) {
5296
s = info[mod1] && info[mod1].supersedes;
5298
for (i = 0; i < s.length; i++) {
5299
if (this._requires(mod2, s[i])) {
5305
// check if this module requires the other directly
5306
// if (r && YArray.indexOf(r, mod2) > -1) {
5307
if (rm && (mod2 in rm)) {
5311
// external css files should be sorted below yui css
5312
if (m.ext && m.type == CSS && !other.ext && other.type == CSS) {
5319
* Apply a new config to the Loader instance
5322
* @param {Object} o The new configuration
5324
_config: function(o) {
5325
var i, j, val, f, group, groupName, self = this;
5326
// apply config values
5329
if (o.hasOwnProperty(i)) {
5331
if (i == 'require') {
5333
} else if (i == 'skin') {
5334
//If the config.skin is a string, format to the expected object
5335
if (typeof val === 'string') {
5336
self.skin.defaultSkin = o.skin;
5342
Y.mix(self.skin, val, true);
5343
} else if (i == 'groups') {
5345
if (val.hasOwnProperty(j)) {
5346
// Y.log('group: ' + j);
5349
self.addGroup(group, groupName);
5350
if (group.aliases) {
5351
oeach(group.aliases, self.addAlias, self);
5356
} else if (i == 'modules') {
5357
// add a hash of module definitions
5358
oeach(val, self.addModule, self);
5359
} else if (i === 'aliases') {
5360
oeach(val, self.addAlias, self);
5361
} else if (i == 'gallery') {
5362
this.groups.gallery.update(val, o);
5363
} else if (i == 'yui2' || i == '2in3') {
5364
this.groups.yui2.update(o['2in3'], o.yui2, o);
5375
if (L.isString(f)) {
5376
f = f.toUpperCase();
5377
self.filterName = f;
5378
self.filter = self.FILTER_DEFS[f];
5380
self.require('yui-log', 'dump');
5386
//Removed this so that when Loader is invoked
5387
//it doesn't request what it doesn't need.
5388
//self.require('intl-base', 'intl');
5394
* Returns the skin module name for the specified skin name. If a
5395
* module name is supplied, the returned skin module name is
5396
* specific to the module passed in.
5397
* @method formatSkin
5398
* @param {string} skin the name of the skin.
5399
* @param {string} mod optional: the name of a module to skin.
5400
* @return {string} the full skin module name.
5402
formatSkin: function(skin, mod) {
5403
var s = SKIN_PREFIX + skin;
5412
* Adds the skin def to the module info
5414
* @param {string} skin the name of the skin.
5415
* @param {string} mod the name of the module.
5416
* @param {string} parent parent module if this is a skin of a
5417
* submodule or plugin.
5418
* @return {string} the module name for the skin.
5421
_addSkin: function(skin, mod, parent) {
5422
var mdef, pkg, name, nmod,
5423
info = this.moduleInfo,
5425
ext = info[mod] && info[mod].ext;
5427
// Add a module definition for the module-specific skin css
5429
name = this.formatSkin(skin, mod);
5432
pkg = mdef.pkg || mod;
5438
path: (parent || pkg) + '/' + sinf.base + skin +
5443
nmod.base = mdef.base;
5445
if (mdef.configFn) {
5446
nmod.configFn = mdef.configFn;
5448
this.addModule(nmod, name);
5450
Y.log('Adding skin (' + name + '), ' + parent + ', ' + pkg + ', ' + info[name].path, 'info', 'loader');
5457
* Adds an alias module to the system
5459
* @param {Array} use An array of modules that makes up this alias
5460
* @param {String} name The name of the alias
5462
* var loader = new Y.Loader({});
5463
* loader.addAlias([ 'node', 'yql' ], 'davglass');
5464
* loader.require(['davglass']);
5465
* var out = loader.resolve(true);
5467
* //out.js will contain Node and YQL modules
5469
addAlias: function(use, name) {
5470
YUI.Env.aliases[name] = use;
5477
* Add a new module group
5479
* @param {Object} config An object containing the group configuration data
5480
* @param {String} config.name required, the group name
5481
* @param {String} config.base The base directory for this module group
5482
* @param {String} config.root The root path to add to each combo resource path
5483
* @param {Boolean} config.combine Should the request be combined
5484
* @param {String} config.comboBase Combo service base path
5485
* @param {Object} config.modules The group of modules
5486
* @param {String} name the group name.
5488
* var loader = new Y.Loader({});
5492
* comboBase: '/combo?',
5495
* //Module List here
5499
addGroup: function(o, name) {
5500
var mods = o.modules,
5502
name = name || o.name;
5504
self.groups[name] = o;
5507
oeach(o.patterns, function(v, k) {
5509
self.patterns[k] = v;
5514
oeach(mods, function(v, k) {
5515
if (typeof v === 'string') {
5516
v = { name: k, fullpath: v };
5519
self.addModule(v, k);
5525
* Add a new module to the component metadata.
5527
* @param {Object} config An object containing the module data.
5528
* @param {String} config.name Required, the component name
5529
* @param {String} config.type Required, the component type (js or css)
5530
* @param {String} config.path Required, the path to the script from `base`
5531
* @param {Array} config.requires Array of modules required by this component
5532
* @param {Array} [config.optional] Array of optional modules for this component
5533
* @param {Array} [config.supersedes] Array of the modules this component replaces
5534
* @param {Array} [config.after] Array of modules the components which, if present, should be sorted above this one
5535
* @param {Object} [config.after_map] Faster alternative to 'after' -- supply a hash instead of an array
5536
* @param {Number} [config.rollup] The number of superseded modules required for automatic rollup
5537
* @param {String} [config.fullpath] If `fullpath` is specified, this is used instead of the configured `base + path`
5538
* @param {Boolean} [config.skinnable] Flag to determine if skin assets should automatically be pulled in
5539
* @param {Object} [config.submodules] Hash of submodules
5540
* @param {String} [config.group] The group the module belongs to -- this is set automatically when it is added as part of a group configuration.
5541
* @param {Array} [config.lang] Array of BCP 47 language tags of languages for which this module has localized resource bundles, e.g., `["en-GB", "zh-Hans-CN"]`
5542
* @param {Object} [config.condition] Specifies that the module should be loaded automatically if a condition is met. This is an object with up to three fields:
5543
* @param {String} [config.condition.trigger] The name of a module that can trigger the auto-load
5544
* @param {Function} [config.condition.test] A function that returns true when the module is to be loaded.
5545
* @param {String} [config.condition.when] Specifies the load order of the conditional module
5546
* with regard to the position of the trigger module.
5547
* This should be one of three values: `before`, `after`, or `instead`. The default is `after`.
5548
* @param {Object} [config.testresults] A hash of test results from `Y.Features.all()`
5549
* @param {Function} [config.configFn] A function to exectute when configuring this module
5550
* @param {Object} config.configFn.mod The module config, modifying this object will modify it's config. Returning false will delete the module's config.
5551
* @param {String} [name] The module name, required if not in the module data.
5552
* @return {Object} the module definition or null if the object passed in did not provide all required attributes.
5554
addModule: function(o, name) {
5555
name = name || o.name;
5557
if (typeof o === 'string') {
5558
o = { name: name, fullpath: o };
5561
//Only merge this data if the temp flag is set
5562
//from an earlier pass from a pattern or else
5563
//an override module (YUI_config) can not be used to
5564
//replace a default module.
5565
if (this.moduleInfo[name] && this.moduleInfo[name].temp) {
5566
//This catches temp modules loaded via a pattern
5567
// The module will be added twice, once from the pattern and
5568
// Once from the actual add call, this ensures that properties
5569
// that were added to the module the first time around (group: gallery)
5570
// are also added the second time around too.
5571
o = Y.merge(this.moduleInfo[name], o);
5576
if (!o || !o.name) {
5581
//Always assume it's javascript unless the CSS pattern is matched.
5583
var p = o.path || o.fullpath;
5584
if (p && this.REGEX_CSS.test(p)) {
5585
Y.log('Auto determined module type as CSS', 'warn', 'loader');
5590
if (!o.path && !o.fullpath) {
5591
o.path = _path(name, name, o.type);
5593
o.supersedes = o.supersedes || o.use;
5595
o.ext = ('ext' in o) ? o.ext : (this._internal) ? false : true;
5597
// Handle submodule logic
5598
var subs = o.submodules, i, l, t, sup, s, smod, plugins, plug,
5599
j, langs, packName, supName, flatSup, flatLang, lang, ret,
5600
overrides, skinname, when,
5601
conditions = this.conditions, trigger;
5602
// , existing = this.moduleInfo[name], newr;
5604
this.moduleInfo[name] = o;
5606
o.requires = o.requires || [];
5609
skinname = this._addSkin(this.skin.defaultSkin, name);
5610
o.requires.unshift(skinname);
5613
o.requires = this.filterRequires(o.requires) || [];
5615
if (!o.langPack && o.lang) {
5616
langs = YArray(o.lang);
5617
for (j = 0; j < langs.length; j++) {
5619
packName = this.getLangPackName(lang, name);
5620
smod = this.moduleInfo[packName];
5622
smod = this._addLangPack(lang, o, packName);
5629
sup = o.supersedes || [];
5633
if (subs.hasOwnProperty(i)) {
5636
s.path = s.path || _path(name, i, o.type);
5641
sup = sup.concat(s.supersedes);
5644
smod = this.addModule(s, i);
5647
if (smod.skinnable) {
5649
overrides = this.skin.overrides;
5650
if (overrides && overrides[i]) {
5651
for (j = 0; j < overrides[i].length; j++) {
5652
skinname = this._addSkin(overrides[i][j],
5657
skinname = this._addSkin(this.skin.defaultSkin,
5662
// looks like we are expected to work out the metadata
5663
// for the parent module language packs from what is
5664
// specified in the child modules.
5665
if (s.lang && s.lang.length) {
5667
langs = YArray(s.lang);
5668
for (j = 0; j < langs.length; j++) {
5670
packName = this.getLangPackName(lang, name);
5671
supName = this.getLangPackName(lang, i);
5672
smod = this.moduleInfo[packName];
5675
smod = this._addLangPack(lang, o, packName);
5678
flatSup = flatSup || YArray.hash(smod.supersedes);
5680
if (!(supName in flatSup)) {
5681
smod.supersedes.push(supName);
5684
o.lang = o.lang || [];
5686
flatLang = flatLang || YArray.hash(o.lang);
5688
if (!(lang in flatLang)) {
5692
// Y.log('pack ' + packName + ' should supersede ' + supName);
5693
// Add rollup file, need to add to supersedes list too
5696
packName = this.getLangPackName(ROOT_LANG, name);
5697
supName = this.getLangPackName(ROOT_LANG, i);
5699
smod = this.moduleInfo[packName];
5702
smod = this._addLangPack(lang, o, packName);
5705
if (!(supName in flatSup)) {
5706
smod.supersedes.push(supName);
5709
// Y.log('pack ' + packName + ' should supersede ' + supName);
5710
// Add rollup file, need to add to supersedes list too
5718
//o.supersedes = YObject.keys(YArray.hash(sup));
5719
o.supersedes = YArray.dedupe(sup);
5720
if (this.allowRollup) {
5721
o.rollup = (l < 4) ? l : Math.min(l - 1, 4);
5725
plugins = o.plugins;
5727
for (i in plugins) {
5728
if (plugins.hasOwnProperty(i)) {
5731
plug.path = plug.path || _path(name, i, o.type);
5732
plug.requires = plug.requires || [];
5733
plug.group = o.group;
5734
this.addModule(plug, i);
5736
this._addSkin(this.skin.defaultSkin, i, name);
5744
t = o.condition.trigger;
5745
if (YUI.Env.aliases[t]) {
5746
t = YUI.Env.aliases[t];
5748
if (!Y.Lang.isArray(t)) {
5752
for (i = 0; i < t.length; i++) {
5754
when = o.condition.when;
5755
conditions[trigger] = conditions[trigger] || {};
5756
conditions[trigger][name] = o.condition;
5757
// the 'when' attribute can be 'before', 'after', or 'instead'
5758
// the default is after.
5759
if (when && when != 'after') {
5760
if (when == 'instead') { // replace the trigger
5761
o.supersedes = o.supersedes || [];
5762
o.supersedes.push(trigger);
5763
} else { // before the trigger
5764
// the trigger requires the conditional mod,
5765
// so it should appear before the conditional
5766
// mod if we do not intersede.
5768
} else { // after the trigger
5769
o.after = o.after || [];
5770
o.after.push(trigger);
5776
o.supersedes = this.filterRequires(o.supersedes);
5780
o.after = this.filterRequires(o.after);
5781
o.after_map = YArray.hash(o.after);
5784
// this.dirty = true;
5787
ret = o.configFn(o);
5788
if (ret === false) {
5789
Y.log('Config function returned false for ' + name + ', skipping.', 'info', 'loader');
5790
delete this.moduleInfo[name];
5791
delete GLOBAL_ENV._renderedMods[name];
5795
//Add to global cache
5797
if (!GLOBAL_ENV._renderedMods) {
5798
GLOBAL_ENV._renderedMods = {};
5800
GLOBAL_ENV._renderedMods[name] = Y.merge(o);
5801
GLOBAL_ENV._conditions = conditions;
5808
* Add a requirement for one or more module
5810
* @param {string[] | string*} what the modules to load.
5812
require: function(what) {
5813
var a = (typeof what === 'string') ? YArray(arguments) : what;
5815
this.required = Y.merge(this.required, YArray.hash(this.filterRequires(a)));
5817
this._explodeRollups();
5820
* Grab all the items that were asked for, check to see if the Loader
5821
* meta-data contains a "use" array. If it doesm remove the asked item and replace it with
5822
* the content of the "use".
5823
* This will make asking for: "dd"
5824
* Actually ask for: "dd-ddm-base,dd-ddm,dd-ddm-drop,dd-drag,dd-proxy,dd-constrain,dd-drop,dd-scroll,dd-drop-plugin"
5826
* @method _explodeRollups
5828
_explodeRollups: function() {
5831
if (!self.allowRollup) {
5832
oeach(r, function(v, name) {
5833
m = self.getModule(name);
5836
YArray.each(m.use, function(v) {
5837
m = self.getModule(v);
5840
YArray.each(m.use, function(v) {
5854
* Explodes the required array to remove aliases and replace them with real modules
5855
* @method filterRequires
5856
* @param {Array} r The original requires array
5857
* @return {Array} The new array of exploded requirements
5859
filterRequires: function(r) {
5861
if (!Y.Lang.isArray(r)) {
5865
var c = [], i, mod, o, m;
5867
for (i = 0; i < r.length; i++) {
5868
mod = this.getModule(r[i]);
5869
if (mod && mod.use) {
5870
for (o = 0; o < mod.use.length; o++) {
5871
//Must walk the other modules in case a module is a rollup of rollups (datatype)
5872
m = this.getModule(mod.use[o]);
5874
c = Y.Array.dedupe([].concat(c, this.filterRequires(m.use)));
5888
* Returns an object containing properties for all modules required
5889
* in order to load the requested module
5890
* @method getRequires
5891
* @param {object} mod The module definition from moduleInfo.
5892
* @return {array} the expanded requirement list.
5894
getRequires: function(mod) {
5897
//console.log('returning no reqs for ' + mod.name);
5898
return NO_REQUIREMENTS;
5902
//console.log('returning requires for ' + mod.name, mod.requires);
5903
return mod.expanded || NO_REQUIREMENTS;
5906
//TODO add modue cache here out of scope..
5908
var i, m, j, add, packName, lang, testresults = this.testresults,
5909
name = mod.name, cond,
5910
adddef = ON_PAGE[name] && ON_PAGE[name].details,
5913
o, skinmod, skindef, skinpar, skinname,
5914
intl = mod.lang || mod.intl,
5915
info = this.moduleInfo,
5916
ftests = Y.Features && Y.Features.tests.load,
5919
// console.log(name);
5921
// pattern match leaves module stub that needs to be filled out
5922
if (mod.temp && adddef) {
5924
mod = this.addModule(adddef, name);
5925
mod.group = old_mod.group;
5926
mod.pkg = old_mod.pkg;
5927
delete mod.expanded;
5930
// console.log('cache: ' + mod.langCache + ' == ' + this.lang);
5932
// if (mod.expanded && (!mod.langCache || mod.langCache == this.lang)) {
5933
if (mod.expanded && (!this.lang || mod.langCache === this.lang)) {
5934
//Y.log('Already expanded ' + name + ', ' + mod.expanded);
5935
return mod.expanded;
5941
r = this.filterRequires(mod.requires);
5943
//If a module has a lang attribute, auto add the intl requirement.
5948
o = this.filterRequires(mod.optional);
5950
// Y.log("getRequires: " + name + " (dirty:" + this.dirty +
5951
// ", expanded:" + mod.expanded + ")");
5954
mod.langCache = this.lang;
5956
for (i = 0; i < r.length; i++) {
5957
//Y.log(name + ' requiring ' + r[i], 'info', 'loader');
5961
m = this.getModule(r[i]);
5963
add = this.getRequires(m);
5964
intl = intl || (m.expanded_map &&
5965
(INTL in m.expanded_map));
5966
for (j = 0; j < add.length; j++) {
5973
// get the requirements from superseded modules, if any
5974
r = this.filterRequires(mod.supersedes);
5976
for (i = 0; i < r.length; i++) {
5978
// if this module has submodules, the requirements list is
5979
// expanded to include the submodules. This is so we can
5980
// prevent dups when a submodule is already loaded and the
5981
// parent is requested.
5982
if (mod.submodules) {
5987
m = this.getModule(r[i]);
5990
add = this.getRequires(m);
5991
intl = intl || (m.expanded_map &&
5992
(INTL in m.expanded_map));
5993
for (j = 0; j < add.length; j++) {
6001
if (o && this.loadOptional) {
6002
for (i = 0; i < o.length; i++) {
6008
add = this.getRequires(m);
6009
intl = intl || (m.expanded_map &&
6010
(INTL in m.expanded_map));
6011
for (j = 0; j < add.length; j++) {
6019
cond = this.conditions[name];
6022
//Set the module to not parsed since we have conditionals and this could change the dependency tree.
6023
mod._parsed = false;
6024
if (testresults && ftests) {
6025
oeach(testresults, function(result, id) {
6026
var condmod = ftests[id].name;
6027
if (!hash[condmod] && ftests[id].trigger == name) {
6028
if (result && ftests[id]) {
6029
hash[condmod] = true;
6035
oeach(cond, function(def, condmod) {
6036
if (!hash[condmod]) {
6037
//first see if they've specfied a ua check
6038
//then see if they've got a test fn & if it returns true
6039
//otherwise just having a condition block is enough
6040
var go = def && ((!def.ua && !def.test) || (def.ua && Y.UA[def.ua]) ||
6041
(def.test && def.test(Y, r)));
6044
hash[condmod] = true;
6046
m = this.getModule(condmod);
6048
add = this.getRequires(m);
6049
for (j = 0; j < add.length; j++) {
6060
// Create skin modules
6061
if (mod.skinnable) {
6062
skindef = this.skin.overrides;
6063
oeach(YUI.Env.aliases, function(o, n) {
6064
if (Y.Array.indexOf(o, name) > -1) {
6068
if (skindef && (skindef[name] || (skinpar && skindef[skinpar]))) {
6070
if (skindef[skinpar]) {
6073
for (i = 0; i < skindef[skinname].length; i++) {
6074
skinmod = this._addSkin(skindef[skinname][i], name);
6075
if (!this.isCSSLoaded(skinmod, this._boot)) {
6080
skinmod = this._addSkin(this.skin.defaultSkin, name);
6081
if (!this.isCSSLoaded(skinmod, this._boot)) {
6087
mod._parsed = false;
6091
if (mod.lang && !mod.langPack && Y.Intl) {
6092
lang = Y.Intl.lookupBestLang(this.lang || ROOT_LANG, mod.lang);
6093
//Y.log('Best lang: ' + lang + ', this.lang: ' + this.lang + ', mod.lang: ' + mod.lang);
6094
packName = this.getLangPackName(lang, name);
6096
d.unshift(packName);
6102
mod.expanded_map = YArray.hash(d);
6104
mod.expanded = YObject.keys(mod.expanded_map);
6106
return mod.expanded;
6109
* Check to see if named css module is already loaded on the page
6110
* @method isCSSLoaded
6111
* @param {String} name The name of the css file
6114
isCSSLoaded: function(name, skip) {
6115
//TODO - Make this call a batching call with name being an array
6116
if (!name || !YUI.Env.cssStampEl || (!skip && this.ignoreRegistered)) {
6117
Y.log('isCSSLoaded was skipped for ' + name, 'warn', 'loader');
6121
var el = YUI.Env.cssStampEl,
6123
style = el.currentStyle; //IE
6125
//Add the classname to the element
6126
el.className = name;
6129
style = Y.config.doc.defaultView.getComputedStyle(el, null);
6132
if (style && style['display'] === 'none') {
6136
Y.log('Has Skin? ' + name + ' : ' + ret, 'info', 'loader');
6138
el.className = ''; //Reset the classname to ''
6143
* Returns a hash of module names the supplied module satisfies.
6144
* @method getProvides
6145
* @param {string} name The name of the module.
6146
* @return {object} what this module provides.
6148
getProvides: function(name) {
6149
var m = this.getModule(name), o, s;
6150
// supmap = this.provides;
6156
if (m && !m.provides) {
6161
YArray.each(s, function(v) {
6162
Y.mix(o, this.getProvides(v));
6175
* Calculates the dependency tree, the result is stored in the sorted
6178
* @param {object} o optional options object.
6179
* @param {string} type optional argument to prune modules.
6181
calculate: function(o, type) {
6182
if (o || type || this.dirty) {
6194
if (this.allowRollup) {
6197
this._explodeRollups();
6204
* Creates a "psuedo" package for languages provided in the lang array
6205
* @method _addLangPack
6207
* @param {String} lang The language to create
6208
* @param {Object} m The module definition to create the language pack around
6209
* @param {String} packName The name of the package (e.g: lang/datatype-date-en-US)
6210
* @return {Object} The module definition
6212
_addLangPack: function(lang, m, packName) {
6215
existing = this.moduleInfo[packName];
6219
packPath = _path((m.pkg || name), packName, JS, true);
6231
conf.configFn = m.configFn;
6234
this.addModule(conf, packName);
6237
Y.Env.lang = Y.Env.lang || {};
6238
Y.Env.lang[lang] = Y.Env.lang[lang] || {};
6239
Y.Env.lang[lang][name] = true;
6243
return this.moduleInfo[packName];
6247
* Investigates the current YUI configuration on the page. By default,
6248
* modules already detected will not be loaded again unless a force
6249
* option is encountered. Called by calculate()
6253
_setup: function() {
6254
var info = this.moduleInfo, name, i, j, m, l,
6257
for (name in info) {
6258
if (info.hasOwnProperty(name)) {
6263
//m.requires = YObject.keys(YArray.hash(m.requires));
6264
m.requires = YArray.dedupe(m.requires);
6266
// Create lang pack modules
6267
if (m.lang && m.lang.length) {
6268
// Setup root package if the module has lang defined,
6269
// it needs to provide a root language pack
6270
packName = this.getLangPackName(ROOT_LANG, name);
6271
this._addLangPack(null, m, packName);
6279
//l = Y.merge(this.inserted);
6282
// available modules
6283
if (!this.ignoreRegistered) {
6284
Y.mix(l, GLOBAL_ENV.mods);
6287
// add the ignore list to the list of loaded packages
6289
Y.mix(l, YArray.hash(this.ignore));
6292
// expand the list to include superseded modules
6294
if (l.hasOwnProperty(j)) {
6295
Y.mix(l, this.getProvides(j));
6299
// remove modules on the force list from the loaded list
6301
for (i = 0; i < this.force.length; i++) {
6302
if (this.force[i] in l) {
6303
delete l[this.force[i]];
6308
Y.mix(this.loaded, l);
6314
* Builds a module name for a language pack
6315
* @method getLangPackName
6316
* @param {string} lang the language code.
6317
* @param {string} mname the module to build it for.
6318
* @return {string} the language pack module name.
6320
getLangPackName: function(lang, mname) {
6321
return ('lang/' + mname + ((lang) ? '_' + lang : ''));
6324
* Inspects the required modules list looking for additional
6325
* dependencies. Expands the required list to include all
6326
* required modules. Called by calculate()
6330
_explode: function() {
6331
//TODO Move done out of scope
6332
var r = this.required, m, reqs, done = {},
6335
// the setup phase is over, all modules have been created
6338
self._explodeRollups();
6341
oeach(r, function(v, name) {
6344
m = self.getModule(name);
6346
var expound = m.expound;
6349
r[expound] = self.getModule(expound);
6350
reqs = self.getRequires(r[expound]);
6351
Y.mix(r, YArray.hash(reqs));
6354
reqs = self.getRequires(m);
6355
Y.mix(r, YArray.hash(reqs));
6360
// Y.log('After explode: ' + YObject.keys(r));
6363
* Get's the loader meta data for the requested module
6365
* @param {String} mname The module name to get
6366
* @return {Object} The module metadata
6368
getModule: function(mname) {
6369
//TODO: Remove name check - it's a quick hack to fix pattern WIP
6374
var p, found, pname,
6375
m = this.moduleInfo[mname],
6376
patterns = this.patterns;
6378
// check the patterns library to see if we should automatically add
6379
// the module with defaults
6381
// Y.log('testing patterns ' + YObject.keys(patterns));
6382
for (pname in patterns) {
6383
if (patterns.hasOwnProperty(pname)) {
6384
// Y.log('testing pattern ' + i);
6385
p = patterns[pname];
6387
//There is no test method, create a default one that tests
6388
// the pattern against the mod name
6390
p.test = function(mname, pname) {
6391
return (mname.indexOf(pname) > -1);
6395
if (p.test(mname, pname)) {
6396
// use the metadata supplied for the pattern
6397
// as the module definition.
6406
// Y.log('executing pattern action: ' + pname);
6407
p.action.call(this, mname, pname);
6409
Y.log('Undefined module: ' + mname + ', matched a pattern: ' +
6410
pname, 'info', 'loader');
6411
// ext true or false?
6412
m = this.addModule(Y.merge(found), mname);
6421
// impl in rollup submodule
6422
_rollup: function() { },
6425
* Remove superceded modules and loaded modules. Called by
6426
* calculate() after we have the mega list of all dependencies
6428
* @return {object} the reduced dependency hash.
6431
_reduce: function(r) {
6433
r = r || this.required;
6435
var i, j, s, m, type = this.loadType,
6436
ignore = this.ignore ? YArray.hash(this.ignore) : false;
6439
if (r.hasOwnProperty(i)) {
6440
m = this.getModule(i);
6441
// remove if already loaded
6442
if (((this.loaded[i] || ON_PAGE[i]) &&
6443
!this.forceMap[i] && !this.ignoreRegistered) ||
6444
(type && m && m.type != type)) {
6447
if (ignore && ignore[i]) {
6450
// remove anything this module supersedes
6451
s = m && m.supersedes;
6453
for (j = 0; j < s.length; j++) {
6465
* Handles the queue when a module has been loaded for all cases
6468
* @param {String} msg The message from Loader
6469
* @param {Boolean} success A boolean denoting success or failure
6471
_finish: function(msg, success) {
6472
Y.log('loader finishing: ' + msg + ', ' + Y.id + ', ' +
6473
this.data, 'info', 'loader');
6475
_queue.running = false;
6477
var onEnd = this.onEnd;
6479
onEnd.call(this.context, {
6488
* The default Loader onSuccess handler, calls this.onSuccess with a payload
6489
* @method _onSuccess
6492
_onSuccess: function() {
6493
var self = this, skipped = Y.merge(self.skipped), fn,
6494
failed = [], rreg = self.requireRegistration,
6497
oeach(skipped, function(k) {
6498
delete self.inserted[k];
6503
oeach(self.inserted, function(v, k) {
6504
var mod = self.getModule(k);
6505
if (mod && rreg && mod.type == JS && !(k in YUI.Env.mods)) {
6508
Y.mix(self.loaded, self.getProvides(k));
6512
fn = self.onSuccess;
6513
msg = (failed.length) ? 'notregistered' : 'success';
6514
success = !(failed.length);
6516
fn.call(self.context, {
6524
self._finish(msg, success);
6527
* The default Loader onProgress handler, calls this.onProgress with a payload
6528
* @method _onProgress
6531
_onProgress: function(e) {
6533
if (self.onProgress) {
6534
self.onProgress.call(self.context, {
6541
* The default Loader onFailure handler, calls this.onFailure with a payload
6542
* @method _onFailure
6545
_onFailure: function(o) {
6546
var f = this.onFailure, msg = [], i = 0, len = o.errors.length;
6548
for (i; i < len; i++) {
6549
msg.push(o.errors[i].error);
6552
msg = msg.join(',');
6554
Y.log('load error: ' + msg + ', ' + Y.id, 'error', 'loader');
6557
f.call(this.context, {
6564
this._finish(msg, false);
6569
* The default Loader onTimeout handler, calls this.onTimeout with a payload
6570
* @method _onTimeout
6573
_onTimeout: function() {
6574
Y.log('loader timeout: ' + Y.id, 'error', 'loader');
6575
var f = this.onTimeout;
6577
f.call(this.context, {
6586
* Sorts the dependency tree. The last step of calculate()
6592
// create an indexed list
6593
var s = YObject.keys(this.required),
6594
// loaded = this.loaded,
6595
//TODO Move this out of scope
6597
p = 0, l, a, b, j, k, moved, doneKey;
6599
// keep going until we make a pass without moving anything
6605
// start the loop after items that are already sorted
6606
for (j = p; j < l; j++) {
6608
// check the next module on the list to see if its
6609
// dependencies have been met
6612
// check everything below current item and move if we
6613
// find a requirement for the current item
6614
for (k = j + 1; k < l; k++) {
6617
if (!done[doneKey] && this._requires(a, s[k])) {
6619
// extract the dependency so we can move it up
6622
// insert the dependency above the item that
6624
s.splice(j, 0, b[0]);
6626
// only swap two dependencies once to short circut
6627
// circular dependencies
6628
done[doneKey] = true;
6637
// jump out of loop if we moved something
6640
// this item is sorted, move our pointer and keep going
6646
// when we make it here and moved is false, we are
6658
* Handles the actual insertion of script/link tags
6661
* @param {Object} source The YUI instance the request came from
6662
* @param {Object} o The metadata to include
6663
* @param {String} type JS or CSS
6664
* @param {Boolean} [skipcalc=false] Do a Loader.calculate on the meta
6666
_insert: function(source, o, type, skipcalc) {
6668
Y.log('private _insert() ' + (type || '') + ', ' + Y.id, "info", "loader");
6670
// restore the state at the time of the request
6672
this._config(source);
6675
// build the dependency list
6676
// don't include type so we can process CSS and script in
6677
// one pass when the type is not specified.
6682
var modules = this.resolve(),
6683
self = this, comp = 0, actions = 0;
6686
//Filter out the opposite type and reset the array so the checks later work
6687
modules[((type === JS) ? CSS : JS)] = [];
6689
if (modules.js.length) {
6692
if (modules.css.length) {
6696
//console.log('Resolved Modules: ', modules);
6698
var complete = function(d) {
6700
var errs = {}, i = 0, u = '', fn;
6702
if (d && d.errors) {
6703
for (i = 0; i < d.errors.length; i++) {
6704
if (d.errors[i].request) {
6705
u = d.errors[i].request.url;
6713
if (d && d.data && d.data.length && (d.type === 'success')) {
6714
for (i = 0; i < d.data.length; i++) {
6715
self.inserted[d.data[i].name] = true;
6719
if (actions === comp) {
6720
self._loading = null;
6721
Y.log('Loader actions complete!', 'info', 'loader');
6723
Y.log('Firing final Loader callback!', 'info', 'loader');
6731
this._loading = true;
6733
if (!modules.js.length && !modules.css.length) {
6734
Y.log('No modules resolved..', 'warn', 'loader');
6743
if (modules.css.length) { //Load CSS first
6744
Y.log('Loading CSS modules', 'info', 'loader');
6745
Y.Get.css(modules.css, {
6746
data: modules.cssMods,
6747
attributes: self.cssAttributes,
6748
insertBefore: self.insertBefore,
6749
charset: self.charset,
6750
timeout: self.timeout,
6752
onProgress: function(e) {
6753
self._onProgress.call(self, e);
6755
onTimeout: function(d) {
6756
self._onTimeout.call(self, d);
6758
onSuccess: function(d) {
6760
d.fn = self._onSuccess;
6761
complete.call(self, d);
6763
onFailure: function(d) {
6765
d.fn = self._onFailure;
6766
complete.call(self, d);
6771
if (modules.js.length) {
6772
Y.log('Loading JS modules', 'info', 'loader');
6773
Y.Get.js(modules.js, {
6774
data: modules.jsMods,
6775
insertBefore: self.insertBefore,
6776
attributes: self.jsAttributes,
6777
charset: self.charset,
6778
timeout: self.timeout,
6782
onProgress: function(e) {
6783
self._onProgress.call(self, e);
6785
onTimeout: function(d) {
6786
self._onTimeout.call(self, d);
6788
onSuccess: function(d) {
6790
d.fn = self._onSuccess;
6791
complete.call(self, d);
6793
onFailure: function(d) {
6795
d.fn = self._onFailure;
6796
complete.call(self, d);
6802
* Once a loader operation is completely finished, process any additional queued items.
6806
_continue: function() {
6807
if (!(_queue.running) && _queue.size() > 0) {
6808
_queue.running = true;
6814
* inserts the requested modules and their dependencies.
6815
* <code>type</code> can be "js" or "css". Both script and
6816
* css are inserted if type is not provided.
6818
* @param {object} o optional options object.
6819
* @param {string} type the type of dependency to insert.
6821
insert: function(o, type, skipsort) {
6822
Y.log('public insert() ' + (type || '') + ', ' +
6823
Y.Object.keys(this.required), "info", "loader");
6824
var self = this, copy = Y.merge(this);
6825
delete copy.require;
6827
_queue.add(function() {
6828
self._insert(copy, o, type, skipsort);
6834
* Executed every time a module is loaded, and if we are in a load
6835
* cycle, we attempt to load the next script. Public so that it
6836
* is possible to call this if using a method other than
6837
* Y.register to determine when scripts are fully loaded
6840
* @param {string} mname optional the name of the module that has
6841
* been loaded (which is usually why it is time to load the next
6844
loadNext: function(mname) {
6845
Y.log('loadNext was called..', 'error', 'loader');
6850
* Apply filter defined for this instance to a url/path
6852
* @param {string} u the string to filter.
6853
* @param {string} name the name of the module, if we are processing
6854
* a single module as opposed to a combined url.
6855
* @return {string} the filtered string.
6858
_filter: function(u, name, group) {
6859
var f = this.filter,
6860
hasFilter = name && (name in this.filters),
6861
modFilter = hasFilter && this.filters[name],
6862
groupName = group || (this.moduleInfo[name] ? this.moduleInfo[name].group : null);
6864
if (groupName && this.groups[groupName] && this.groups[groupName].filter) {
6865
modFilter = this.groups[groupName].filter;
6871
f = (L.isString(modFilter)) ?
6872
this.FILTER_DEFS[modFilter.toUpperCase()] || null :
6876
u = u.replace(new RegExp(f.searchExp, 'g'), f.replaceStr);
6884
* Generates the full url for a module
6886
* @param {string} path the path fragment.
6887
* @param {String} name The name of the module
6888
* @param {String} [base=self.base] The base url to use
6889
* @return {string} the full url.
6892
_url: function(path, name, base) {
6893
return this._filter((base || this.base || '') + path, name);
6896
* Returns an Object hash of file arrays built from `loader.sorted` or from an arbitrary list of sorted modules.
6898
* @param {Boolean} [calc=false] Perform a loader.calculate() before anything else
6899
* @param {Array} [s=loader.sorted] An override for the loader.sorted array
6900
* @return {Object} Object hash (js and css) of two arrays of file lists
6901
* @example This method can be used as an off-line dep calculator
6904
* var loader = new Y.Loader({
6909
* require: ['node', 'dd', 'console']
6911
* var out = loader.resolve(true);
6914
resolve: function(calc, s) {
6916
var len, i, m, url, fn, msg, attr, group, groupName, j, frag,
6917
comboSource, comboSources, mods, comboBase,
6918
base, urls, u = [], tmpBase, baseLen, resCombos = {},
6919
self = this, comboSep, maxURLLength, singles = [],
6920
inserted = (self.ignoreRegistered) ? {} : self.inserted,
6921
resolved = { js: [], jsMods: [], css: [], cssMods: [] },
6922
type = self.loadType || 'js';
6927
s = s || self.sorted;
6929
var addSingle = function(m) {
6932
group = (m.group && self.groups[m.group]) || NOT_FOUND;
6934
//Always assume it's async
6935
if (group.async === false) {
6936
m.async = group.async;
6939
url = (m.fullpath) ? self._filter(m.fullpath, s[i]) :
6940
self._url(m.path, s[i], group.base || m.base);
6942
if (m.attributes || m.async === false) {
6948
url.attributes = m.attributes
6951
resolved[m.type].push(url);
6952
resolved[m.type + 'Mods'].push(m);
6954
Y.log('Undefined Module', 'warn', 'loader');
6961
// the default combo base
6962
comboBase = self.comboBase;
6968
for (i = 0; i < len; i++) {
6969
comboSource = comboBase;
6970
m = self.getModule(s[i]);
6971
groupName = m && m.group;
6972
group = self.groups[groupName];
6973
if (groupName && group) {
6975
if (!group.combine || m.fullpath) {
6976
//This is not a combo module, skip it and load it singly later.
6977
//singles.push(s[i]);
6982
if (group.comboBase) {
6983
comboSource = group.comboBase;
6986
if ("root" in group && L.isValue(group.root)) {
6987
m.root = group.root;
6989
m.comboSep = group.comboSep || self.comboSep;
6990
m.maxURLLength = group.maxURLLength || self.maxURLLength;
6992
if (!self.combine) {
6993
//This is not a combo module, skip it and load it singly later.
6994
//singles.push(s[i]);
7000
comboSources[comboSource] = comboSources[comboSource] || [];
7001
comboSources[comboSource].push(m);
7004
for (j in comboSources) {
7005
if (comboSources.hasOwnProperty(j)) {
7006
resCombos[j] = resCombos[j] || { js: [], jsMods: [], css: [], cssMods: [] };
7008
mods = comboSources[j];
7012
for (i = 0; i < len; i++) {
7013
if (inserted[mods[i]]) {
7017
// Do not try to combine non-yui JS unless combo def
7019
if (m && (m.combine || !m.ext)) {
7020
resCombos[j].comboSep = m.comboSep;
7021
resCombos[j].group = m.group;
7022
resCombos[j].maxURLLength = m.maxURLLength;
7023
frag = ((L.isValue(m.root)) ? m.root : self.root) + (m.path || m.fullpath);
7024
frag = self._filter(frag, m.name);
7025
resCombos[j][m.type].push(frag);
7026
resCombos[j][m.type + 'Mods'].push(m);
7028
//Add them to the next process..
7030
//singles.push(mods[i].name);
7041
for (j in resCombos) {
7043
comboSep = resCombos[base].comboSep || self.comboSep;
7044
maxURLLength = resCombos[base].maxURLLength || self.maxURLLength;
7045
Y.log('Using maxURLLength of ' + maxURLLength, 'info', 'loader');
7046
for (type in resCombos[base]) {
7047
if (type === JS || type === CSS) {
7048
urls = resCombos[base][type];
7049
mods = resCombos[base][type + 'Mods'];
7051
tmpBase = base + urls.join(comboSep);
7052
baseLen = tmpBase.length;
7053
if (maxURLLength <= base.length) {
7054
Y.log('maxURLLength (' + maxURLLength + ') is lower than the comboBase length (' + base.length + '), resetting to default (' + MAX_URL_LENGTH + ')', 'error', 'loader');
7055
maxURLLength = MAX_URL_LENGTH;
7059
if (baseLen > maxURLLength) {
7060
Y.log('Exceeded maxURLLength (' + maxURLLength + ') for ' + type + ', splitting', 'info', 'loader');
7062
for (s = 0; s < len; s++) {
7064
tmpBase = base + u.join(comboSep);
7066
if (tmpBase.length > maxURLLength) {
7068
tmpBase = base + u.join(comboSep)
7069
resolved[type].push(self._filter(tmpBase, null, resCombos[base].group));
7077
tmpBase = base + u.join(comboSep);
7078
resolved[type].push(self._filter(tmpBase, null, resCombos[base].group));
7081
resolved[type].push(self._filter(tmpBase, null, resCombos[base].group));
7084
resolved[type + 'Mods'] = resolved[type + 'Mods'].concat(mods);
7094
Shortcut to calculate, resolve and load all modules.
7096
var loader = new Y.Loader({
7097
ignoreRegistered: true,
7105
loader.load(function() {
7106
console.log('All modules have loaded..');
7111
@param {Callback} cb Executed after all load operations are complete
7113
load: function(cb) {
7115
Y.log('No callback supplied to load()', 'error', 'loader');
7119
out = self.resolve(true);
7123
self.onEnd = function() {
7124
cb.apply(self.context || self, arguments);
7133
}, '3.5.1' ,{requires:['get', 'features']});
7134
YUI.add('loader-rollup', function(Y) {
7137
* Optional automatic rollup logic for reducing http connections
7138
* when not using a combo service.
7144
* Look for rollup packages to determine if all of the modules a
7145
* rollup supersedes are required. If so, include the rollup to
7146
* help reduce the total number of connections required. Called
7147
* by calculate(). This is an optional feature, and requires the
7148
* appropriate submodule to function.
7153
Y.Loader.prototype._rollup = function() {
7154
var i, j, m, s, r = this.required, roll,
7155
info = this.moduleInfo, rolled, c, smod;
7157
// find and cache rollup modules
7158
if (this.dirty || !this.rollups) {
7161
if (info.hasOwnProperty(i)) {
7162
m = this.getModule(i);
7163
// if (m && m.rollup && m.supersedes) {
7164
if (m && m.rollup) {
7165
this.rollups[i] = m;
7171
// make as many passes as needed to pick up rollup rollups
7175
// go through the rollup candidates
7176
for (i in this.rollups) {
7177
if (this.rollups.hasOwnProperty(i)) {
7178
// there can be only one, unless forced
7179
if (!r[i] && ((!this.loaded[i]) || this.forceMap[i])) {
7180
m = this.getModule(i);
7181
s = m.supersedes || [];
7184
// @TODO remove continue
7191
// check the threshold
7192
for (j = 0; j < s.length; j++) {
7195
// if the superseded module is loaded, we can't
7196
// load the rollup unless it has been forced.
7197
if (this.loaded[s[j]] && !this.forceMap[s[j]]) {
7200
// increment the counter if this module is required.
7201
// if we are beyond the rollup threshold, we will
7202
// use the rollup module
7203
} else if (r[s[j]] && m.type == smod.type) {
7205
// Y.log("adding to thresh: " + c + ", " + s[j]);
7206
roll = (c >= m.rollup);
7208
// Y.log("over thresh " + c + ", " + s[j]);
7215
// Y.log("adding rollup: " + i);
7220
// expand the rollup's dependencies
7221
this.getRequires(m);
7227
// if we made it here w/o rolling up something, we are done
7235
}, '3.5.1' ,{requires:['loader-base']});
7236
YUI.add('loader-yui3', function(Y) {
7238
/* This file is auto-generated by src/loader/scripts/meta_join.py */
7241
* YUI 3 module metadata
7245
YUI.Env[Y.version].modules = YUI.Env[Y.version].modules || {
7284
"anim-node-plugin": {
7295
"anim-shape-transform": {
7326
"app-transitions": {
7331
"app-transitions-css": {
7334
"app-transitions-native": {
7336
"name": "app-transitions-native",
7337
"test": function (Y) {
7338
var doc = Y.config.doc,
7339
node = doc ? doc.documentElement : null;
7341
if (node && node.style) {
7342
return ('MozTransition' in node.style || 'WebkitTransition' in node.style);
7347
"trigger": "app-transitions"
7351
"app-transitions-css",
7376
"arraylist-filter": {
7404
"attribute-complex": {
7414
"attribute-events": {
7419
"attribute-extras": {
7426
"autocomplete-base",
7427
"autocomplete-sources",
7428
"autocomplete-list",
7429
"autocomplete-plugin"
7432
"autocomplete-base": {
7434
"autocomplete-sources"
7440
"event-valuechange",
7444
"autocomplete-filters": {
7450
"autocomplete-filters-accentfold": {
7457
"autocomplete-highlighters": {
7463
"autocomplete-highlighters-accentfold": {
7466
"highlight-accentfold"
7469
"autocomplete-list": {
7471
"autocomplete-sources"
7477
"autocomplete-base",
7484
"widget-position-align"
7488
"autocomplete-list-keys": {
7490
"name": "autocomplete-list-keys",
7491
"test": function (Y) {
7492
// Only add keyboard support to autocomplete-list if this doesn't appear to
7493
// be an iOS or Android-based mobile device.
7495
// There's currently no feasible way to actually detect whether a device has
7496
// a hardware keyboard, so this sniff will have to do. It can easily be
7497
// overridden by manually loading the autocomplete-list-keys module.
7499
// Worth noting: even though iOS supports bluetooth keyboards, Mobile Safari
7500
// doesn't fire the keyboard events used by AutoCompleteList, so there's
7501
// no point loading the -keys module even when a bluetooth keyboard may be
7503
return !(Y.UA.ios || Y.UA.android);
7505
"trigger": "autocomplete-list"
7508
"autocomplete-list",
7512
"autocomplete-plugin": {
7514
"autocomplete-list",
7518
"autocomplete-sources": {
7555
"base-pluginhost": {
7645
"datatype-date-math",
7650
"calendarnavigator": {
7684
"classnamemanager": {
7716
"console-filters": {
7733
"createlink-base": {
7749
"cssbase-context": {
7766
"cssfonts-context": {
7796
"cssreset-context": {
7808
"dataschema-array": {
7813
"dataschema-base": {
7818
"dataschema-json": {
7824
"dataschema-text": {
7839
"datasource-function",
7841
"datasource-jsonschema",
7842
"datasource-xmlschema",
7843
"datasource-arrayschema",
7844
"datasource-textschema",
7845
"datasource-polling"
7848
"datasource-arrayschema": {
7855
"datasource-cache": {
7862
"datasource-function": {
7879
"datasource-jsonschema": {
7886
"datasource-local": {
7891
"datasource-polling": {
7896
"datasource-textschema": {
7903
"datasource-xmlschema": {
7916
"datatable-column-widths",
7917
"datatable-message",
7918
"datatable-mutable",
7920
"datatable-datasource"
7933
"datatable-base-deprecated": {
7949
"datatable-column-widths": {
7958
"node-event-delegate"
7961
"datatable-datasource": {
7968
"datatable-datasource-deprecated": {
7970
"datatable-base-deprecated",
7975
"datatable-deprecated": {
7977
"datatable-base-deprecated",
7978
"datatable-datasource-deprecated",
7979
"datatable-sort-deprecated",
7980
"datatable-scroll-deprecated"
7990
"datatable-message": {
7999
"datatable-mutable": {
8004
"datatable-scroll": {
8007
"datatable-column-widths",
8012
"datatable-scroll-deprecated": {
8014
"datatable-base-deprecated",
8027
"datatable-sort-deprecated": {
8032
"datatable-base-deprecated",
8046
"datatype-date-format"
8049
"datatype-date-parse",
8050
"datatype-date-format"
8053
"datatype-date-format": {
8137
"datatype-date-math": {
8142
"datatype-date-parse": {},
8143
"datatype-number": {
8145
"datatype-number-parse",
8146
"datatype-number-format"
8149
"datatype-number-format": {},
8150
"datatype-number-parse": {},
8153
"datatype-xml-parse",
8154
"datatype-xml-format"
8157
"datatype-xml-format": {},
8158
"datatype-xml-parse": {},
8221
"name": "dd-gestures",
8222
"test": function(Y) {
8223
return ((Y.config.win && ("ontouchstart" in Y.config.win)) && !(Y.UA.chrome && Y.UA.chrome < 6));
8225
"trigger": "dd-drag"
8307
"name": "dom-style-ie",
8308
"test": function (Y) {
8310
var testFeature = Y.Features.test,
8311
addFeature = Y.Features.add,
8312
WINDOW = Y.config.win,
8313
DOCUMENT = Y.config.doc,
8314
DOCUMENT_ELEMENT = 'documentElement',
8317
addFeature('style', 'computedStyle', {
8319
return WINDOW && 'getComputedStyle' in WINDOW;
8323
addFeature('style', 'opacity', {
8325
return DOCUMENT && 'opacity' in DOCUMENT[DOCUMENT_ELEMENT].style;
8329
ret = (!testFeature('style', 'opacity') &&
8330
!testFeature('style', 'computedStyle'));
8334
"trigger": "dom-style"
8387
"editor-para-base": {
8394
"name": "editor-para-ie",
8395
"trigger": "editor-para",
8403
"editor-selection": {
8452
"name": "event-base-ie",
8453
"test": function(Y) {
8454
var imp = Y.config.doc && Y.config.doc.implementation;
8455
return (imp && (!imp.hasFeature('Events', '2.0')));
8457
"trigger": "node-base"
8463
"event-contextmenu": {
8471
"event-custom-base",
8472
"event-custom-complex"
8475
"event-custom-base": {
8480
"event-custom-complex": {
8518
"event-mouseenter": {
8523
"event-mousewheel": {
8551
"event-synthetic": {
8554
"event-custom-complex"
8562
"event-valuechange": {
8616
"graphics-canvas": {
8618
"name": "graphics-canvas",
8619
"test": function(Y) {
8620
var DOCUMENT = Y.config.doc,
8621
useCanvas = Y.config.defaultGraphicEngine && Y.config.defaultGraphicEngine == "canvas",
8622
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
8623
svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
8624
return (!svg || useCanvas) && (canvas && canvas.getContext && canvas.getContext("2d"));
8626
"trigger": "graphics"
8632
"graphics-canvas-default": {
8634
"name": "graphics-canvas-default",
8635
"test": function(Y) {
8636
var DOCUMENT = Y.config.doc,
8637
useCanvas = Y.config.defaultGraphicEngine && Y.config.defaultGraphicEngine == "canvas",
8638
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
8639
svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
8640
return (!svg || useCanvas) && (canvas && canvas.getContext && canvas.getContext("2d"));
8642
"trigger": "graphics"
8647
"name": "graphics-svg",
8648
"test": function(Y) {
8649
var DOCUMENT = Y.config.doc,
8650
useSVG = !Y.config.defaultGraphicEngine || Y.config.defaultGraphicEngine != "canvas",
8651
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
8652
svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
8654
return svg && (useSVG || !canvas);
8656
"trigger": "graphics"
8662
"graphics-svg-default": {
8664
"name": "graphics-svg-default",
8665
"test": function(Y) {
8666
var DOCUMENT = Y.config.doc,
8667
useSVG = !Y.config.defaultGraphicEngine || Y.config.defaultGraphicEngine != "canvas",
8668
canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
8669
svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"));
8671
return svg && (useSVG || !canvas);
8673
"trigger": "graphics"
8678
"name": "graphics-vml",
8679
"test": function(Y) {
8680
var DOCUMENT = Y.config.doc,
8681
canvas = DOCUMENT && DOCUMENT.createElement("canvas");
8682
return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d")));
8684
"trigger": "graphics"
8690
"graphics-vml-default": {
8692
"name": "graphics-vml-default",
8693
"test": function(Y) {
8694
var DOCUMENT = Y.config.doc,
8695
canvas = DOCUMENT && DOCUMENT.createElement("canvas");
8696
return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d")));
8698
"trigger": "graphics"
8703
"handlebars-compiler"
8706
"handlebars-base": {
8711
"handlebars-compiler": {
8719
"highlight-accentfold"
8722
"highlight-accentfold": {
8746
"event-custom-complex"
8759
"history-hash-ie": {
8761
"name": "history-hash-ie",
8762
"test": function (Y) {
8763
var docMode = Y.config.doc && Y.config.doc.documentMode;
8765
return Y.UA.ie && (!('onhashchange' in Y.config.win) ||
8766
!docMode || docMode < 8);
8768
"trigger": "history-hash"
8814
"event-custom-base",
8815
"querystring-stringify-simple"
8826
"name": "io-nodejs",
8827
"trigger": "io-base",
8840
"io-upload-iframe": {
8849
"datatype-xml-parse"
8928
"node-event-delegate",
8947
"node-deprecated": {
8952
"node-event-delegate": {
8958
"node-event-html5": {
8963
"node-event-simulate": {
8978
"node-focusmanager": {
8983
"node-event-simulate",
9003
"node-pluginhost": {
9031
"widget-position-align",
9033
"widget-position-constrain"
9044
"widget-position-align",
9045
"widget-position-constrain",
9065
"node-event-delegate",
9087
"pluginhost-base": {
9092
"pluginhost-config": {
9104
"querystring-parse",
9105
"querystring-stringify"
9108
"querystring-parse": {
9114
"querystring-parse-simple": {
9119
"querystring-stringify": {
9124
"querystring-stringify-simple": {
9137
"slider-value-range",
9155
"recordset-filter": {
9162
"recordset-indexer": {
9195
"resize-constrain": {
9235
"scrollview-scrollbars"
9238
"scrollview-base": {
9247
"scrollview-base-ie": {
9249
"name": "scrollview-base-ie",
9250
"trigger": "scrollview-base",
9257
"scrollview-list": {
9264
"scrollview-paginator": {
9269
"scrollview-scrollbars": {
9284
"name": "selector-css2",
9285
"test": function (Y) {
9286
var DOCUMENT = Y.config.doc,
9287
ret = DOCUMENT && !('querySelectorAll' in DOCUMENT);
9291
"trigger": "selector"
9303
"selector-native": {
9317
"slider-value-range",
9331
"slider-value-range": {
9343
"sortable-scroll": {
9388
"node-event-delegate",
9420
"text-accentfold": {
9423
"text-data-accentfold"
9426
"text-data-accentfold": {
9431
"text-data-wordbreak": {
9439
"text-data-wordbreak"
9447
"transition-timer": {
9449
"name": "transition-timer",
9450
"test": function (Y) {
9451
var DOCUMENT = Y.config.doc,
9452
node = (DOCUMENT) ? DOCUMENT.documentElement: null,
9455
if (node && node.style) {
9456
ret = !('MozTransition' in node.style || 'WebkitTransition' in node.style);
9461
"trigger": "transition"
9473
"uploader-deprecated": {
9497
"node-event-simulate",
9511
"node-event-delegate"
9522
"widget-htmlparser",
9534
"widget-autohide": {
9556
"name": "widget-base-ie",
9557
"trigger": "widget-base",
9577
"widget-htmlparser": {
9587
"widget-modality": {
9602
"widget-position": {
9609
"widget-position-align": {
9614
"widget-position-constrain": {
9637
"widget-uievents": {
9639
"node-event-delegate",
9668
YUI.Env[Y.version].md5 = 'f5a3bc9bda2441a3b15fb52c567fc1f7';
9671
}, '3.5.1' ,{requires:['loader-base']});
9674
YUI.add('yui', function(Y){}, '3.5.1' ,{use:['yui-base','get','features','intl-base','yui-log','yui-log-nodejs','yui-later','loader-base', 'loader-rollup', 'loader-yui3']});