|
1 /** |
|
2 The YUI module contains the components required for building the YUI seed file. |
|
3 This includes the script loading mechanism, a simple queue, and the core |
|
4 utilities for the library. |
|
5 |
|
6 @module yui |
|
7 @main yui |
|
8 @submodule yui-base |
|
9 **/ |
|
10 |
|
11 /*jshint eqeqeq: false*/ |
|
12 if (typeof YUI != 'undefined') { |
|
13 YUI._YUI = YUI; |
|
14 } |
|
15 |
|
16 /** |
|
17 The YUI global namespace object. This is the constructor for all YUI instances. |
|
18 |
|
19 This is a self-instantiable factory function, meaning you don't need to precede |
|
20 it with the `new` operator. You can invoke it directly like this: |
|
21 |
|
22 YUI().use('*', function (Y) { |
|
23 // Y is a new YUI instance. |
|
24 }); |
|
25 |
|
26 But it also works like this: |
|
27 |
|
28 var Y = YUI(); |
|
29 |
|
30 The `YUI` constructor accepts an optional config object, like this: |
|
31 |
|
32 YUI({ |
|
33 debug: true, |
|
34 combine: false |
|
35 }).use('node', function (Y) { |
|
36 // Y.Node is ready to use. |
|
37 }); |
|
38 |
|
39 See the API docs for the <a href="config.html">Config</a> class for the complete |
|
40 list of supported configuration properties accepted by the YUI constuctor. |
|
41 |
|
42 If a global `YUI` object is already defined, the existing YUI object will not be |
|
43 overwritten, to ensure that defined namespaces are preserved. |
|
44 |
|
45 Each YUI instance has full custom event support, but only if the event system is |
|
46 available. |
|
47 |
|
48 @class YUI |
|
49 @uses EventTarget |
|
50 @constructor |
|
51 @global |
|
52 @param {Object} [config]* Zero or more optional configuration objects. Config |
|
53 values are stored in the `Y.config` property. See the |
|
54 <a href="config.html">Config</a> docs for the list of supported properties. |
|
55 **/ |
|
56 |
|
57 /*global YUI*/ |
|
58 /*global YUI_config*/ |
|
59 var YUI = function() { |
|
60 var i = 0, |
|
61 Y = this, |
|
62 args = arguments, |
|
63 l = args.length, |
|
64 instanceOf = function(o, type) { |
|
65 return (o && o.hasOwnProperty && (o instanceof type)); |
|
66 }, |
|
67 gconf = (typeof YUI_config !== 'undefined') && YUI_config; |
|
68 |
|
69 if (!(instanceOf(Y, YUI))) { |
|
70 Y = new YUI(); |
|
71 } else { |
|
72 // set up the core environment |
|
73 Y._init(); |
|
74 |
|
75 /** |
|
76 Master configuration that might span multiple contexts in a non- |
|
77 browser environment. It is applied first to all instances in all |
|
78 contexts. |
|
79 |
|
80 @example |
|
81 |
|
82 YUI.GlobalConfig = { |
|
83 filter: 'debug' |
|
84 }; |
|
85 |
|
86 YUI().use('node', function (Y) { |
|
87 // debug files used here |
|
88 }); |
|
89 |
|
90 YUI({ |
|
91 filter: 'min' |
|
92 }).use('node', function (Y) { |
|
93 // min files used here |
|
94 }); |
|
95 |
|
96 @property {Object} GlobalConfig |
|
97 @global |
|
98 @static |
|
99 **/ |
|
100 if (YUI.GlobalConfig) { |
|
101 Y.applyConfig(YUI.GlobalConfig); |
|
102 } |
|
103 |
|
104 /** |
|
105 Page-level config applied to all YUI instances created on the |
|
106 current page. This is applied after `YUI.GlobalConfig` and before |
|
107 any instance-level configuration. |
|
108 |
|
109 @example |
|
110 |
|
111 // Single global var to include before YUI seed file |
|
112 YUI_config = { |
|
113 filter: 'debug' |
|
114 }; |
|
115 |
|
116 YUI().use('node', function (Y) { |
|
117 // debug files used here |
|
118 }); |
|
119 |
|
120 YUI({ |
|
121 filter: 'min' |
|
122 }).use('node', function (Y) { |
|
123 // min files used here |
|
124 }); |
|
125 |
|
126 @property {Object} YUI_config |
|
127 @global |
|
128 **/ |
|
129 if (gconf) { |
|
130 Y.applyConfig(gconf); |
|
131 } |
|
132 |
|
133 // bind the specified additional modules for this instance |
|
134 if (!l) { |
|
135 Y._setup(); |
|
136 } |
|
137 } |
|
138 |
|
139 if (l) { |
|
140 // Each instance can accept one or more configuration objects. |
|
141 // These are applied after YUI.GlobalConfig and YUI_Config, |
|
142 // overriding values set in those config files if there is a |
|
143 // matching property. |
|
144 for (; i < l; i++) { |
|
145 Y.applyConfig(args[i]); |
|
146 } |
|
147 |
|
148 Y._setup(); |
|
149 } |
|
150 |
|
151 Y.instanceOf = instanceOf; |
|
152 |
|
153 return Y; |
|
154 }; |
|
155 |
|
156 (function() { |
|
157 |
|
158 var proto, prop, |
|
159 VERSION = '@VERSION@', |
|
160 PERIOD = '.', |
|
161 BASE = 'http://yui.yahooapis.com/', |
|
162 /* |
|
163 These CSS class names can't be generated by |
|
164 getClassName since it is not available at the |
|
165 time they are being used. |
|
166 */ |
|
167 DOC_LABEL = 'yui3-js-enabled', |
|
168 CSS_STAMP_EL = 'yui3-css-stamp', |
|
169 NOOP = function() {}, |
|
170 SLICE = Array.prototype.slice, |
|
171 APPLY_TO_AUTH = { 'io.xdrReady': 1, // the functions applyTo |
|
172 'io.xdrResponse': 1, // can call. this should |
|
173 'SWF.eventHandler': 1 }, // be done at build time |
|
174 hasWin = (typeof window != 'undefined'), |
|
175 win = (hasWin) ? window : null, |
|
176 doc = (hasWin) ? win.document : null, |
|
177 docEl = doc && doc.documentElement, |
|
178 docClass = docEl && docEl.className, |
|
179 instances = {}, |
|
180 time = new Date().getTime(), |
|
181 add = function(el, type, fn, capture) { |
|
182 if (el && el.addEventListener) { |
|
183 el.addEventListener(type, fn, capture); |
|
184 } else if (el && el.attachEvent) { |
|
185 el.attachEvent('on' + type, fn); |
|
186 } |
|
187 }, |
|
188 remove = function(el, type, fn, capture) { |
|
189 if (el && el.removeEventListener) { |
|
190 // this can throw an uncaught exception in FF |
|
191 try { |
|
192 el.removeEventListener(type, fn, capture); |
|
193 } catch (ex) {} |
|
194 } else if (el && el.detachEvent) { |
|
195 el.detachEvent('on' + type, fn); |
|
196 } |
|
197 }, |
|
198 handleReady = function() { |
|
199 YUI.Env.DOMReady = true; |
|
200 if (hasWin) { |
|
201 remove(doc, 'DOMContentLoaded', handleReady); |
|
202 } |
|
203 }, |
|
204 handleLoad = function() { |
|
205 YUI.Env.windowLoaded = true; |
|
206 YUI.Env.DOMReady = true; |
|
207 if (hasWin) { |
|
208 remove(window, 'load', handleLoad); |
|
209 } |
|
210 }, |
|
211 getLoader = function(Y, o) { |
|
212 var loader = Y.Env._loader, |
|
213 lCore = [ 'loader-base' ], |
|
214 G_ENV = YUI.Env, |
|
215 mods = G_ENV.mods; |
|
216 |
|
217 if (loader) { |
|
218 //loader._config(Y.config); |
|
219 loader.ignoreRegistered = false; |
|
220 loader.onEnd = null; |
|
221 loader.data = null; |
|
222 loader.required = []; |
|
223 loader.loadType = null; |
|
224 } else { |
|
225 loader = new Y.Loader(Y.config); |
|
226 Y.Env._loader = loader; |
|
227 } |
|
228 if (mods && mods.loader) { |
|
229 lCore = [].concat(lCore, YUI.Env.loaderExtras); |
|
230 } |
|
231 YUI.Env.core = Y.Array.dedupe([].concat(YUI.Env.core, lCore)); |
|
232 |
|
233 return loader; |
|
234 }, |
|
235 |
|
236 clobber = function(r, s) { |
|
237 for (var i in s) { |
|
238 if (s.hasOwnProperty(i)) { |
|
239 r[i] = s[i]; |
|
240 } |
|
241 } |
|
242 }, |
|
243 |
|
244 ALREADY_DONE = { success: true }; |
|
245 |
|
246 // Stamp the documentElement (HTML) with a class of "yui-loaded" to |
|
247 // enable styles that need to key off of JS being enabled. |
|
248 if (docEl && docClass.indexOf(DOC_LABEL) == -1) { |
|
249 if (docClass) { |
|
250 docClass += ' '; |
|
251 } |
|
252 docClass += DOC_LABEL; |
|
253 docEl.className = docClass; |
|
254 } |
|
255 |
|
256 if (VERSION.indexOf('@') > -1) { |
|
257 VERSION = '3.5.0'; // dev time hack for cdn test |
|
258 } |
|
259 |
|
260 proto = { |
|
261 /** |
|
262 Applies a new configuration object to the config of this YUI instance. This |
|
263 will merge new group/module definitions, and will also update the loader |
|
264 cache if necessary. Updating `Y.config` directly will not update the cache. |
|
265 |
|
266 @method applyConfig |
|
267 @param {Object} o the configuration object. |
|
268 @since 3.2.0 |
|
269 **/ |
|
270 applyConfig: function(o) { |
|
271 |
|
272 o = o || NOOP; |
|
273 |
|
274 var attr, |
|
275 name, |
|
276 // detail, |
|
277 config = this.config, |
|
278 mods = config.modules, |
|
279 groups = config.groups, |
|
280 aliases = config.aliases, |
|
281 loader = this.Env._loader; |
|
282 |
|
283 for (name in o) { |
|
284 if (o.hasOwnProperty(name)) { |
|
285 attr = o[name]; |
|
286 if (mods && name == 'modules') { |
|
287 clobber(mods, attr); |
|
288 } else if (aliases && name == 'aliases') { |
|
289 clobber(aliases, attr); |
|
290 } else if (groups && name == 'groups') { |
|
291 clobber(groups, attr); |
|
292 } else if (name == 'win') { |
|
293 config[name] = (attr && attr.contentWindow) || attr; |
|
294 config.doc = config[name] ? config[name].document : null; |
|
295 } else if (name == '_yuid') { |
|
296 // preserve the guid |
|
297 } else { |
|
298 config[name] = attr; |
|
299 } |
|
300 } |
|
301 } |
|
302 |
|
303 if (loader) { |
|
304 loader._config(o); |
|
305 } |
|
306 |
|
307 }, |
|
308 |
|
309 /** |
|
310 Old way to apply a config to this instance (calls `applyConfig` under the |
|
311 hood). |
|
312 |
|
313 @private |
|
314 @method _config |
|
315 @param {Object} o The config to apply |
|
316 **/ |
|
317 _config: function(o) { |
|
318 this.applyConfig(o); |
|
319 }, |
|
320 |
|
321 /** |
|
322 Initializes this YUI instance. |
|
323 |
|
324 @private |
|
325 @method _init |
|
326 **/ |
|
327 _init: function() { |
|
328 var filter, el, |
|
329 Y = this, |
|
330 G_ENV = YUI.Env, |
|
331 Env = Y.Env, |
|
332 prop; |
|
333 |
|
334 /** |
|
335 The version number of this YUI instance. |
|
336 |
|
337 This value is typically updated by a script when a YUI release is built, |
|
338 so it may not reflect the correct version number when YUI is run from |
|
339 the development source tree. |
|
340 |
|
341 @property {String} version |
|
342 **/ |
|
343 Y.version = VERSION; |
|
344 |
|
345 if (!Env) { |
|
346 Y.Env = { |
|
347 core: ['get', 'features', 'intl-base', 'yui-log', 'yui-log-nodejs', 'yui-later', 'loader-base', 'loader-rollup', 'loader-yui3'], |
|
348 loaderExtras: ['loader-rollup', 'loader-yui3'], |
|
349 mods: {}, // flat module map |
|
350 versions: {}, // version module map |
|
351 base: BASE, |
|
352 cdn: BASE + VERSION + '/build/', |
|
353 // bootstrapped: false, |
|
354 _idx: 0, |
|
355 _used: {}, |
|
356 _attached: {}, |
|
357 _exported: {}, |
|
358 _missed: [], |
|
359 _yidx: 0, |
|
360 _uidx: 0, |
|
361 _guidp: 'y', |
|
362 _loaded: {}, |
|
363 // serviced: {}, |
|
364 // Regex in English: |
|
365 // I'll start at the \b(yui). |
|
366 // 1. Look in the test string for "yui" or |
|
367 // "yui-base" or "yui-davglass" or "yui-foobar" that comes after a word break. That is, it |
|
368 // can't match "foyui" or "i_heart_yui". This can be anywhere in the string. |
|
369 // 2. After #1 must come a forward slash followed by the string matched in #1, so |
|
370 // "yui-base/yui-base" or "yui-pants/yui-pants". |
|
371 // 3. The second occurence of the #1 token can optionally be followed by "-debug" or "-min", |
|
372 // so "yui/yui-min", "yui/yui-debug", "yui-base/yui-base-debug". NOT "yui/yui-tshirt". |
|
373 // 4. This is followed by ".js", so "yui/yui.js". |
|
374 // 0. Going back to the beginning, now. If all that stuff in 1-4 comes after a "?" in the string, |
|
375 // then capture the junk between the LAST "&" and the string in 1-4. So |
|
376 // "blah?foo/yui/yui.js" will capture "foo/" and "blah?some/thing.js&3.3.0/build/yui-davglass/yui-davglass.js" |
|
377 // will capture "3.3.0/build/" |
|
378 // |
|
379 // Regex Exploded: |
|
380 // (?:\? Find a ? |
|
381 // (?:[^&]*&) followed by 0..n characters followed by an & |
|
382 // * in fact, find as many sets of characters followed by a & as you can |
|
383 // ([^&]*) capture the stuff after the last & in \1 |
|
384 // )? but it's ok if all this ?junk&more_junk stuff isn't even there |
|
385 // \b( after a word break find either the string |
|
386 // yui(?:-\w+)? "yui" optionally followed by a -, then more characters |
|
387 // ) and store the yui-* string in \2 |
|
388 // \/\2 then comes a / followed by the yui-* string in \2 |
|
389 // (?:-(min|debug))? optionally followed by "-min" or "-debug" |
|
390 // .js and ending in ".js" |
|
391 _BASE_RE: /(?:\?(?:[^&]*&)*([^&]*))?\b(yui(?:-\w+)?)\/\2(?:-(min|debug))?\.js/, |
|
392 parseBasePath: function(src, pattern) { |
|
393 var match = src.match(pattern), |
|
394 path, filter; |
|
395 |
|
396 if (match) { |
|
397 path = RegExp.leftContext || src.slice(0, src.indexOf(match[0])); |
|
398 |
|
399 // this is to set up the path to the loader. The file |
|
400 // filter for loader should match the yui include. |
|
401 filter = match[3]; |
|
402 |
|
403 // extract correct path for mixed combo urls |
|
404 // http://yuilibrary.com/projects/yui3/ticket/2528423 |
|
405 if (match[1]) { |
|
406 path += '?' + match[1]; |
|
407 } |
|
408 path = { |
|
409 filter: filter, |
|
410 path: path |
|
411 }; |
|
412 } |
|
413 return path; |
|
414 }, |
|
415 getBase: G_ENV && G_ENV.getBase || |
|
416 function(pattern) { |
|
417 var nodes = (doc && doc.getElementsByTagName('script')) || [], |
|
418 path = Env.cdn, parsed, |
|
419 i, len, src; |
|
420 |
|
421 for (i = 0, len = nodes.length; i < len; ++i) { |
|
422 src = nodes[i].src; |
|
423 if (src) { |
|
424 parsed = Y.Env.parseBasePath(src, pattern); |
|
425 if (parsed) { |
|
426 filter = parsed.filter; |
|
427 path = parsed.path; |
|
428 break; |
|
429 } |
|
430 } |
|
431 } |
|
432 |
|
433 // use CDN default |
|
434 return path; |
|
435 } |
|
436 |
|
437 }; |
|
438 |
|
439 Env = Y.Env; |
|
440 |
|
441 Env._loaded[VERSION] = {}; |
|
442 |
|
443 if (G_ENV && Y !== YUI) { |
|
444 Env._yidx = ++G_ENV._yidx; |
|
445 Env._guidp = ('yui_' + VERSION + '_' + |
|
446 Env._yidx + '_' + time).replace(/[^a-z0-9_]+/g, '_'); |
|
447 } else if (YUI._YUI) { |
|
448 |
|
449 G_ENV = YUI._YUI.Env; |
|
450 Env._yidx += G_ENV._yidx; |
|
451 Env._uidx += G_ENV._uidx; |
|
452 |
|
453 for (prop in G_ENV) { |
|
454 if (!(prop in Env)) { |
|
455 Env[prop] = G_ENV[prop]; |
|
456 } |
|
457 } |
|
458 |
|
459 delete YUI._YUI; |
|
460 } |
|
461 |
|
462 Y.id = Y.stamp(Y); |
|
463 instances[Y.id] = Y; |
|
464 |
|
465 } |
|
466 |
|
467 Y.constructor = YUI; |
|
468 |
|
469 // configuration defaults |
|
470 Y.config = Y.config || { |
|
471 bootstrap: true, |
|
472 cacheUse: true, |
|
473 debug: true, |
|
474 doc: doc, |
|
475 fetchCSS: true, |
|
476 throwFail: true, |
|
477 useBrowserConsole: true, |
|
478 useNativeES5: true, |
|
479 win: win, |
|
480 global: Function('return this')() |
|
481 }; |
|
482 |
|
483 //Register the CSS stamp element |
|
484 if (doc && !doc.getElementById(CSS_STAMP_EL)) { |
|
485 el = doc.createElement('div'); |
|
486 el.innerHTML = '<div id="' + CSS_STAMP_EL + '" style="position: absolute !important; visibility: hidden !important"></div>'; |
|
487 YUI.Env.cssStampEl = el.firstChild; |
|
488 if (doc.body) { |
|
489 doc.body.appendChild(YUI.Env.cssStampEl); |
|
490 } else { |
|
491 docEl.insertBefore(YUI.Env.cssStampEl, docEl.firstChild); |
|
492 } |
|
493 } else if (doc && doc.getElementById(CSS_STAMP_EL) && !YUI.Env.cssStampEl) { |
|
494 YUI.Env.cssStampEl = doc.getElementById(CSS_STAMP_EL); |
|
495 } |
|
496 |
|
497 Y.config.lang = Y.config.lang || 'en-US'; |
|
498 |
|
499 Y.config.base = YUI.config.base || Y.Env.getBase(Y.Env._BASE_RE); |
|
500 |
|
501 if (!filter || (!('mindebug').indexOf(filter))) { |
|
502 filter = 'min'; |
|
503 } |
|
504 filter = (filter) ? '-' + filter : filter; |
|
505 Y.config.loaderPath = YUI.config.loaderPath || 'loader/loader' + filter + '.js'; |
|
506 |
|
507 }, |
|
508 |
|
509 /** |
|
510 Finishes the instance setup. Attaches whatever YUI modules were defined |
|
511 at the time that this instance was created. |
|
512 |
|
513 @method _setup |
|
514 @private |
|
515 **/ |
|
516 _setup: function() { |
|
517 var i, Y = this, |
|
518 core = [], |
|
519 mods = YUI.Env.mods, |
|
520 extras = Y.config.core || [].concat(YUI.Env.core); //Clone it.. |
|
521 |
|
522 for (i = 0; i < extras.length; i++) { |
|
523 if (mods[extras[i]]) { |
|
524 core.push(extras[i]); |
|
525 } |
|
526 } |
|
527 |
|
528 Y._attach(['yui-base']); |
|
529 Y._attach(core); |
|
530 |
|
531 if (Y.Loader) { |
|
532 getLoader(Y); |
|
533 } |
|
534 |
|
535 // Y.log(Y.id + ' initialized', 'info', 'yui'); |
|
536 }, |
|
537 |
|
538 /** |
|
539 Executes the named method on the specified YUI instance if that method is |
|
540 whitelisted. |
|
541 |
|
542 @method applyTo |
|
543 @param {String} id YUI instance id. |
|
544 @param {String} method Name of the method to execute. For example: |
|
545 'Object.keys'. |
|
546 @param {Array} args Arguments to apply to the method. |
|
547 @return {Mixed} Return value from the applied method, or `null` if the |
|
548 specified instance was not found or the method was not whitelisted. |
|
549 **/ |
|
550 applyTo: function(id, method, args) { |
|
551 if (!(method in APPLY_TO_AUTH)) { |
|
552 this.log(method + ': applyTo not allowed', 'warn', 'yui'); |
|
553 return null; |
|
554 } |
|
555 |
|
556 var instance = instances[id], nest, m, i; |
|
557 if (instance) { |
|
558 nest = method.split('.'); |
|
559 m = instance; |
|
560 for (i = 0; i < nest.length; i = i + 1) { |
|
561 m = m[nest[i]]; |
|
562 if (!m) { |
|
563 this.log('applyTo not found: ' + method, 'warn', 'yui'); |
|
564 } |
|
565 } |
|
566 return m && m.apply(instance, args); |
|
567 } |
|
568 |
|
569 return null; |
|
570 }, |
|
571 |
|
572 /** |
|
573 Registers a YUI module and makes it available for use in a `YUI().use()` call or |
|
574 as a dependency for other modules. |
|
575 |
|
576 The easiest way to create a first-class YUI module is to use |
|
577 <a href="http://yui.github.com/shifter/">Shifter</a>, the YUI component build |
|
578 tool. |
|
579 |
|
580 Shifter will automatically wrap your module code in a `YUI.add()` call along |
|
581 with any configuration info required for the module. |
|
582 |
|
583 @example |
|
584 |
|
585 YUI.add('davglass', function (Y) { |
|
586 Y.davglass = function () { |
|
587 Y.log('Dav was here!'); |
|
588 }; |
|
589 }, '3.4.0', { |
|
590 requires: ['harley-davidson', 'mt-dew'] |
|
591 }); |
|
592 |
|
593 @method add |
|
594 @param {String} name Module name. |
|
595 @param {Function} fn Function containing module code. This function will be |
|
596 executed whenever the module is attached to a specific YUI instance. |
|
597 |
|
598 @param {YUI} fn.Y The YUI instance to which this module is attached. |
|
599 @param {String} fn.name Name of the module |
|
600 |
|
601 @param {String} version Module version number. This is currently used only for |
|
602 informational purposes, and is not used internally by YUI. |
|
603 |
|
604 @param {Object} [config] Module config. |
|
605 @param {Array} [config.requires] Array of other module names that must be |
|
606 attached before this module can be attached. |
|
607 @param {Array} [config.optional] Array of optional module names that should |
|
608 be attached before this module is attached if they've already been |
|
609 loaded. If the `loadOptional` YUI option is `true`, optional modules |
|
610 that have not yet been loaded will be loaded just as if they were hard |
|
611 requirements. |
|
612 @param {Array} [config.use] Array of module names that are included within |
|
613 or otherwise provided by this module, and which should be attached |
|
614 automatically when this module is attached. This makes it possible to |
|
615 create "virtual rollup" modules that simply attach a collection of other |
|
616 modules or submodules. |
|
617 |
|
618 @return {YUI} This YUI instance. |
|
619 **/ |
|
620 add: function(name, fn, version, details) { |
|
621 details = details || {}; |
|
622 var env = YUI.Env, |
|
623 mod = { |
|
624 name: name, |
|
625 fn: fn, |
|
626 version: version, |
|
627 details: details |
|
628 }, |
|
629 //Instance hash so we don't apply it to the same instance twice |
|
630 applied = {}, |
|
631 loader, inst, |
|
632 i, versions = env.versions; |
|
633 |
|
634 env.mods[name] = mod; |
|
635 versions[version] = versions[version] || {}; |
|
636 versions[version][name] = mod; |
|
637 |
|
638 for (i in instances) { |
|
639 if (instances.hasOwnProperty(i)) { |
|
640 inst = instances[i]; |
|
641 if (!applied[inst.id]) { |
|
642 applied[inst.id] = true; |
|
643 loader = inst.Env._loader; |
|
644 if (loader) { |
|
645 if (!loader.moduleInfo[name] || loader.moduleInfo[name].temp) { |
|
646 loader.addModule(details, name); |
|
647 } |
|
648 } |
|
649 } |
|
650 } |
|
651 } |
|
652 |
|
653 return this; |
|
654 }, |
|
655 |
|
656 /** |
|
657 Executes the callback function associated with each required module, |
|
658 attaching the module to this YUI instance. |
|
659 |
|
660 @method _attach |
|
661 @param {Array} r The array of modules to attach |
|
662 @param {Boolean} [moot=false] If `true`, don't throw a warning if the module |
|
663 is not attached. |
|
664 @private |
|
665 **/ |
|
666 _attach: function(r, moot) { |
|
667 var i, name, mod, details, req, use, after, |
|
668 mods = YUI.Env.mods, |
|
669 aliases = YUI.Env.aliases, |
|
670 Y = this, j, |
|
671 cache = YUI.Env._renderedMods, |
|
672 loader = Y.Env._loader, |
|
673 done = Y.Env._attached, |
|
674 exported = Y.Env._exported, |
|
675 len = r.length, loader, def, go, |
|
676 c = [], |
|
677 modArgs, esCompat, reqlen, |
|
678 condition, |
|
679 __exports__, __imports__; |
|
680 |
|
681 //Check for conditional modules (in a second+ instance) and add their requirements |
|
682 //TODO I hate this entire method, it needs to be fixed ASAP (3.5.0) ^davglass |
|
683 for (i = 0; i < len; i++) { |
|
684 name = r[i]; |
|
685 mod = mods[name]; |
|
686 c.push(name); |
|
687 if (loader && loader.conditions[name]) { |
|
688 for (j in loader.conditions[name]) { |
|
689 if (loader.conditions[name].hasOwnProperty(j)) { |
|
690 def = loader.conditions[name][j]; |
|
691 go = def && ((def.ua && Y.UA[def.ua]) || (def.test && def.test(Y))); |
|
692 if (go) { |
|
693 c.push(def.name); |
|
694 } |
|
695 } |
|
696 } |
|
697 } |
|
698 } |
|
699 r = c; |
|
700 len = r.length; |
|
701 |
|
702 for (i = 0; i < len; i++) { |
|
703 if (!done[r[i]]) { |
|
704 name = r[i]; |
|
705 mod = mods[name]; |
|
706 |
|
707 if (aliases && aliases[name] && !mod) { |
|
708 Y._attach(aliases[name]); |
|
709 continue; |
|
710 } |
|
711 if (!mod) { |
|
712 if (loader && loader.moduleInfo[name]) { |
|
713 mod = loader.moduleInfo[name]; |
|
714 moot = true; |
|
715 } |
|
716 |
|
717 // Y.log('no js def for: ' + name, 'info', 'yui'); |
|
718 |
|
719 //if (!loader || !loader.moduleInfo[name]) { |
|
720 //if ((!loader || !loader.moduleInfo[name]) && !moot) { |
|
721 if (!moot && name) { |
|
722 if ((name.indexOf('skin-') === -1) && (name.indexOf('css') === -1)) { |
|
723 Y.Env._missed.push(name); |
|
724 Y.Env._missed = Y.Array.dedupe(Y.Env._missed); |
|
725 Y.message('NOT loaded: ' + name, 'warn', 'yui'); |
|
726 } |
|
727 } |
|
728 } else { |
|
729 done[name] = true; |
|
730 //Don't like this, but in case a mod was asked for once, then we fetch it |
|
731 //We need to remove it from the missed list ^davglass |
|
732 for (j = 0; j < Y.Env._missed.length; j++) { |
|
733 if (Y.Env._missed[j] === name) { |
|
734 Y.message('Found: ' + name + ' (was reported as missing earlier)', 'warn', 'yui'); |
|
735 Y.Env._missed.splice(j, 1); |
|
736 } |
|
737 } |
|
738 /* |
|
739 If it's a temp module, we need to redo it's requirements if it's already loaded |
|
740 since it may have been loaded by another instance and it's dependencies might |
|
741 have been redefined inside the fetched file. |
|
742 */ |
|
743 if (loader && cache && cache[name] && cache[name].temp) { |
|
744 loader.getRequires(cache[name]); |
|
745 req = []; |
|
746 for (j in loader.moduleInfo[name].expanded_map) { |
|
747 if (loader.moduleInfo[name].expanded_map.hasOwnProperty(j)) { |
|
748 req.push(j); |
|
749 } |
|
750 } |
|
751 Y._attach(req); |
|
752 } |
|
753 |
|
754 details = mod.details; |
|
755 req = details.requires; |
|
756 esCompat = details.es; |
|
757 use = details.use; |
|
758 after = details.after; |
|
759 //Force Intl load if there is a language (Loader logic) @todo fix this shit |
|
760 if (details.lang) { |
|
761 req = req || []; |
|
762 req.unshift('intl'); |
|
763 } |
|
764 |
|
765 if (req) { |
|
766 reqlen = req.length; |
|
767 for (j = 0; j < reqlen; j++) { |
|
768 if (!done[req[j]]) { |
|
769 if (!Y._attach(req)) { |
|
770 return false; |
|
771 } |
|
772 break; |
|
773 } |
|
774 } |
|
775 } |
|
776 |
|
777 if (after) { |
|
778 for (j = 0; j < after.length; j++) { |
|
779 if (!done[after[j]]) { |
|
780 if (!Y._attach(after, true)) { |
|
781 return false; |
|
782 } |
|
783 break; |
|
784 } |
|
785 } |
|
786 } |
|
787 |
|
788 if (mod.fn) { |
|
789 modArgs = [Y, name]; |
|
790 if (esCompat) { |
|
791 __imports__ = {}; |
|
792 __exports__ = {}; |
|
793 // passing `exports` and `imports` onto the module function |
|
794 modArgs.push(__imports__, __exports__); |
|
795 if (req) { |
|
796 reqlen = req.length; |
|
797 for (j = 0; j < reqlen; j++) { |
|
798 __imports__[req[j]] = exported.hasOwnProperty(req[j]) ? exported[req[j]] : Y; |
|
799 } |
|
800 } |
|
801 } |
|
802 if (Y.config.throwFail) { |
|
803 __exports__ = mod.fn.apply(esCompat ? undefined : mod, modArgs); |
|
804 } else { |
|
805 try { |
|
806 __exports__ = mod.fn.apply(esCompat ? undefined : mod, modArgs); |
|
807 } catch (e) { |
|
808 Y.error('Attach error: ' + name, e, name); |
|
809 return false; |
|
810 } |
|
811 } |
|
812 if (esCompat) { |
|
813 // store the `exports` in case others `es` modules requires it |
|
814 exported[name] = __exports__; |
|
815 |
|
816 // If an ES module is conditionally loaded and set |
|
817 // to be used "instead" another module, replace the |
|
818 // trigger module's content with the conditionally |
|
819 // loaded one so the values returned by require() |
|
820 // still makes sense |
|
821 condition = mod.details.condition; |
|
822 if (condition && condition.when === 'instead') { |
|
823 exported[condition.trigger] = __exports__; |
|
824 } |
|
825 } |
|
826 } |
|
827 |
|
828 if (use) { |
|
829 for (j = 0; j < use.length; j++) { |
|
830 if (!done[use[j]]) { |
|
831 if (!Y._attach(use)) { |
|
832 return false; |
|
833 } |
|
834 break; |
|
835 } |
|
836 } |
|
837 } |
|
838 |
|
839 |
|
840 |
|
841 } |
|
842 } |
|
843 } |
|
844 |
|
845 return true; |
|
846 }, |
|
847 |
|
848 /** |
|
849 Delays the `use` callback until another event has taken place such as |
|
850 `window.onload`, `domready`, `contentready`, or `available`. |
|
851 |
|
852 @private |
|
853 @method _delayCallback |
|
854 @param {Function} cb The original `use` callback. |
|
855 @param {String|Object} until Either an event name ('load', 'domready', etc.) |
|
856 or an object containing event/args keys for contentready/available. |
|
857 @return {Function} |
|
858 **/ |
|
859 _delayCallback: function(cb, until) { |
|
860 |
|
861 var Y = this, |
|
862 mod = ['event-base']; |
|
863 |
|
864 until = (Y.Lang.isObject(until) ? until : { event: until }); |
|
865 |
|
866 if (until.event === 'load') { |
|
867 mod.push('event-synthetic'); |
|
868 } |
|
869 |
|
870 Y.log('Delaying use callback until: ' + until.event, 'info', 'yui'); |
|
871 return function() { |
|
872 Y.log('Use callback fired, waiting on delay', 'info', 'yui'); |
|
873 var args = arguments; |
|
874 Y._use(mod, function() { |
|
875 Y.log('Delayed use wrapper callback after dependencies', 'info', 'yui'); |
|
876 Y.on(until.event, function() { |
|
877 args[1].delayUntil = until.event; |
|
878 Y.log('Delayed use callback done after ' + until.event, 'info', 'yui'); |
|
879 cb.apply(Y, args); |
|
880 }, until.args); |
|
881 }); |
|
882 }; |
|
883 }, |
|
884 |
|
885 /** |
|
886 Attaches one or more modules to this YUI instance. When this is executed, |
|
887 the requirements of the desired modules are analyzed, and one of several |
|
888 things can happen: |
|
889 |
|
890 |
|
891 * All required modules have already been loaded, and just need to be |
|
892 attached to this YUI instance. In this case, the `use()` callback will |
|
893 be executed synchronously after the modules are attached. |
|
894 |
|
895 * One or more modules have not yet been loaded, or the Get utility is not |
|
896 available, or the `bootstrap` config option is `false`. In this case, |
|
897 a warning is issued indicating that modules are missing, but all |
|
898 available modules will still be attached and the `use()` callback will |
|
899 be executed synchronously. |
|
900 |
|
901 * One or more modules are missing and the Loader is not available but the |
|
902 Get utility is, and `bootstrap` is not `false`. In this case, the Get |
|
903 utility will be used to load the Loader, and we will then proceed to |
|
904 the following state: |
|
905 |
|
906 * One or more modules are missing and the Loader is available. In this |
|
907 case, the Loader will be used to resolve the dependency tree for the |
|
908 missing modules and load them and their dependencies. When the Loader is |
|
909 finished loading modules, the `use()` callback will be executed |
|
910 asynchronously. |
|
911 |
|
912 @example |
|
913 |
|
914 // Loads and attaches dd and its dependencies. |
|
915 YUI().use('dd', function (Y) { |
|
916 // ... |
|
917 }); |
|
918 |
|
919 // Loads and attaches dd and node as well as all of their dependencies. |
|
920 YUI().use(['dd', 'node'], function (Y) { |
|
921 // ... |
|
922 }); |
|
923 |
|
924 // Attaches all modules that have already been loaded. |
|
925 YUI().use('*', function (Y) { |
|
926 // ... |
|
927 }); |
|
928 |
|
929 // Attaches a gallery module. |
|
930 YUI().use('gallery-yql', function (Y) { |
|
931 // ... |
|
932 }); |
|
933 |
|
934 // Attaches a YUI 2in3 module. |
|
935 YUI().use('yui2-datatable', function (Y) { |
|
936 // ... |
|
937 }); |
|
938 |
|
939 @method use |
|
940 @param {String|Array} modules* One or more module names to attach. |
|
941 @param {Function} [callback] Callback function to be executed once all |
|
942 specified modules and their dependencies have been attached. |
|
943 @param {YUI} callback.Y The YUI instance created for this sandbox. |
|
944 @param {Object} callback.status Object containing `success`, `msg` and |
|
945 `data` properties. |
|
946 @chainable |
|
947 **/ |
|
948 use: function() { |
|
949 var args = SLICE.call(arguments, 0), |
|
950 callback = args[args.length - 1], |
|
951 Y = this, |
|
952 i = 0, |
|
953 name, |
|
954 Env = Y.Env, |
|
955 provisioned = true; |
|
956 |
|
957 // The last argument supplied to use can be a load complete callback |
|
958 if (Y.Lang.isFunction(callback)) { |
|
959 args.pop(); |
|
960 if (Y.config.delayUntil) { |
|
961 callback = Y._delayCallback(callback, Y.config.delayUntil); |
|
962 } |
|
963 } else { |
|
964 callback = null; |
|
965 } |
|
966 if (Y.Lang.isArray(args[0])) { |
|
967 args = args[0]; |
|
968 } |
|
969 |
|
970 if (Y.config.cacheUse) { |
|
971 while ((name = args[i++])) { |
|
972 if (!Env._attached[name]) { |
|
973 provisioned = false; |
|
974 break; |
|
975 } |
|
976 } |
|
977 |
|
978 if (provisioned) { |
|
979 if (args.length) { |
|
980 Y.log('already provisioned: ' + args, 'info', 'yui'); |
|
981 } |
|
982 Y._notify(callback, ALREADY_DONE, args); |
|
983 return Y; |
|
984 } |
|
985 } |
|
986 |
|
987 if (Y._loading) { |
|
988 Y._useQueue = Y._useQueue || new Y.Queue(); |
|
989 Y._useQueue.add([args, callback]); |
|
990 } else { |
|
991 Y._use(args, function(Y, response) { |
|
992 Y._notify(callback, response, args); |
|
993 }); |
|
994 } |
|
995 |
|
996 return Y; |
|
997 }, |
|
998 |
|
999 /** |
|
1000 Sugar for loading both legacy and ES6-based YUI modules. |
|
1001 |
|
1002 @method require |
|
1003 @param {String} [modules*] List of module names to import or a single |
|
1004 module name. |
|
1005 @param {Function} callback Callback that gets called once all the modules |
|
1006 were loaded. Each parameter of the callback is the export value of the |
|
1007 corresponding module in the list. If the module is a legacy YUI module, |
|
1008 the YUI instance is used instead of the module exports. |
|
1009 @example |
|
1010 ``` |
|
1011 YUI().require(['es6-set'], function (Y, imports) { |
|
1012 var Set = imports.Set, |
|
1013 set = new Set(); |
|
1014 }); |
|
1015 ``` |
|
1016 **/ |
|
1017 require: function () { |
|
1018 var args = SLICE.call(arguments), |
|
1019 callback; |
|
1020 |
|
1021 if (typeof args[args.length - 1] === 'function') { |
|
1022 callback = args.pop(); |
|
1023 |
|
1024 // only add the callback if one was provided |
|
1025 // YUI().require('foo'); is valid |
|
1026 args.push(function (Y) { |
|
1027 var i, length = args.length, |
|
1028 exported = Y.Env._exported, |
|
1029 __imports__ = {}; |
|
1030 |
|
1031 // Get only the imports requested as arguments |
|
1032 for (i = 0; i < length; i++) { |
|
1033 if (exported.hasOwnProperty(args[i])) { |
|
1034 __imports__[args[i]] = exported[args[i]]; |
|
1035 } |
|
1036 } |
|
1037 |
|
1038 // Using `undefined` because: |
|
1039 // - Using `Y.config.global` would force the value of `this` to be |
|
1040 // the global object even in strict mode |
|
1041 // - Using `Y` goes against the goal of moving away from a shared |
|
1042 // object and start thinking in terms of imported and exported |
|
1043 // objects |
|
1044 callback.call(undefined, Y, __imports__); |
|
1045 }); |
|
1046 } |
|
1047 // Do not return the Y object. This makes it hard to follow this |
|
1048 // traditional pattern: |
|
1049 // var Y = YUI().use(...); |
|
1050 // This is a good idea in the light of ES6 modules, to avoid working |
|
1051 // in the global scope. |
|
1052 // This also leaves the door open for returning a promise, once the |
|
1053 // YUI loader is based on the ES6 loader which uses |
|
1054 // loader.import(...).then(...) |
|
1055 this.use.apply(this, args); |
|
1056 }, |
|
1057 |
|
1058 /** |
|
1059 Handles Loader notifications about attachment/load errors. |
|
1060 |
|
1061 @method _notify |
|
1062 @param {Function} callback Callback to pass to `Y.config.loadErrorFn`. |
|
1063 @param {Object} response Response returned from Loader. |
|
1064 @param {Array} args Arguments passed from Loader. |
|
1065 @private |
|
1066 **/ |
|
1067 _notify: function(callback, response, args) { |
|
1068 if (!response.success && this.config.loadErrorFn) { |
|
1069 this.config.loadErrorFn.call(this, this, callback, response, args); |
|
1070 } else if (callback) { |
|
1071 if (this.Env._missed && this.Env._missed.length) { |
|
1072 response.msg = 'Missing modules: ' + this.Env._missed.join(); |
|
1073 response.success = false; |
|
1074 } |
|
1075 if (this.config.throwFail) { |
|
1076 callback(this, response); |
|
1077 } else { |
|
1078 try { |
|
1079 callback(this, response); |
|
1080 } catch (e) { |
|
1081 this.error('use callback error', e, args); |
|
1082 } |
|
1083 } |
|
1084 } |
|
1085 }, |
|
1086 |
|
1087 /** |
|
1088 Called from the `use` method queue to ensure that only one set of loading |
|
1089 logic is performed at a time. |
|
1090 |
|
1091 @method _use |
|
1092 @param {String} args* One or more modules to attach. |
|
1093 @param {Function} [callback] Function to call once all required modules have |
|
1094 been attached. |
|
1095 @private |
|
1096 **/ |
|
1097 _use: function(args, callback) { |
|
1098 |
|
1099 if (!this.Array) { |
|
1100 this._attach(['yui-base']); |
|
1101 } |
|
1102 |
|
1103 var len, loader, handleBoot, |
|
1104 Y = this, |
|
1105 G_ENV = YUI.Env, |
|
1106 mods = G_ENV.mods, |
|
1107 Env = Y.Env, |
|
1108 used = Env._used, |
|
1109 aliases = G_ENV.aliases, |
|
1110 queue = G_ENV._loaderQueue, |
|
1111 firstArg = args[0], |
|
1112 YArray = Y.Array, |
|
1113 config = Y.config, |
|
1114 boot = config.bootstrap, |
|
1115 missing = [], |
|
1116 i, |
|
1117 r = [], |
|
1118 ret = true, |
|
1119 fetchCSS = config.fetchCSS, |
|
1120 process = function(names, skip) { |
|
1121 |
|
1122 var i = 0, a = [], name, len, m, req, use; |
|
1123 |
|
1124 if (!names.length) { |
|
1125 return; |
|
1126 } |
|
1127 |
|
1128 if (aliases) { |
|
1129 len = names.length; |
|
1130 for (i = 0; i < len; i++) { |
|
1131 if (aliases[names[i]] && !mods[names[i]]) { |
|
1132 a = [].concat(a, aliases[names[i]]); |
|
1133 } else { |
|
1134 a.push(names[i]); |
|
1135 } |
|
1136 } |
|
1137 names = a; |
|
1138 } |
|
1139 |
|
1140 len = names.length; |
|
1141 |
|
1142 for (i = 0; i < len; i++) { |
|
1143 name = names[i]; |
|
1144 if (!skip) { |
|
1145 r.push(name); |
|
1146 } |
|
1147 |
|
1148 // only attach a module once |
|
1149 if (used[name]) { |
|
1150 continue; |
|
1151 } |
|
1152 |
|
1153 m = mods[name]; |
|
1154 req = null; |
|
1155 use = null; |
|
1156 |
|
1157 if (m) { |
|
1158 used[name] = true; |
|
1159 req = m.details.requires; |
|
1160 use = m.details.use; |
|
1161 } else { |
|
1162 // CSS files don't register themselves, see if it has |
|
1163 // been loaded |
|
1164 if (!G_ENV._loaded[VERSION][name]) { |
|
1165 missing.push(name); |
|
1166 } else { |
|
1167 used[name] = true; // probably css |
|
1168 } |
|
1169 } |
|
1170 |
|
1171 // make sure requirements are attached |
|
1172 if (req && req.length) { |
|
1173 process(req); |
|
1174 } |
|
1175 |
|
1176 // make sure we grab the submodule dependencies too |
|
1177 if (use && use.length) { |
|
1178 process(use, 1); |
|
1179 } |
|
1180 } |
|
1181 |
|
1182 }, |
|
1183 |
|
1184 handleLoader = function(fromLoader) { |
|
1185 var response = fromLoader || { |
|
1186 success: true, |
|
1187 msg: 'not dynamic' |
|
1188 }, |
|
1189 redo, origMissing, |
|
1190 ret = true, |
|
1191 data = response.data; |
|
1192 |
|
1193 Y._loading = false; |
|
1194 |
|
1195 if (data) { |
|
1196 origMissing = missing; |
|
1197 missing = []; |
|
1198 r = []; |
|
1199 process(data); |
|
1200 redo = missing.length; |
|
1201 if (redo) { |
|
1202 if ([].concat(missing).sort().join() == |
|
1203 origMissing.sort().join()) { |
|
1204 redo = false; |
|
1205 } |
|
1206 } |
|
1207 } |
|
1208 |
|
1209 if (redo && data) { |
|
1210 Y._loading = true; |
|
1211 Y._use(missing, function() { |
|
1212 Y.log('Nested use callback: ' + data, 'info', 'yui'); |
|
1213 if (Y._attach(data)) { |
|
1214 Y._notify(callback, response, data); |
|
1215 } |
|
1216 }); |
|
1217 } else { |
|
1218 if (data) { |
|
1219 // Y.log('attaching from loader: ' + data, 'info', 'yui'); |
|
1220 ret = Y._attach(data); |
|
1221 } |
|
1222 if (ret) { |
|
1223 Y._notify(callback, response, args); |
|
1224 } |
|
1225 } |
|
1226 |
|
1227 if (Y._useQueue && Y._useQueue.size() && !Y._loading) { |
|
1228 Y._use.apply(Y, Y._useQueue.next()); |
|
1229 } |
|
1230 |
|
1231 }; |
|
1232 |
|
1233 // Y.log(Y.id + ': use called: ' + a + ' :: ' + callback, 'info', 'yui'); |
|
1234 |
|
1235 // YUI().use('*'); // bind everything available |
|
1236 if (firstArg === '*') { |
|
1237 args = []; |
|
1238 for (i in mods) { |
|
1239 if (mods.hasOwnProperty(i)) { |
|
1240 args.push(i); |
|
1241 } |
|
1242 } |
|
1243 ret = Y._attach(args); |
|
1244 if (ret) { |
|
1245 handleLoader(); |
|
1246 } |
|
1247 return Y; |
|
1248 } |
|
1249 |
|
1250 if ((mods.loader || mods['loader-base']) && !Y.Loader) { |
|
1251 Y.log('Loader was found in meta, but it is not attached. Attaching..', 'info', 'yui'); |
|
1252 Y._attach(['loader' + ((!mods.loader) ? '-base' : '')]); |
|
1253 } |
|
1254 |
|
1255 // Y.log('before loader requirements: ' + args, 'info', 'yui'); |
|
1256 |
|
1257 // use loader to expand dependencies and sort the |
|
1258 // requirements if it is available. |
|
1259 if (boot && Y.Loader && args.length) { |
|
1260 Y.log('Using loader to expand dependencies', 'info', 'yui'); |
|
1261 loader = getLoader(Y); |
|
1262 loader.require(args); |
|
1263 loader.ignoreRegistered = true; |
|
1264 loader._boot = true; |
|
1265 loader.calculate(null, (fetchCSS) ? null : 'js'); |
|
1266 args = loader.sorted; |
|
1267 loader._boot = false; |
|
1268 } |
|
1269 |
|
1270 process(args); |
|
1271 |
|
1272 len = missing.length; |
|
1273 |
|
1274 |
|
1275 if (len) { |
|
1276 missing = YArray.dedupe(missing); |
|
1277 len = missing.length; |
|
1278 Y.log('Modules missing: ' + missing + ', ' + missing.length, 'info', 'yui'); |
|
1279 } |
|
1280 |
|
1281 |
|
1282 // dynamic load |
|
1283 if (boot && len && Y.Loader) { |
|
1284 // Y.log('Using loader to fetch missing deps: ' + missing, 'info', 'yui'); |
|
1285 Y.log('Using Loader', 'info', 'yui'); |
|
1286 Y._loading = true; |
|
1287 loader = getLoader(Y); |
|
1288 loader.onEnd = handleLoader; |
|
1289 loader.context = Y; |
|
1290 loader.data = args; |
|
1291 loader.ignoreRegistered = false; |
|
1292 loader.require(missing); |
|
1293 loader.insert(null, (fetchCSS) ? null : 'js'); |
|
1294 |
|
1295 } else if (boot && len && Y.Get && !Env.bootstrapped) { |
|
1296 |
|
1297 Y._loading = true; |
|
1298 |
|
1299 handleBoot = function() { |
|
1300 Y._loading = false; |
|
1301 queue.running = false; |
|
1302 Env.bootstrapped = true; |
|
1303 G_ENV._bootstrapping = false; |
|
1304 if (Y._attach(['loader'])) { |
|
1305 Y._use(args, callback); |
|
1306 } |
|
1307 }; |
|
1308 |
|
1309 if (G_ENV._bootstrapping) { |
|
1310 Y.log('Waiting for loader', 'info', 'yui'); |
|
1311 queue.add(handleBoot); |
|
1312 } else { |
|
1313 G_ENV._bootstrapping = true; |
|
1314 Y.log('Fetching loader: ' + config.base + config.loaderPath, 'info', 'yui'); |
|
1315 Y.Get.script(config.base + config.loaderPath, { |
|
1316 onEnd: handleBoot |
|
1317 }); |
|
1318 } |
|
1319 |
|
1320 } else { |
|
1321 Y.log('Attaching available dependencies: ' + args, 'info', 'yui'); |
|
1322 ret = Y._attach(args); |
|
1323 if (ret) { |
|
1324 handleLoader(); |
|
1325 } |
|
1326 } |
|
1327 |
|
1328 return Y; |
|
1329 }, |
|
1330 |
|
1331 |
|
1332 /** |
|
1333 Utility method for safely creating namespaces if they don't already exist. |
|
1334 May be called statically on the YUI global object or as a method on a YUI |
|
1335 instance. |
|
1336 |
|
1337 When called statically, a namespace will be created on the YUI global |
|
1338 object: |
|
1339 |
|
1340 // Create `YUI.your.namespace.here` as nested objects, preserving any |
|
1341 // objects that already exist instead of overwriting them. |
|
1342 YUI.namespace('your.namespace.here'); |
|
1343 |
|
1344 When called as a method on a YUI instance, a namespace will be created on |
|
1345 that instance: |
|
1346 |
|
1347 // Creates `Y.property.package`. |
|
1348 Y.namespace('property.package'); |
|
1349 |
|
1350 Dots in the input string cause `namespace` to create nested objects for each |
|
1351 token. If any part of the requested namespace already exists, the current |
|
1352 object will be left in place and will not be overwritten. This allows |
|
1353 multiple calls to `namespace` to preserve existing namespaced properties. |
|
1354 |
|
1355 If the first token in the namespace string is "YAHOO", that token is |
|
1356 discarded. This is legacy behavior for backwards compatibility with YUI 2. |
|
1357 |
|
1358 Be careful with namespace tokens. Reserved words may work in some browsers |
|
1359 and not others. For instance, the following will fail in some browsers |
|
1360 because the supported version of JavaScript reserves the word "long": |
|
1361 |
|
1362 Y.namespace('really.long.nested.namespace'); |
|
1363 |
|
1364 Note: If you pass multiple arguments to create multiple namespaces, only the |
|
1365 last one created is returned from this function. |
|
1366 |
|
1367 @method namespace |
|
1368 @param {String} namespace* One or more namespaces to create. |
|
1369 @return {Object} Reference to the last namespace object created. |
|
1370 **/ |
|
1371 namespace: function() { |
|
1372 var a = arguments, o, i = 0, j, d, arg; |
|
1373 |
|
1374 for (; i < a.length; i++) { |
|
1375 o = this; //Reset base object per argument or it will get reused from the last |
|
1376 arg = a[i]; |
|
1377 if (arg.indexOf(PERIOD) > -1) { //Skip this if no "." is present |
|
1378 d = arg.split(PERIOD); |
|
1379 for (j = (d[0] == 'YAHOO') ? 1 : 0; j < d.length; j++) { |
|
1380 o[d[j]] = o[d[j]] || {}; |
|
1381 o = o[d[j]]; |
|
1382 } |
|
1383 } else { |
|
1384 o[arg] = o[arg] || {}; |
|
1385 o = o[arg]; //Reset base object to the new object so it's returned |
|
1386 } |
|
1387 } |
|
1388 return o; |
|
1389 }, |
|
1390 |
|
1391 // this is replaced if the log module is included |
|
1392 log: NOOP, |
|
1393 message: NOOP, |
|
1394 // this is replaced if the dump module is included |
|
1395 dump: function (o) { return ''+o; }, |
|
1396 |
|
1397 /** |
|
1398 Reports an error. |
|
1399 |
|
1400 The reporting mechanism is controlled by the `throwFail` configuration |
|
1401 attribute. If `throwFail` is falsy, the message is logged. If `throwFail` is |
|
1402 truthy, a JS exception is thrown. |
|
1403 |
|
1404 If an `errorFn` is specified in the config it must return `true` to indicate |
|
1405 that the exception was handled and keep it from being thrown. |
|
1406 |
|
1407 @method error |
|
1408 @param {String} msg Error message. |
|
1409 @param {Error|String} [e] JavaScript error object or an error string. |
|
1410 @param {String} [src] Source of the error (such as the name of the module in |
|
1411 which the error occurred). |
|
1412 @chainable |
|
1413 **/ |
|
1414 error: function(msg, e, src) { |
|
1415 //TODO Add check for window.onerror here |
|
1416 |
|
1417 var Y = this, ret; |
|
1418 |
|
1419 if (Y.config.errorFn) { |
|
1420 ret = Y.config.errorFn.apply(Y, arguments); |
|
1421 } |
|
1422 |
|
1423 if (!ret) { |
|
1424 throw (e || new Error(msg)); |
|
1425 } else { |
|
1426 Y.message(msg, 'error', ''+src); // don't scrub this one |
|
1427 } |
|
1428 |
|
1429 return Y; |
|
1430 }, |
|
1431 |
|
1432 /** |
|
1433 Generates an id string that is unique among all YUI instances in this |
|
1434 execution context. |
|
1435 |
|
1436 @method guid |
|
1437 @param {String} [pre] Prefix. |
|
1438 @return {String} Unique id. |
|
1439 **/ |
|
1440 guid: function(pre) { |
|
1441 var id = this.Env._guidp + '_' + (++this.Env._uidx); |
|
1442 return (pre) ? (pre + id) : id; |
|
1443 }, |
|
1444 |
|
1445 /** |
|
1446 Returns a unique id associated with the given object and (if *readOnly* is |
|
1447 falsy) stamps the object with that id so it can be identified in the future. |
|
1448 |
|
1449 Stamping an object involves adding a `_yuid` property to it that contains |
|
1450 the object's id. One exception to this is that in Internet Explorer, DOM |
|
1451 nodes have a `uniqueID` property that contains a browser-generated unique |
|
1452 id, which will be used instead of a YUI-generated id when available. |
|
1453 |
|
1454 @method stamp |
|
1455 @param {Object} o Object to stamp. |
|
1456 @param {Boolean} readOnly If truthy and the given object has not already |
|
1457 been stamped, the object will not be modified and `null` will be |
|
1458 returned. |
|
1459 @return {String} Object's unique id, or `null` if *readOnly* was truthy and |
|
1460 the given object was not already stamped. |
|
1461 **/ |
|
1462 stamp: function(o, readOnly) { |
|
1463 var uid; |
|
1464 if (!o) { |
|
1465 return o; |
|
1466 } |
|
1467 |
|
1468 // IE generates its own unique ID for dom nodes |
|
1469 // The uniqueID property of a document node returns a new ID |
|
1470 if (o.uniqueID && o.nodeType && o.nodeType !== 9) { |
|
1471 uid = o.uniqueID; |
|
1472 } else { |
|
1473 uid = (typeof o === 'string') ? o : o._yuid; |
|
1474 } |
|
1475 |
|
1476 if (!uid) { |
|
1477 uid = this.guid(); |
|
1478 if (!readOnly) { |
|
1479 try { |
|
1480 o._yuid = uid; |
|
1481 } catch (e) { |
|
1482 uid = null; |
|
1483 } |
|
1484 } |
|
1485 } |
|
1486 return uid; |
|
1487 }, |
|
1488 |
|
1489 /** |
|
1490 Destroys this YUI instance. |
|
1491 |
|
1492 @method destroy |
|
1493 @since 3.3.0 |
|
1494 **/ |
|
1495 destroy: function() { |
|
1496 var Y = this; |
|
1497 if (Y.Event) { |
|
1498 Y.Event._unload(); |
|
1499 } |
|
1500 delete instances[Y.id]; |
|
1501 delete Y.Env; |
|
1502 delete Y.config; |
|
1503 } |
|
1504 |
|
1505 /** |
|
1506 Safe `instanceof` wrapper that works around a memory leak in IE when the |
|
1507 object being tested is `window` or `document`. |
|
1508 |
|
1509 Unless you are testing objects that may be `window` or `document`, you |
|
1510 should use the native `instanceof` operator instead of this method. |
|
1511 |
|
1512 @method instanceOf |
|
1513 @param {Object} o Object to check. |
|
1514 @param {Object} type Class to check against. |
|
1515 @since 3.3.0 |
|
1516 **/ |
|
1517 }; |
|
1518 |
|
1519 YUI.prototype = proto; |
|
1520 |
|
1521 // inheritance utilities are not available yet |
|
1522 for (prop in proto) { |
|
1523 if (proto.hasOwnProperty(prop)) { |
|
1524 YUI[prop] = proto[prop]; |
|
1525 } |
|
1526 } |
|
1527 |
|
1528 /** |
|
1529 Applies a configuration to all YUI instances in this execution context. |
|
1530 |
|
1531 The main use case for this method is in "mashups" where several third-party |
|
1532 scripts need to write to a global YUI config, but cannot share a single |
|
1533 centrally-managed config object. This way they can all call |
|
1534 `YUI.applyConfig({})` instead of overwriting the single global config. |
|
1535 |
|
1536 @example |
|
1537 |
|
1538 YUI.applyConfig({ |
|
1539 modules: { |
|
1540 davglass: { |
|
1541 fullpath: './davglass.js' |
|
1542 } |
|
1543 } |
|
1544 }); |
|
1545 |
|
1546 YUI.applyConfig({ |
|
1547 modules: { |
|
1548 foo: { |
|
1549 fullpath: './foo.js' |
|
1550 } |
|
1551 } |
|
1552 }); |
|
1553 |
|
1554 YUI().use('davglass', function (Y) { |
|
1555 // Module davglass will be available here. |
|
1556 }); |
|
1557 |
|
1558 @method applyConfig |
|
1559 @param {Object} o Configuration object to apply. |
|
1560 @static |
|
1561 @since 3.5.0 |
|
1562 **/ |
|
1563 YUI.applyConfig = function(o) { |
|
1564 if (!o) { |
|
1565 return; |
|
1566 } |
|
1567 //If there is a GlobalConfig, apply it first to set the defaults |
|
1568 if (YUI.GlobalConfig) { |
|
1569 this.prototype.applyConfig.call(this, YUI.GlobalConfig); |
|
1570 } |
|
1571 //Apply this config to it |
|
1572 this.prototype.applyConfig.call(this, o); |
|
1573 //Reset GlobalConfig to the combined config |
|
1574 YUI.GlobalConfig = this.config; |
|
1575 }; |
|
1576 |
|
1577 // set up the environment |
|
1578 YUI._init(); |
|
1579 |
|
1580 if (hasWin) { |
|
1581 add(doc, 'DOMContentLoaded', handleReady); |
|
1582 |
|
1583 // add a window load event at load time so we can capture |
|
1584 // the case where it fires before dynamic loading is |
|
1585 // complete. |
|
1586 add(window, 'load', handleLoad); |
|
1587 } else { |
|
1588 handleReady(); |
|
1589 handleLoad(); |
|
1590 } |
|
1591 |
|
1592 YUI.Env.add = add; |
|
1593 YUI.Env.remove = remove; |
|
1594 |
|
1595 /*global exports*/ |
|
1596 // Support the CommonJS method for exporting our single global |
|
1597 if (typeof exports == 'object') { |
|
1598 exports.YUI = YUI; |
|
1599 /** |
|
1600 * Set a method to be called when `Get.script` is called in Node.js |
|
1601 * `Get` will open the file, then pass it's content and it's path |
|
1602 * to this method before attaching it. Commonly used for code coverage |
|
1603 * instrumentation. <strong>Calling this multiple times will only |
|
1604 * attach the last hook method</strong>. This method is only |
|
1605 * available in Node.js. |
|
1606 * @method setLoadHook |
|
1607 * @static |
|
1608 * @param {Function} fn The function to set |
|
1609 * @param {String} fn.data The content of the file |
|
1610 * @param {String} fn.path The file path of the file |
|
1611 */ |
|
1612 YUI.setLoadHook = function(fn) { |
|
1613 YUI._getLoadHook = fn; |
|
1614 }; |
|
1615 /** |
|
1616 * Load hook for `Y.Get.script` in Node.js, see `YUI.setLoadHook` |
|
1617 * @method _getLoadHook |
|
1618 * @private |
|
1619 * @param {String} data The content of the file |
|
1620 * @param {String} path The file path of the file |
|
1621 */ |
|
1622 YUI._getLoadHook = null; |
|
1623 } |
|
1624 |
|
1625 YUI.Env[VERSION] = {}; |
|
1626 }()); |
|
1627 |
|
1628 |
|
1629 /** |
|
1630 Config object that contains all of the configuration options for |
|
1631 this `YUI` instance. |
|
1632 |
|
1633 This object is supplied by the implementer when instantiating YUI. Some |
|
1634 properties have default values if they are not supplied by the implementer. |
|
1635 |
|
1636 This object should not be updated directly because some values are cached. Use |
|
1637 `applyConfig()` to update the config object on a YUI instance that has already |
|
1638 been configured. |
|
1639 |
|
1640 @class config |
|
1641 @static |
|
1642 **/ |
|
1643 |
|
1644 /** |
|
1645 If `true` (the default), YUI will "bootstrap" the YUI Loader and module metadata |
|
1646 if they're needed to load additional dependencies and aren't already available. |
|
1647 |
|
1648 Setting this to `false` will prevent YUI from automatically loading the Loader |
|
1649 and module metadata, so you will need to manually ensure that they're available |
|
1650 or handle dependency resolution yourself. |
|
1651 |
|
1652 @property {Boolean} bootstrap |
|
1653 @default true |
|
1654 **/ |
|
1655 |
|
1656 /** |
|
1657 If `true`, `Y.log()` messages will be written to the browser's debug console |
|
1658 when available and when `useBrowserConsole` is also `true`. |
|
1659 |
|
1660 @property {Boolean} debug |
|
1661 @default true |
|
1662 **/ |
|
1663 |
|
1664 /** |
|
1665 Log messages to the browser console if `debug` is `true` and the browser has a |
|
1666 supported console. |
|
1667 |
|
1668 @property {Boolean} useBrowserConsole |
|
1669 @default true |
|
1670 **/ |
|
1671 |
|
1672 /** |
|
1673 A hash of log sources that should be logged. If specified, only messages from |
|
1674 these sources will be logged. Others will be discarded. |
|
1675 |
|
1676 @property {Object} logInclude |
|
1677 @type object |
|
1678 **/ |
|
1679 |
|
1680 /** |
|
1681 A hash of log sources that should be not be logged. If specified, all sources |
|
1682 will be logged *except* those on this list. |
|
1683 |
|
1684 @property {Object} logExclude |
|
1685 **/ |
|
1686 |
|
1687 /** |
|
1688 When the YUI seed file is dynamically loaded after the `window.onload` event has |
|
1689 fired, set this to `true` to tell YUI that it shouldn't wait for `window.onload` |
|
1690 to occur. |
|
1691 |
|
1692 This ensures that components that rely on `window.onload` and the `domready` |
|
1693 custom event will work as expected even when YUI is dynamically injected. |
|
1694 |
|
1695 @property {Boolean} injected |
|
1696 @default false |
|
1697 **/ |
|
1698 |
|
1699 /** |
|
1700 If `true`, `Y.error()` will generate or re-throw a JavaScript error. Otherwise, |
|
1701 errors are merely logged silently. |
|
1702 |
|
1703 @property {Boolean} throwFail |
|
1704 @default true |
|
1705 **/ |
|
1706 |
|
1707 /** |
|
1708 Reference to the global object for this execution context. |
|
1709 |
|
1710 In a browser, this is the current `window` object. In Node.js, this is the |
|
1711 Node.js `global` object. |
|
1712 |
|
1713 @property {Object} global |
|
1714 **/ |
|
1715 |
|
1716 /** |
|
1717 The browser window or frame that this YUI instance should operate in. |
|
1718 |
|
1719 When running in Node.js, this property is `undefined`, since there is no |
|
1720 `window` object. Use `global` to get a reference to the global object that will |
|
1721 work in both browsers and Node.js. |
|
1722 |
|
1723 @property {Window} win |
|
1724 **/ |
|
1725 |
|
1726 /** |
|
1727 The browser `document` object associated with this YUI instance's `win` object. |
|
1728 |
|
1729 When running in Node.js, this property is `undefined`, since there is no |
|
1730 `document` object. |
|
1731 |
|
1732 @property {Document} doc |
|
1733 **/ |
|
1734 |
|
1735 /** |
|
1736 A list of modules that defines the YUI core (overrides the default list). |
|
1737 |
|
1738 @property {Array} core |
|
1739 @type Array |
|
1740 @default ['get', 'features', 'intl-base', 'yui-log', 'yui-later', 'loader-base', 'loader-rollup', 'loader-yui3'] |
|
1741 **/ |
|
1742 |
|
1743 /** |
|
1744 A list of languages to use in order of preference. |
|
1745 |
|
1746 This list is matched against the list of available languages in modules that the |
|
1747 YUI instance uses to determine the best possible localization of language |
|
1748 sensitive modules. |
|
1749 |
|
1750 Languages are represented using BCP 47 language tags, such as "en-GB" for |
|
1751 English as used in the United Kingdom, or "zh-Hans-CN" for simplified Chinese as |
|
1752 used in China. The list may be provided as a comma-separated string or as an |
|
1753 array. |
|
1754 |
|
1755 @property {String|String[]} lang |
|
1756 **/ |
|
1757 |
|
1758 /** |
|
1759 Default date format. |
|
1760 |
|
1761 @property {String} dateFormat |
|
1762 @deprecated Use configuration in `DataType.Date.format()` instead. |
|
1763 **/ |
|
1764 |
|
1765 /** |
|
1766 Default locale. |
|
1767 |
|
1768 @property {String} locale |
|
1769 @deprecated Use `config.lang` instead. |
|
1770 **/ |
|
1771 |
|
1772 /** |
|
1773 Default generic polling interval in milliseconds. |
|
1774 |
|
1775 @property {Number} pollInterval |
|
1776 @default 20 |
|
1777 **/ |
|
1778 |
|
1779 /** |
|
1780 The number of dynamic `<script>` nodes to insert by default before automatically |
|
1781 removing them when loading scripts. |
|
1782 |
|
1783 This applies only to script nodes because removing the node will not make the |
|
1784 evaluated script unavailable. Dynamic CSS nodes are not auto purged, because |
|
1785 removing a linked style sheet will also remove the style definitions. |
|
1786 |
|
1787 @property {Number} purgethreshold |
|
1788 @default 20 |
|
1789 **/ |
|
1790 |
|
1791 /** |
|
1792 Delay in milliseconds to wait after a window `resize` event before firing the |
|
1793 event. If another `resize` event occurs before this delay has elapsed, the |
|
1794 delay will start over to ensure that `resize` events are throttled. |
|
1795 |
|
1796 @property {Number} windowResizeDelay |
|
1797 @default 40 |
|
1798 **/ |
|
1799 |
|
1800 /** |
|
1801 Base directory for dynamic loading. |
|
1802 |
|
1803 @property {String} base |
|
1804 **/ |
|
1805 |
|
1806 /** |
|
1807 Base URL for a dynamic combo handler. This will be used to make combo-handled |
|
1808 module requests if `combine` is set to `true. |
|
1809 |
|
1810 @property {String} comboBase |
|
1811 @default "http://yui.yahooapis.com/combo?" |
|
1812 **/ |
|
1813 |
|
1814 /** |
|
1815 Root path to prepend to each module path when creating a combo-handled request. |
|
1816 |
|
1817 This is updated for each YUI release to point to a specific version of the |
|
1818 library; for example: "3.8.0/build/". |
|
1819 |
|
1820 @property {String} root |
|
1821 **/ |
|
1822 |
|
1823 /** |
|
1824 Filter to apply to module urls. This filter will modify the default path for all |
|
1825 modules. |
|
1826 |
|
1827 The default path for the YUI library is the minified version of the files (e.g., |
|
1828 event-min.js). The filter property can be a predefined filter or a custom |
|
1829 filter. The valid predefined filters are: |
|
1830 |
|
1831 - **debug**: Loads debug versions of modules (e.g., event-debug.js). |
|
1832 - **raw**: Loads raw, non-minified versions of modules without debug logging |
|
1833 (e.g., event.js). |
|
1834 |
|
1835 You can also define a custom filter, which must be an object literal containing |
|
1836 a search regular expression and a replacement string: |
|
1837 |
|
1838 myFilter: { |
|
1839 searchExp : "-min\\.js", |
|
1840 replaceStr: "-debug.js" |
|
1841 } |
|
1842 |
|
1843 @property {Object|String} filter |
|
1844 **/ |
|
1845 |
|
1846 /** |
|
1847 Skin configuration and customizations. |
|
1848 |
|
1849 @property {Object} skin |
|
1850 @param {String} [skin.defaultSkin='sam'] Default skin name. This skin will be |
|
1851 applied automatically to skinnable components if not overridden by a |
|
1852 component-specific skin name. |
|
1853 @param {String} [skin.base='assets/skins/'] Default base path for a skin, |
|
1854 relative to Loader's `base` path. |
|
1855 @param {Object} [skin.overrides] Component-specific skin name overrides. Specify |
|
1856 a component name as the key and, as the value, a string or array of strings |
|
1857 for a skin or skins that should be loaded for that component instead of the |
|
1858 `defaultSkin`. |
|
1859 **/ |
|
1860 |
|
1861 /** |
|
1862 Hash of per-component filter specifications. If specified for a given component, |
|
1863 this overrides the global `filter` config. |
|
1864 |
|
1865 @example |
|
1866 YUI({ |
|
1867 modules: { |
|
1868 'foo': './foo.js', |
|
1869 'bar': './bar.js', |
|
1870 'baz': './baz.js' |
|
1871 }, |
|
1872 filters: { |
|
1873 'foo': { |
|
1874 searchExp: '.js', |
|
1875 replaceStr: '-coverage.js' |
|
1876 } |
|
1877 } |
|
1878 }).use('foo', 'bar', 'baz', function (Y) { |
|
1879 // foo-coverage.js is loaded |
|
1880 // bar.js is loaded |
|
1881 // baz.js is loaded |
|
1882 }); |
|
1883 |
|
1884 @property {Object} filters |
|
1885 **/ |
|
1886 |
|
1887 /** |
|
1888 If `true`, YUI will use a combo handler to load multiple modules in as few |
|
1889 requests as possible. |
|
1890 |
|
1891 The YUI CDN (which YUI uses by default) supports combo handling, but other |
|
1892 servers may not. If the server from which you're loading YUI does not support |
|
1893 combo handling, set this to `false`. |
|
1894 |
|
1895 Providing a value for the `base` config property will cause `combine` to default |
|
1896 to `false` instead of `true`. |
|
1897 |
|
1898 @property {Boolean} combine |
|
1899 @default true |
|
1900 */ |
|
1901 |
|
1902 /** |
|
1903 Array of module names that should never be dynamically loaded. |
|
1904 |
|
1905 @property {String[]} ignore |
|
1906 **/ |
|
1907 |
|
1908 /** |
|
1909 Array of module names that should always be loaded when required, even if |
|
1910 already present on the page. |
|
1911 |
|
1912 @property {String[]} force |
|
1913 **/ |
|
1914 |
|
1915 /** |
|
1916 DOM element or id that should be used as the insertion point for dynamically |
|
1917 added `<script>` and `<link>` nodes. |
|
1918 |
|
1919 @property {HTMLElement|String} insertBefore |
|
1920 **/ |
|
1921 |
|
1922 /** |
|
1923 Object hash containing attributes to add to dynamically added `<script>` nodes. |
|
1924 |
|
1925 @property {Object} jsAttributes |
|
1926 **/ |
|
1927 |
|
1928 /** |
|
1929 Object hash containing attributes to add to dynamically added `<link>` nodes. |
|
1930 |
|
1931 @property {Object} cssAttributes |
|
1932 **/ |
|
1933 |
|
1934 /** |
|
1935 Timeout in milliseconds before a dynamic JS or CSS request will be considered a |
|
1936 failure. If not set, no timeout will be enforced. |
|
1937 |
|
1938 @property {Number} timeout |
|
1939 **/ |
|
1940 |
|
1941 /** |
|
1942 Callback for the 'CSSComplete' event. When dynamically loading YUI components |
|
1943 with CSS, this property fires when the CSS is finished loading. |
|
1944 |
|
1945 This provides an opportunity to enhance the presentation of a loading page a |
|
1946 little bit before the entire loading process is done. |
|
1947 |
|
1948 @property {Function} onCSS |
|
1949 **/ |
|
1950 |
|
1951 /** |
|
1952 A hash of module definitions to add to the list of available YUI modules. These |
|
1953 modules can then be dynamically loaded via the `use()` method. |
|
1954 |
|
1955 This is a hash in which keys are module names and values are objects containing |
|
1956 module metadata. |
|
1957 |
|
1958 See `Loader.addModule()` for the supported module metadata fields. Also see |
|
1959 `groups`, which provides a way to configure the base and combo spec for a set of |
|
1960 modules. |
|
1961 |
|
1962 @example |
|
1963 |
|
1964 modules: { |
|
1965 mymod1: { |
|
1966 requires: ['node'], |
|
1967 fullpath: '/mymod1/mymod1.js' |
|
1968 }, |
|
1969 |
|
1970 mymod2: { |
|
1971 requires: ['mymod1'], |
|
1972 fullpath: '/mymod2/mymod2.js' |
|
1973 }, |
|
1974 |
|
1975 mymod3: '/js/mymod3.js', |
|
1976 mycssmod: '/css/mycssmod.css' |
|
1977 } |
|
1978 |
|
1979 @property {Object} modules |
|
1980 **/ |
|
1981 |
|
1982 /** |
|
1983 Aliases are dynamic groups of modules that can be used as shortcuts. |
|
1984 |
|
1985 @example |
|
1986 |
|
1987 YUI({ |
|
1988 aliases: { |
|
1989 davglass: [ 'node', 'yql', 'dd' ], |
|
1990 mine: [ 'davglass', 'autocomplete'] |
|
1991 } |
|
1992 }).use('mine', function (Y) { |
|
1993 // Node, YQL, DD & AutoComplete available here. |
|
1994 }); |
|
1995 |
|
1996 @property {Object} aliases |
|
1997 **/ |
|
1998 |
|
1999 /** |
|
2000 A hash of module group definitions. |
|
2001 |
|
2002 For each group you can specify a list of modules and the base path and |
|
2003 combo spec to use when dynamically loading the modules. |
|
2004 |
|
2005 @example |
|
2006 |
|
2007 groups: { |
|
2008 yui2: { |
|
2009 // specify whether or not this group has a combo service |
|
2010 combine: true, |
|
2011 |
|
2012 // The comboSeperator to use with this group's combo handler |
|
2013 comboSep: ';', |
|
2014 |
|
2015 // The maxURLLength for this server |
|
2016 maxURLLength: 500, |
|
2017 |
|
2018 // the base path for non-combo paths |
|
2019 base: 'http://yui.yahooapis.com/2.8.0r4/build/', |
|
2020 |
|
2021 // the path to the combo service |
|
2022 comboBase: 'http://yui.yahooapis.com/combo?', |
|
2023 |
|
2024 // a fragment to prepend to the path attribute when |
|
2025 // when building combo urls |
|
2026 root: '2.8.0r4/build/', |
|
2027 |
|
2028 // the module definitions |
|
2029 modules: { |
|
2030 yui2_yde: { |
|
2031 path: "yahoo-dom-event/yahoo-dom-event.js" |
|
2032 }, |
|
2033 yui2_anim: { |
|
2034 path: "animation/animation.js", |
|
2035 requires: ['yui2_yde'] |
|
2036 } |
|
2037 } |
|
2038 } |
|
2039 } |
|
2040 |
|
2041 @property {Object} groups |
|
2042 **/ |
|
2043 |
|
2044 /** |
|
2045 Path to the Loader JS file, relative to the `base` path. |
|
2046 |
|
2047 This is used to dynamically bootstrap the Loader when it's needed and isn't yet |
|
2048 available. |
|
2049 |
|
2050 @property {String} loaderPath |
|
2051 @default "loader/loader-min.js" |
|
2052 **/ |
|
2053 |
|
2054 /** |
|
2055 If `true`, YUI will attempt to load CSS dependencies and skins. Set this to |
|
2056 `false` to prevent YUI from loading any CSS, or set it to the string `"force"` |
|
2057 to force CSS dependencies to be loaded even if their associated JS modules are |
|
2058 already loaded. |
|
2059 |
|
2060 @property {Boolean|String} fetchCSS |
|
2061 @default true |
|
2062 **/ |
|
2063 |
|
2064 /** |
|
2065 Default gallery version used to build gallery module urls. |
|
2066 |
|
2067 @property {String} gallery |
|
2068 @since 3.1.0 |
|
2069 **/ |
|
2070 |
|
2071 /** |
|
2072 Default YUI 2 version used to build YUI 2 module urls. |
|
2073 |
|
2074 This is used for intrinsic YUI 2 support via the 2in3 project. Also see the |
|
2075 `2in3` config for pulling different revisions of the wrapped YUI 2 modules. |
|
2076 |
|
2077 @property {String} yui2 |
|
2078 @default "2.9.0" |
|
2079 @since 3.1.0 |
|
2080 **/ |
|
2081 |
|
2082 /** |
|
2083 Revision number of YUI 2in3 modules that should be used when loading YUI 2in3. |
|
2084 |
|
2085 @property {String} 2in3 |
|
2086 @default "4" |
|
2087 @since 3.1.0 |
|
2088 **/ |
|
2089 |
|
2090 /** |
|
2091 Alternate console log function that should be used in environments without a |
|
2092 supported native console. This function is executed with the YUI instance as its |
|
2093 `this` object. |
|
2094 |
|
2095 @property {Function} logFn |
|
2096 @since 3.1.0 |
|
2097 **/ |
|
2098 |
|
2099 /** |
|
2100 The minimum log level to log messages for. Log levels are defined |
|
2101 incrementally. Messages greater than or equal to the level specified will |
|
2102 be shown. All others will be discarded. The order of log levels in |
|
2103 increasing priority is: |
|
2104 |
|
2105 debug |
|
2106 info |
|
2107 warn |
|
2108 error |
|
2109 |
|
2110 @property {String} logLevel |
|
2111 @default 'debug' |
|
2112 @since 3.10.0 |
|
2113 **/ |
|
2114 |
|
2115 /** |
|
2116 Callback to execute when `Y.error()` is called. It receives the error message |
|
2117 and a JavaScript error object if one was provided. |
|
2118 |
|
2119 This function is executed with the YUI instance as its `this` object. |
|
2120 |
|
2121 Returning `true` from this function will prevent an exception from being thrown. |
|
2122 |
|
2123 @property {Function} errorFn |
|
2124 @param {String} errorFn.msg Error message |
|
2125 @param {Object} [errorFn.err] Error object (if one was provided). |
|
2126 @since 3.2.0 |
|
2127 **/ |
|
2128 |
|
2129 /** |
|
2130 A callback to execute when Loader fails to load one or more resources. |
|
2131 |
|
2132 This could be because of a script load failure. It could also be because a |
|
2133 module fails to register itself when the `requireRegistration` config is `true`. |
|
2134 |
|
2135 If this function is defined, the `use()` callback will only be called when the |
|
2136 loader succeeds. Otherwise, `use()` will always executes unless there was a |
|
2137 JavaScript error when attaching a module. |
|
2138 |
|
2139 @property {Function} loadErrorFn |
|
2140 @since 3.3.0 |
|
2141 **/ |
|
2142 |
|
2143 /** |
|
2144 If `true`, Loader will expect all loaded scripts to be first-class YUI modules |
|
2145 that register themselves with the YUI global, and will trigger a failure if a |
|
2146 loaded script does not register a YUI module. |
|
2147 |
|
2148 @property {Boolean} requireRegistration |
|
2149 @default false |
|
2150 @since 3.3.0 |
|
2151 **/ |
|
2152 |
|
2153 /** |
|
2154 Cache serviced use() requests. |
|
2155 |
|
2156 @property {Boolean} cacheUse |
|
2157 @default true |
|
2158 @since 3.3.0 |
|
2159 @deprecated No longer used. |
|
2160 **/ |
|
2161 |
|
2162 /** |
|
2163 Whether or not YUI should use native ES5 functionality when available for |
|
2164 features like `Y.Array.each()`, `Y.Object()`, etc. |
|
2165 |
|
2166 When `false`, YUI will always use its own fallback implementations instead of |
|
2167 relying on ES5 functionality, even when ES5 functionality is available. |
|
2168 |
|
2169 @property {Boolean} useNativeES5 |
|
2170 @default true |
|
2171 @since 3.5.0 |
|
2172 **/ |
|
2173 |
|
2174 /** |
|
2175 * Leverage native JSON stringify if the browser has a native |
|
2176 * implementation. In general, this is a good idea. See the Known Issues |
|
2177 * section in the JSON user guide for caveats. The default value is true |
|
2178 * for browsers with native JSON support. |
|
2179 * |
|
2180 * @property useNativeJSONStringify |
|
2181 * @type Boolean |
|
2182 * @default true |
|
2183 * @since 3.8.0 |
|
2184 */ |
|
2185 |
|
2186 /** |
|
2187 * Leverage native JSON parse if the browser has a native implementation. |
|
2188 * In general, this is a good idea. See the Known Issues section in the |
|
2189 * JSON user guide for caveats. The default value is true for browsers with |
|
2190 * native JSON support. |
|
2191 * |
|
2192 * @property useNativeJSONParse |
|
2193 * @type Boolean |
|
2194 * @default true |
|
2195 * @since 3.8.0 |
|
2196 */ |
|
2197 |
|
2198 /** |
|
2199 Delay the `use` callback until a specific event has passed (`load`, `domready`, `contentready` or `available`) |
|
2200 |
|
2201 @property {Object|String} delayUntil |
|
2202 @since 3.6.0 |
|
2203 @example |
|
2204 |
|
2205 You can use `load` or `domready` strings by default: |
|
2206 |
|
2207 YUI({ |
|
2208 delayUntil: 'domready' |
|
2209 }, function (Y) { |
|
2210 // This will not execute until 'domeready' occurs. |
|
2211 }); |
|
2212 |
|
2213 Or you can delay until a node is available (with `available` or `contentready`): |
|
2214 |
|
2215 YUI({ |
|
2216 delayUntil: { |
|
2217 event: 'available', |
|
2218 args : '#foo' |
|
2219 } |
|
2220 }, function (Y) { |
|
2221 // This will not execute until a node matching the selector "#foo" is |
|
2222 // available in the DOM. |
|
2223 }); |
|
2224 |
|
2225 **/ |
|
2226 YUI.add('yui-base', function (Y, NAME) { |
|
2227 |
|
2228 /* |
|
2229 * YUI stub |
|
2230 * @module yui |
|
2231 * @submodule yui-base |
|
2232 */ |
|
2233 /** |
|
2234 * The YUI module contains the components required for building the YUI |
|
2235 * seed file. This includes the script loading mechanism, a simple queue, |
|
2236 * and the core utilities for the library. |
|
2237 * @module yui |
|
2238 * @submodule yui-base |
|
2239 */ |
|
2240 |
|
2241 /** |
|
2242 * Provides core language utilites and extensions used throughout YUI. |
|
2243 * |
|
2244 * @class Lang |
|
2245 * @static |
|
2246 */ |
|
2247 |
|
2248 var L = Y.Lang || (Y.Lang = {}), |
|
2249 |
|
2250 STRING_PROTO = String.prototype, |
|
2251 TOSTRING = Object.prototype.toString, |
|
2252 |
|
2253 TYPES = { |
|
2254 'undefined' : 'undefined', |
|
2255 'number' : 'number', |
|
2256 'boolean' : 'boolean', |
|
2257 'string' : 'string', |
|
2258 '[object Function]': 'function', |
|
2259 '[object RegExp]' : 'regexp', |
|
2260 '[object Array]' : 'array', |
|
2261 '[object Date]' : 'date', |
|
2262 '[object Error]' : 'error' |
|
2263 }, |
|
2264 |
|
2265 SUBREGEX = /\{\s*([^|}]+?)\s*(?:\|([^}]*))?\s*\}/g, |
|
2266 |
|
2267 WHITESPACE = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF", |
|
2268 WHITESPACE_CLASS = "[\x09-\x0D\x20\xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+", |
|
2269 TRIM_LEFT_REGEX = new RegExp("^" + WHITESPACE_CLASS), |
|
2270 TRIM_RIGHT_REGEX = new RegExp(WHITESPACE_CLASS + "$"), |
|
2271 TRIMREGEX = new RegExp(TRIM_LEFT_REGEX.source + "|" + TRIM_RIGHT_REGEX.source, "g"), |
|
2272 |
|
2273 NATIVE_FN_REGEX = /\{\s*\[(?:native code|function)\]\s*\}/i; |
|
2274 |
|
2275 // -- Protected Methods -------------------------------------------------------- |
|
2276 |
|
2277 /** |
|
2278 Returns `true` if the given function appears to be implemented in native code, |
|
2279 `false` otherwise. Will always return `false` -- even in ES5-capable browsers -- |
|
2280 if the `useNativeES5` YUI config option is set to `false`. |
|
2281 |
|
2282 This isn't guaranteed to be 100% accurate and won't work for anything other than |
|
2283 functions, but it can be useful for determining whether a function like |
|
2284 `Array.prototype.forEach` is native or a JS shim provided by another library. |
|
2285 |
|
2286 There's a great article by @kangax discussing certain flaws with this technique: |
|
2287 <http://perfectionkills.com/detecting-built-in-host-methods/> |
|
2288 |
|
2289 While his points are valid, it's still possible to benefit from this function |
|
2290 as long as it's used carefully and sparingly, and in such a way that false |
|
2291 negatives have minimal consequences. It's used internally to avoid using |
|
2292 potentially broken non-native ES5 shims that have been added to the page by |
|
2293 other libraries. |
|
2294 |
|
2295 @method _isNative |
|
2296 @param {Function} fn Function to test. |
|
2297 @return {Boolean} `true` if _fn_ appears to be native, `false` otherwise. |
|
2298 @static |
|
2299 @protected |
|
2300 @since 3.5.0 |
|
2301 **/ |
|
2302 L._isNative = function (fn) { |
|
2303 return !!(Y.config.useNativeES5 && fn && NATIVE_FN_REGEX.test(fn)); |
|
2304 }; |
|
2305 |
|
2306 // -- Public Methods ----------------------------------------------------------- |
|
2307 |
|
2308 /** |
|
2309 * Determines whether or not the provided item is an array. |
|
2310 * |
|
2311 * Returns `false` for array-like collections such as the function `arguments` |
|
2312 * collection or `HTMLElement` collections. Use `Y.Array.test()` if you want to |
|
2313 * test for an array-like collection. |
|
2314 * |
|
2315 * @method isArray |
|
2316 * @param o The object to test. |
|
2317 * @return {boolean} true if o is an array. |
|
2318 * @static |
|
2319 */ |
|
2320 L.isArray = L._isNative(Array.isArray) ? Array.isArray : function (o) { |
|
2321 return L.type(o) === 'array'; |
|
2322 }; |
|
2323 |
|
2324 /** |
|
2325 * Determines whether or not the provided item is a boolean. |
|
2326 * @method isBoolean |
|
2327 * @static |
|
2328 * @param o The object to test. |
|
2329 * @return {boolean} true if o is a boolean. |
|
2330 */ |
|
2331 L.isBoolean = function(o) { |
|
2332 return typeof o === 'boolean'; |
|
2333 }; |
|
2334 |
|
2335 /** |
|
2336 * Determines whether or not the supplied item is a date instance. |
|
2337 * @method isDate |
|
2338 * @static |
|
2339 * @param o The object to test. |
|
2340 * @return {boolean} true if o is a date. |
|
2341 */ |
|
2342 L.isDate = function(o) { |
|
2343 return L.type(o) === 'date' && o.toString() !== 'Invalid Date' && !isNaN(o); |
|
2344 }; |
|
2345 |
|
2346 /** |
|
2347 * <p> |
|
2348 * Determines whether or not the provided item is a function. |
|
2349 * Note: Internet Explorer thinks certain functions are objects: |
|
2350 * </p> |
|
2351 * |
|
2352 * <pre> |
|
2353 * var obj = document.createElement("object"); |
|
2354 * Y.Lang.isFunction(obj.getAttribute) // reports false in IE |
|
2355 * |
|
2356 * var input = document.createElement("input"); // append to body |
|
2357 * Y.Lang.isFunction(input.focus) // reports false in IE |
|
2358 * </pre> |
|
2359 * |
|
2360 * <p> |
|
2361 * You will have to implement additional tests if these functions |
|
2362 * matter to you. |
|
2363 * </p> |
|
2364 * |
|
2365 * @method isFunction |
|
2366 * @static |
|
2367 * @param o The object to test. |
|
2368 * @return {boolean} true if o is a function. |
|
2369 */ |
|
2370 L.isFunction = function(o) { |
|
2371 return L.type(o) === 'function'; |
|
2372 }; |
|
2373 |
|
2374 /** |
|
2375 * Determines whether or not the provided item is null. |
|
2376 * @method isNull |
|
2377 * @static |
|
2378 * @param o The object to test. |
|
2379 * @return {boolean} true if o is null. |
|
2380 */ |
|
2381 L.isNull = function(o) { |
|
2382 return o === null; |
|
2383 }; |
|
2384 |
|
2385 /** |
|
2386 * Determines whether or not the provided item is a legal number. |
|
2387 * @method isNumber |
|
2388 * @static |
|
2389 * @param o The object to test. |
|
2390 * @return {boolean} true if o is a number. |
|
2391 */ |
|
2392 L.isNumber = function(o) { |
|
2393 return typeof o === 'number' && isFinite(o); |
|
2394 }; |
|
2395 |
|
2396 /** |
|
2397 * Determines whether or not the provided item is of type object |
|
2398 * or function. Note that arrays are also objects, so |
|
2399 * <code>Y.Lang.isObject([]) === true</code>. |
|
2400 * @method isObject |
|
2401 * @static |
|
2402 * @param o The object to test. |
|
2403 * @param failfn {boolean} fail if the input is a function. |
|
2404 * @return {boolean} true if o is an object. |
|
2405 * @see isPlainObject |
|
2406 */ |
|
2407 L.isObject = function(o, failfn) { |
|
2408 var t = typeof o; |
|
2409 return (o && (t === 'object' || |
|
2410 (!failfn && (t === 'function' || L.isFunction(o))))) || false; |
|
2411 }; |
|
2412 |
|
2413 /** |
|
2414 * Determines whether or not the provided value is a regexp. |
|
2415 * @method isRegExp |
|
2416 * @static |
|
2417 * @param value The value or object to test. |
|
2418 * @return {boolean} true if value is a regexp. |
|
2419 */ |
|
2420 L.isRegExp = function(value) { |
|
2421 return L.type(value) === 'regexp'; |
|
2422 }; |
|
2423 |
|
2424 /** |
|
2425 * Determines whether or not the provided item is a string. |
|
2426 * @method isString |
|
2427 * @static |
|
2428 * @param o The object to test. |
|
2429 * @return {boolean} true if o is a string. |
|
2430 */ |
|
2431 L.isString = function(o) { |
|
2432 return typeof o === 'string'; |
|
2433 }; |
|
2434 |
|
2435 /** |
|
2436 * Determines whether or not the provided item is undefined. |
|
2437 * @method isUndefined |
|
2438 * @static |
|
2439 * @param o The object to test. |
|
2440 * @return {boolean} true if o is undefined. |
|
2441 */ |
|
2442 L.isUndefined = function(o) { |
|
2443 return typeof o === 'undefined'; |
|
2444 }; |
|
2445 |
|
2446 /** |
|
2447 * A convenience method for detecting a legitimate non-null value. |
|
2448 * Returns false for null/undefined/NaN, true for other values, |
|
2449 * including 0/false/'' |
|
2450 * @method isValue |
|
2451 * @static |
|
2452 * @param o The item to test. |
|
2453 * @return {boolean} true if it is not null/undefined/NaN || false. |
|
2454 */ |
|
2455 L.isValue = function(o) { |
|
2456 var t = L.type(o); |
|
2457 |
|
2458 switch (t) { |
|
2459 case 'number': |
|
2460 return isFinite(o); |
|
2461 |
|
2462 case 'null': // fallthru |
|
2463 case 'undefined': |
|
2464 return false; |
|
2465 |
|
2466 default: |
|
2467 return !!t; |
|
2468 } |
|
2469 }; |
|
2470 |
|
2471 /** |
|
2472 * Returns the current time in milliseconds. |
|
2473 * |
|
2474 * @method now |
|
2475 * @return {Number} Current time in milliseconds. |
|
2476 * @static |
|
2477 * @since 3.3.0 |
|
2478 */ |
|
2479 L.now = Date.now || function () { |
|
2480 return new Date().getTime(); |
|
2481 }; |
|
2482 |
|
2483 /** |
|
2484 * Performs `{placeholder}` substitution on a string. The object passed as the |
|
2485 * second parameter provides values to replace the `{placeholder}`s. |
|
2486 * `{placeholder}` token names must match property names of the object. For example, |
|
2487 * |
|
2488 *`var greeting = Y.Lang.sub("Hello, {who}!", { who: "World" });` |
|
2489 * |
|
2490 * `{placeholder}` tokens that are undefined on the object map will be left |
|
2491 * in tact (leaving unsightly `{placeholder}`'s in the output string). |
|
2492 * |
|
2493 * @method sub |
|
2494 * @param {string} s String to be modified. |
|
2495 * @param {object} o Object containing replacement values. |
|
2496 * @return {string} the substitute result. |
|
2497 * @static |
|
2498 * @since 3.2.0 |
|
2499 */ |
|
2500 L.sub = function(s, o) { |
|
2501 return s.replace ? s.replace(SUBREGEX, function (match, key) { |
|
2502 return L.isUndefined(o[key]) ? match : o[key]; |
|
2503 }) : s; |
|
2504 }; |
|
2505 |
|
2506 /** |
|
2507 * Returns a string without any leading or trailing whitespace. If |
|
2508 * the input is not a string, the input will be returned untouched. |
|
2509 * @method trim |
|
2510 * @static |
|
2511 * @param s {string} the string to trim. |
|
2512 * @return {string} the trimmed string. |
|
2513 */ |
|
2514 L.trim = L._isNative(STRING_PROTO.trim) && !WHITESPACE.trim() ? function(s) { |
|
2515 return s && s.trim ? s.trim() : s; |
|
2516 } : function (s) { |
|
2517 try { |
|
2518 return s.replace(TRIMREGEX, ''); |
|
2519 } catch (e) { |
|
2520 return s; |
|
2521 } |
|
2522 }; |
|
2523 |
|
2524 /** |
|
2525 * Returns a string without any leading whitespace. |
|
2526 * @method trimLeft |
|
2527 * @static |
|
2528 * @param s {string} the string to trim. |
|
2529 * @return {string} the trimmed string. |
|
2530 */ |
|
2531 L.trimLeft = L._isNative(STRING_PROTO.trimLeft) && !WHITESPACE.trimLeft() ? function (s) { |
|
2532 return s.trimLeft(); |
|
2533 } : function (s) { |
|
2534 return s.replace(TRIM_LEFT_REGEX, ''); |
|
2535 }; |
|
2536 |
|
2537 /** |
|
2538 * Returns a string without any trailing whitespace. |
|
2539 * @method trimRight |
|
2540 * @static |
|
2541 * @param s {string} the string to trim. |
|
2542 * @return {string} the trimmed string. |
|
2543 */ |
|
2544 L.trimRight = L._isNative(STRING_PROTO.trimRight) && !WHITESPACE.trimRight() ? function (s) { |
|
2545 return s.trimRight(); |
|
2546 } : function (s) { |
|
2547 return s.replace(TRIM_RIGHT_REGEX, ''); |
|
2548 }; |
|
2549 |
|
2550 /** |
|
2551 Returns one of the following strings, representing the type of the item passed |
|
2552 in: |
|
2553 |
|
2554 * "array" |
|
2555 * "boolean" |
|
2556 * "date" |
|
2557 * "error" |
|
2558 * "function" |
|
2559 * "null" |
|
2560 * "number" |
|
2561 * "object" |
|
2562 * "regexp" |
|
2563 * "string" |
|
2564 * "undefined" |
|
2565 |
|
2566 Known issues: |
|
2567 |
|
2568 * `typeof HTMLElementCollection` returns function in Safari, but |
|
2569 `Y.Lang.type()` reports "object", which could be a good thing -- |
|
2570 but it actually caused the logic in <code>Y.Lang.isObject</code> to fail. |
|
2571 |
|
2572 @method type |
|
2573 @param o the item to test. |
|
2574 @return {string} the detected type. |
|
2575 @static |
|
2576 **/ |
|
2577 L.type = function(o) { |
|
2578 return TYPES[typeof o] || TYPES[TOSTRING.call(o)] || (o ? 'object' : 'null'); |
|
2579 }; |
|
2580 /** |
|
2581 @module yui |
|
2582 @submodule yui-base |
|
2583 */ |
|
2584 |
|
2585 var Lang = Y.Lang, |
|
2586 Native = Array.prototype, |
|
2587 |
|
2588 hasOwn = Object.prototype.hasOwnProperty; |
|
2589 |
|
2590 /** |
|
2591 Provides utility methods for working with arrays. Additional array helpers can |
|
2592 be found in the `collection` and `array-extras` modules. |
|
2593 |
|
2594 `Y.Array(thing)` returns a native array created from _thing_. Depending on |
|
2595 _thing_'s type, one of the following will happen: |
|
2596 |
|
2597 * Arrays are returned unmodified unless a non-zero _startIndex_ is |
|
2598 specified. |
|
2599 * Array-like collections (see `Array.test()`) are converted to arrays. |
|
2600 * For everything else, a new array is created with _thing_ as the sole |
|
2601 item. |
|
2602 |
|
2603 Note: elements that are also collections, such as `<form>` and `<select>` |
|
2604 elements, are not automatically converted to arrays. To force a conversion, |
|
2605 pass `true` as the value of the _force_ parameter. |
|
2606 |
|
2607 @class Array |
|
2608 @constructor |
|
2609 @param {Any} thing The thing to arrayify. |
|
2610 @param {Number} [startIndex=0] If non-zero and _thing_ is an array or array-like |
|
2611 collection, a subset of items starting at the specified index will be |
|
2612 returned. |
|
2613 @param {Boolean} [force=false] If `true`, _thing_ will be treated as an |
|
2614 array-like collection no matter what. |
|
2615 @return {Array} A native array created from _thing_, according to the rules |
|
2616 described above. |
|
2617 **/ |
|
2618 function YArray(thing, startIndex, force) { |
|
2619 var len, result; |
|
2620 |
|
2621 /*jshint expr: true*/ |
|
2622 startIndex || (startIndex = 0); |
|
2623 |
|
2624 if (force || YArray.test(thing)) { |
|
2625 // IE throws when trying to slice HTMLElement collections. |
|
2626 try { |
|
2627 return Native.slice.call(thing, startIndex); |
|
2628 } catch (ex) { |
|
2629 result = []; |
|
2630 |
|
2631 for (len = thing.length; startIndex < len; ++startIndex) { |
|
2632 result.push(thing[startIndex]); |
|
2633 } |
|
2634 |
|
2635 return result; |
|
2636 } |
|
2637 } |
|
2638 |
|
2639 return [thing]; |
|
2640 } |
|
2641 |
|
2642 Y.Array = YArray; |
|
2643 |
|
2644 /** |
|
2645 Dedupes an array of strings, returning an array that's guaranteed to contain |
|
2646 only one copy of a given string. |
|
2647 |
|
2648 This method differs from `Array.unique()` in that it's optimized for use only |
|
2649 with arrays consisting entirely of strings or entirely of numbers, whereas |
|
2650 `unique` may be used with other value types (but is slower). |
|
2651 |
|
2652 Using `dedupe()` with values other than strings or numbers, or with arrays |
|
2653 containing a mix of strings and numbers, may result in unexpected behavior. |
|
2654 |
|
2655 @method dedupe |
|
2656 @param {String[]|Number[]} array Array of strings or numbers to dedupe. |
|
2657 @return {Array} Copy of _array_ containing no duplicate values. |
|
2658 @static |
|
2659 @since 3.4.0 |
|
2660 **/ |
|
2661 YArray.dedupe = Lang._isNative(Object.create) ? function (array) { |
|
2662 var hash = Object.create(null), |
|
2663 results = [], |
|
2664 i, item, len; |
|
2665 |
|
2666 for (i = 0, len = array.length; i < len; ++i) { |
|
2667 item = array[i]; |
|
2668 |
|
2669 if (!hash[item]) { |
|
2670 hash[item] = 1; |
|
2671 results.push(item); |
|
2672 } |
|
2673 } |
|
2674 |
|
2675 return results; |
|
2676 } : function (array) { |
|
2677 var hash = {}, |
|
2678 results = [], |
|
2679 i, item, len; |
|
2680 |
|
2681 for (i = 0, len = array.length; i < len; ++i) { |
|
2682 item = array[i]; |
|
2683 |
|
2684 if (!hasOwn.call(hash, item)) { |
|
2685 hash[item] = 1; |
|
2686 results.push(item); |
|
2687 } |
|
2688 } |
|
2689 |
|
2690 return results; |
|
2691 }; |
|
2692 |
|
2693 /** |
|
2694 Executes the supplied function on each item in the array. This method wraps |
|
2695 the native ES5 `Array.forEach()` method if available. |
|
2696 |
|
2697 @method each |
|
2698 @param {Array} array Array to iterate. |
|
2699 @param {Function} fn Function to execute on each item in the array. The function |
|
2700 will receive the following arguments: |
|
2701 @param {Any} fn.item Current array item. |
|
2702 @param {Number} fn.index Current array index. |
|
2703 @param {Array} fn.array Array being iterated. |
|
2704 @param {Object} [thisObj] `this` object to use when calling _fn_. |
|
2705 @return {YUI} The YUI instance. |
|
2706 @static |
|
2707 **/ |
|
2708 YArray.each = YArray.forEach = Lang._isNative(Native.forEach) ? function (array, fn, thisObj) { |
|
2709 Native.forEach.call(array || [], fn, thisObj || Y); |
|
2710 return Y; |
|
2711 } : function (array, fn, thisObj) { |
|
2712 for (var i = 0, len = (array && array.length) || 0; i < len; ++i) { |
|
2713 if (i in array) { |
|
2714 fn.call(thisObj || Y, array[i], i, array); |
|
2715 } |
|
2716 } |
|
2717 |
|
2718 return Y; |
|
2719 }; |
|
2720 |
|
2721 /** |
|
2722 Alias for `each()`. |
|
2723 |
|
2724 @method forEach |
|
2725 @static |
|
2726 **/ |
|
2727 |
|
2728 /** |
|
2729 Returns an object using the first array as keys and the second as values. If |
|
2730 the second array is not provided, or if it doesn't contain the same number of |
|
2731 values as the first array, then `true` will be used in place of the missing |
|
2732 values. |
|
2733 |
|
2734 @example |
|
2735 |
|
2736 Y.Array.hash(['a', 'b', 'c'], ['foo', 'bar']); |
|
2737 // => {a: 'foo', b: 'bar', c: true} |
|
2738 |
|
2739 @method hash |
|
2740 @param {String[]} keys Array of strings to use as keys. |
|
2741 @param {Array} [values] Array to use as values. |
|
2742 @return {Object} Hash using the first array as keys and the second as values. |
|
2743 @static |
|
2744 **/ |
|
2745 YArray.hash = function (keys, values) { |
|
2746 var hash = {}, |
|
2747 vlen = (values && values.length) || 0, |
|
2748 i, len; |
|
2749 |
|
2750 for (i = 0, len = keys.length; i < len; ++i) { |
|
2751 if (i in keys) { |
|
2752 hash[keys[i]] = vlen > i && i in values ? values[i] : true; |
|
2753 } |
|
2754 } |
|
2755 |
|
2756 return hash; |
|
2757 }; |
|
2758 |
|
2759 /** |
|
2760 Returns the index of the first item in the array that's equal (using a strict |
|
2761 equality check) to the specified _value_, or `-1` if the value isn't found. |
|
2762 |
|
2763 This method wraps the native ES5 `Array.indexOf()` method if available. |
|
2764 |
|
2765 @method indexOf |
|
2766 @param {Array} array Array to search. |
|
2767 @param {Any} value Value to search for. |
|
2768 @param {Number} [from=0] The index at which to begin the search. |
|
2769 @return {Number} Index of the item strictly equal to _value_, or `-1` if not |
|
2770 found. |
|
2771 @static |
|
2772 **/ |
|
2773 YArray.indexOf = Lang._isNative(Native.indexOf) ? function (array, value, from) { |
|
2774 return Native.indexOf.call(array, value, from); |
|
2775 } : function (array, value, from) { |
|
2776 // http://es5.github.com/#x15.4.4.14 |
|
2777 var len = array.length; |
|
2778 |
|
2779 from = +from || 0; |
|
2780 from = (from > 0 || -1) * Math.floor(Math.abs(from)); |
|
2781 |
|
2782 if (from < 0) { |
|
2783 from += len; |
|
2784 |
|
2785 if (from < 0) { |
|
2786 from = 0; |
|
2787 } |
|
2788 } |
|
2789 |
|
2790 for (; from < len; ++from) { |
|
2791 if (from in array && array[from] === value) { |
|
2792 return from; |
|
2793 } |
|
2794 } |
|
2795 |
|
2796 return -1; |
|
2797 }; |
|
2798 |
|
2799 /** |
|
2800 Numeric sort convenience function. |
|
2801 |
|
2802 The native `Array.prototype.sort()` function converts values to strings and |
|
2803 sorts them in lexicographic order, which is unsuitable for sorting numeric |
|
2804 values. Provide `Array.numericSort` as a custom sort function when you want |
|
2805 to sort values in numeric order. |
|
2806 |
|
2807 @example |
|
2808 |
|
2809 [42, 23, 8, 16, 4, 15].sort(Y.Array.numericSort); |
|
2810 // => [4, 8, 15, 16, 23, 42] |
|
2811 |
|
2812 @method numericSort |
|
2813 @param {Number} a First value to compare. |
|
2814 @param {Number} b Second value to compare. |
|
2815 @return {Number} Difference between _a_ and _b_. |
|
2816 @static |
|
2817 **/ |
|
2818 YArray.numericSort = function (a, b) { |
|
2819 return a - b; |
|
2820 }; |
|
2821 |
|
2822 /** |
|
2823 Executes the supplied function on each item in the array. Returning a truthy |
|
2824 value from the function will stop the processing of remaining items. |
|
2825 |
|
2826 @method some |
|
2827 @param {Array} array Array to iterate over. |
|
2828 @param {Function} fn Function to execute on each item. The function will receive |
|
2829 the following arguments: |
|
2830 @param {Any} fn.value Current array item. |
|
2831 @param {Number} fn.index Current array index. |
|
2832 @param {Array} fn.array Array being iterated over. |
|
2833 @param {Object} [thisObj] `this` object to use when calling _fn_. |
|
2834 @return {Boolean} `true` if the function returns a truthy value on any of the |
|
2835 items in the array; `false` otherwise. |
|
2836 @static |
|
2837 **/ |
|
2838 YArray.some = Lang._isNative(Native.some) ? function (array, fn, thisObj) { |
|
2839 return Native.some.call(array, fn, thisObj); |
|
2840 } : function (array, fn, thisObj) { |
|
2841 for (var i = 0, len = array.length; i < len; ++i) { |
|
2842 if (i in array && fn.call(thisObj, array[i], i, array)) { |
|
2843 return true; |
|
2844 } |
|
2845 } |
|
2846 |
|
2847 return false; |
|
2848 }; |
|
2849 |
|
2850 /** |
|
2851 Evaluates _obj_ to determine if it's an array, an array-like collection, or |
|
2852 something else. This is useful when working with the function `arguments` |
|
2853 collection and `HTMLElement` collections. |
|
2854 |
|
2855 Note: This implementation doesn't consider elements that are also |
|
2856 collections, such as `<form>` and `<select>`, to be array-like. |
|
2857 |
|
2858 @method test |
|
2859 @param {Object} obj Object to test. |
|
2860 @return {Number} A number indicating the results of the test: |
|
2861 |
|
2862 * 0: Neither an array nor an array-like collection. |
|
2863 * 1: Real array. |
|
2864 * 2: Array-like collection. |
|
2865 |
|
2866 @static |
|
2867 **/ |
|
2868 YArray.test = function (obj) { |
|
2869 var result = 0; |
|
2870 |
|
2871 if (Lang.isArray(obj)) { |
|
2872 result = 1; |
|
2873 } else if (Lang.isObject(obj)) { |
|
2874 try { |
|
2875 // indexed, but no tagName (element) or scrollTo/document (window. From DOM.isWindow test which we can't use here), |
|
2876 // or functions without apply/call (Safari |
|
2877 // HTMLElementCollection bug). |
|
2878 if ('length' in obj && !obj.tagName && !(obj.scrollTo && obj.document) && !obj.apply) { |
|
2879 result = 2; |
|
2880 } |
|
2881 } catch (ex) {} |
|
2882 } |
|
2883 |
|
2884 return result; |
|
2885 }; |
|
2886 /** |
|
2887 * The YUI module contains the components required for building the YUI |
|
2888 * seed file. This includes the script loading mechanism, a simple queue, |
|
2889 * and the core utilities for the library. |
|
2890 * @module yui |
|
2891 * @submodule yui-base |
|
2892 */ |
|
2893 |
|
2894 /** |
|
2895 * A simple FIFO queue. Items are added to the Queue with add(1..n items) and |
|
2896 * removed using next(). |
|
2897 * |
|
2898 * @class Queue |
|
2899 * @constructor |
|
2900 * @param {MIXED} item* 0..n items to seed the queue. |
|
2901 */ |
|
2902 function Queue() { |
|
2903 this._init(); |
|
2904 this.add.apply(this, arguments); |
|
2905 } |
|
2906 |
|
2907 Queue.prototype = { |
|
2908 /** |
|
2909 * Initialize the queue |
|
2910 * |
|
2911 * @method _init |
|
2912 * @protected |
|
2913 */ |
|
2914 _init: function() { |
|
2915 /** |
|
2916 * The collection of enqueued items |
|
2917 * |
|
2918 * @property _q |
|
2919 * @type Array |
|
2920 * @protected |
|
2921 */ |
|
2922 this._q = []; |
|
2923 }, |
|
2924 |
|
2925 /** |
|
2926 * Get the next item in the queue. FIFO support |
|
2927 * |
|
2928 * @method next |
|
2929 * @return {MIXED} the next item in the queue. |
|
2930 */ |
|
2931 next: function() { |
|
2932 return this._q.shift(); |
|
2933 }, |
|
2934 |
|
2935 /** |
|
2936 * Get the last in the queue. LIFO support. |
|
2937 * |
|
2938 * @method last |
|
2939 * @return {MIXED} the last item in the queue. |
|
2940 */ |
|
2941 last: function() { |
|
2942 return this._q.pop(); |
|
2943 }, |
|
2944 |
|
2945 /** |
|
2946 * Add 0..n items to the end of the queue. |
|
2947 * |
|
2948 * @method add |
|
2949 * @param {MIXED} item* 0..n items. |
|
2950 * @return {object} this queue. |
|
2951 */ |
|
2952 add: function() { |
|
2953 this._q.push.apply(this._q, arguments); |
|
2954 |
|
2955 return this; |
|
2956 }, |
|
2957 |
|
2958 /** |
|
2959 * Returns the current number of queued items. |
|
2960 * |
|
2961 * @method size |
|
2962 * @return {Number} The size. |
|
2963 */ |
|
2964 size: function() { |
|
2965 return this._q.length; |
|
2966 } |
|
2967 }; |
|
2968 |
|
2969 Y.Queue = Queue; |
|
2970 |
|
2971 YUI.Env._loaderQueue = YUI.Env._loaderQueue || new Queue(); |
|
2972 |
|
2973 /** |
|
2974 The YUI module contains the components required for building the YUI seed file. |
|
2975 This includes the script loading mechanism, a simple queue, and the core |
|
2976 utilities for the library. |
|
2977 |
|
2978 @module yui |
|
2979 @submodule yui-base |
|
2980 **/ |
|
2981 |
|
2982 var CACHED_DELIMITER = '__', |
|
2983 |
|
2984 hasOwn = Object.prototype.hasOwnProperty, |
|
2985 isObject = Y.Lang.isObject; |
|
2986 |
|
2987 /** |
|
2988 Returns a wrapper for a function which caches the return value of that function, |
|
2989 keyed off of the combined string representation of the argument values provided |
|
2990 when the wrapper is called. |
|
2991 |
|
2992 Calling this function again with the same arguments will return the cached value |
|
2993 rather than executing the wrapped function. |
|
2994 |
|
2995 Note that since the cache is keyed off of the string representation of arguments |
|
2996 passed to the wrapper function, arguments that aren't strings and don't provide |
|
2997 a meaningful `toString()` method may result in unexpected caching behavior. For |
|
2998 example, the objects `{}` and `{foo: 'bar'}` would both be converted to the |
|
2999 string `[object Object]` when used as a cache key. |
|
3000 |
|
3001 @method cached |
|
3002 @param {Function} source The function to memoize. |
|
3003 @param {Object} [cache={}] Object in which to store cached values. You may seed |
|
3004 this object with pre-existing cached values if desired. |
|
3005 @param {any} [refetch] If supplied, this value is compared with the cached value |
|
3006 using a `==` comparison. If the values are equal, the wrapped function is |
|
3007 executed again even though a cached value exists. |
|
3008 @return {Function} Wrapped function. |
|
3009 @for YUI |
|
3010 **/ |
|
3011 Y.cached = function (source, cache, refetch) { |
|
3012 /*jshint expr: true*/ |
|
3013 cache || (cache = {}); |
|
3014 |
|
3015 return function (arg) { |
|
3016 var key = arguments.length > 1 ? |
|
3017 Array.prototype.join.call(arguments, CACHED_DELIMITER) : |
|
3018 String(arg); |
|
3019 |
|
3020 /*jshint eqeqeq: false*/ |
|
3021 if (!(key in cache) || (refetch && cache[key] == refetch)) { |
|
3022 cache[key] = source.apply(source, arguments); |
|
3023 } |
|
3024 |
|
3025 return cache[key]; |
|
3026 }; |
|
3027 }; |
|
3028 |
|
3029 /** |
|
3030 Returns the `location` object from the window/frame in which this YUI instance |
|
3031 operates, or `undefined` when executing in a non-browser environment |
|
3032 (e.g. Node.js). |
|
3033 |
|
3034 It is _not_ recommended to hold references to the `window.location` object |
|
3035 outside of the scope of a function in which its properties are being accessed or |
|
3036 its methods are being called. This is because of a nasty bug/issue that exists |
|
3037 in both Safari and MobileSafari browsers: |
|
3038 [WebKit Bug 34679](https://bugs.webkit.org/show_bug.cgi?id=34679). |
|
3039 |
|
3040 @method getLocation |
|
3041 @return {location} The `location` object from the window/frame in which this YUI |
|
3042 instance operates. |
|
3043 @since 3.5.0 |
|
3044 **/ |
|
3045 Y.getLocation = function () { |
|
3046 // It is safer to look this up every time because yui-base is attached to a |
|
3047 // YUI instance before a user's config is applied; i.e. `Y.config.win` does |
|
3048 // not point the correct window object when this file is loaded. |
|
3049 var win = Y.config.win; |
|
3050 |
|
3051 // It is not safe to hold a reference to the `location` object outside the |
|
3052 // scope in which it is being used. The WebKit engine used in Safari and |
|
3053 // MobileSafari will "disconnect" the `location` object from the `window` |
|
3054 // when a page is restored from back/forward history cache. |
|
3055 return win && win.location; |
|
3056 }; |
|
3057 |
|
3058 /** |
|
3059 Returns a new object containing all of the properties of all the supplied |
|
3060 objects. The properties from later objects will overwrite those in earlier |
|
3061 objects. |
|
3062 |
|
3063 Passing in a single object will create a shallow copy of it. For a deep copy, |
|
3064 use `clone()`. |
|
3065 |
|
3066 @method merge |
|
3067 @param {Object} objects* One or more objects to merge. |
|
3068 @return {Object} A new merged object. |
|
3069 **/ |
|
3070 Y.merge = function () { |
|
3071 var i = 0, |
|
3072 len = arguments.length, |
|
3073 result = {}, |
|
3074 key, |
|
3075 obj; |
|
3076 |
|
3077 for (; i < len; ++i) { |
|
3078 obj = arguments[i]; |
|
3079 |
|
3080 for (key in obj) { |
|
3081 if (hasOwn.call(obj, key)) { |
|
3082 result[key] = obj[key]; |
|
3083 } |
|
3084 } |
|
3085 } |
|
3086 |
|
3087 return result; |
|
3088 }; |
|
3089 |
|
3090 /** |
|
3091 Mixes _supplier_'s properties into _receiver_. |
|
3092 |
|
3093 Properties on _receiver_ or _receiver_'s prototype will not be overwritten or |
|
3094 shadowed unless the _overwrite_ parameter is `true`, and will not be merged |
|
3095 unless the _merge_ parameter is `true`. |
|
3096 |
|
3097 In the default mode (0), only properties the supplier owns are copied (prototype |
|
3098 properties are not copied). The following copying modes are available: |
|
3099 |
|
3100 * `0`: _Default_. Object to object. |
|
3101 * `1`: Prototype to prototype. |
|
3102 * `2`: Prototype to prototype and object to object. |
|
3103 * `3`: Prototype to object. |
|
3104 * `4`: Object to prototype. |
|
3105 |
|
3106 @method mix |
|
3107 @param {Function|Object} receiver The object or function to receive the mixed |
|
3108 properties. |
|
3109 @param {Function|Object} supplier The object or function supplying the |
|
3110 properties to be mixed. |
|
3111 @param {Boolean} [overwrite=false] If `true`, properties that already exist |
|
3112 on the receiver will be overwritten with properties from the supplier. |
|
3113 @param {String[]} [whitelist] An array of property names to copy. If |
|
3114 specified, only the whitelisted properties will be copied, and all others |
|
3115 will be ignored. |
|
3116 @param {Number} [mode=0] Mix mode to use. See above for available modes. |
|
3117 @param {Boolean} [merge=false] If `true`, objects and arrays that already |
|
3118 exist on the receiver will have the corresponding object/array from the |
|
3119 supplier merged into them, rather than being skipped or overwritten. When |
|
3120 both _overwrite_ and _merge_ are `true`, _merge_ takes precedence. |
|
3121 @return {Function|Object|YUI} The receiver, or the YUI instance if the |
|
3122 specified receiver is falsy. |
|
3123 **/ |
|
3124 Y.mix = function(receiver, supplier, overwrite, whitelist, mode, merge) { |
|
3125 var alwaysOverwrite, exists, from, i, key, len, to; |
|
3126 |
|
3127 // If no supplier is given, we return the receiver. If no receiver is given, |
|
3128 // we return Y. Returning Y doesn't make much sense to me, but it's |
|
3129 // grandfathered in for backcompat reasons. |
|
3130 if (!receiver || !supplier) { |
|
3131 return receiver || Y; |
|
3132 } |
|
3133 |
|
3134 if (mode) { |
|
3135 // In mode 2 (prototype to prototype and object to object), we recurse |
|
3136 // once to do the proto to proto mix. The object to object mix will be |
|
3137 // handled later on. |
|
3138 if (mode === 2) { |
|
3139 Y.mix(receiver.prototype, supplier.prototype, overwrite, |
|
3140 whitelist, 0, merge); |
|
3141 } |
|
3142 |
|
3143 // Depending on which mode is specified, we may be copying from or to |
|
3144 // the prototypes of the supplier and receiver. |
|
3145 from = mode === 1 || mode === 3 ? supplier.prototype : supplier; |
|
3146 to = mode === 1 || mode === 4 ? receiver.prototype : receiver; |
|
3147 |
|
3148 // If either the supplier or receiver doesn't actually have a |
|
3149 // prototype property, then we could end up with an undefined `from` |
|
3150 // or `to`. If that happens, we abort and return the receiver. |
|
3151 if (!from || !to) { |
|
3152 return receiver; |
|
3153 } |
|
3154 } else { |
|
3155 from = supplier; |
|
3156 to = receiver; |
|
3157 } |
|
3158 |
|
3159 // If `overwrite` is truthy and `merge` is falsy, then we can skip a |
|
3160 // property existence check on each iteration and save some time. |
|
3161 alwaysOverwrite = overwrite && !merge; |
|
3162 |
|
3163 if (whitelist) { |
|
3164 for (i = 0, len = whitelist.length; i < len; ++i) { |
|
3165 key = whitelist[i]; |
|
3166 |
|
3167 // We call `Object.prototype.hasOwnProperty` instead of calling |
|
3168 // `hasOwnProperty` on the object itself, since the object's |
|
3169 // `hasOwnProperty` method may have been overridden or removed. |
|
3170 // Also, some native objects don't implement a `hasOwnProperty` |
|
3171 // method. |
|
3172 if (!hasOwn.call(from, key)) { |
|
3173 continue; |
|
3174 } |
|
3175 |
|
3176 // The `key in to` check here is (sadly) intentional for backwards |
|
3177 // compatibility reasons. It prevents undesired shadowing of |
|
3178 // prototype members on `to`. |
|
3179 exists = alwaysOverwrite ? false : key in to; |
|
3180 |
|
3181 if (merge && exists && isObject(to[key], true) |
|
3182 && isObject(from[key], true)) { |
|
3183 // If we're in merge mode, and the key is present on both |
|
3184 // objects, and the value on both objects is either an object or |
|
3185 // an array (but not a function), then we recurse to merge the |
|
3186 // `from` value into the `to` value instead of overwriting it. |
|
3187 // |
|
3188 // Note: It's intentional that the whitelist isn't passed to the |
|
3189 // recursive call here. This is legacy behavior that lots of |
|
3190 // code still depends on. |
|
3191 Y.mix(to[key], from[key], overwrite, null, 0, merge); |
|
3192 } else if (overwrite || !exists) { |
|
3193 // We're not in merge mode, so we'll only copy the `from` value |
|
3194 // to the `to` value if we're in overwrite mode or if the |
|
3195 // current key doesn't exist on the `to` object. |
|
3196 to[key] = from[key]; |
|
3197 } |
|
3198 } |
|
3199 } else { |
|
3200 for (key in from) { |
|
3201 // The code duplication here is for runtime performance reasons. |
|
3202 // Combining whitelist and non-whitelist operations into a single |
|
3203 // loop or breaking the shared logic out into a function both result |
|
3204 // in worse performance, and Y.mix is critical enough that the byte |
|
3205 // tradeoff is worth it. |
|
3206 if (!hasOwn.call(from, key)) { |
|
3207 continue; |
|
3208 } |
|
3209 |
|
3210 // The `key in to` check here is (sadly) intentional for backwards |
|
3211 // compatibility reasons. It prevents undesired shadowing of |
|
3212 // prototype members on `to`. |
|
3213 exists = alwaysOverwrite ? false : key in to; |
|
3214 |
|
3215 if (merge && exists && isObject(to[key], true) |
|
3216 && isObject(from[key], true)) { |
|
3217 Y.mix(to[key], from[key], overwrite, null, 0, merge); |
|
3218 } else if (overwrite || !exists) { |
|
3219 to[key] = from[key]; |
|
3220 } |
|
3221 } |
|
3222 |
|
3223 // If this is an IE browser with the JScript enumeration bug, force |
|
3224 // enumeration of the buggy properties by making a recursive call with |
|
3225 // the buggy properties as the whitelist. |
|
3226 if (Y.Object._hasEnumBug) { |
|
3227 Y.mix(to, from, overwrite, Y.Object._forceEnum, mode, merge); |
|
3228 } |
|
3229 } |
|
3230 |
|
3231 return receiver; |
|
3232 }; |
|
3233 /** |
|
3234 * The YUI module contains the components required for building the YUI |
|
3235 * seed file. This includes the script loading mechanism, a simple queue, |
|
3236 * and the core utilities for the library. |
|
3237 * @module yui |
|
3238 * @submodule yui-base |
|
3239 */ |
|
3240 |
|
3241 /** |
|
3242 * Adds utilities to the YUI instance for working with objects. |
|
3243 * |
|
3244 * @class Object |
|
3245 */ |
|
3246 |
|
3247 var Lang = Y.Lang, |
|
3248 hasOwn = Object.prototype.hasOwnProperty, |
|
3249 |
|
3250 UNDEFINED, // <-- Note the comma. We're still declaring vars. |
|
3251 |
|
3252 /** |
|
3253 * Returns a new object that uses _obj_ as its prototype. This method wraps the |
|
3254 * native ES5 `Object.create()` method if available, but doesn't currently |
|
3255 * pass through `Object.create()`'s second argument (properties) in order to |
|
3256 * ensure compatibility with older browsers. |
|
3257 * |
|
3258 * @method () |
|
3259 * @param {Object} obj Prototype object. |
|
3260 * @return {Object} New object using _obj_ as its prototype. |
|
3261 * @static |
|
3262 */ |
|
3263 O = Y.Object = Lang._isNative(Object.create) ? function (obj) { |
|
3264 // We currently wrap the native Object.create instead of simply aliasing it |
|
3265 // to ensure consistency with our fallback shim, which currently doesn't |
|
3266 // support Object.create()'s second argument (properties). Once we have a |
|
3267 // safe fallback for the properties arg, we can stop wrapping |
|
3268 // Object.create(). |
|
3269 return Object.create(obj); |
|
3270 } : (function () { |
|
3271 // Reusable constructor function for the Object.create() shim. |
|
3272 function F() {} |
|
3273 |
|
3274 // The actual shim. |
|
3275 return function (obj) { |
|
3276 F.prototype = obj; |
|
3277 return new F(); |
|
3278 }; |
|
3279 }()), |
|
3280 |
|
3281 /** |
|
3282 * Property names that IE doesn't enumerate in for..in loops, even when they |
|
3283 * should be enumerable. When `_hasEnumBug` is `true`, it's necessary to |
|
3284 * manually enumerate these properties. |
|
3285 * |
|
3286 * @property _forceEnum |
|
3287 * @type String[] |
|
3288 * @protected |
|
3289 * @static |
|
3290 */ |
|
3291 forceEnum = O._forceEnum = [ |
|
3292 'hasOwnProperty', |
|
3293 'isPrototypeOf', |
|
3294 'propertyIsEnumerable', |
|
3295 'toString', |
|
3296 'toLocaleString', |
|
3297 'valueOf' |
|
3298 ], |
|
3299 |
|
3300 /** |
|
3301 * `true` if this browser has the JScript enumeration bug that prevents |
|
3302 * enumeration of the properties named in the `_forceEnum` array, `false` |
|
3303 * otherwise. |
|
3304 * |
|
3305 * See: |
|
3306 * - <https://developer.mozilla.org/en/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug> |
|
3307 * - <http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation> |
|
3308 * |
|
3309 * @property _hasEnumBug |
|
3310 * @type Boolean |
|
3311 * @protected |
|
3312 * @static |
|
3313 */ |
|
3314 hasEnumBug = O._hasEnumBug = !{valueOf: 0}.propertyIsEnumerable('valueOf'), |
|
3315 |
|
3316 /** |
|
3317 * `true` if this browser incorrectly considers the `prototype` property of |
|
3318 * functions to be enumerable. Currently known to affect Opera 11.50 and Android 2.3.x. |
|
3319 * |
|
3320 * @property _hasProtoEnumBug |
|
3321 * @type Boolean |
|
3322 * @protected |
|
3323 * @static |
|
3324 */ |
|
3325 hasProtoEnumBug = O._hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'), |
|
3326 |
|
3327 /** |
|
3328 * Returns `true` if _key_ exists on _obj_, `false` if _key_ doesn't exist or |
|
3329 * exists only on _obj_'s prototype. This is essentially a safer version of |
|
3330 * `obj.hasOwnProperty()`. |
|
3331 * |
|
3332 * @method owns |
|
3333 * @param {Object} obj Object to test. |
|
3334 * @param {String} key Property name to look for. |
|
3335 * @return {Boolean} `true` if _key_ exists on _obj_, `false` otherwise. |
|
3336 * @static |
|
3337 */ |
|
3338 owns = O.owns = function (obj, key) { |
|
3339 return !!obj && hasOwn.call(obj, key); |
|
3340 }; // <-- End of var declarations. |
|
3341 |
|
3342 /** |
|
3343 * Alias for `owns()`. |
|
3344 * |
|
3345 * @method hasKey |
|
3346 * @param {Object} obj Object to test. |
|
3347 * @param {String} key Property name to look for. |
|
3348 * @return {Boolean} `true` if _key_ exists on _obj_, `false` otherwise. |
|
3349 * @static |
|
3350 */ |
|
3351 O.hasKey = owns; |
|
3352 |
|
3353 /** |
|
3354 * Returns an array containing the object's enumerable keys. Does not include |
|
3355 * prototype keys or non-enumerable keys. |
|
3356 * |
|
3357 * Note that keys are returned in enumeration order (that is, in the same order |
|
3358 * that they would be enumerated by a `for-in` loop), which may not be the same |
|
3359 * as the order in which they were defined. |
|
3360 * |
|
3361 * This method is an alias for the native ES5 `Object.keys()` method if |
|
3362 * available and non-buggy. The Opera 11.50 and Android 2.3.x versions of |
|
3363 * `Object.keys()` have an inconsistency as they consider `prototype` to be |
|
3364 * enumerable, so a non-native shim is used to rectify the difference. |
|
3365 * |
|
3366 * @example |
|
3367 * |
|
3368 * Y.Object.keys({a: 'foo', b: 'bar', c: 'baz'}); |
|
3369 * // => ['a', 'b', 'c'] |
|
3370 * |
|
3371 * @method keys |
|
3372 * @param {Object} obj An object. |
|
3373 * @return {String[]} Array of keys. |
|
3374 * @static |
|
3375 */ |
|
3376 O.keys = Lang._isNative(Object.keys) && !hasProtoEnumBug ? Object.keys : function (obj) { |
|
3377 if (!Lang.isObject(obj)) { |
|
3378 throw new TypeError('Object.keys called on a non-object'); |
|
3379 } |
|
3380 |
|
3381 var keys = [], |
|
3382 i, key, len; |
|
3383 |
|
3384 if (hasProtoEnumBug && typeof obj === 'function') { |
|
3385 for (key in obj) { |
|
3386 if (owns(obj, key) && key !== 'prototype') { |
|
3387 keys.push(key); |
|
3388 } |
|
3389 } |
|
3390 } else { |
|
3391 for (key in obj) { |
|
3392 if (owns(obj, key)) { |
|
3393 keys.push(key); |
|
3394 } |
|
3395 } |
|
3396 } |
|
3397 |
|
3398 if (hasEnumBug) { |
|
3399 for (i = 0, len = forceEnum.length; i < len; ++i) { |
|
3400 key = forceEnum[i]; |
|
3401 |
|
3402 if (owns(obj, key)) { |
|
3403 keys.push(key); |
|
3404 } |
|
3405 } |
|
3406 } |
|
3407 |
|
3408 return keys; |
|
3409 }; |
|
3410 |
|
3411 /** |
|
3412 * Returns an array containing the values of the object's enumerable keys. |
|
3413 * |
|
3414 * Note that values are returned in enumeration order (that is, in the same |
|
3415 * order that they would be enumerated by a `for-in` loop), which may not be the |
|
3416 * same as the order in which they were defined. |
|
3417 * |
|
3418 * @example |
|
3419 * |
|
3420 * Y.Object.values({a: 'foo', b: 'bar', c: 'baz'}); |
|
3421 * // => ['foo', 'bar', 'baz'] |
|
3422 * |
|
3423 * @method values |
|
3424 * @param {Object} obj An object. |
|
3425 * @return {Array} Array of values. |
|
3426 * @static |
|
3427 */ |
|
3428 O.values = function (obj) { |
|
3429 var keys = O.keys(obj), |
|
3430 i = 0, |
|
3431 len = keys.length, |
|
3432 values = []; |
|
3433 |
|
3434 for (; i < len; ++i) { |
|
3435 values.push(obj[keys[i]]); |
|
3436 } |
|
3437 |
|
3438 return values; |
|
3439 }; |
|
3440 |
|
3441 /** |
|
3442 * Returns the number of enumerable keys owned by an object. |
|
3443 * |
|
3444 * @method size |
|
3445 * @param {Object} obj An object. |
|
3446 * @return {Number} The object's size. |
|
3447 * @static |
|
3448 */ |
|
3449 O.size = function (obj) { |
|
3450 try { |
|
3451 return O.keys(obj).length; |
|
3452 } catch (ex) { |
|
3453 return 0; // Legacy behavior for non-objects. |
|
3454 } |
|
3455 }; |
|
3456 |
|
3457 /** |
|
3458 * Returns `true` if the object owns an enumerable property with the specified |
|
3459 * value. |
|
3460 * |
|
3461 * @method hasValue |
|
3462 * @param {Object} obj An object. |
|
3463 * @param {any} value The value to search for. |
|
3464 * @return {Boolean} `true` if _obj_ contains _value_, `false` otherwise. |
|
3465 * @static |
|
3466 */ |
|
3467 O.hasValue = function (obj, value) { |
|
3468 return Y.Array.indexOf(O.values(obj), value) > -1; |
|
3469 }; |
|
3470 |
|
3471 /** |
|
3472 * Executes a function on each enumerable property in _obj_. The function |
|
3473 * receives the value, the key, and the object itself as parameters (in that |
|
3474 * order). |
|
3475 * |
|
3476 * By default, only properties owned by _obj_ are enumerated. To include |
|
3477 * prototype properties, set the _proto_ parameter to `true`. |
|
3478 * |
|
3479 * @method each |
|
3480 * @param {Object} obj Object to enumerate. |
|
3481 * @param {Function} fn Function to execute on each enumerable property. |
|
3482 * @param {mixed} fn.value Value of the current property. |
|
3483 * @param {String} fn.key Key of the current property. |
|
3484 * @param {Object} fn.obj Object being enumerated. |
|
3485 * @param {Object} [thisObj] `this` object to use when calling _fn_. |
|
3486 * @param {Boolean} [proto=false] Include prototype properties. |
|
3487 * @return {YUI} the YUI instance. |
|
3488 * @chainable |
|
3489 * @static |
|
3490 */ |
|
3491 O.each = function (obj, fn, thisObj, proto) { |
|
3492 var key; |
|
3493 |
|
3494 for (key in obj) { |
|
3495 if (proto || owns(obj, key)) { |
|
3496 fn.call(thisObj || Y, obj[key], key, obj); |
|
3497 } |
|
3498 } |
|
3499 |
|
3500 return Y; |
|
3501 }; |
|
3502 |
|
3503 /** |
|
3504 * Executes a function on each enumerable property in _obj_, but halts if the |
|
3505 * function returns a truthy value. The function receives the value, the key, |
|
3506 * and the object itself as paramters (in that order). |
|
3507 * |
|
3508 * By default, only properties owned by _obj_ are enumerated. To include |
|
3509 * prototype properties, set the _proto_ parameter to `true`. |
|
3510 * |
|
3511 * @method some |
|
3512 * @param {Object} obj Object to enumerate. |
|
3513 * @param {Function} fn Function to execute on each enumerable property. |
|
3514 * @param {mixed} fn.value Value of the current property. |
|
3515 * @param {String} fn.key Key of the current property. |
|
3516 * @param {Object} fn.obj Object being enumerated. |
|
3517 * @param {Object} [thisObj] `this` object to use when calling _fn_. |
|
3518 * @param {Boolean} [proto=false] Include prototype properties. |
|
3519 * @return {Boolean} `true` if any execution of _fn_ returns a truthy value, |
|
3520 * `false` otherwise. |
|
3521 * @static |
|
3522 */ |
|
3523 O.some = function (obj, fn, thisObj, proto) { |
|
3524 var key; |
|
3525 |
|
3526 for (key in obj) { |
|
3527 if (proto || owns(obj, key)) { |
|
3528 if (fn.call(thisObj || Y, obj[key], key, obj)) { |
|
3529 return true; |
|
3530 } |
|
3531 } |
|
3532 } |
|
3533 |
|
3534 return false; |
|
3535 }; |
|
3536 |
|
3537 /** |
|
3538 * Retrieves the sub value at the provided path, |
|
3539 * from the value object provided. |
|
3540 * |
|
3541 * @method getValue |
|
3542 * @static |
|
3543 * @param o The object from which to extract the property value. |
|
3544 * @param path {Array} A path array, specifying the object traversal path |
|
3545 * from which to obtain the sub value. |
|
3546 * @return {Any} The value stored in the path, undefined if not found, |
|
3547 * undefined if the source is not an object. Returns the source object |
|
3548 * if an empty path is provided. |
|
3549 */ |
|
3550 O.getValue = function(o, path) { |
|
3551 if (!Lang.isObject(o)) { |
|
3552 return UNDEFINED; |
|
3553 } |
|
3554 |
|
3555 var i, |
|
3556 p = Y.Array(path), |
|
3557 l = p.length; |
|
3558 |
|
3559 for (i = 0; o !== UNDEFINED && i < l; i++) { |
|
3560 o = o[p[i]]; |
|
3561 } |
|
3562 |
|
3563 return o; |
|
3564 }; |
|
3565 |
|
3566 /** |
|
3567 * Sets the sub-attribute value at the provided path on the |
|
3568 * value object. Returns the modified value object, or |
|
3569 * undefined if the path is invalid. |
|
3570 * |
|
3571 * @method setValue |
|
3572 * @static |
|
3573 * @param o The object on which to set the sub value. |
|
3574 * @param path {Array} A path array, specifying the object traversal path |
|
3575 * at which to set the sub value. |
|
3576 * @param val {Any} The new value for the sub-attribute. |
|
3577 * @return {Object} The modified object, with the new sub value set, or |
|
3578 * undefined, if the path was invalid. |
|
3579 */ |
|
3580 O.setValue = function(o, path, val) { |
|
3581 var i, |
|
3582 p = Y.Array(path), |
|
3583 leafIdx = p.length - 1, |
|
3584 ref = o; |
|
3585 |
|
3586 if (leafIdx >= 0) { |
|
3587 for (i = 0; ref !== UNDEFINED && i < leafIdx; i++) { |
|
3588 ref = ref[p[i]]; |
|
3589 } |
|
3590 |
|
3591 if (ref !== UNDEFINED) { |
|
3592 ref[p[i]] = val; |
|
3593 } else { |
|
3594 return UNDEFINED; |
|
3595 } |
|
3596 } |
|
3597 |
|
3598 return o; |
|
3599 }; |
|
3600 |
|
3601 /** |
|
3602 * Returns `true` if the object has no enumerable properties of its own. |
|
3603 * |
|
3604 * @method isEmpty |
|
3605 * @param {Object} obj An object. |
|
3606 * @return {Boolean} `true` if the object is empty. |
|
3607 * @static |
|
3608 * @since 3.2.0 |
|
3609 */ |
|
3610 O.isEmpty = function (obj) { |
|
3611 return !O.keys(Object(obj)).length; |
|
3612 }; |
|
3613 /** |
|
3614 * The YUI module contains the components required for building the YUI seed |
|
3615 * file. This includes the script loading mechanism, a simple queue, and the |
|
3616 * core utilities for the library. |
|
3617 * @module yui |
|
3618 * @submodule yui-base |
|
3619 */ |
|
3620 |
|
3621 /** |
|
3622 * YUI user agent detection. |
|
3623 * Do not fork for a browser if it can be avoided. Use feature detection when |
|
3624 * you can. Use the user agent as a last resort. For all fields listed |
|
3625 * as @type float, UA stores a version number for the browser engine, |
|
3626 * 0 otherwise. This value may or may not map to the version number of |
|
3627 * the browser using the engine. The value is presented as a float so |
|
3628 * that it can easily be used for boolean evaluation as well as for |
|
3629 * looking for a particular range of versions. Because of this, |
|
3630 * some of the granularity of the version info may be lost. The fields that |
|
3631 * are @type string default to null. The API docs list the values that |
|
3632 * these fields can have. |
|
3633 * @class UA |
|
3634 * @static |
|
3635 */ |
|
3636 |
|
3637 /** |
|
3638 * Static method on `YUI.Env` for parsing a UA string. Called at instantiation |
|
3639 * to populate `Y.UA`. |
|
3640 * |
|
3641 * @static |
|
3642 * @method parseUA |
|
3643 * @param {String} [subUA=navigator.userAgent] UA string to parse |
|
3644 * @return {Object} The Y.UA object |
|
3645 */ |
|
3646 YUI.Env.parseUA = function(subUA) { |
|
3647 |
|
3648 var numberify = function(s) { |
|
3649 var c = 0; |
|
3650 return parseFloat(s.replace(/\./g, function() { |
|
3651 return (c++ === 1) ? '' : '.'; |
|
3652 })); |
|
3653 }, |
|
3654 |
|
3655 win = Y.config.win, |
|
3656 |
|
3657 nav = win && win.navigator, |
|
3658 |
|
3659 o = { |
|
3660 |
|
3661 /** |
|
3662 * Internet Explorer version number or 0. Example: 6 |
|
3663 * @property ie |
|
3664 * @type float |
|
3665 * @static |
|
3666 */ |
|
3667 ie: 0, |
|
3668 |
|
3669 /** |
|
3670 * Opera version number or 0. Example: 9.2 |
|
3671 * @property opera |
|
3672 * @type float |
|
3673 * @static |
|
3674 */ |
|
3675 opera: 0, |
|
3676 |
|
3677 /** |
|
3678 * Gecko engine revision number. Will evaluate to 1 if Gecko |
|
3679 * is detected but the revision could not be found. Other browsers |
|
3680 * will be 0. Example: 1.8 |
|
3681 * <pre> |
|
3682 * Firefox 1.0.0.4: 1.7.8 <-- Reports 1.7 |
|
3683 * Firefox 1.5.0.9: 1.8.0.9 <-- 1.8 |
|
3684 * Firefox 2.0.0.3: 1.8.1.3 <-- 1.81 |
|
3685 * Firefox 3.0 <-- 1.9 |
|
3686 * Firefox 3.5 <-- 1.91 |
|
3687 * </pre> |
|
3688 * @property gecko |
|
3689 * @type float |
|
3690 * @static |
|
3691 */ |
|
3692 gecko: 0, |
|
3693 |
|
3694 /** |
|
3695 * AppleWebKit version. KHTML browsers that are not WebKit browsers |
|
3696 * will evaluate to 1, other browsers 0. Example: 418.9 |
|
3697 * <pre> |
|
3698 * Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the |
|
3699 * latest available for Mac OSX 10.3. |
|
3700 * Safari 2.0.2: 416 <-- hasOwnProperty introduced |
|
3701 * Safari 2.0.4: 418 <-- preventDefault fixed |
|
3702 * Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run |
|
3703 * different versions of webkit |
|
3704 * Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been |
|
3705 * updated, but not updated |
|
3706 * to the latest patch. |
|
3707 * Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native |
|
3708 * SVG and many major issues fixed). |
|
3709 * Safari 3.0.4 (523.12) 523.12 <-- First Tiger release - automatic |
|
3710 * update from 2.x via the 10.4.11 OS patch. |
|
3711 * Webkit nightly 1/2008:525+ <-- Supports DOMContentLoaded event. |
|
3712 * yahoo.com user agent hack removed. |
|
3713 * </pre> |
|
3714 * http://en.wikipedia.org/wiki/Safari_version_history |
|
3715 * @property webkit |
|
3716 * @type float |
|
3717 * @static |
|
3718 */ |
|
3719 webkit: 0, |
|
3720 |
|
3721 /** |
|
3722 * Safari will be detected as webkit, but this property will also |
|
3723 * be populated with the Safari version number |
|
3724 * @property safari |
|
3725 * @type float |
|
3726 * @static |
|
3727 */ |
|
3728 safari: 0, |
|
3729 |
|
3730 /** |
|
3731 * Chrome will be detected as webkit, but this property will also |
|
3732 * be populated with the Chrome version number |
|
3733 * @property chrome |
|
3734 * @type float |
|
3735 * @static |
|
3736 */ |
|
3737 chrome: 0, |
|
3738 |
|
3739 /** |
|
3740 * The mobile property will be set to a string containing any relevant |
|
3741 * user agent information when a modern mobile browser is detected. |
|
3742 * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series |
|
3743 * devices with the WebKit-based browser, and Opera Mini. |
|
3744 * @property mobile |
|
3745 * @type string |
|
3746 * @default null |
|
3747 * @static |
|
3748 */ |
|
3749 mobile: null, |
|
3750 |
|
3751 /** |
|
3752 * Adobe AIR version number or 0. Only populated if webkit is detected. |
|
3753 * Example: 1.0 |
|
3754 * @property air |
|
3755 * @type float |
|
3756 */ |
|
3757 air: 0, |
|
3758 /** |
|
3759 * PhantomJS version number or 0. Only populated if webkit is detected. |
|
3760 * Example: 1.0 |
|
3761 * @property phantomjs |
|
3762 * @type float |
|
3763 */ |
|
3764 phantomjs: 0, |
|
3765 /** |
|
3766 * Detects Apple iPad's OS version |
|
3767 * @property ipad |
|
3768 * @type float |
|
3769 * @static |
|
3770 */ |
|
3771 ipad: 0, |
|
3772 /** |
|
3773 * Detects Apple iPhone's OS version |
|
3774 * @property iphone |
|
3775 * @type float |
|
3776 * @static |
|
3777 */ |
|
3778 iphone: 0, |
|
3779 /** |
|
3780 * Detects Apples iPod's OS version |
|
3781 * @property ipod |
|
3782 * @type float |
|
3783 * @static |
|
3784 */ |
|
3785 ipod: 0, |
|
3786 /** |
|
3787 * General truthy check for iPad, iPhone or iPod |
|
3788 * @property ios |
|
3789 * @type Boolean |
|
3790 * @default null |
|
3791 * @static |
|
3792 */ |
|
3793 ios: null, |
|
3794 /** |
|
3795 * Detects Googles Android OS version |
|
3796 * @property android |
|
3797 * @type float |
|
3798 * @static |
|
3799 */ |
|
3800 android: 0, |
|
3801 /** |
|
3802 * Detects Kindle Silk |
|
3803 * @property silk |
|
3804 * @type float |
|
3805 * @static |
|
3806 */ |
|
3807 silk: 0, |
|
3808 /** |
|
3809 * Detects Kindle Silk Acceleration |
|
3810 * @property accel |
|
3811 * @type Boolean |
|
3812 * @static |
|
3813 */ |
|
3814 accel: false, |
|
3815 /** |
|
3816 * Detects Palms WebOS version |
|
3817 * @property webos |
|
3818 * @type float |
|
3819 * @static |
|
3820 */ |
|
3821 webos: 0, |
|
3822 |
|
3823 /** |
|
3824 * Google Caja version number or 0. |
|
3825 * @property caja |
|
3826 * @type float |
|
3827 */ |
|
3828 caja: nav && nav.cajaVersion, |
|
3829 |
|
3830 /** |
|
3831 * Set to true if the page appears to be in SSL |
|
3832 * @property secure |
|
3833 * @type boolean |
|
3834 * @static |
|
3835 */ |
|
3836 secure: false, |
|
3837 |
|
3838 /** |
|
3839 * The operating system. Currently only detecting windows or macintosh |
|
3840 * @property os |
|
3841 * @type string |
|
3842 * @default null |
|
3843 * @static |
|
3844 */ |
|
3845 os: null, |
|
3846 |
|
3847 /** |
|
3848 * The Nodejs Version |
|
3849 * @property nodejs |
|
3850 * @type float |
|
3851 * @default 0 |
|
3852 * @static |
|
3853 */ |
|
3854 nodejs: 0, |
|
3855 /** |
|
3856 * Window8/IE10 Application host environment |
|
3857 * @property winjs |
|
3858 * @type Boolean |
|
3859 * @static |
|
3860 */ |
|
3861 winjs: !!((typeof Windows !== "undefined") && Windows.System), |
|
3862 /** |
|
3863 * Are touch/msPointer events available on this device |
|
3864 * @property touchEnabled |
|
3865 * @type Boolean |
|
3866 * @static |
|
3867 */ |
|
3868 touchEnabled: false |
|
3869 }, |
|
3870 |
|
3871 ua = subUA || nav && nav.userAgent, |
|
3872 |
|
3873 loc = win && win.location, |
|
3874 |
|
3875 href = loc && loc.href, |
|
3876 |
|
3877 m; |
|
3878 |
|
3879 /** |
|
3880 * The User Agent string that was parsed |
|
3881 * @property userAgent |
|
3882 * @type String |
|
3883 * @static |
|
3884 */ |
|
3885 o.userAgent = ua; |
|
3886 |
|
3887 |
|
3888 o.secure = href && (href.toLowerCase().indexOf('https') === 0); |
|
3889 |
|
3890 if (ua) { |
|
3891 |
|
3892 if ((/windows|win32/i).test(ua)) { |
|
3893 o.os = 'windows'; |
|
3894 } else if ((/macintosh|mac_powerpc/i).test(ua)) { |
|
3895 o.os = 'macintosh'; |
|
3896 } else if ((/android/i).test(ua)) { |
|
3897 o.os = 'android'; |
|
3898 } else if ((/symbos/i).test(ua)) { |
|
3899 o.os = 'symbos'; |
|
3900 } else if ((/linux/i).test(ua)) { |
|
3901 o.os = 'linux'; |
|
3902 } else if ((/rhino/i).test(ua)) { |
|
3903 o.os = 'rhino'; |
|
3904 } |
|
3905 |
|
3906 // Modern KHTML browsers should qualify as Safari X-Grade |
|
3907 if ((/KHTML/).test(ua)) { |
|
3908 o.webkit = 1; |
|
3909 } |
|
3910 if ((/IEMobile|XBLWP7/).test(ua)) { |
|
3911 o.mobile = 'windows'; |
|
3912 } |
|
3913 if ((/Fennec/).test(ua)) { |
|
3914 o.mobile = 'gecko'; |
|
3915 } |
|
3916 // Modern WebKit browsers are at least X-Grade |
|
3917 m = ua.match(/AppleWebKit\/([^\s]*)/); |
|
3918 if (m && m[1]) { |
|
3919 o.webkit = numberify(m[1]); |
|
3920 o.safari = o.webkit; |
|
3921 |
|
3922 if (/PhantomJS/.test(ua)) { |
|
3923 m = ua.match(/PhantomJS\/([^\s]*)/); |
|
3924 if (m && m[1]) { |
|
3925 o.phantomjs = numberify(m[1]); |
|
3926 } |
|
3927 } |
|
3928 |
|
3929 // Mobile browser check |
|
3930 if (/ Mobile\//.test(ua) || (/iPad|iPod|iPhone/).test(ua)) { |
|
3931 o.mobile = 'Apple'; // iPhone or iPod Touch |
|
3932 |
|
3933 m = ua.match(/OS ([^\s]*)/); |
|
3934 if (m && m[1]) { |
|
3935 m = numberify(m[1].replace('_', '.')); |
|
3936 } |
|
3937 o.ios = m; |
|
3938 o.os = 'ios'; |
|
3939 o.ipad = o.ipod = o.iphone = 0; |
|
3940 |
|
3941 m = ua.match(/iPad|iPod|iPhone/); |
|
3942 if (m && m[0]) { |
|
3943 o[m[0].toLowerCase()] = o.ios; |
|
3944 } |
|
3945 } else { |
|
3946 m = ua.match(/NokiaN[^\/]*|webOS\/\d\.\d/); |
|
3947 if (m) { |
|
3948 // Nokia N-series, webOS, ex: NokiaN95 |
|
3949 o.mobile = m[0]; |
|
3950 } |
|
3951 if (/webOS/.test(ua)) { |
|
3952 o.mobile = 'WebOS'; |
|
3953 m = ua.match(/webOS\/([^\s]*);/); |
|
3954 if (m && m[1]) { |
|
3955 o.webos = numberify(m[1]); |
|
3956 } |
|
3957 } |
|
3958 if (/ Android/.test(ua)) { |
|
3959 if (/Mobile/.test(ua)) { |
|
3960 o.mobile = 'Android'; |
|
3961 } |
|
3962 m = ua.match(/Android ([^\s]*);/); |
|
3963 if (m && m[1]) { |
|
3964 o.android = numberify(m[1]); |
|
3965 } |
|
3966 |
|
3967 } |
|
3968 if (/Silk/.test(ua)) { |
|
3969 m = ua.match(/Silk\/([^\s]*)/); |
|
3970 if (m && m[1]) { |
|
3971 o.silk = numberify(m[1]); |
|
3972 } |
|
3973 if (!o.android) { |
|
3974 o.android = 2.34; //Hack for desktop mode in Kindle |
|
3975 o.os = 'Android'; |
|
3976 } |
|
3977 if (/Accelerated=true/.test(ua)) { |
|
3978 o.accel = true; |
|
3979 } |
|
3980 } |
|
3981 } |
|
3982 |
|
3983 m = ua.match(/OPR\/(\d+\.\d+)/); |
|
3984 |
|
3985 if (m && m[1]) { |
|
3986 // Opera 15+ with Blink (pretends to be both Chrome and Safari) |
|
3987 o.opera = numberify(m[1]); |
|
3988 } else { |
|
3989 m = ua.match(/(Chrome|CrMo|CriOS)\/([^\s]*)/); |
|
3990 |
|
3991 if (m && m[1] && m[2]) { |
|
3992 o.chrome = numberify(m[2]); // Chrome |
|
3993 o.safari = 0; //Reset safari back to 0 |
|
3994 if (m[1] === 'CrMo') { |
|
3995 o.mobile = 'chrome'; |
|
3996 } |
|
3997 } else { |
|
3998 m = ua.match(/AdobeAIR\/([^\s]*)/); |
|
3999 if (m) { |
|
4000 o.air = m[0]; // Adobe AIR 1.0 or better |
|
4001 } |
|
4002 } |
|
4003 } |
|
4004 } |
|
4005 |
|
4006 if (!o.webkit) { // not webkit |
|
4007 // @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr) |
|
4008 if (/Opera/.test(ua)) { |
|
4009 m = ua.match(/Opera[\s\/]([^\s]*)/); |
|
4010 if (m && m[1]) { |
|
4011 o.opera = numberify(m[1]); |
|
4012 } |
|
4013 m = ua.match(/Version\/([^\s]*)/); |
|
4014 if (m && m[1]) { |
|
4015 o.opera = numberify(m[1]); // opera 10+ |
|
4016 } |
|
4017 |
|
4018 if (/Opera Mobi/.test(ua)) { |
|
4019 o.mobile = 'opera'; |
|
4020 m = ua.replace('Opera Mobi', '').match(/Opera ([^\s]*)/); |
|
4021 if (m && m[1]) { |
|
4022 o.opera = numberify(m[1]); |
|
4023 } |
|
4024 } |
|
4025 m = ua.match(/Opera Mini[^;]*/); |
|
4026 |
|
4027 if (m) { |
|
4028 o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316 |
|
4029 } |
|
4030 } else { // not opera or webkit |
|
4031 m = ua.match(/MSIE ([^;]*)|Trident.*; rv:([0-9.]+)/); |
|
4032 |
|
4033 if (m && (m[1] || m[2])) { |
|
4034 o.ie = numberify(m[1] || m[2]); |
|
4035 } else { // not opera, webkit, or ie |
|
4036 m = ua.match(/Gecko\/([^\s]*)/); |
|
4037 |
|
4038 if (m) { |
|
4039 o.gecko = 1; // Gecko detected, look for revision |
|
4040 m = ua.match(/rv:([^\s\)]*)/); |
|
4041 if (m && m[1]) { |
|
4042 o.gecko = numberify(m[1]); |
|
4043 if (/Mobile|Tablet/.test(ua)) { |
|
4044 o.mobile = "ffos"; |
|
4045 } |
|
4046 } |
|
4047 } |
|
4048 } |
|
4049 } |
|
4050 } |
|
4051 } |
|
4052 |
|
4053 //Check for known properties to tell if touch events are enabled on this device or if |
|
4054 //the number of MSPointer touchpoints on this device is greater than 0. |
|
4055 if (win && nav && !(o.chrome && o.chrome < 6)) { |
|
4056 o.touchEnabled = (("ontouchstart" in win) || (("msMaxTouchPoints" in nav) && (nav.msMaxTouchPoints > 0))); |
|
4057 } |
|
4058 |
|
4059 //It was a parsed UA, do not assign the global value. |
|
4060 if (!subUA) { |
|
4061 |
|
4062 if (typeof process === 'object') { |
|
4063 |
|
4064 if (process.versions && process.versions.node) { |
|
4065 //NodeJS |
|
4066 o.os = process.platform; |
|
4067 o.nodejs = numberify(process.versions.node); |
|
4068 } |
|
4069 } |
|
4070 |
|
4071 YUI.Env.UA = o; |
|
4072 |
|
4073 } |
|
4074 |
|
4075 return o; |
|
4076 }; |
|
4077 |
|
4078 |
|
4079 Y.UA = YUI.Env.UA || YUI.Env.parseUA(); |
|
4080 |
|
4081 /** |
|
4082 Performs a simple comparison between two version numbers, accounting for |
|
4083 standard versioning logic such as the fact that "535.8" is a lower version than |
|
4084 "535.24", even though a simple numerical comparison would indicate that it's |
|
4085 greater. Also accounts for cases such as "1.1" vs. "1.1.0", which are |
|
4086 considered equivalent. |
|
4087 |
|
4088 Returns -1 if version _a_ is lower than version _b_, 0 if they're equivalent, |
|
4089 1 if _a_ is higher than _b_. |
|
4090 |
|
4091 Versions may be numbers or strings containing numbers and dots. For example, |
|
4092 both `535` and `"535.8.10"` are acceptable. A version string containing |
|
4093 non-numeric characters, like `"535.8.beta"`, may produce unexpected results. |
|
4094 |
|
4095 @method compareVersions |
|
4096 @param {Number|String} a First version number to compare. |
|
4097 @param {Number|String} b Second version number to compare. |
|
4098 @return -1 if _a_ is lower than _b_, 0 if they're equivalent, 1 if _a_ is |
|
4099 higher than _b_. |
|
4100 **/ |
|
4101 Y.UA.compareVersions = function (a, b) { |
|
4102 var aPart, aParts, bPart, bParts, i, len; |
|
4103 |
|
4104 if (a === b) { |
|
4105 return 0; |
|
4106 } |
|
4107 |
|
4108 aParts = (a + '').split('.'); |
|
4109 bParts = (b + '').split('.'); |
|
4110 |
|
4111 for (i = 0, len = Math.max(aParts.length, bParts.length); i < len; ++i) { |
|
4112 aPart = parseInt(aParts[i], 10); |
|
4113 bPart = parseInt(bParts[i], 10); |
|
4114 |
|
4115 /*jshint expr: true*/ |
|
4116 isNaN(aPart) && (aPart = 0); |
|
4117 isNaN(bPart) && (bPart = 0); |
|
4118 |
|
4119 if (aPart < bPart) { |
|
4120 return -1; |
|
4121 } |
|
4122 |
|
4123 if (aPart > bPart) { |
|
4124 return 1; |
|
4125 } |
|
4126 } |
|
4127 |
|
4128 return 0; |
|
4129 }; |
|
4130 YUI.Env.aliases = { |
|
4131 "anim": ["anim-base","anim-color","anim-curve","anim-easing","anim-node-plugin","anim-scroll","anim-xy"], |
|
4132 "anim-shape-transform": ["anim-shape"], |
|
4133 "app": ["app-base","app-content","app-transitions","lazy-model-list","model","model-list","model-sync-rest","model-sync-local","router","view","view-node-map"], |
|
4134 "attribute": ["attribute-base","attribute-complex"], |
|
4135 "attribute-events": ["attribute-observable"], |
|
4136 "autocomplete": ["autocomplete-base","autocomplete-sources","autocomplete-list","autocomplete-plugin"], |
|
4137 "axes": ["axis-numeric","axis-category","axis-time","axis-stacked"], |
|
4138 "axes-base": ["axis-numeric-base","axis-category-base","axis-time-base","axis-stacked-base"], |
|
4139 "base": ["base-base","base-pluginhost","base-build"], |
|
4140 "cache": ["cache-base","cache-offline","cache-plugin"], |
|
4141 "charts": ["charts-base"], |
|
4142 "collection": ["array-extras","arraylist","arraylist-add","arraylist-filter","array-invoke"], |
|
4143 "color": ["color-base","color-hsl","color-harmony"], |
|
4144 "controller": ["router"], |
|
4145 "dataschema": ["dataschema-base","dataschema-json","dataschema-xml","dataschema-array","dataschema-text"], |
|
4146 "datasource": ["datasource-local","datasource-io","datasource-get","datasource-function","datasource-cache","datasource-jsonschema","datasource-xmlschema","datasource-arrayschema","datasource-textschema","datasource-polling"], |
|
4147 "datatable": ["datatable-core","datatable-table","datatable-head","datatable-body","datatable-base","datatable-column-widths","datatable-message","datatable-mutable","datatable-sort","datatable-datasource"], |
|
4148 "datatype": ["datatype-date","datatype-number","datatype-xml"], |
|
4149 "datatype-date": ["datatype-date-parse","datatype-date-format","datatype-date-math"], |
|
4150 "datatype-number": ["datatype-number-parse","datatype-number-format"], |
|
4151 "datatype-xml": ["datatype-xml-parse","datatype-xml-format"], |
|
4152 "dd": ["dd-ddm-base","dd-ddm","dd-ddm-drop","dd-drag","dd-proxy","dd-constrain","dd-drop","dd-scroll","dd-delegate"], |
|
4153 "dom": ["dom-base","dom-screen","dom-style","selector-native","selector"], |
|
4154 "editor": ["frame","editor-selection","exec-command","editor-base","editor-para","editor-br","editor-bidi","editor-tab","createlink-base"], |
|
4155 "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","event-tap"], |
|
4156 "event-custom": ["event-custom-base","event-custom-complex"], |
|
4157 "event-gestures": ["event-flick","event-move"], |
|
4158 "handlebars": ["handlebars-compiler"], |
|
4159 "highlight": ["highlight-base","highlight-accentfold"], |
|
4160 "history": ["history-base","history-hash","history-html5"], |
|
4161 "io": ["io-base","io-xdr","io-form","io-upload-iframe","io-queue"], |
|
4162 "json": ["json-parse","json-stringify"], |
|
4163 "loader": ["loader-base","loader-rollup","loader-yui3"], |
|
4164 "node": ["node-base","node-event-delegate","node-pluginhost","node-screen","node-style"], |
|
4165 "pluginhost": ["pluginhost-base","pluginhost-config"], |
|
4166 "querystring": ["querystring-parse","querystring-stringify"], |
|
4167 "recordset": ["recordset-base","recordset-sort","recordset-filter","recordset-indexer"], |
|
4168 "resize": ["resize-base","resize-proxy","resize-constrain"], |
|
4169 "slider": ["slider-base","slider-value-range","clickable-rail","range-slider"], |
|
4170 "template": ["template-base","template-micro"], |
|
4171 "text": ["text-accentfold","text-wordbreak"], |
|
4172 "widget": ["widget-base","widget-htmlparser","widget-skin","widget-uievents"] |
|
4173 }; |
|
4174 |
|
4175 |
|
4176 }, '@VERSION@', { |
|
4177 "use": [ |
|
4178 "yui-base", |
|
4179 "get", |
|
4180 "features", |
|
4181 "intl-base", |
|
4182 "yui-log", |
|
4183 "yui-log-nodejs", |
|
4184 "yui-later", |
|
4185 "loader-base", |
|
4186 "loader-rollup", |
|
4187 "loader-yui3" |
|
4188 ] |
|
4189 }); |
|
4190 YUI.add('get', function (Y, NAME) { |
|
4191 |
|
4192 /** |
|
4193 * NodeJS specific Get module used to load remote resources. |
|
4194 * It contains the same signature as the default Get module so there is no code change needed. |
|
4195 * @module get-nodejs |
|
4196 * @class GetNodeJS |
|
4197 */ |
|
4198 |
|
4199 var Module = require('module'), |
|
4200 |
|
4201 path = require('path'), |
|
4202 fs = require('fs'), |
|
4203 request = require('request'), |
|
4204 end = function(cb, msg, result) { |
|
4205 //Y.log('Get end: ' + cb.onEnd); |
|
4206 if (Y.Lang.isFunction(cb.onEnd)) { |
|
4207 cb.onEnd.call(Y, msg, result); |
|
4208 } |
|
4209 }, pass = function(cb) { |
|
4210 //Y.log('Get pass: ' + cb.onSuccess); |
|
4211 if (Y.Lang.isFunction(cb.onSuccess)) { |
|
4212 cb.onSuccess.call(Y, cb); |
|
4213 } |
|
4214 end(cb, 'success', 'success'); |
|
4215 }, fail = function(cb, er) { |
|
4216 //Y.log('Get fail: ' + er); |
|
4217 er.errors = [er]; |
|
4218 if (Y.Lang.isFunction(cb.onFailure)) { |
|
4219 cb.onFailure.call(Y, er, cb); |
|
4220 } |
|
4221 end(cb, er, 'fail'); |
|
4222 }; |
|
4223 |
|
4224 |
|
4225 Y.Get = function() { |
|
4226 }; |
|
4227 |
|
4228 //Setup the default config base path |
|
4229 Y.config.base = path.join(__dirname, '../'); |
|
4230 |
|
4231 YUI.require = require; |
|
4232 YUI.process = process; |
|
4233 |
|
4234 /** |
|
4235 * Takes the raw JS files and wraps them to be executed in the YUI context so they can be loaded |
|
4236 * into the YUI object |
|
4237 * @method _exec |
|
4238 * @private |
|
4239 * @param {String} data The JS to execute |
|
4240 * @param {String} url The path to the file that was parsed |
|
4241 * @param {Function} cb The callback to execute when this is completed |
|
4242 * @param {Error} cb.err=null Error object |
|
4243 * @param {String} cb.url The URL that was just parsed |
|
4244 */ |
|
4245 |
|
4246 Y.Get._exec = function(data, url, cb) { |
|
4247 if (data.charCodeAt(0) === 0xFEFF) { |
|
4248 data = data.slice(1); |
|
4249 } |
|
4250 |
|
4251 var mod = new Module(url, module); |
|
4252 mod.filename = url; |
|
4253 mod.paths = Module._nodeModulePaths(path.dirname(url)); |
|
4254 if (typeof YUI._getLoadHook === 'function') { |
|
4255 data = YUI._getLoadHook(data, url); |
|
4256 } |
|
4257 mod._compile('module.exports = function (YUI) {' + |
|
4258 'return (function () {'+ data + '\n;return YUI;}).apply(global);' + |
|
4259 '};', url); |
|
4260 |
|
4261 /*global YUI:true */ |
|
4262 YUI = mod.exports(YUI); |
|
4263 |
|
4264 mod.loaded = true; |
|
4265 |
|
4266 cb(null, url); |
|
4267 }; |
|
4268 |
|
4269 /** |
|
4270 * Fetches the content from a remote URL or a file from disc and passes the content |
|
4271 * off to `_exec` for parsing |
|
4272 * @method _include |
|
4273 * @private |
|
4274 * @param {String} url The URL/File path to fetch the content from |
|
4275 * @param {Function} cb The callback to fire once the content has been executed via `_exec` |
|
4276 */ |
|
4277 Y.Get._include = function (url, cb) { |
|
4278 var cfg, |
|
4279 mod, |
|
4280 self = this; |
|
4281 |
|
4282 if (url.match(/^https?:\/\//)) { |
|
4283 cfg = { |
|
4284 url: url, |
|
4285 timeout: self.timeout |
|
4286 }; |
|
4287 request(cfg, function (err, response, body) { |
|
4288 if (err) { |
|
4289 Y.log(err, 'error', 'get'); |
|
4290 cb(err, url); |
|
4291 } else { |
|
4292 Y.Get._exec(body, url, cb); |
|
4293 } |
|
4294 }); |
|
4295 } else { |
|
4296 try { |
|
4297 // Try to resolve paths relative to the module that required yui. |
|
4298 url = Module._findPath(url, Module._resolveLookupPaths(url, module.parent.parent)[1]); |
|
4299 |
|
4300 if (Y.config.useSync) { |
|
4301 //Needs to be in useSync |
|
4302 mod = fs.readFileSync(url,'utf8'); |
|
4303 } else { |
|
4304 fs.readFile(url, 'utf8', function (err, mod) { |
|
4305 if (err) { |
|
4306 cb(err, url); |
|
4307 } else { |
|
4308 Y.Get._exec(mod, url, cb); |
|
4309 } |
|
4310 }); |
|
4311 return; |
|
4312 } |
|
4313 } catch (err) { |
|
4314 cb(err, url); |
|
4315 return; |
|
4316 } |
|
4317 |
|
4318 Y.Get._exec(mod, url, cb); |
|
4319 } |
|
4320 }; |
|
4321 |
|
4322 |
|
4323 /** |
|
4324 * Override for Get.script for loading local or remote YUI modules. |
|
4325 * @method js |
|
4326 * @param {Array|String} s The URL's to load into this context |
|
4327 * @param {Object} options Transaction options |
|
4328 */ |
|
4329 Y.Get.js = function(s, options) { |
|
4330 var urls = Y.Array(s), url, i, l = urls.length, c= 0, |
|
4331 check = function() { |
|
4332 if (c === l) { |
|
4333 pass(options); |
|
4334 } |
|
4335 }; |
|
4336 |
|
4337 |
|
4338 /*jshint loopfunc: true */ |
|
4339 for (i=0; i<l; i++) { |
|
4340 url = urls[i]; |
|
4341 if (Y.Lang.isObject(url)) { |
|
4342 url = url.url; |
|
4343 } |
|
4344 |
|
4345 url = url.replace(/'/g, '%27'); |
|
4346 Y.log('URL: ' + url, 'info', 'get'); |
|
4347 Y.Get._include(url, function(err, url) { |
|
4348 if (!Y.config) { |
|
4349 Y.config = { |
|
4350 debug: true |
|
4351 }; |
|
4352 } |
|
4353 if (options.onProgress) { |
|
4354 options.onProgress.call(options.context || Y, url); |
|
4355 } |
|
4356 Y.log('After Load: ' + url, 'info', 'get'); |
|
4357 if (err) { |
|
4358 fail(options, err); |
|
4359 Y.log('----------------------------------------------------------', 'error', 'get'); |
|
4360 Y.log(err, 'error', 'get'); |
|
4361 Y.log('----------------------------------------------------------', 'error', 'get'); |
|
4362 } else { |
|
4363 c++; |
|
4364 check(); |
|
4365 } |
|
4366 }); |
|
4367 } |
|
4368 |
|
4369 //Keeping Signature in the browser. |
|
4370 return { |
|
4371 execute: function() {} |
|
4372 }; |
|
4373 }; |
|
4374 |
|
4375 /** |
|
4376 * Alias for `Y.Get.js` |
|
4377 * @method script |
|
4378 */ |
|
4379 Y.Get.script = Y.Get.js; |
|
4380 |
|
4381 //Place holder for SS Dom access |
|
4382 Y.Get.css = function(s, cb) { |
|
4383 Y.log('Y.Get.css is not supported, just reporting that it has loaded but not fetching.', 'warn', 'get'); |
|
4384 pass(cb); |
|
4385 }; |
|
4386 |
|
4387 |
|
4388 |
|
4389 }, '@VERSION@'); |
|
4390 YUI.add('features', function (Y, NAME) { |
|
4391 |
|
4392 var feature_tests = {}; |
|
4393 |
|
4394 /** |
|
4395 Contains the core of YUI's feature test architecture. |
|
4396 @module features |
|
4397 */ |
|
4398 |
|
4399 /** |
|
4400 * Feature detection |
|
4401 * @class Features |
|
4402 * @static |
|
4403 */ |
|
4404 |
|
4405 Y.mix(Y.namespace('Features'), { |
|
4406 |
|
4407 /** |
|
4408 * Object hash of all registered feature tests |
|
4409 * @property tests |
|
4410 * @type Object |
|
4411 */ |
|
4412 tests: feature_tests, |
|
4413 |
|
4414 /** |
|
4415 * Add a test to the system |
|
4416 * |
|
4417 * ``` |
|
4418 * Y.Features.add("load", "1", {}); |
|
4419 * ``` |
|
4420 * |
|
4421 * @method add |
|
4422 * @param {String} cat The category, right now only 'load' is supported |
|
4423 * @param {String} name The number sequence of the test, how it's reported in the URL or config: 1, 2, 3 |
|
4424 * @param {Object} o Object containing test properties |
|
4425 * @param {String} o.name The name of the test |
|
4426 * @param {Function} o.test The test function to execute, the only argument to the function is the `Y` instance |
|
4427 * @param {String} o.trigger The module that triggers this test. |
|
4428 */ |
|
4429 add: function(cat, name, o) { |
|
4430 feature_tests[cat] = feature_tests[cat] || {}; |
|
4431 feature_tests[cat][name] = o; |
|
4432 }, |
|
4433 /** |
|
4434 * Execute all tests of a given category and return the serialized results |
|
4435 * |
|
4436 * ``` |
|
4437 * caps=1:1;2:1;3:0 |
|
4438 * ``` |
|
4439 * @method all |
|
4440 * @param {String} cat The category to execute |
|
4441 * @param {Array} args The arguments to pass to the test function |
|
4442 * @return {String} A semi-colon separated string of tests and their success/failure: 1:1;2:1;3:0 |
|
4443 */ |
|
4444 all: function(cat, args) { |
|
4445 var cat_o = feature_tests[cat], |
|
4446 // results = {}; |
|
4447 result = []; |
|
4448 if (cat_o) { |
|
4449 Y.Object.each(cat_o, function(v, k) { |
|
4450 result.push(k + ':' + (Y.Features.test(cat, k, args) ? 1 : 0)); |
|
4451 }); |
|
4452 } |
|
4453 |
|
4454 return (result.length) ? result.join(';') : ''; |
|
4455 }, |
|
4456 /** |
|
4457 * Run a sepecific test and return a Boolean response. |
|
4458 * |
|
4459 * ``` |
|
4460 * Y.Features.test("load", "1"); |
|
4461 * ``` |
|
4462 * |
|
4463 * @method test |
|
4464 * @param {String} cat The category of the test to run |
|
4465 * @param {String} name The name of the test to run |
|
4466 * @param {Array} args The arguments to pass to the test function |
|
4467 * @return {Boolean} True or false if the test passed/failed. |
|
4468 */ |
|
4469 test: function(cat, name, args) { |
|
4470 args = args || []; |
|
4471 var result, ua, test, |
|
4472 cat_o = feature_tests[cat], |
|
4473 feature = cat_o && cat_o[name]; |
|
4474 |
|
4475 if (!feature) { |
|
4476 Y.log('Feature test ' + cat + ', ' + name + ' not found'); |
|
4477 } else { |
|
4478 |
|
4479 result = feature.result; |
|
4480 |
|
4481 if (Y.Lang.isUndefined(result)) { |
|
4482 |
|
4483 ua = feature.ua; |
|
4484 if (ua) { |
|
4485 result = (Y.UA[ua]); |
|
4486 } |
|
4487 |
|
4488 test = feature.test; |
|
4489 if (test && ((!ua) || result)) { |
|
4490 result = test.apply(Y, args); |
|
4491 } |
|
4492 |
|
4493 feature.result = result; |
|
4494 } |
|
4495 } |
|
4496 |
|
4497 return result; |
|
4498 } |
|
4499 }); |
|
4500 |
|
4501 // Y.Features.add("load", "1", {}); |
|
4502 // Y.Features.test("load", "1"); |
|
4503 // caps=1:1;2:0;3:1; |
|
4504 |
|
4505 /* This file is auto-generated by (yogi loader --yes --mix --start ../) */ |
|
4506 /*jshint maxlen:900, eqeqeq: false */ |
|
4507 var add = Y.Features.add; |
|
4508 // app-transitions-native |
|
4509 add('load', '0', { |
|
4510 "name": "app-transitions-native", |
|
4511 "test": function (Y) { |
|
4512 var doc = Y.config.doc, |
|
4513 node = doc ? doc.documentElement : null; |
|
4514 |
|
4515 if (node && node.style) { |
|
4516 return ('MozTransition' in node.style || 'WebkitTransition' in node.style || 'transition' in node.style); |
|
4517 } |
|
4518 |
|
4519 return false; |
|
4520 }, |
|
4521 "trigger": "app-transitions" |
|
4522 }); |
|
4523 // autocomplete-list-keys |
|
4524 add('load', '1', { |
|
4525 "name": "autocomplete-list-keys", |
|
4526 "test": function (Y) { |
|
4527 // Only add keyboard support to autocomplete-list if this doesn't appear to |
|
4528 // be an iOS or Android-based mobile device. |
|
4529 // |
|
4530 // There's currently no feasible way to actually detect whether a device has |
|
4531 // a hardware keyboard, so this sniff will have to do. It can easily be |
|
4532 // overridden by manually loading the autocomplete-list-keys module. |
|
4533 // |
|
4534 // Worth noting: even though iOS supports bluetooth keyboards, Mobile Safari |
|
4535 // doesn't fire the keyboard events used by AutoCompleteList, so there's |
|
4536 // no point loading the -keys module even when a bluetooth keyboard may be |
|
4537 // available. |
|
4538 return !(Y.UA.ios || Y.UA.android); |
|
4539 }, |
|
4540 "trigger": "autocomplete-list" |
|
4541 }); |
|
4542 // dd-gestures |
|
4543 add('load', '2', { |
|
4544 "name": "dd-gestures", |
|
4545 "trigger": "dd-drag", |
|
4546 "ua": "touchEnabled" |
|
4547 }); |
|
4548 // dom-style-ie |
|
4549 add('load', '3', { |
|
4550 "name": "dom-style-ie", |
|
4551 "test": function (Y) { |
|
4552 |
|
4553 var testFeature = Y.Features.test, |
|
4554 addFeature = Y.Features.add, |
|
4555 WINDOW = Y.config.win, |
|
4556 DOCUMENT = Y.config.doc, |
|
4557 DOCUMENT_ELEMENT = 'documentElement', |
|
4558 ret = false; |
|
4559 |
|
4560 addFeature('style', 'computedStyle', { |
|
4561 test: function() { |
|
4562 return WINDOW && 'getComputedStyle' in WINDOW; |
|
4563 } |
|
4564 }); |
|
4565 |
|
4566 addFeature('style', 'opacity', { |
|
4567 test: function() { |
|
4568 return DOCUMENT && 'opacity' in DOCUMENT[DOCUMENT_ELEMENT].style; |
|
4569 } |
|
4570 }); |
|
4571 |
|
4572 ret = (!testFeature('style', 'opacity') && |
|
4573 !testFeature('style', 'computedStyle')); |
|
4574 |
|
4575 return ret; |
|
4576 }, |
|
4577 "trigger": "dom-style" |
|
4578 }); |
|
4579 // editor-para-ie |
|
4580 add('load', '4', { |
|
4581 "name": "editor-para-ie", |
|
4582 "trigger": "editor-para", |
|
4583 "ua": "ie", |
|
4584 "when": "instead" |
|
4585 }); |
|
4586 // event-base-ie |
|
4587 add('load', '5', { |
|
4588 "name": "event-base-ie", |
|
4589 "test": function(Y) { |
|
4590 var imp = Y.config.doc && Y.config.doc.implementation; |
|
4591 return (imp && (!imp.hasFeature('Events', '2.0'))); |
|
4592 }, |
|
4593 "trigger": "node-base" |
|
4594 }); |
|
4595 // graphics-canvas |
|
4596 add('load', '6', { |
|
4597 "name": "graphics-canvas", |
|
4598 "test": function(Y) { |
|
4599 var DOCUMENT = Y.config.doc, |
|
4600 useCanvas = Y.config.defaultGraphicEngine && Y.config.defaultGraphicEngine == "canvas", |
|
4601 canvas = DOCUMENT && DOCUMENT.createElement("canvas"), |
|
4602 svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")); |
|
4603 return (!svg || useCanvas) && (canvas && canvas.getContext && canvas.getContext("2d")); |
|
4604 }, |
|
4605 "trigger": "graphics" |
|
4606 }); |
|
4607 // graphics-canvas-default |
|
4608 add('load', '7', { |
|
4609 "name": "graphics-canvas-default", |
|
4610 "test": function(Y) { |
|
4611 var DOCUMENT = Y.config.doc, |
|
4612 useCanvas = Y.config.defaultGraphicEngine && Y.config.defaultGraphicEngine == "canvas", |
|
4613 canvas = DOCUMENT && DOCUMENT.createElement("canvas"), |
|
4614 svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")); |
|
4615 return (!svg || useCanvas) && (canvas && canvas.getContext && canvas.getContext("2d")); |
|
4616 }, |
|
4617 "trigger": "graphics" |
|
4618 }); |
|
4619 // graphics-svg |
|
4620 add('load', '8', { |
|
4621 "name": "graphics-svg", |
|
4622 "test": function(Y) { |
|
4623 var DOCUMENT = Y.config.doc, |
|
4624 useSVG = !Y.config.defaultGraphicEngine || Y.config.defaultGraphicEngine != "canvas", |
|
4625 canvas = DOCUMENT && DOCUMENT.createElement("canvas"), |
|
4626 svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")); |
|
4627 |
|
4628 return svg && (useSVG || !canvas); |
|
4629 }, |
|
4630 "trigger": "graphics" |
|
4631 }); |
|
4632 // graphics-svg-default |
|
4633 add('load', '9', { |
|
4634 "name": "graphics-svg-default", |
|
4635 "test": function(Y) { |
|
4636 var DOCUMENT = Y.config.doc, |
|
4637 useSVG = !Y.config.defaultGraphicEngine || Y.config.defaultGraphicEngine != "canvas", |
|
4638 canvas = DOCUMENT && DOCUMENT.createElement("canvas"), |
|
4639 svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")); |
|
4640 |
|
4641 return svg && (useSVG || !canvas); |
|
4642 }, |
|
4643 "trigger": "graphics" |
|
4644 }); |
|
4645 // graphics-vml |
|
4646 add('load', '10', { |
|
4647 "name": "graphics-vml", |
|
4648 "test": function(Y) { |
|
4649 var DOCUMENT = Y.config.doc, |
|
4650 canvas = DOCUMENT && DOCUMENT.createElement("canvas"); |
|
4651 return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d"))); |
|
4652 }, |
|
4653 "trigger": "graphics" |
|
4654 }); |
|
4655 // graphics-vml-default |
|
4656 add('load', '11', { |
|
4657 "name": "graphics-vml-default", |
|
4658 "test": function(Y) { |
|
4659 var DOCUMENT = Y.config.doc, |
|
4660 canvas = DOCUMENT && DOCUMENT.createElement("canvas"); |
|
4661 return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d"))); |
|
4662 }, |
|
4663 "trigger": "graphics" |
|
4664 }); |
|
4665 // history-hash-ie |
|
4666 add('load', '12', { |
|
4667 "name": "history-hash-ie", |
|
4668 "test": function (Y) { |
|
4669 var docMode = Y.config.doc && Y.config.doc.documentMode; |
|
4670 |
|
4671 return Y.UA.ie && (!('onhashchange' in Y.config.win) || |
|
4672 !docMode || docMode < 8); |
|
4673 }, |
|
4674 "trigger": "history-hash" |
|
4675 }); |
|
4676 // io-nodejs |
|
4677 add('load', '13', { |
|
4678 "name": "io-nodejs", |
|
4679 "trigger": "io-base", |
|
4680 "ua": "nodejs" |
|
4681 }); |
|
4682 // json-parse-shim |
|
4683 add('load', '14', { |
|
4684 "name": "json-parse-shim", |
|
4685 "test": function (Y) { |
|
4686 var _JSON = Y.config.global.JSON, |
|
4687 Native = Object.prototype.toString.call(_JSON) === '[object JSON]' && _JSON, |
|
4688 nativeSupport = Y.config.useNativeJSONParse !== false && !!Native; |
|
4689 |
|
4690 function workingNative( k, v ) { |
|
4691 return k === "ok" ? true : v; |
|
4692 } |
|
4693 |
|
4694 // Double check basic functionality. This is mainly to catch early broken |
|
4695 // implementations of the JSON API in Firefox 3.1 beta1 and beta2 |
|
4696 if ( nativeSupport ) { |
|
4697 try { |
|
4698 nativeSupport = ( Native.parse( '{"ok":false}', workingNative ) ).ok; |
|
4699 } |
|
4700 catch ( e ) { |
|
4701 nativeSupport = false; |
|
4702 } |
|
4703 } |
|
4704 |
|
4705 return !nativeSupport; |
|
4706 }, |
|
4707 "trigger": "json-parse" |
|
4708 }); |
|
4709 // json-stringify-shim |
|
4710 add('load', '15', { |
|
4711 "name": "json-stringify-shim", |
|
4712 "test": function (Y) { |
|
4713 var _JSON = Y.config.global.JSON, |
|
4714 Native = Object.prototype.toString.call(_JSON) === '[object JSON]' && _JSON, |
|
4715 nativeSupport = Y.config.useNativeJSONStringify !== false && !!Native; |
|
4716 |
|
4717 // Double check basic native functionality. This is primarily to catch broken |
|
4718 // early JSON API implementations in Firefox 3.1 beta1 and beta2. |
|
4719 if ( nativeSupport ) { |
|
4720 try { |
|
4721 nativeSupport = ( '0' === Native.stringify(0) ); |
|
4722 } catch ( e ) { |
|
4723 nativeSupport = false; |
|
4724 } |
|
4725 } |
|
4726 |
|
4727 |
|
4728 return !nativeSupport; |
|
4729 }, |
|
4730 "trigger": "json-stringify" |
|
4731 }); |
|
4732 // scrollview-base-ie |
|
4733 add('load', '16', { |
|
4734 "name": "scrollview-base-ie", |
|
4735 "trigger": "scrollview-base", |
|
4736 "ua": "ie" |
|
4737 }); |
|
4738 // selector-css2 |
|
4739 add('load', '17', { |
|
4740 "name": "selector-css2", |
|
4741 "test": function (Y) { |
|
4742 var DOCUMENT = Y.config.doc, |
|
4743 ret = DOCUMENT && !('querySelectorAll' in DOCUMENT); |
|
4744 |
|
4745 return ret; |
|
4746 }, |
|
4747 "trigger": "selector" |
|
4748 }); |
|
4749 // transition-timer |
|
4750 add('load', '18', { |
|
4751 "name": "transition-timer", |
|
4752 "test": function (Y) { |
|
4753 var DOCUMENT = Y.config.doc, |
|
4754 node = (DOCUMENT) ? DOCUMENT.documentElement: null, |
|
4755 ret = true; |
|
4756 |
|
4757 if (node && node.style) { |
|
4758 ret = !('MozTransition' in node.style || 'WebkitTransition' in node.style || 'transition' in node.style); |
|
4759 } |
|
4760 |
|
4761 return ret; |
|
4762 }, |
|
4763 "trigger": "transition" |
|
4764 }); |
|
4765 // widget-base-ie |
|
4766 add('load', '19', { |
|
4767 "name": "widget-base-ie", |
|
4768 "trigger": "widget-base", |
|
4769 "ua": "ie" |
|
4770 }); |
|
4771 // yql-jsonp |
|
4772 add('load', '20', { |
|
4773 "name": "yql-jsonp", |
|
4774 "test": function (Y) { |
|
4775 /* Only load the JSONP module when not in nodejs or winjs |
|
4776 TODO Make the winjs module a CORS module |
|
4777 */ |
|
4778 return (!Y.UA.nodejs && !Y.UA.winjs); |
|
4779 }, |
|
4780 "trigger": "yql", |
|
4781 "when": "after" |
|
4782 }); |
|
4783 // yql-nodejs |
|
4784 add('load', '21', { |
|
4785 "name": "yql-nodejs", |
|
4786 "trigger": "yql", |
|
4787 "ua": "nodejs", |
|
4788 "when": "after" |
|
4789 }); |
|
4790 // yql-winjs |
|
4791 add('load', '22', { |
|
4792 "name": "yql-winjs", |
|
4793 "trigger": "yql", |
|
4794 "ua": "winjs", |
|
4795 "when": "after" |
|
4796 }); |
|
4797 |
|
4798 }, '@VERSION@', {"requires": ["yui-base"]}); |
|
4799 YUI.add('intl-base', function (Y, NAME) { |
|
4800 |
|
4801 /** |
|
4802 * The Intl utility provides a central location for managing sets of |
|
4803 * localized resources (strings and formatting patterns). |
|
4804 * |
|
4805 * @class Intl |
|
4806 * @uses EventTarget |
|
4807 * @static |
|
4808 */ |
|
4809 |
|
4810 var SPLIT_REGEX = /[, ]/; |
|
4811 |
|
4812 Y.mix(Y.namespace('Intl'), { |
|
4813 |
|
4814 /** |
|
4815 * Returns the language among those available that |
|
4816 * best matches the preferred language list, using the Lookup |
|
4817 * algorithm of BCP 47. |
|
4818 * If none of the available languages meets the user's preferences, |
|
4819 * then "" is returned. |
|
4820 * Extended language ranges are not supported. |
|
4821 * |
|
4822 * @method lookupBestLang |
|
4823 * @param {String[] | String} preferredLanguages The list of preferred |
|
4824 * languages in descending preference order, represented as BCP 47 |
|
4825 * language tags. A string array or a comma-separated list. |
|
4826 * @param {String[]} availableLanguages The list of languages |
|
4827 * that the application supports, represented as BCP 47 language |
|
4828 * tags. |
|
4829 * |
|
4830 * @return {String} The available language that best matches the |
|
4831 * preferred language list, or "". |
|
4832 * @since 3.1.0 |
|
4833 */ |
|
4834 lookupBestLang: function(preferredLanguages, availableLanguages) { |
|
4835 |
|
4836 var i, language, result, index; |
|
4837 |
|
4838 // check whether the list of available languages contains language; |
|
4839 // if so return it |
|
4840 function scan(language) { |
|
4841 var i; |
|
4842 for (i = 0; i < availableLanguages.length; i += 1) { |
|
4843 if (language.toLowerCase() === |
|
4844 availableLanguages[i].toLowerCase()) { |
|
4845 return availableLanguages[i]; |
|
4846 } |
|
4847 } |
|
4848 } |
|
4849 |
|
4850 if (Y.Lang.isString(preferredLanguages)) { |
|
4851 preferredLanguages = preferredLanguages.split(SPLIT_REGEX); |
|
4852 } |
|
4853 |
|
4854 for (i = 0; i < preferredLanguages.length; i += 1) { |
|
4855 language = preferredLanguages[i]; |
|
4856 if (!language || language === '*') { |
|
4857 continue; |
|
4858 } |
|
4859 // check the fallback sequence for one language |
|
4860 while (language.length > 0) { |
|
4861 result = scan(language); |
|
4862 if (result) { |
|
4863 return result; |
|
4864 } else { |
|
4865 index = language.lastIndexOf('-'); |
|
4866 if (index >= 0) { |
|
4867 language = language.substring(0, index); |
|
4868 // one-character subtags get cut along with the |
|
4869 // following subtag |
|
4870 if (index >= 2 && language.charAt(index - 2) === '-') { |
|
4871 language = language.substring(0, index - 2); |
|
4872 } |
|
4873 } else { |
|
4874 // nothing available for this language |
|
4875 break; |
|
4876 } |
|
4877 } |
|
4878 } |
|
4879 } |
|
4880 |
|
4881 return ''; |
|
4882 } |
|
4883 }); |
|
4884 |
|
4885 |
|
4886 }, '@VERSION@', {"requires": ["yui-base"]}); |
|
4887 YUI.add('yui-log', function (Y, NAME) { |
|
4888 |
|
4889 /** |
|
4890 * Provides console log capability and exposes a custom event for |
|
4891 * console implementations. This module is a `core` YUI module, |
|
4892 * <a href="../classes/YUI.html#method_log">it's documentation is located under the YUI class</a>. |
|
4893 * |
|
4894 * @module yui |
|
4895 * @submodule yui-log |
|
4896 */ |
|
4897 |
|
4898 var INSTANCE = Y, |
|
4899 LOGEVENT = 'yui:log', |
|
4900 UNDEFINED = 'undefined', |
|
4901 LEVELS = { debug: 1, |
|
4902 info: 2, |
|
4903 warn: 4, |
|
4904 error: 8 }; |
|
4905 |
|
4906 /** |
|
4907 * If the 'debug' config is true, a 'yui:log' event will be |
|
4908 * dispatched, which the Console widget and anything else |
|
4909 * can consume. If the 'useBrowserConsole' config is true, it will |
|
4910 * write to the browser console if available. YUI-specific log |
|
4911 * messages will only be present in the -debug versions of the |
|
4912 * JS files. The build system is supposed to remove log statements |
|
4913 * from the raw and minified versions of the files. |
|
4914 * |
|
4915 * @method log |
|
4916 * @for YUI |
|
4917 * @param {String} msg The message to log. |
|
4918 * @param {String} cat The log category for the message. Default |
|
4919 * categories are "info", "warn", "error", "debug". |
|
4920 * Custom categories can be used as well. (opt). |
|
4921 * @param {String} src The source of the the message (opt). |
|
4922 * @param {boolean} silent If true, the log event won't fire. |
|
4923 * @return {YUI} YUI instance. |
|
4924 */ |
|
4925 INSTANCE.log = function(msg, cat, src, silent) { |
|
4926 var bail, excl, incl, m, f, minlevel, |
|
4927 Y = INSTANCE, |
|
4928 c = Y.config, |
|
4929 publisher = (Y.fire) ? Y : YUI.Env.globalEvents; |
|
4930 // suppress log message if the config is off or the event stack |
|
4931 // or the event call stack contains a consumer of the yui:log event |
|
4932 if (c.debug) { |
|
4933 // apply source filters |
|
4934 src = src || ""; |
|
4935 if (typeof src !== "undefined") { |
|
4936 excl = c.logExclude; |
|
4937 incl = c.logInclude; |
|
4938 if (incl && !(src in incl)) { |
|
4939 bail = 1; |
|
4940 } else if (incl && (src in incl)) { |
|
4941 bail = !incl[src]; |
|
4942 } else if (excl && (src in excl)) { |
|
4943 bail = excl[src]; |
|
4944 } |
|
4945 |
|
4946 // Set a default category of info if the category was not defined or was not |
|
4947 // a real category. |
|
4948 if ((typeof cat === 'undefined') || !(cat in LEVELS)) { |
|
4949 cat = 'info'; |
|
4950 } |
|
4951 |
|
4952 // Determine the current minlevel as defined in configuration |
|
4953 Y.config.logLevel = Y.config.logLevel || 'debug'; |
|
4954 minlevel = LEVELS[Y.config.logLevel.toLowerCase()]; |
|
4955 |
|
4956 if (cat in LEVELS && LEVELS[cat] < minlevel) { |
|
4957 // Skip this message if the we don't meet the defined minlevel |
|
4958 bail = 1; |
|
4959 } |
|
4960 } |
|
4961 if (!bail) { |
|
4962 if (c.useBrowserConsole) { |
|
4963 m = (src) ? src + ': ' + msg : msg; |
|
4964 if (Y.Lang.isFunction(c.logFn)) { |
|
4965 c.logFn.call(Y, msg, cat, src); |
|
4966 } else if (typeof console !== UNDEFINED && console.log) { |
|
4967 f = (cat && console[cat] && (cat in LEVELS)) ? cat : 'log'; |
|
4968 console[f](m); |
|
4969 } else if (typeof opera !== UNDEFINED) { |
|
4970 opera.postError(m); |
|
4971 } |
|
4972 } |
|
4973 |
|
4974 if (publisher && !silent) { |
|
4975 |
|
4976 if (publisher === Y && (!publisher.getEvent(LOGEVENT))) { |
|
4977 publisher.publish(LOGEVENT, { |
|
4978 broadcast: 2 |
|
4979 }); |
|
4980 } |
|
4981 |
|
4982 publisher.fire(LOGEVENT, { |
|
4983 msg: msg, |
|
4984 cat: cat, |
|
4985 src: src |
|
4986 }); |
|
4987 } |
|
4988 } |
|
4989 } |
|
4990 |
|
4991 return Y; |
|
4992 }; |
|
4993 |
|
4994 /** |
|
4995 * Write a system message. This message will be preserved in the |
|
4996 * minified and raw versions of the YUI files, unlike log statements. |
|
4997 * @method message |
|
4998 * @for YUI |
|
4999 * @param {String} msg The message to log. |
|
5000 * @param {String} cat The log category for the message. Default |
|
5001 * categories are "info", "warn", "error", "debug". |
|
5002 * Custom categories can be used as well. (opt). |
|
5003 * @param {String} src The source of the the message (opt). |
|
5004 * @param {boolean} silent If true, the log event won't fire. |
|
5005 * @return {YUI} YUI instance. |
|
5006 */ |
|
5007 INSTANCE.message = function() { |
|
5008 return INSTANCE.log.apply(INSTANCE, arguments); |
|
5009 }; |
|
5010 |
|
5011 |
|
5012 }, '@VERSION@', {"requires": ["yui-base"]}); |
|
5013 YUI.add('yui-log-nodejs', function (Y, NAME) { |
|
5014 |
|
5015 var sys = require(process.binding('natives').util ? 'util' : 'sys'), |
|
5016 hasColor = false; |
|
5017 |
|
5018 try { |
|
5019 var stdio = require("stdio"); |
|
5020 hasColor = stdio.isStderrATTY(); |
|
5021 } catch (ex) { |
|
5022 hasColor = true; |
|
5023 } |
|
5024 |
|
5025 Y.config.useColor = hasColor; |
|
5026 |
|
5027 Y.consoleColor = function(str, num) { |
|
5028 if (!this.config.useColor) { |
|
5029 return str; |
|
5030 } |
|
5031 if (!num) { |
|
5032 num = '32'; |
|
5033 } |
|
5034 return "\u001b[" + num +"m" + str + "\u001b[0m"; |
|
5035 }; |
|
5036 |
|
5037 |
|
5038 var logFn = function(str, t, m) { |
|
5039 var id = '', lvl, mLvl; |
|
5040 if (this.id) { |
|
5041 id = '[' + this.id + ']:'; |
|
5042 } |
|
5043 t = t || 'info'; |
|
5044 m = (m) ? this.consoleColor(' (' + m.toLowerCase() + '):', 35) : ''; |
|
5045 |
|
5046 if (str === null) { |
|
5047 str = 'null'; |
|
5048 } |
|
5049 |
|
5050 if ((typeof str === 'object') || str instanceof Array) { |
|
5051 try { |
|
5052 //Should we use this? |
|
5053 if (str.tagName || str._yuid || str._query) { |
|
5054 str = str.toString(); |
|
5055 } else { |
|
5056 str = sys.inspect(str); |
|
5057 } |
|
5058 } catch (e) { |
|
5059 //Fail catcher |
|
5060 } |
|
5061 } |
|
5062 |
|
5063 lvl = '37;40'; |
|
5064 mLvl = ((str) ? '' : 31); |
|
5065 t = t+''; //Force to a string.. |
|
5066 switch (t.toLowerCase()) { |
|
5067 case 'error': |
|
5068 lvl = mLvl = 31; |
|
5069 break; |
|
5070 case 'warn': |
|
5071 lvl = 33; |
|
5072 break; |
|
5073 case 'debug': |
|
5074 lvl = 34; |
|
5075 break; |
|
5076 } |
|
5077 if (typeof str === 'string') { |
|
5078 if (str && str.indexOf("\n") !== -1) { |
|
5079 str = "\n" + str; |
|
5080 } |
|
5081 } |
|
5082 |
|
5083 // output log messages to stderr |
|
5084 sys.error(this.consoleColor(t.toLowerCase() + ':', lvl) + m + ' ' + this.consoleColor(str, mLvl)); |
|
5085 }; |
|
5086 |
|
5087 if (!Y.config.logFn) { |
|
5088 Y.config.logFn = logFn; |
|
5089 } |
|
5090 |
|
5091 |
|
5092 |
|
5093 }, '@VERSION@'); |
|
5094 YUI.add('yui-later', function (Y, NAME) { |
|
5095 |
|
5096 /** |
|
5097 * Provides a setTimeout/setInterval wrapper. This module is a `core` YUI module, |
|
5098 * <a href="../classes/YUI.html#method_later">it's documentation is located under the YUI class</a>. |
|
5099 * |
|
5100 * @module yui |
|
5101 * @submodule yui-later |
|
5102 */ |
|
5103 |
|
5104 var NO_ARGS = []; |
|
5105 |
|
5106 /** |
|
5107 * Executes the supplied function in the context of the supplied |
|
5108 * object 'when' milliseconds later. Executes the function a |
|
5109 * single time unless periodic is set to true. |
|
5110 * @for YUI |
|
5111 * @method later |
|
5112 * @param when {Number} the number of milliseconds to wait until the fn |
|
5113 * is executed. |
|
5114 * @param o the context object. |
|
5115 * @param fn {Function|String} the function to execute or the name of |
|
5116 * the method in the 'o' object to execute. |
|
5117 * @param data [Array] data that is provided to the function. This |
|
5118 * accepts either a single item or an array. If an array is provided, |
|
5119 * the function is executed with one parameter for each array item. |
|
5120 * If you need to pass a single array parameter, it needs to be wrapped |
|
5121 * in an array [myarray]. |
|
5122 * |
|
5123 * Note: native methods in IE may not have the call and apply methods. |
|
5124 * In this case, it will work, but you are limited to four arguments. |
|
5125 * |
|
5126 * @param periodic {boolean} if true, executes continuously at supplied |
|
5127 * interval until canceled. |
|
5128 * @return {object} a timer object. Call the cancel() method on this |
|
5129 * object to stop the timer. |
|
5130 */ |
|
5131 Y.later = function(when, o, fn, data, periodic) { |
|
5132 when = when || 0; |
|
5133 data = (!Y.Lang.isUndefined(data)) ? Y.Array(data) : NO_ARGS; |
|
5134 o = o || Y.config.win || Y; |
|
5135 |
|
5136 var cancelled = false, |
|
5137 method = (o && Y.Lang.isString(fn)) ? o[fn] : fn, |
|
5138 wrapper = function() { |
|
5139 // IE 8- may execute a setInterval callback one last time |
|
5140 // after clearInterval was called, so in order to preserve |
|
5141 // the cancel() === no more runny-run, we have to jump through |
|
5142 // an extra hoop. |
|
5143 if (!cancelled) { |
|
5144 if (!method.apply) { |
|
5145 method(data[0], data[1], data[2], data[3]); |
|
5146 } else { |
|
5147 method.apply(o, data || NO_ARGS); |
|
5148 } |
|
5149 } |
|
5150 }, |
|
5151 id = (periodic) ? setInterval(wrapper, when) : setTimeout(wrapper, when); |
|
5152 |
|
5153 return { |
|
5154 id: id, |
|
5155 interval: periodic, |
|
5156 cancel: function() { |
|
5157 cancelled = true; |
|
5158 if (this.interval) { |
|
5159 clearInterval(id); |
|
5160 } else { |
|
5161 clearTimeout(id); |
|
5162 } |
|
5163 } |
|
5164 }; |
|
5165 }; |
|
5166 |
|
5167 Y.Lang.later = Y.later; |
|
5168 |
|
5169 |
|
5170 |
|
5171 }, '@VERSION@', {"requires": ["yui-base"]}); |
|
5172 YUI.add('loader-base', function (Y, NAME) { |
|
5173 |
|
5174 /** |
|
5175 * The YUI loader core |
|
5176 * @module loader |
|
5177 * @submodule loader-base |
|
5178 */ |
|
5179 |
|
5180 (function() { |
|
5181 var VERSION = Y.version, |
|
5182 BUILD = '/build/', |
|
5183 ROOT = VERSION + '/', |
|
5184 CDN_BASE = Y.Env.base, |
|
5185 GALLERY_VERSION = 'gallery-2014.02.20-23-55', |
|
5186 TNT = '2in3', |
|
5187 TNT_VERSION = '4', |
|
5188 YUI2_VERSION = '2.9.0', |
|
5189 COMBO_BASE = CDN_BASE + 'combo?', |
|
5190 META = { |
|
5191 version: VERSION, |
|
5192 root: ROOT, |
|
5193 base: Y.Env.base, |
|
5194 comboBase: COMBO_BASE, |
|
5195 skin: { |
|
5196 defaultSkin: 'sam', |
|
5197 base: 'assets/skins/', |
|
5198 path: 'skin.css', |
|
5199 after: [ |
|
5200 'cssreset', |
|
5201 'cssfonts', |
|
5202 'cssgrids', |
|
5203 'cssbase', |
|
5204 'cssreset-context', |
|
5205 'cssfonts-context' |
|
5206 ] |
|
5207 }, |
|
5208 groups: {}, |
|
5209 patterns: {} |
|
5210 }, |
|
5211 groups = META.groups, |
|
5212 yui2Update = function(tnt, yui2, config) { |
|
5213 var root = TNT + '.' + |
|
5214 (tnt || TNT_VERSION) + '/' + |
|
5215 (yui2 || YUI2_VERSION) + BUILD, |
|
5216 base = (config && config.base) ? config.base : CDN_BASE, |
|
5217 combo = (config && config.comboBase) ? config.comboBase : COMBO_BASE; |
|
5218 |
|
5219 groups.yui2.base = base + root; |
|
5220 groups.yui2.root = root; |
|
5221 groups.yui2.comboBase = combo; |
|
5222 }, |
|
5223 galleryUpdate = function(tag, config) { |
|
5224 var root = (tag || GALLERY_VERSION) + BUILD, |
|
5225 base = (config && config.base) ? config.base : CDN_BASE, |
|
5226 combo = (config && config.comboBase) ? config.comboBase : COMBO_BASE; |
|
5227 |
|
5228 groups.gallery.base = base + root; |
|
5229 groups.gallery.root = root; |
|
5230 groups.gallery.comboBase = combo; |
|
5231 }; |
|
5232 |
|
5233 |
|
5234 groups[VERSION] = {}; |
|
5235 |
|
5236 groups.gallery = { |
|
5237 ext: false, |
|
5238 combine: true, |
|
5239 comboBase: COMBO_BASE, |
|
5240 update: galleryUpdate, |
|
5241 patterns: { |
|
5242 'gallery-': {}, |
|
5243 'lang/gallery-': {}, |
|
5244 'gallerycss-': { |
|
5245 type: 'css' |
|
5246 } |
|
5247 } |
|
5248 }; |
|
5249 |
|
5250 groups.yui2 = { |
|
5251 combine: true, |
|
5252 ext: false, |
|
5253 comboBase: COMBO_BASE, |
|
5254 update: yui2Update, |
|
5255 patterns: { |
|
5256 'yui2-': { |
|
5257 configFn: function(me) { |
|
5258 if (/-skin|reset|fonts|grids|base/.test(me.name)) { |
|
5259 me.type = 'css'; |
|
5260 me.path = me.path.replace(/\.js/, '.css'); |
|
5261 // this makes skins in builds earlier than |
|
5262 // 2.6.0 work as long as combine is false |
|
5263 me.path = me.path.replace(/\/yui2-skin/, |
|
5264 '/assets/skins/sam/yui2-skin'); |
|
5265 } |
|
5266 } |
|
5267 } |
|
5268 } |
|
5269 }; |
|
5270 |
|
5271 galleryUpdate(); |
|
5272 yui2Update(); |
|
5273 |
|
5274 if (YUI.Env[VERSION]) { |
|
5275 Y.mix(META, YUI.Env[VERSION], false, [ |
|
5276 'modules', |
|
5277 'groups', |
|
5278 'skin' |
|
5279 ], 0, true); |
|
5280 } |
|
5281 |
|
5282 YUI.Env[VERSION] = META; |
|
5283 }()); |
|
5284 /*jslint forin: true, maxlen: 350 */ |
|
5285 |
|
5286 /** |
|
5287 * Loader dynamically loads script and css files. It includes the dependency |
|
5288 * information for the version of the library in use, and will automatically pull in |
|
5289 * dependencies for the modules requested. It can also load the |
|
5290 * files from the Yahoo! CDN, and it can utilize the combo service provided on |
|
5291 * this network to reduce the number of http connections required to download |
|
5292 * YUI files. |
|
5293 * |
|
5294 * @module loader |
|
5295 * @main loader |
|
5296 * @submodule loader-base |
|
5297 */ |
|
5298 |
|
5299 var NOT_FOUND = {}, |
|
5300 NO_REQUIREMENTS = [], |
|
5301 MAX_URL_LENGTH = 1024, |
|
5302 GLOBAL_ENV = YUI.Env, |
|
5303 GLOBAL_LOADED = GLOBAL_ENV._loaded, |
|
5304 CSS = 'css', |
|
5305 JS = 'js', |
|
5306 INTL = 'intl', |
|
5307 DEFAULT_SKIN = 'sam', |
|
5308 VERSION = Y.version, |
|
5309 ROOT_LANG = '', |
|
5310 YObject = Y.Object, |
|
5311 oeach = YObject.each, |
|
5312 yArray = Y.Array, |
|
5313 _queue = GLOBAL_ENV._loaderQueue, |
|
5314 META = GLOBAL_ENV[VERSION], |
|
5315 SKIN_PREFIX = 'skin-', |
|
5316 L = Y.Lang, |
|
5317 ON_PAGE = GLOBAL_ENV.mods, |
|
5318 modulekey, |
|
5319 _path = function(dir, file, type, nomin) { |
|
5320 var path = dir + '/' + file; |
|
5321 if (!nomin) { |
|
5322 path += '-min'; |
|
5323 } |
|
5324 path += '.' + (type || CSS); |
|
5325 |
|
5326 return path; |
|
5327 }; |
|
5328 |
|
5329 |
|
5330 if (!YUI.Env._cssLoaded) { |
|
5331 YUI.Env._cssLoaded = {}; |
|
5332 } |
|
5333 |
|
5334 |
|
5335 /** |
|
5336 * The component metadata is stored in Y.Env.meta. |
|
5337 * Part of the loader module. |
|
5338 * @property meta |
|
5339 * @for YUI |
|
5340 */ |
|
5341 Y.Env.meta = META; |
|
5342 |
|
5343 /** |
|
5344 * Loader dynamically loads script and css files. It includes the dependency |
|
5345 * info for the version of the library in use, and will automatically pull in |
|
5346 * dependencies for the modules requested. It can load the |
|
5347 * files from the Yahoo! CDN, and it can utilize the combo service provided on |
|
5348 * this network to reduce the number of http connections required to download |
|
5349 * YUI files. You can also specify an external, custom combo service to host |
|
5350 * your modules as well. |
|
5351 |
|
5352 var Y = YUI(); |
|
5353 var loader = new Y.Loader({ |
|
5354 filter: 'debug', |
|
5355 base: '../../', |
|
5356 root: 'build/', |
|
5357 combine: true, |
|
5358 require: ['node', 'dd', 'console'] |
|
5359 }); |
|
5360 var out = loader.resolve(true); |
|
5361 |
|
5362 * @constructor |
|
5363 * @class Loader |
|
5364 * @param {Object} config an optional set of configuration options. |
|
5365 * @param {String} config.base The base dir which to fetch this module from |
|
5366 * @param {String} config.comboBase The Combo service base path. Ex: `http://yui.yahooapis.com/combo?` |
|
5367 * @param {String} config.root The root path to prepend to module names for the combo service. Ex: `2.5.2/build/` |
|
5368 * @param {String|Object} config.filter A filter to apply to result urls. <a href="#property_filter">See filter property</a> |
|
5369 * @param {Object} config.filters Per-component filter specification. If specified for a given component, this overrides the filter config. |
|
5370 * @param {Boolean} config.combine Use a combo service to reduce the number of http connections required to load your dependencies |
|
5371 * @param {Boolean} [config.async=true] Fetch files in async |
|
5372 * @param {Array} config.ignore: A list of modules that should never be dynamically loaded |
|
5373 * @param {Array} config.force A list of modules that should always be loaded when required, even if already present on the page |
|
5374 * @param {HTMLElement|String} config.insertBefore Node or id for a node that should be used as the insertion point for new nodes |
|
5375 * @param {Object} config.jsAttributes Object literal containing attributes to add to script nodes |
|
5376 * @param {Object} config.cssAttributes Object literal containing attributes to add to link nodes |
|
5377 * @param {Number} config.timeout The number of milliseconds before a timeout occurs when dynamically loading nodes. If not set, there is no timeout |
|
5378 * @param {Object} config.context Execution context for all callbacks |
|
5379 * @param {Function} config.onSuccess Callback for the 'success' event |
|
5380 * @param {Function} config.onFailure Callback for the 'failure' event |
|
5381 * @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. |
|
5382 * @param {Function} config.onTimeout Callback for the 'timeout' event |
|
5383 * @param {Function} config.onProgress Callback executed each time a script or css file is loaded |
|
5384 * @param {Object} config.modules A list of module definitions. See <a href="#method_addModule">Loader.addModule</a> for the supported module metadata |
|
5385 * @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`. |
|
5386 * @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. |
|
5387 * @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. |
|
5388 */ |
|
5389 Y.Loader = function(o) { |
|
5390 |
|
5391 var self = this; |
|
5392 |
|
5393 //Catch no config passed. |
|
5394 o = o || {}; |
|
5395 |
|
5396 modulekey = META.md5; |
|
5397 |
|
5398 /** |
|
5399 * Internal callback to handle multiple internal insert() calls |
|
5400 * so that css is inserted prior to js |
|
5401 * @property _internalCallback |
|
5402 * @private |
|
5403 */ |
|
5404 // self._internalCallback = null; |
|
5405 |
|
5406 /** |
|
5407 * Callback that will be executed when the loader is finished |
|
5408 * with an insert |
|
5409 * @method onSuccess |
|
5410 * @type function |
|
5411 */ |
|
5412 // self.onSuccess = null; |
|
5413 |
|
5414 /** |
|
5415 * Callback that will be executed if there is a failure |
|
5416 * @method onFailure |
|
5417 * @type function |
|
5418 */ |
|
5419 // self.onFailure = null; |
|
5420 |
|
5421 /** |
|
5422 * Callback for the 'CSSComplete' event. When loading YUI components |
|
5423 * with CSS the CSS is loaded first, then the script. This provides |
|
5424 * a moment you can tie into to improve the presentation of the page |
|
5425 * while the script is loading. |
|
5426 * @method onCSS |
|
5427 * @type function |
|
5428 */ |
|
5429 // self.onCSS = null; |
|
5430 |
|
5431 /** |
|
5432 * Callback executed each time a script or css file is loaded |
|
5433 * @method onProgress |
|
5434 * @type function |
|
5435 */ |
|
5436 // self.onProgress = null; |
|
5437 |
|
5438 /** |
|
5439 * Callback that will be executed if a timeout occurs |
|
5440 * @method onTimeout |
|
5441 * @type function |
|
5442 */ |
|
5443 // self.onTimeout = null; |
|
5444 |
|
5445 /** |
|
5446 * The execution context for all callbacks |
|
5447 * @property context |
|
5448 * @default {YUI} the YUI instance |
|
5449 */ |
|
5450 self.context = Y; |
|
5451 |
|
5452 /** |
|
5453 * Data that is passed to all callbacks |
|
5454 * @property data |
|
5455 */ |
|
5456 // self.data = null; |
|
5457 |
|
5458 /** |
|
5459 * Node reference or id where new nodes should be inserted before |
|
5460 * @property insertBefore |
|
5461 * @type string|HTMLElement |
|
5462 */ |
|
5463 // self.insertBefore = null; |
|
5464 |
|
5465 /** |
|
5466 * The charset attribute for inserted nodes |
|
5467 * @property charset |
|
5468 * @type string |
|
5469 * @deprecated , use cssAttributes or jsAttributes. |
|
5470 */ |
|
5471 // self.charset = null; |
|
5472 |
|
5473 /** |
|
5474 * An object literal containing attributes to add to link nodes |
|
5475 * @property cssAttributes |
|
5476 * @type object |
|
5477 */ |
|
5478 // self.cssAttributes = null; |
|
5479 |
|
5480 /** |
|
5481 * An object literal containing attributes to add to script nodes |
|
5482 * @property jsAttributes |
|
5483 * @type object |
|
5484 */ |
|
5485 // self.jsAttributes = null; |
|
5486 |
|
5487 /** |
|
5488 * The base directory. |
|
5489 * @property base |
|
5490 * @type string |
|
5491 * @default http://yui.yahooapis.com/[YUI VERSION]/build/ |
|
5492 */ |
|
5493 self.base = Y.Env.meta.base + Y.Env.meta.root; |
|
5494 |
|
5495 /** |
|
5496 * Base path for the combo service |
|
5497 * @property comboBase |
|
5498 * @type string |
|
5499 * @default http://yui.yahooapis.com/combo? |
|
5500 */ |
|
5501 self.comboBase = Y.Env.meta.comboBase; |
|
5502 |
|
5503 /* |
|
5504 * Base path for language packs. |
|
5505 */ |
|
5506 // self.langBase = Y.Env.meta.langBase; |
|
5507 // self.lang = ""; |
|
5508 |
|
5509 /** |
|
5510 * If configured, the loader will attempt to use the combo |
|
5511 * service for YUI resources and configured external resources. |
|
5512 * @property combine |
|
5513 * @type boolean |
|
5514 * @default true if a base dir isn't in the config |
|
5515 */ |
|
5516 self.combine = o.base && |
|
5517 (o.base.indexOf(self.comboBase.substr(0, 20)) > -1); |
|
5518 |
|
5519 /** |
|
5520 * The default seperator to use between files in a combo URL |
|
5521 * @property comboSep |
|
5522 * @type {String} |
|
5523 * @default Ampersand |
|
5524 */ |
|
5525 self.comboSep = '&'; |
|
5526 /** |
|
5527 * Max url length for combo urls. The default is 1024. This is the URL |
|
5528 * limit for the Yahoo! hosted combo servers. If consuming |
|
5529 * a different combo service that has a different URL limit |
|
5530 * it is possible to override this default by supplying |
|
5531 * the maxURLLength config option. The config option will |
|
5532 * only take effect if lower than the default. |
|
5533 * |
|
5534 * @property maxURLLength |
|
5535 * @type int |
|
5536 */ |
|
5537 self.maxURLLength = MAX_URL_LENGTH; |
|
5538 |
|
5539 /** |
|
5540 * Ignore modules registered on the YUI global |
|
5541 * @property ignoreRegistered |
|
5542 * @default false |
|
5543 */ |
|
5544 self.ignoreRegistered = o.ignoreRegistered; |
|
5545 |
|
5546 /** |
|
5547 * Root path to prepend to module path for the combo |
|
5548 * service |
|
5549 * @property root |
|
5550 * @type string |
|
5551 * @default [YUI VERSION]/build/ |
|
5552 */ |
|
5553 self.root = Y.Env.meta.root; |
|
5554 |
|
5555 /** |
|
5556 * Timeout value in milliseconds. If set, self value will be used by |
|
5557 * the get utility. the timeout event will fire if |
|
5558 * a timeout occurs. |
|
5559 * @property timeout |
|
5560 * @type int |
|
5561 */ |
|
5562 self.timeout = 0; |
|
5563 |
|
5564 /** |
|
5565 * A list of modules that should not be loaded, even if |
|
5566 * they turn up in the dependency tree |
|
5567 * @property ignore |
|
5568 * @type string[] |
|
5569 */ |
|
5570 // self.ignore = null; |
|
5571 |
|
5572 /** |
|
5573 * A list of modules that should always be loaded, even |
|
5574 * if they have already been inserted into the page. |
|
5575 * @property force |
|
5576 * @type string[] |
|
5577 */ |
|
5578 // self.force = null; |
|
5579 |
|
5580 self.forceMap = {}; |
|
5581 |
|
5582 /** |
|
5583 * Should we allow rollups |
|
5584 * @property allowRollup |
|
5585 * @type boolean |
|
5586 * @default false |
|
5587 */ |
|
5588 self.allowRollup = false; |
|
5589 |
|
5590 /** |
|
5591 * A filter to apply to result urls. This filter will modify the default |
|
5592 * path for all modules. The default path for the YUI library is the |
|
5593 * minified version of the files (e.g., event-min.js). The filter property |
|
5594 * can be a predefined filter or a custom filter. The valid predefined |
|
5595 * filters are: |
|
5596 * <dl> |
|
5597 * <dt>DEBUG</dt> |
|
5598 * <dd>Selects the debug versions of the library (e.g., event-debug.js). |
|
5599 * This option will automatically include the Logger widget</dd> |
|
5600 * <dt>RAW</dt> |
|
5601 * <dd>Selects the non-minified version of the library (e.g., event.js). |
|
5602 * </dd> |
|
5603 * </dl> |
|
5604 * You can also define a custom filter, which must be an object literal |
|
5605 * containing a search expression and a replace string: |
|
5606 * |
|
5607 * myFilter: { |
|
5608 * 'searchExp': "-min\\.js", |
|
5609 * 'replaceStr': "-debug.js" |
|
5610 * } |
|
5611 * |
|
5612 * @property filter |
|
5613 * @type string| {searchExp: string, replaceStr: string} |
|
5614 */ |
|
5615 // self.filter = null; |
|
5616 |
|
5617 /** |
|
5618 * per-component filter specification. If specified for a given |
|
5619 * component, this overrides the filter config. |
|
5620 * @property filters |
|
5621 * @type object |
|
5622 */ |
|
5623 self.filters = {}; |
|
5624 |
|
5625 /** |
|
5626 * The list of requested modules |
|
5627 * @property required |
|
5628 * @type {string: boolean} |
|
5629 */ |
|
5630 self.required = {}; |
|
5631 |
|
5632 /** |
|
5633 * If a module name is predefined when requested, it is checked againsts |
|
5634 * the patterns provided in this property. If there is a match, the |
|
5635 * module is added with the default configuration. |
|
5636 * |
|
5637 * At the moment only supporting module prefixes, but anticipate |
|
5638 * supporting at least regular expressions. |
|
5639 * @property patterns |
|
5640 * @type Object |
|
5641 */ |
|
5642 // self.patterns = Y.merge(Y.Env.meta.patterns); |
|
5643 self.patterns = {}; |
|
5644 |
|
5645 /** |
|
5646 * The library metadata |
|
5647 * @property moduleInfo |
|
5648 */ |
|
5649 // self.moduleInfo = Y.merge(Y.Env.meta.moduleInfo); |
|
5650 self.moduleInfo = {}; |
|
5651 |
|
5652 self.groups = Y.merge(Y.Env.meta.groups); |
|
5653 |
|
5654 /** |
|
5655 * Provides the information used to skin the skinnable components. |
|
5656 * The following skin definition would result in 'skin1' and 'skin2' |
|
5657 * being loaded for calendar (if calendar was requested), and |
|
5658 * 'sam' for all other skinnable components: |
|
5659 * |
|
5660 * skin: { |
|
5661 * // The default skin, which is automatically applied if not |
|
5662 * // overriden by a component-specific skin definition. |
|
5663 * // Change this in to apply a different skin globally |
|
5664 * defaultSkin: 'sam', |
|
5665 * |
|
5666 * // This is combined with the loader base property to get |
|
5667 * // the default root directory for a skin. ex: |
|
5668 * // http://yui.yahooapis.com/2.3.0/build/assets/skins/sam/ |
|
5669 * base: 'assets/skins/', |
|
5670 * |
|
5671 * // Any component-specific overrides can be specified here, |
|
5672 * // making it possible to load different skins for different |
|
5673 * // components. It is possible to load more than one skin |
|
5674 * // for a given component as well. |
|
5675 * overrides: { |
|
5676 * calendar: ['skin1', 'skin2'] |
|
5677 * } |
|
5678 * } |
|
5679 * @property skin |
|
5680 * @type {Object} |
|
5681 */ |
|
5682 self.skin = Y.merge(Y.Env.meta.skin); |
|
5683 |
|
5684 /* |
|
5685 * Map of conditional modules |
|
5686 * @since 3.2.0 |
|
5687 */ |
|
5688 self.conditions = {}; |
|
5689 |
|
5690 // map of modules with a hash of modules that meet the requirement |
|
5691 // self.provides = {}; |
|
5692 |
|
5693 self.config = o; |
|
5694 self._internal = true; |
|
5695 |
|
5696 self._populateCache(); |
|
5697 |
|
5698 /** |
|
5699 * Set when beginning to compute the dependency tree. |
|
5700 * Composed of what YUI reports to be loaded combined |
|
5701 * with what has been loaded by any instance on the page |
|
5702 * with the version number specified in the metadata. |
|
5703 * @property loaded |
|
5704 * @type {string: boolean} |
|
5705 */ |
|
5706 self.loaded = GLOBAL_LOADED[VERSION]; |
|
5707 |
|
5708 |
|
5709 /** |
|
5710 * Should Loader fetch scripts in `async`, defaults to `true` |
|
5711 * @property async |
|
5712 */ |
|
5713 |
|
5714 self.async = true; |
|
5715 |
|
5716 self._inspectPage(); |
|
5717 |
|
5718 self._internal = false; |
|
5719 |
|
5720 self._config(o); |
|
5721 |
|
5722 self.forceMap = (self.force) ? Y.Array.hash(self.force) : {}; |
|
5723 |
|
5724 self.testresults = null; |
|
5725 |
|
5726 if (Y.config.tests) { |
|
5727 self.testresults = Y.config.tests; |
|
5728 } |
|
5729 |
|
5730 /** |
|
5731 * List of rollup files found in the library metadata |
|
5732 * @property rollups |
|
5733 */ |
|
5734 // self.rollups = null; |
|
5735 |
|
5736 /** |
|
5737 * Whether or not to load optional dependencies for |
|
5738 * the requested modules |
|
5739 * @property loadOptional |
|
5740 * @type boolean |
|
5741 * @default false |
|
5742 */ |
|
5743 // self.loadOptional = false; |
|
5744 |
|
5745 /** |
|
5746 * All of the derived dependencies in sorted order, which |
|
5747 * will be populated when either calculate() or insert() |
|
5748 * is called |
|
5749 * @property sorted |
|
5750 * @type string[] |
|
5751 */ |
|
5752 self.sorted = []; |
|
5753 |
|
5754 /* |
|
5755 * A list of modules to attach to the YUI instance when complete. |
|
5756 * If not supplied, the sorted list of dependencies are applied. |
|
5757 * @property attaching |
|
5758 */ |
|
5759 // self.attaching = null; |
|
5760 |
|
5761 /** |
|
5762 * Flag to indicate the dependency tree needs to be recomputed |
|
5763 * if insert is called again. |
|
5764 * @property dirty |
|
5765 * @type boolean |
|
5766 * @default true |
|
5767 */ |
|
5768 self.dirty = true; |
|
5769 |
|
5770 /** |
|
5771 * List of modules inserted by the utility |
|
5772 * @property inserted |
|
5773 * @type {string: boolean} |
|
5774 */ |
|
5775 self.inserted = {}; |
|
5776 |
|
5777 /** |
|
5778 * List of skipped modules during insert() because the module |
|
5779 * was not defined |
|
5780 * @property skipped |
|
5781 */ |
|
5782 self.skipped = {}; |
|
5783 |
|
5784 // Y.on('yui:load', self.loadNext, self); |
|
5785 |
|
5786 self.tested = {}; |
|
5787 |
|
5788 /* |
|
5789 * Cached sorted calculate results |
|
5790 * @property results |
|
5791 * @since 3.2.0 |
|
5792 */ |
|
5793 //self.results = {}; |
|
5794 |
|
5795 if (self.ignoreRegistered) { |
|
5796 //Clear inpage already processed modules. |
|
5797 self._resetModules(); |
|
5798 } |
|
5799 |
|
5800 }; |
|
5801 |
|
5802 Y.Loader.prototype = { |
|
5803 /** |
|
5804 * Checks the cache for modules and conditions, if they do not exist |
|
5805 * process the default metadata and populate the local moduleInfo hash. |
|
5806 * @method _populateCache |
|
5807 * @private |
|
5808 */ |
|
5809 _populateCache: function() { |
|
5810 var self = this, |
|
5811 defaults = META.modules, |
|
5812 cache = GLOBAL_ENV._renderedMods, |
|
5813 i; |
|
5814 |
|
5815 if (cache && !self.ignoreRegistered) { |
|
5816 for (i in cache) { |
|
5817 if (cache.hasOwnProperty(i)) { |
|
5818 self.moduleInfo[i] = Y.merge(cache[i]); |
|
5819 } |
|
5820 } |
|
5821 |
|
5822 cache = GLOBAL_ENV._conditions; |
|
5823 for (i in cache) { |
|
5824 if (cache.hasOwnProperty(i)) { |
|
5825 self.conditions[i] = Y.merge(cache[i]); |
|
5826 } |
|
5827 } |
|
5828 |
|
5829 } else { |
|
5830 for (i in defaults) { |
|
5831 if (defaults.hasOwnProperty(i)) { |
|
5832 self.addModule(defaults[i], i); |
|
5833 } |
|
5834 } |
|
5835 } |
|
5836 |
|
5837 }, |
|
5838 /** |
|
5839 * Reset modules in the module cache to a pre-processed state so additional |
|
5840 * computations with a different skin or language will work as expected. |
|
5841 * @method _resetModules |
|
5842 * @private |
|
5843 */ |
|
5844 _resetModules: function() { |
|
5845 var self = this, i, o, |
|
5846 mod, name, details; |
|
5847 for (i in self.moduleInfo) { |
|
5848 if (self.moduleInfo.hasOwnProperty(i)) { |
|
5849 mod = self.moduleInfo[i]; |
|
5850 name = mod.name; |
|
5851 details = (YUI.Env.mods[name] ? YUI.Env.mods[name].details : null); |
|
5852 |
|
5853 if (details) { |
|
5854 self.moduleInfo[name]._reset = true; |
|
5855 self.moduleInfo[name].requires = details.requires || []; |
|
5856 self.moduleInfo[name].optional = details.optional || []; |
|
5857 self.moduleInfo[name].supersedes = details.supercedes || []; |
|
5858 } |
|
5859 |
|
5860 if (mod.defaults) { |
|
5861 for (o in mod.defaults) { |
|
5862 if (mod.defaults.hasOwnProperty(o)) { |
|
5863 if (mod[o]) { |
|
5864 mod[o] = mod.defaults[o]; |
|
5865 } |
|
5866 } |
|
5867 } |
|
5868 } |
|
5869 delete mod.langCache; |
|
5870 delete mod.skinCache; |
|
5871 if (mod.skinnable) { |
|
5872 self._addSkin(self.skin.defaultSkin, mod.name); |
|
5873 } |
|
5874 } |
|
5875 } |
|
5876 }, |
|
5877 /** |
|
5878 Regex that matches a CSS URL. Used to guess the file type when it's not |
|
5879 specified. |
|
5880 |
|
5881 @property REGEX_CSS |
|
5882 @type RegExp |
|
5883 @final |
|
5884 @protected |
|
5885 @since 3.5.0 |
|
5886 **/ |
|
5887 REGEX_CSS: /\.css(?:[?;].*)?$/i, |
|
5888 |
|
5889 /** |
|
5890 * Default filters for raw and debug |
|
5891 * @property FILTER_DEFS |
|
5892 * @type Object |
|
5893 * @final |
|
5894 * @protected |
|
5895 */ |
|
5896 FILTER_DEFS: { |
|
5897 RAW: { |
|
5898 'searchExp': '-min\\.js', |
|
5899 'replaceStr': '.js' |
|
5900 }, |
|
5901 DEBUG: { |
|
5902 'searchExp': '-min\\.js', |
|
5903 'replaceStr': '-debug.js' |
|
5904 }, |
|
5905 COVERAGE: { |
|
5906 'searchExp': '-min\\.js', |
|
5907 'replaceStr': '-coverage.js' |
|
5908 } |
|
5909 }, |
|
5910 /* |
|
5911 * Check the pages meta-data and cache the result. |
|
5912 * @method _inspectPage |
|
5913 * @private |
|
5914 */ |
|
5915 _inspectPage: function() { |
|
5916 var self = this, v, m, req, mr, i; |
|
5917 |
|
5918 //Inspect the page for CSS only modules and mark them as loaded. |
|
5919 for (i in self.moduleInfo) { |
|
5920 if (self.moduleInfo.hasOwnProperty(i)) { |
|
5921 v = self.moduleInfo[i]; |
|
5922 if (v.type && v.type === CSS) { |
|
5923 if (self.isCSSLoaded(v.name)) { |
|
5924 Y.log('Found CSS module on page: ' + v.name, 'info', 'loader'); |
|
5925 self.loaded[i] = true; |
|
5926 } |
|
5927 } |
|
5928 } |
|
5929 } |
|
5930 for (i in ON_PAGE) { |
|
5931 if (ON_PAGE.hasOwnProperty(i)) { |
|
5932 v = ON_PAGE[i]; |
|
5933 if (v.details) { |
|
5934 m = self.moduleInfo[v.name]; |
|
5935 req = v.details.requires; |
|
5936 mr = m && m.requires; |
|
5937 |
|
5938 if (m) { |
|
5939 if (!m._inspected && req && mr.length !== req.length) { |
|
5940 // console.log('deleting ' + m.name); |
|
5941 delete m.expanded; |
|
5942 } |
|
5943 } else { |
|
5944 m = self.addModule(v.details, i); |
|
5945 } |
|
5946 m._inspected = true; |
|
5947 } |
|
5948 } |
|
5949 } |
|
5950 }, |
|
5951 /* |
|
5952 * returns true if b is not loaded, and is required directly or by means of modules it supersedes. |
|
5953 * @private |
|
5954 * @method _requires |
|
5955 * @param {String} mod1 The first module to compare |
|
5956 * @param {String} mod2 The second module to compare |
|
5957 */ |
|
5958 _requires: function(mod1, mod2) { |
|
5959 |
|
5960 var i, rm, after_map, s, |
|
5961 info = this.moduleInfo, |
|
5962 m = info[mod1], |
|
5963 other = info[mod2]; |
|
5964 |
|
5965 if (!m || !other) { |
|
5966 return false; |
|
5967 } |
|
5968 |
|
5969 rm = m.expanded_map; |
|
5970 after_map = m.after_map; |
|
5971 |
|
5972 // check if this module should be sorted after the other |
|
5973 // do this first to short circut circular deps |
|
5974 if (after_map && (mod2 in after_map)) { |
|
5975 return true; |
|
5976 } |
|
5977 |
|
5978 after_map = other.after_map; |
|
5979 |
|
5980 // and vis-versa |
|
5981 if (after_map && (mod1 in after_map)) { |
|
5982 return false; |
|
5983 } |
|
5984 |
|
5985 // check if this module requires one the other supersedes |
|
5986 s = info[mod2] && info[mod2].supersedes; |
|
5987 if (s) { |
|
5988 for (i = 0; i < s.length; i++) { |
|
5989 if (this._requires(mod1, s[i])) { |
|
5990 return true; |
|
5991 } |
|
5992 } |
|
5993 } |
|
5994 |
|
5995 s = info[mod1] && info[mod1].supersedes; |
|
5996 if (s) { |
|
5997 for (i = 0; i < s.length; i++) { |
|
5998 if (this._requires(mod2, s[i])) { |
|
5999 return false; |
|
6000 } |
|
6001 } |
|
6002 } |
|
6003 |
|
6004 // check if this module requires the other directly |
|
6005 // if (r && yArray.indexOf(r, mod2) > -1) { |
|
6006 if (rm && (mod2 in rm)) { |
|
6007 return true; |
|
6008 } |
|
6009 |
|
6010 // external css files should be sorted below yui css |
|
6011 if (m.ext && m.type === CSS && !other.ext && other.type === CSS) { |
|
6012 return true; |
|
6013 } |
|
6014 |
|
6015 return false; |
|
6016 }, |
|
6017 /** |
|
6018 * Apply a new config to the Loader instance |
|
6019 * @method _config |
|
6020 * @private |
|
6021 * @param {Object} o The new configuration |
|
6022 */ |
|
6023 _config: function(o) { |
|
6024 var i, j, val, a, f, group, groupName, self = this, |
|
6025 mods = [], mod; |
|
6026 // apply config values |
|
6027 if (o) { |
|
6028 for (i in o) { |
|
6029 if (o.hasOwnProperty(i)) { |
|
6030 val = o[i]; |
|
6031 //TODO This should be a case |
|
6032 if (i === 'require') { |
|
6033 self.require(val); |
|
6034 } else if (i === 'skin') { |
|
6035 //If the config.skin is a string, format to the expected object |
|
6036 if (typeof val === 'string') { |
|
6037 self.skin.defaultSkin = o.skin; |
|
6038 val = { |
|
6039 defaultSkin: val |
|
6040 }; |
|
6041 } |
|
6042 |
|
6043 Y.mix(self.skin, val, true); |
|
6044 } else if (i === 'groups') { |
|
6045 for (j in val) { |
|
6046 if (val.hasOwnProperty(j)) { |
|
6047 // Y.log('group: ' + j); |
|
6048 groupName = j; |
|
6049 group = val[j]; |
|
6050 self.addGroup(group, groupName); |
|
6051 if (group.aliases) { |
|
6052 for (a in group.aliases) { |
|
6053 if (group.aliases.hasOwnProperty(a)) { |
|
6054 self.addAlias(group.aliases[a], a); |
|
6055 } |
|
6056 } |
|
6057 } |
|
6058 } |
|
6059 } |
|
6060 |
|
6061 } else if (i === 'modules') { |
|
6062 // add a hash of module definitions |
|
6063 for (j in val) { |
|
6064 if (val.hasOwnProperty(j)) { |
|
6065 self.addModule(val[j], j); |
|
6066 } |
|
6067 } |
|
6068 } else if (i === 'aliases') { |
|
6069 for (j in val) { |
|
6070 if (val.hasOwnProperty(j)) { |
|
6071 self.addAlias(val[j], j); |
|
6072 } |
|
6073 } |
|
6074 } else if (i === 'gallery') { |
|
6075 if (this.groups.gallery.update) { |
|
6076 this.groups.gallery.update(val, o); |
|
6077 } |
|
6078 } else if (i === 'yui2' || i === '2in3') { |
|
6079 if (this.groups.yui2.update) { |
|
6080 this.groups.yui2.update(o['2in3'], o.yui2, o); |
|
6081 } |
|
6082 } else { |
|
6083 self[i] = val; |
|
6084 } |
|
6085 } |
|
6086 } |
|
6087 } |
|
6088 |
|
6089 // fix filter |
|
6090 f = self.filter; |
|
6091 |
|
6092 if (L.isString(f)) { |
|
6093 f = f.toUpperCase(); |
|
6094 self.filterName = f; |
|
6095 self.filter = self.FILTER_DEFS[f]; |
|
6096 if (f === 'DEBUG') { |
|
6097 self.require('yui-log', 'dump'); |
|
6098 } |
|
6099 } |
|
6100 |
|
6101 if (self.filterName && self.coverage) { |
|
6102 if (self.filterName === 'COVERAGE' && L.isArray(self.coverage) && self.coverage.length) { |
|
6103 for (i = 0; i < self.coverage.length; i++) { |
|
6104 mod = self.coverage[i]; |
|
6105 if (self.moduleInfo[mod] && self.moduleInfo[mod].use) { |
|
6106 mods = [].concat(mods, self.moduleInfo[mod].use); |
|
6107 } else { |
|
6108 mods.push(mod); |
|
6109 } |
|
6110 } |
|
6111 self.filters = self.filters || {}; |
|
6112 Y.Array.each(mods, function(mod) { |
|
6113 self.filters[mod] = self.FILTER_DEFS.COVERAGE; |
|
6114 }); |
|
6115 self.filterName = 'RAW'; |
|
6116 self.filter = self.FILTER_DEFS[self.filterName]; |
|
6117 } |
|
6118 } |
|
6119 |
|
6120 }, |
|
6121 |
|
6122 /** |
|
6123 * Returns the skin module name for the specified skin name. If a |
|
6124 * module name is supplied, the returned skin module name is |
|
6125 * specific to the module passed in. |
|
6126 * @method formatSkin |
|
6127 * @param {string} skin the name of the skin. |
|
6128 * @param {string} mod optional: the name of a module to skin. |
|
6129 * @return {string} the full skin module name. |
|
6130 */ |
|
6131 formatSkin: function(skin, mod) { |
|
6132 var s = SKIN_PREFIX + skin; |
|
6133 if (mod) { |
|
6134 s = s + '-' + mod; |
|
6135 } |
|
6136 |
|
6137 return s; |
|
6138 }, |
|
6139 |
|
6140 /** |
|
6141 * Adds the skin def to the module info |
|
6142 * @method _addSkin |
|
6143 * @param {string} skin the name of the skin. |
|
6144 * @param {string} mod the name of the module. |
|
6145 * @param {string} parent parent module if this is a skin of a |
|
6146 * submodule or plugin. |
|
6147 * @return {string} the module name for the skin. |
|
6148 * @private |
|
6149 */ |
|
6150 _addSkin: function(skin, mod, parent) { |
|
6151 var mdef, pkg, name, nmod, |
|
6152 info = this.moduleInfo, |
|
6153 sinf = this.skin, |
|
6154 ext = info[mod] && info[mod].ext; |
|
6155 |
|
6156 // Add a module definition for the module-specific skin css |
|
6157 if (mod) { |
|
6158 name = this.formatSkin(skin, mod); |
|
6159 if (!info[name]) { |
|
6160 mdef = info[mod]; |
|
6161 pkg = mdef.pkg || mod; |
|
6162 nmod = { |
|
6163 skin: true, |
|
6164 name: name, |
|
6165 group: mdef.group, |
|
6166 type: 'css', |
|
6167 after: sinf.after, |
|
6168 path: (parent || pkg) + '/' + sinf.base + skin + |
|
6169 '/' + mod + '.css', |
|
6170 ext: ext |
|
6171 }; |
|
6172 if (mdef.base) { |
|
6173 nmod.base = mdef.base; |
|
6174 } |
|
6175 if (mdef.configFn) { |
|
6176 nmod.configFn = mdef.configFn; |
|
6177 } |
|
6178 this.addModule(nmod, name); |
|
6179 |
|
6180 Y.log('Adding skin (' + name + '), ' + parent + ', ' + pkg + ', ' + info[name].path, 'info', 'loader'); |
|
6181 } |
|
6182 } |
|
6183 |
|
6184 return name; |
|
6185 }, |
|
6186 /** |
|
6187 * Adds an alias module to the system |
|
6188 * @method addAlias |
|
6189 * @param {Array} use An array of modules that makes up this alias |
|
6190 * @param {String} name The name of the alias |
|
6191 * @example |
|
6192 * var loader = new Y.Loader({}); |
|
6193 * loader.addAlias([ 'node', 'yql' ], 'davglass'); |
|
6194 * loader.require(['davglass']); |
|
6195 * var out = loader.resolve(true); |
|
6196 * |
|
6197 * //out.js will contain Node and YQL modules |
|
6198 */ |
|
6199 addAlias: function(use, name) { |
|
6200 YUI.Env.aliases[name] = use; |
|
6201 this.addModule({ |
|
6202 name: name, |
|
6203 use: use |
|
6204 }); |
|
6205 }, |
|
6206 /** |
|
6207 * Add a new module group |
|
6208 * @method addGroup |
|
6209 * @param {Object} config An object containing the group configuration data |
|
6210 * @param {String} config.name required, the group name |
|
6211 * @param {String} config.base The base directory for this module group |
|
6212 * @param {String} config.root The root path to add to each combo resource path |
|
6213 * @param {Boolean} config.combine Should the request be combined |
|
6214 * @param {String} config.comboBase Combo service base path |
|
6215 * @param {Object} config.modules The group of modules |
|
6216 * @param {String} name the group name. |
|
6217 * @example |
|
6218 * var loader = new Y.Loader({}); |
|
6219 * loader.addGroup({ |
|
6220 * name: 'davglass', |
|
6221 * combine: true, |
|
6222 * comboBase: '/combo?', |
|
6223 * root: '', |
|
6224 * modules: { |
|
6225 * //Module List here |
|
6226 * } |
|
6227 * }, 'davglass'); |
|
6228 */ |
|
6229 addGroup: function(o, name) { |
|
6230 var mods = o.modules, |
|
6231 self = this, i, v; |
|
6232 |
|
6233 name = name || o.name; |
|
6234 o.name = name; |
|
6235 self.groups[name] = o; |
|
6236 |
|
6237 if (o.patterns) { |
|
6238 for (i in o.patterns) { |
|
6239 if (o.patterns.hasOwnProperty(i)) { |
|
6240 o.patterns[i].group = name; |
|
6241 self.patterns[i] = o.patterns[i]; |
|
6242 } |
|
6243 } |
|
6244 } |
|
6245 |
|
6246 if (mods) { |
|
6247 for (i in mods) { |
|
6248 if (mods.hasOwnProperty(i)) { |
|
6249 v = mods[i]; |
|
6250 if (typeof v === 'string') { |
|
6251 v = { name: i, fullpath: v }; |
|
6252 } |
|
6253 v.group = name; |
|
6254 self.addModule(v, i); |
|
6255 } |
|
6256 } |
|
6257 } |
|
6258 }, |
|
6259 |
|
6260 /** |
|
6261 * Add a new module to the component metadata. |
|
6262 * @method addModule |
|
6263 * @param {Object} config An object containing the module data. |
|
6264 * @param {String} config.name Required, the component name |
|
6265 * @param {String} config.type Required, the component type (js or css) |
|
6266 * @param {String} config.path Required, the path to the script from `base` |
|
6267 * @param {Array} config.requires Array of modules required by this component |
|
6268 * @param {Array} [config.optional] Array of optional modules for this component |
|
6269 * @param {Array} [config.supersedes] Array of the modules this component replaces |
|
6270 * @param {Array} [config.after] Array of modules the components which, if present, should be sorted above this one |
|
6271 * @param {Object} [config.after_map] Faster alternative to 'after' -- supply a hash instead of an array |
|
6272 * @param {Number} [config.rollup] The number of superseded modules required for automatic rollup |
|
6273 * @param {String} [config.fullpath] If `fullpath` is specified, this is used instead of the configured `base + path` |
|
6274 * @param {Boolean} [config.skinnable] Flag to determine if skin assets should automatically be pulled in |
|
6275 * @param {Object} [config.submodules] Hash of submodules |
|
6276 * @param {String} [config.group] The group the module belongs to -- this is set automatically when it is added as part of a group configuration. |
|
6277 * @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"]` |
|
6278 * @param {Object} [config.condition] Specifies that the module should be loaded automatically if a condition is met. This is an object with up to four fields: |
|
6279 * @param {String} [config.condition.trigger] The name of a module that can trigger the auto-load |
|
6280 * @param {Function} [config.condition.test] A function that returns true when the module is to be loaded. |
|
6281 * @param {String} [config.condition.ua] The UA name of <a href="UA.html">Y.UA</a> object that returns true when the module is to be loaded. e.g., `"ie"`, `"nodejs"`. |
|
6282 * @param {String} [config.condition.when] Specifies the load order of the conditional module |
|
6283 * with regard to the position of the trigger module. |
|
6284 * This should be one of three values: `before`, `after`, or `instead`. The default is `after`. |
|
6285 * @param {Object} [config.testresults] A hash of test results from `Y.Features.all()` |
|
6286 * @param {Function} [config.configFn] A function to exectute when configuring this module |
|
6287 * @param {Object} config.configFn.mod The module config, modifying this object will modify it's config. Returning false will delete the module's config. |
|
6288 * @param {String} [name] The module name, required if not in the module data. |
|
6289 * @return {Object} the module definition or null if the object passed in did not provide all required attributes. |
|
6290 */ |
|
6291 addModule: function(o, name) { |
|
6292 name = name || o.name; |
|
6293 |
|
6294 if (typeof o === 'string') { |
|
6295 o = { name: name, fullpath: o }; |
|
6296 } |
|
6297 |
|
6298 |
|
6299 var subs, i, l, t, sup, s, smod, plugins, plug, |
|
6300 j, langs, packName, supName, flatSup, flatLang, lang, ret, |
|
6301 overrides, skinname, when, g, p, |
|
6302 conditions = this.conditions, trigger; |
|
6303 |
|
6304 //Only merge this data if the temp flag is set |
|
6305 //from an earlier pass from a pattern or else |
|
6306 //an override module (YUI_config) can not be used to |
|
6307 //replace a default module. |
|
6308 if (this.moduleInfo[name] && this.moduleInfo[name].temp) { |
|
6309 //This catches temp modules loaded via a pattern |
|
6310 // The module will be added twice, once from the pattern and |
|
6311 // Once from the actual add call, this ensures that properties |
|
6312 // that were added to the module the first time around (group: gallery) |
|
6313 // are also added the second time around too. |
|
6314 o = Y.merge(this.moduleInfo[name], o); |
|
6315 } |
|
6316 |
|
6317 o.name = name; |
|
6318 |
|
6319 if (!o || !o.name) { |
|
6320 return null; |
|
6321 } |
|
6322 |
|
6323 if (!o.type) { |
|
6324 //Always assume it's javascript unless the CSS pattern is matched. |
|
6325 o.type = JS; |
|
6326 p = o.path || o.fullpath; |
|
6327 if (p && this.REGEX_CSS.test(p)) { |
|
6328 Y.log('Auto determined module type as CSS', 'warn', 'loader'); |
|
6329 o.type = CSS; |
|
6330 } |
|
6331 } |
|
6332 |
|
6333 if (!o.path && !o.fullpath) { |
|
6334 o.path = _path(name, name, o.type); |
|
6335 } |
|
6336 o.supersedes = o.supersedes || o.use; |
|
6337 |
|
6338 o.ext = ('ext' in o) ? o.ext : (this._internal) ? false : true; |
|
6339 |
|
6340 // Handle submodule logic |
|
6341 subs = o.submodules; |
|
6342 |
|
6343 this.moduleInfo[name] = o; |
|
6344 |
|
6345 o.requires = o.requires || []; |
|
6346 |
|
6347 /* |
|
6348 Only allowing the cascade of requires information, since |
|
6349 optional and supersedes are far more fine grained than |
|
6350 a blanket requires is. |
|
6351 */ |
|
6352 if (this.requires) { |
|
6353 for (i = 0; i < this.requires.length; i++) { |
|
6354 o.requires.push(this.requires[i]); |
|
6355 } |
|
6356 } |
|
6357 if (o.group && this.groups && this.groups[o.group]) { |
|
6358 g = this.groups[o.group]; |
|
6359 if (g.requires) { |
|
6360 for (i = 0; i < g.requires.length; i++) { |
|
6361 o.requires.push(g.requires[i]); |
|
6362 } |
|
6363 } |
|
6364 } |
|
6365 |
|
6366 |
|
6367 if (!o.defaults) { |
|
6368 o.defaults = { |
|
6369 requires: o.requires ? [].concat(o.requires) : null, |
|
6370 supersedes: o.supersedes ? [].concat(o.supersedes) : null, |
|
6371 optional: o.optional ? [].concat(o.optional) : null |
|
6372 }; |
|
6373 } |
|
6374 |
|
6375 if (o.skinnable && o.ext && o.temp) { |
|
6376 skinname = this._addSkin(this.skin.defaultSkin, name); |
|
6377 o.requires.unshift(skinname); |
|
6378 } |
|
6379 |
|
6380 if (o.requires.length) { |
|
6381 o.requires = this.filterRequires(o.requires) || []; |
|
6382 } |
|
6383 |
|
6384 if (!o.langPack && o.lang) { |
|
6385 langs = yArray(o.lang); |
|
6386 for (j = 0; j < langs.length; j++) { |
|
6387 lang = langs[j]; |
|
6388 packName = this.getLangPackName(lang, name); |
|
6389 smod = this.moduleInfo[packName]; |
|
6390 if (!smod) { |
|
6391 smod = this._addLangPack(lang, o, packName); |
|
6392 } |
|
6393 } |
|
6394 } |
|
6395 |
|
6396 |
|
6397 if (subs) { |
|
6398 sup = o.supersedes || []; |
|
6399 l = 0; |
|
6400 |
|
6401 for (i in subs) { |
|
6402 if (subs.hasOwnProperty(i)) { |
|
6403 s = subs[i]; |
|
6404 |
|
6405 s.path = s.path || _path(name, i, o.type); |
|
6406 s.pkg = name; |
|
6407 s.group = o.group; |
|
6408 |
|
6409 if (s.supersedes) { |
|
6410 sup = sup.concat(s.supersedes); |
|
6411 } |
|
6412 |
|
6413 smod = this.addModule(s, i); |
|
6414 sup.push(i); |
|
6415 |
|
6416 if (smod.skinnable) { |
|
6417 o.skinnable = true; |
|
6418 overrides = this.skin.overrides; |
|
6419 if (overrides && overrides[i]) { |
|
6420 for (j = 0; j < overrides[i].length; j++) { |
|
6421 skinname = this._addSkin(overrides[i][j], |
|
6422 i, name); |
|
6423 sup.push(skinname); |
|
6424 } |
|
6425 } |
|
6426 skinname = this._addSkin(this.skin.defaultSkin, |
|
6427 i, name); |
|
6428 sup.push(skinname); |
|
6429 } |
|
6430 |
|
6431 // looks like we are expected to work out the metadata |
|
6432 // for the parent module language packs from what is |
|
6433 // specified in the child modules. |
|
6434 if (s.lang && s.lang.length) { |
|
6435 |
|
6436 langs = yArray(s.lang); |
|
6437 for (j = 0; j < langs.length; j++) { |
|
6438 lang = langs[j]; |
|
6439 packName = this.getLangPackName(lang, name); |
|
6440 supName = this.getLangPackName(lang, i); |
|
6441 smod = this.moduleInfo[packName]; |
|
6442 |
|
6443 if (!smod) { |
|
6444 smod = this._addLangPack(lang, o, packName); |
|
6445 } |
|
6446 |
|
6447 flatSup = flatSup || yArray.hash(smod.supersedes); |
|
6448 |
|
6449 if (!(supName in flatSup)) { |
|
6450 smod.supersedes.push(supName); |
|
6451 } |
|
6452 |
|
6453 o.lang = o.lang || []; |
|
6454 |
|
6455 flatLang = flatLang || yArray.hash(o.lang); |
|
6456 |
|
6457 if (!(lang in flatLang)) { |
|
6458 o.lang.push(lang); |
|
6459 } |
|
6460 |
|
6461 // Y.log('pack ' + packName + ' should supersede ' + supName); |
|
6462 // Add rollup file, need to add to supersedes list too |
|
6463 |
|
6464 // default packages |
|
6465 packName = this.getLangPackName(ROOT_LANG, name); |
|
6466 supName = this.getLangPackName(ROOT_LANG, i); |
|
6467 |
|
6468 smod = this.moduleInfo[packName]; |
|
6469 |
|
6470 if (!smod) { |
|
6471 smod = this._addLangPack(lang, o, packName); |
|
6472 } |
|
6473 |
|
6474 if (!(supName in flatSup)) { |
|
6475 smod.supersedes.push(supName); |
|
6476 } |
|
6477 |
|
6478 // Y.log('pack ' + packName + ' should supersede ' + supName); |
|
6479 // Add rollup file, need to add to supersedes list too |
|
6480 |
|
6481 } |
|
6482 } |
|
6483 |
|
6484 l++; |
|
6485 } |
|
6486 } |
|
6487 //o.supersedes = YObject.keys(yArray.hash(sup)); |
|
6488 o.supersedes = yArray.dedupe(sup); |
|
6489 if (this.allowRollup) { |
|
6490 o.rollup = (l < 4) ? l : Math.min(l - 1, 4); |
|
6491 } |
|
6492 } |
|
6493 |
|
6494 plugins = o.plugins; |
|
6495 if (plugins) { |
|
6496 for (i in plugins) { |
|
6497 if (plugins.hasOwnProperty(i)) { |
|
6498 plug = plugins[i]; |
|
6499 plug.pkg = name; |
|
6500 plug.path = plug.path || _path(name, i, o.type); |
|
6501 plug.requires = plug.requires || []; |
|
6502 plug.group = o.group; |
|
6503 this.addModule(plug, i); |
|
6504 if (o.skinnable) { |
|
6505 this._addSkin(this.skin.defaultSkin, i, name); |
|
6506 } |
|
6507 |
|
6508 } |
|
6509 } |
|
6510 } |
|
6511 |
|
6512 if (o.condition) { |
|
6513 t = o.condition.trigger; |
|
6514 if (YUI.Env.aliases[t]) { |
|
6515 t = YUI.Env.aliases[t]; |
|
6516 } |
|
6517 if (!Y.Lang.isArray(t)) { |
|
6518 t = [t]; |
|
6519 } |
|
6520 |
|
6521 for (i = 0; i < t.length; i++) { |
|
6522 trigger = t[i]; |
|
6523 when = o.condition.when; |
|
6524 conditions[trigger] = conditions[trigger] || {}; |
|
6525 conditions[trigger][name] = o.condition; |
|
6526 // the 'when' attribute can be 'before', 'after', or 'instead' |
|
6527 // the default is after. |
|
6528 if (when && when !== 'after') { |
|
6529 if (when === 'instead') { // replace the trigger |
|
6530 o.supersedes = o.supersedes || []; |
|
6531 o.supersedes.push(trigger); |
|
6532 } |
|
6533 // before the trigger |
|
6534 // the trigger requires the conditional mod, |
|
6535 // so it should appear before the conditional |
|
6536 // mod if we do not intersede. |
|
6537 } else { // after the trigger |
|
6538 o.after = o.after || []; |
|
6539 o.after.push(trigger); |
|
6540 } |
|
6541 } |
|
6542 } |
|
6543 |
|
6544 if (o.supersedes) { |
|
6545 o.supersedes = this.filterRequires(o.supersedes); |
|
6546 } |
|
6547 |
|
6548 if (o.after) { |
|
6549 o.after = this.filterRequires(o.after); |
|
6550 o.after_map = yArray.hash(o.after); |
|
6551 } |
|
6552 |
|
6553 // this.dirty = true; |
|
6554 |
|
6555 if (o.configFn) { |
|
6556 ret = o.configFn(o); |
|
6557 if (ret === false) { |
|
6558 Y.log('Config function returned false for ' + name + ', skipping.', 'info', 'loader'); |
|
6559 delete this.moduleInfo[name]; |
|
6560 delete GLOBAL_ENV._renderedMods[name]; |
|
6561 o = null; |
|
6562 } |
|
6563 } |
|
6564 //Add to global cache |
|
6565 if (o) { |
|
6566 if (!GLOBAL_ENV._renderedMods) { |
|
6567 GLOBAL_ENV._renderedMods = {}; |
|
6568 } |
|
6569 GLOBAL_ENV._renderedMods[name] = Y.mix(GLOBAL_ENV._renderedMods[name] || {}, o); |
|
6570 GLOBAL_ENV._conditions = conditions; |
|
6571 } |
|
6572 |
|
6573 return o; |
|
6574 }, |
|
6575 |
|
6576 /** |
|
6577 * Add a requirement for one or more module |
|
6578 * @method require |
|
6579 * @param {string[] | string*} what the modules to load. |
|
6580 */ |
|
6581 require: function(what) { |
|
6582 var a = (typeof what === 'string') ? yArray(arguments) : what; |
|
6583 this.dirty = true; |
|
6584 this.required = Y.merge(this.required, yArray.hash(this.filterRequires(a))); |
|
6585 |
|
6586 this._explodeRollups(); |
|
6587 }, |
|
6588 /** |
|
6589 * Grab all the items that were asked for, check to see if the Loader |
|
6590 * meta-data contains a "use" array. If it doesm remove the asked item and replace it with |
|
6591 * the content of the "use". |
|
6592 * This will make asking for: "dd" |
|
6593 * Actually ask for: "dd-ddm-base,dd-ddm,dd-ddm-drop,dd-drag,dd-proxy,dd-constrain,dd-drop,dd-scroll,dd-drop-plugin" |
|
6594 * @private |
|
6595 * @method _explodeRollups |
|
6596 */ |
|
6597 _explodeRollups: function() { |
|
6598 var self = this, m, m2, i, a, v, len, len2, |
|
6599 r = self.required; |
|
6600 |
|
6601 if (!self.allowRollup) { |
|
6602 for (i in r) { |
|
6603 if (r.hasOwnProperty(i)) { |
|
6604 m = self.getModule(i); |
|
6605 if (m && m.use) { |
|
6606 len = m.use.length; |
|
6607 for (a = 0; a < len; a++) { |
|
6608 m2 = self.getModule(m.use[a]); |
|
6609 if (m2 && m2.use) { |
|
6610 len2 = m2.use.length; |
|
6611 for (v = 0; v < len2; v++) { |
|
6612 r[m2.use[v]] = true; |
|
6613 } |
|
6614 } else { |
|
6615 r[m.use[a]] = true; |
|
6616 } |
|
6617 } |
|
6618 } |
|
6619 } |
|
6620 } |
|
6621 self.required = r; |
|
6622 } |
|
6623 |
|
6624 }, |
|
6625 /** |
|
6626 * Explodes the required array to remove aliases and replace them with real modules |
|
6627 * @method filterRequires |
|
6628 * @param {Array} r The original requires array |
|
6629 * @return {Array} The new array of exploded requirements |
|
6630 */ |
|
6631 filterRequires: function(r) { |
|
6632 if (r) { |
|
6633 if (!Y.Lang.isArray(r)) { |
|
6634 r = [r]; |
|
6635 } |
|
6636 r = Y.Array(r); |
|
6637 var c = [], i, mod, o, m; |
|
6638 |
|
6639 for (i = 0; i < r.length; i++) { |
|
6640 mod = this.getModule(r[i]); |
|
6641 if (mod && mod.use) { |
|
6642 for (o = 0; o < mod.use.length; o++) { |
|
6643 //Must walk the other modules in case a module is a rollup of rollups (datatype) |
|
6644 m = this.getModule(mod.use[o]); |
|
6645 if (m && m.use && (m.name !== mod.name)) { |
|
6646 c = Y.Array.dedupe([].concat(c, this.filterRequires(m.use))); |
|
6647 } else { |
|
6648 c.push(mod.use[o]); |
|
6649 } |
|
6650 } |
|
6651 } else { |
|
6652 c.push(r[i]); |
|
6653 } |
|
6654 } |
|
6655 r = c; |
|
6656 } |
|
6657 return r; |
|
6658 }, |
|
6659 /** |
|
6660 * Returns an object containing properties for all modules required |
|
6661 * in order to load the requested module |
|
6662 * @method getRequires |
|
6663 * @param {object} mod The module definition from moduleInfo. |
|
6664 * @return {array} the expanded requirement list. |
|
6665 */ |
|
6666 getRequires: function(mod) { |
|
6667 |
|
6668 if (!mod) { |
|
6669 //console.log('returning no reqs for ' + mod.name); |
|
6670 return NO_REQUIREMENTS; |
|
6671 } |
|
6672 |
|
6673 if (mod._parsed) { |
|
6674 //console.log('returning requires for ' + mod.name, mod.requires); |
|
6675 return mod.expanded || NO_REQUIREMENTS; |
|
6676 } |
|
6677 |
|
6678 //TODO add modue cache here out of scope.. |
|
6679 |
|
6680 var i, m, j, add, packName, lang, testresults = this.testresults, |
|
6681 name = mod.name, cond, |
|
6682 adddef = ON_PAGE[name] && ON_PAGE[name].details, |
|
6683 d, go, def, |
|
6684 r, old_mod, |
|
6685 o, skinmod, skindef, skinpar, skinname, |
|
6686 intl = mod.lang || mod.intl, |
|
6687 info = this.moduleInfo, |
|
6688 ftests = Y.Features && Y.Features.tests.load, |
|
6689 hash, reparse; |
|
6690 |
|
6691 // console.log(name); |
|
6692 |
|
6693 // pattern match leaves module stub that needs to be filled out |
|
6694 if (mod.temp && adddef) { |
|
6695 old_mod = mod; |
|
6696 mod = this.addModule(adddef, name); |
|
6697 mod.group = old_mod.group; |
|
6698 mod.pkg = old_mod.pkg; |
|
6699 delete mod.expanded; |
|
6700 } |
|
6701 |
|
6702 // console.log('cache: ' + mod.langCache + ' == ' + this.lang); |
|
6703 |
|
6704 //If a skin or a lang is different, reparse.. |
|
6705 reparse = !((!this.lang || mod.langCache === this.lang) && (mod.skinCache === this.skin.defaultSkin)); |
|
6706 |
|
6707 if (mod.expanded && !reparse) { |
|
6708 //Y.log('Already expanded ' + name + ', ' + mod.expanded); |
|
6709 return mod.expanded; |
|
6710 } |
|
6711 |
|
6712 |
|
6713 d = []; |
|
6714 hash = {}; |
|
6715 r = this.filterRequires(mod.requires); |
|
6716 if (mod.lang) { |
|
6717 //If a module has a lang attribute, auto add the intl requirement. |
|
6718 d.unshift('intl'); |
|
6719 r.unshift('intl'); |
|
6720 intl = true; |
|
6721 } |
|
6722 o = this.filterRequires(mod.optional); |
|
6723 |
|
6724 // Y.log("getRequires: " + name + " (dirty:" + this.dirty + |
|
6725 // ", expanded:" + mod.expanded + ")"); |
|
6726 |
|
6727 mod._parsed = true; |
|
6728 mod.langCache = this.lang; |
|
6729 mod.skinCache = this.skin.defaultSkin; |
|
6730 |
|
6731 for (i = 0; i < r.length; i++) { |
|
6732 //Y.log(name + ' requiring ' + r[i], 'info', 'loader'); |
|
6733 if (!hash[r[i]]) { |
|
6734 d.push(r[i]); |
|
6735 hash[r[i]] = true; |
|
6736 m = this.getModule(r[i]); |
|
6737 if (m) { |
|
6738 add = this.getRequires(m); |
|
6739 intl = intl || (m.expanded_map && |
|
6740 (INTL in m.expanded_map)); |
|
6741 for (j = 0; j < add.length; j++) { |
|
6742 d.push(add[j]); |
|
6743 } |
|
6744 } |
|
6745 } |
|
6746 } |
|
6747 |
|
6748 // get the requirements from superseded modules, if any |
|
6749 r = this.filterRequires(mod.supersedes); |
|
6750 if (r) { |
|
6751 for (i = 0; i < r.length; i++) { |
|
6752 if (!hash[r[i]]) { |
|
6753 // if this module has submodules, the requirements list is |
|
6754 // expanded to include the submodules. This is so we can |
|
6755 // prevent dups when a submodule is already loaded and the |
|
6756 // parent is requested. |
|
6757 if (mod.submodules) { |
|
6758 d.push(r[i]); |
|
6759 } |
|
6760 |
|
6761 hash[r[i]] = true; |
|
6762 m = this.getModule(r[i]); |
|
6763 |
|
6764 if (m) { |
|
6765 add = this.getRequires(m); |
|
6766 intl = intl || (m.expanded_map && |
|
6767 (INTL in m.expanded_map)); |
|
6768 for (j = 0; j < add.length; j++) { |
|
6769 d.push(add[j]); |
|
6770 } |
|
6771 } |
|
6772 } |
|
6773 } |
|
6774 } |
|
6775 |
|
6776 if (o && this.loadOptional) { |
|
6777 for (i = 0; i < o.length; i++) { |
|
6778 if (!hash[o[i]]) { |
|
6779 d.push(o[i]); |
|
6780 hash[o[i]] = true; |
|
6781 m = info[o[i]]; |
|
6782 if (m) { |
|
6783 add = this.getRequires(m); |
|
6784 intl = intl || (m.expanded_map && |
|
6785 (INTL in m.expanded_map)); |
|
6786 for (j = 0; j < add.length; j++) { |
|
6787 d.push(add[j]); |
|
6788 } |
|
6789 } |
|
6790 } |
|
6791 } |
|
6792 } |
|
6793 |
|
6794 cond = this.conditions[name]; |
|
6795 |
|
6796 if (cond) { |
|
6797 //Set the module to not parsed since we have conditionals and this could change the dependency tree. |
|
6798 mod._parsed = false; |
|
6799 if (testresults && ftests) { |
|
6800 oeach(testresults, function(result, id) { |
|
6801 var condmod = ftests[id].name; |
|
6802 if (!hash[condmod] && ftests[id].trigger === name) { |
|
6803 if (result && ftests[id]) { |
|
6804 hash[condmod] = true; |
|
6805 d.push(condmod); |
|
6806 } |
|
6807 } |
|
6808 }); |
|
6809 } else { |
|
6810 for (i in cond) { |
|
6811 if (cond.hasOwnProperty(i)) { |
|
6812 if (!hash[i]) { |
|
6813 def = cond[i]; |
|
6814 //first see if they've specfied a ua check |
|
6815 //then see if they've got a test fn & if it returns true |
|
6816 //otherwise just having a condition block is enough |
|
6817 go = def && ((!def.ua && !def.test) || (def.ua && Y.UA[def.ua]) || |
|
6818 (def.test && def.test(Y, r))); |
|
6819 |
|
6820 if (go) { |
|
6821 hash[i] = true; |
|
6822 d.push(i); |
|
6823 m = this.getModule(i); |
|
6824 if (m) { |
|
6825 add = this.getRequires(m); |
|
6826 for (j = 0; j < add.length; j++) { |
|
6827 d.push(add[j]); |
|
6828 } |
|
6829 |
|
6830 } |
|
6831 } |
|
6832 } |
|
6833 } |
|
6834 } |
|
6835 } |
|
6836 } |
|
6837 |
|
6838 // Create skin modules |
|
6839 if (mod.skinnable) { |
|
6840 skindef = this.skin.overrides; |
|
6841 for (i in YUI.Env.aliases) { |
|
6842 if (YUI.Env.aliases.hasOwnProperty(i)) { |
|
6843 if (Y.Array.indexOf(YUI.Env.aliases[i], name) > -1) { |
|
6844 skinpar = i; |
|
6845 } |
|
6846 } |
|
6847 } |
|
6848 if (skindef && (skindef[name] || (skinpar && skindef[skinpar]))) { |
|
6849 skinname = name; |
|
6850 if (skindef[skinpar]) { |
|
6851 skinname = skinpar; |
|
6852 } |
|
6853 for (i = 0; i < skindef[skinname].length; i++) { |
|
6854 skinmod = this._addSkin(skindef[skinname][i], name); |
|
6855 if (!this.isCSSLoaded(skinmod, this._boot)) { |
|
6856 d.push(skinmod); |
|
6857 } |
|
6858 } |
|
6859 } else { |
|
6860 skinmod = this._addSkin(this.skin.defaultSkin, name); |
|
6861 if (!this.isCSSLoaded(skinmod, this._boot)) { |
|
6862 d.push(skinmod); |
|
6863 } |
|
6864 } |
|
6865 } |
|
6866 |
|
6867 mod._parsed = false; |
|
6868 |
|
6869 if (intl) { |
|
6870 |
|
6871 if (mod.lang && !mod.langPack && Y.Intl) { |
|
6872 lang = Y.Intl.lookupBestLang(this.lang || ROOT_LANG, mod.lang); |
|
6873 //Y.log('Best lang: ' + lang + ', this.lang: ' + this.lang + ', mod.lang: ' + mod.lang); |
|
6874 packName = this.getLangPackName(lang, name); |
|
6875 if (packName) { |
|
6876 d.unshift(packName); |
|
6877 } |
|
6878 } |
|
6879 d.unshift(INTL); |
|
6880 } |
|
6881 |
|
6882 mod.expanded_map = yArray.hash(d); |
|
6883 |
|
6884 mod.expanded = YObject.keys(mod.expanded_map); |
|
6885 |
|
6886 return mod.expanded; |
|
6887 }, |
|
6888 /** |
|
6889 * Check to see if named css module is already loaded on the page |
|
6890 * @method isCSSLoaded |
|
6891 * @param {String} name The name of the css file |
|
6892 * @return Boolean |
|
6893 */ |
|
6894 isCSSLoaded: function(name, skip) { |
|
6895 //TODO - Make this call a batching call with name being an array |
|
6896 if (!name || !YUI.Env.cssStampEl || (!skip && this.ignoreRegistered)) { |
|
6897 Y.log('isCSSLoaded was skipped for ' + name, 'warn', 'loader'); |
|
6898 return false; |
|
6899 } |
|
6900 var el = YUI.Env.cssStampEl, |
|
6901 ret = false, |
|
6902 mod = YUI.Env._cssLoaded[name], |
|
6903 style = el.currentStyle; //IE |
|
6904 |
|
6905 |
|
6906 if (mod !== undefined) { |
|
6907 //Y.log('isCSSLoaded was cached for ' + name, 'warn', 'loader'); |
|
6908 return mod; |
|
6909 } |
|
6910 |
|
6911 //Add the classname to the element |
|
6912 el.className = name; |
|
6913 |
|
6914 if (!style) { |
|
6915 style = Y.config.doc.defaultView.getComputedStyle(el, null); |
|
6916 } |
|
6917 |
|
6918 if (style && style.display === 'none') { |
|
6919 ret = true; |
|
6920 } |
|
6921 |
|
6922 Y.log('Has Skin? ' + name + ' : ' + ret, 'info', 'loader'); |
|
6923 |
|
6924 el.className = ''; //Reset the classname to '' |
|
6925 |
|
6926 YUI.Env._cssLoaded[name] = ret; |
|
6927 |
|
6928 return ret; |
|
6929 }, |
|
6930 |
|
6931 /** |
|
6932 * Returns a hash of module names the supplied module satisfies. |
|
6933 * @method getProvides |
|
6934 * @param {string} name The name of the module. |
|
6935 * @return {object} what this module provides. |
|
6936 */ |
|
6937 getProvides: function(name) { |
|
6938 var m = this.getModule(name), o, s; |
|
6939 // supmap = this.provides; |
|
6940 |
|
6941 if (!m) { |
|
6942 return NOT_FOUND; |
|
6943 } |
|
6944 |
|
6945 if (m && !m.provides) { |
|
6946 o = {}; |
|
6947 s = m.supersedes; |
|
6948 |
|
6949 if (s) { |
|
6950 yArray.each(s, function(v) { |
|
6951 Y.mix(o, this.getProvides(v)); |
|
6952 }, this); |
|
6953 } |
|
6954 |
|
6955 o[name] = true; |
|
6956 m.provides = o; |
|
6957 |
|
6958 } |
|
6959 |
|
6960 return m.provides; |
|
6961 }, |
|
6962 |
|
6963 /** |
|
6964 * Calculates the dependency tree, the result is stored in the sorted |
|
6965 * property. |
|
6966 * @method calculate |
|
6967 * @param {object} o optional options object. |
|
6968 * @param {string} type optional argument to prune modules. |
|
6969 */ |
|
6970 calculate: function(o, type) { |
|
6971 if (o || type || this.dirty) { |
|
6972 |
|
6973 if (o) { |
|
6974 this._config(o); |
|
6975 } |
|
6976 |
|
6977 if (!this._init) { |
|
6978 this._setup(); |
|
6979 } |
|
6980 |
|
6981 this._explode(); |
|
6982 |
|
6983 if (this.allowRollup) { |
|
6984 this._rollup(); |
|
6985 } else { |
|
6986 this._explodeRollups(); |
|
6987 } |
|
6988 this._reduce(); |
|
6989 this._sort(); |
|
6990 } |
|
6991 }, |
|
6992 /** |
|
6993 * Creates a "psuedo" package for languages provided in the lang array |
|
6994 * @method _addLangPack |
|
6995 * @private |
|
6996 * @param {String} lang The language to create |
|
6997 * @param {Object} m The module definition to create the language pack around |
|
6998 * @param {String} packName The name of the package (e.g: lang/datatype-date-en-US) |
|
6999 * @return {Object} The module definition |
|
7000 */ |
|
7001 _addLangPack: function(lang, m, packName) { |
|
7002 var name = m.name, |
|
7003 packPath, conf, |
|
7004 existing = this.moduleInfo[packName]; |
|
7005 |
|
7006 if (!existing) { |
|
7007 |
|
7008 packPath = _path((m.pkg || name), packName, JS, true); |
|
7009 |
|
7010 conf = { |
|
7011 path: packPath, |
|
7012 intl: true, |
|
7013 langPack: true, |
|
7014 ext: m.ext, |
|
7015 group: m.group, |
|
7016 supersedes: [] |
|
7017 }; |
|
7018 if (m.root) { |
|
7019 conf.root = m.root; |
|
7020 } |
|
7021 if (m.base) { |
|
7022 conf.base = m.base; |
|
7023 } |
|
7024 |
|
7025 if (m.configFn) { |
|
7026 conf.configFn = m.configFn; |
|
7027 } |
|
7028 |
|
7029 this.addModule(conf, packName); |
|
7030 |
|
7031 if (lang) { |
|
7032 Y.Env.lang = Y.Env.lang || {}; |
|
7033 Y.Env.lang[lang] = Y.Env.lang[lang] || {}; |
|
7034 Y.Env.lang[lang][name] = true; |
|
7035 } |
|
7036 } |
|
7037 |
|
7038 return this.moduleInfo[packName]; |
|
7039 }, |
|
7040 |
|
7041 /** |
|
7042 * Investigates the current YUI configuration on the page. By default, |
|
7043 * modules already detected will not be loaded again unless a force |
|
7044 * option is encountered. Called by calculate() |
|
7045 * @method _setup |
|
7046 * @private |
|
7047 */ |
|
7048 _setup: function() { |
|
7049 var info = this.moduleInfo, name, i, j, m, l, |
|
7050 packName; |
|
7051 |
|
7052 for (name in info) { |
|
7053 if (info.hasOwnProperty(name)) { |
|
7054 m = info[name]; |
|
7055 if (m) { |
|
7056 |
|
7057 // remove dups |
|
7058 //m.requires = YObject.keys(yArray.hash(m.requires)); |
|
7059 m.requires = yArray.dedupe(m.requires); |
|
7060 |
|
7061 // Create lang pack modules |
|
7062 //if (m.lang && m.lang.length) { |
|
7063 if (m.lang) { |
|
7064 // Setup root package if the module has lang defined, |
|
7065 // it needs to provide a root language pack |
|
7066 packName = this.getLangPackName(ROOT_LANG, name); |
|
7067 this._addLangPack(null, m, packName); |
|
7068 } |
|
7069 |
|
7070 } |
|
7071 } |
|
7072 } |
|
7073 |
|
7074 |
|
7075 //l = Y.merge(this.inserted); |
|
7076 l = {}; |
|
7077 |
|
7078 // available modules |
|
7079 if (!this.ignoreRegistered) { |
|
7080 Y.mix(l, GLOBAL_ENV.mods); |
|
7081 } |
|
7082 |
|
7083 // add the ignore list to the list of loaded packages |
|
7084 if (this.ignore) { |
|
7085 Y.mix(l, yArray.hash(this.ignore)); |
|
7086 } |
|
7087 |
|
7088 // expand the list to include superseded modules |
|
7089 for (j in l) { |
|
7090 if (l.hasOwnProperty(j)) { |
|
7091 Y.mix(l, this.getProvides(j)); |
|
7092 } |
|
7093 } |
|
7094 |
|
7095 // remove modules on the force list from the loaded list |
|
7096 if (this.force) { |
|
7097 for (i = 0; i < this.force.length; i++) { |
|
7098 if (this.force[i] in l) { |
|
7099 delete l[this.force[i]]; |
|
7100 } |
|
7101 } |
|
7102 } |
|
7103 |
|
7104 Y.mix(this.loaded, l); |
|
7105 |
|
7106 this._init = true; |
|
7107 }, |
|
7108 |
|
7109 /** |
|
7110 * Builds a module name for a language pack |
|
7111 * @method getLangPackName |
|
7112 * @param {string} lang the language code. |
|
7113 * @param {string} mname the module to build it for. |
|
7114 * @return {string} the language pack module name. |
|
7115 */ |
|
7116 getLangPackName: function(lang, mname) { |
|
7117 return ('lang/' + mname + ((lang) ? '_' + lang : '')); |
|
7118 }, |
|
7119 /** |
|
7120 * Inspects the required modules list looking for additional |
|
7121 * dependencies. Expands the required list to include all |
|
7122 * required modules. Called by calculate() |
|
7123 * @method _explode |
|
7124 * @private |
|
7125 */ |
|
7126 _explode: function() { |
|
7127 //TODO Move done out of scope |
|
7128 var r = this.required, m, reqs, done = {}, |
|
7129 self = this, name, expound; |
|
7130 |
|
7131 // the setup phase is over, all modules have been created |
|
7132 self.dirty = false; |
|
7133 |
|
7134 self._explodeRollups(); |
|
7135 r = self.required; |
|
7136 |
|
7137 for (name in r) { |
|
7138 if (r.hasOwnProperty(name)) { |
|
7139 if (!done[name]) { |
|
7140 done[name] = true; |
|
7141 m = self.getModule(name); |
|
7142 if (m) { |
|
7143 expound = m.expound; |
|
7144 |
|
7145 if (expound) { |
|
7146 r[expound] = self.getModule(expound); |
|
7147 reqs = self.getRequires(r[expound]); |
|
7148 Y.mix(r, yArray.hash(reqs)); |
|
7149 } |
|
7150 |
|
7151 reqs = self.getRequires(m); |
|
7152 Y.mix(r, yArray.hash(reqs)); |
|
7153 } |
|
7154 } |
|
7155 } |
|
7156 } |
|
7157 |
|
7158 // Y.log('After explode: ' + YObject.keys(r)); |
|
7159 }, |
|
7160 /** |
|
7161 * The default method used to test a module against a pattern |
|
7162 * @method _patternTest |
|
7163 * @private |
|
7164 * @param {String} mname The module being tested |
|
7165 * @param {String} pname The pattern to match |
|
7166 */ |
|
7167 _patternTest: function(mname, pname) { |
|
7168 return (mname.indexOf(pname) > -1); |
|
7169 }, |
|
7170 /** |
|
7171 * Get's the loader meta data for the requested module |
|
7172 * @method getModule |
|
7173 * @param {String} mname The module name to get |
|
7174 * @return {Object} The module metadata |
|
7175 */ |
|
7176 getModule: function(mname) { |
|
7177 //TODO: Remove name check - it's a quick hack to fix pattern WIP |
|
7178 if (!mname) { |
|
7179 return null; |
|
7180 } |
|
7181 |
|
7182 var p, found, pname, |
|
7183 m = this.moduleInfo[mname], |
|
7184 patterns = this.patterns; |
|
7185 |
|
7186 // check the patterns library to see if we should automatically add |
|
7187 // the module with defaults |
|
7188 if (!m || (m && m.ext)) { |
|
7189 // Y.log('testing patterns ' + YObject.keys(patterns)); |
|
7190 for (pname in patterns) { |
|
7191 if (patterns.hasOwnProperty(pname)) { |
|
7192 // Y.log('testing pattern ' + i); |
|
7193 p = patterns[pname]; |
|
7194 |
|
7195 //There is no test method, create a default one that tests |
|
7196 // the pattern against the mod name |
|
7197 if (!p.test) { |
|
7198 p.test = this._patternTest; |
|
7199 } |
|
7200 |
|
7201 if (p.test(mname, pname)) { |
|
7202 // use the metadata supplied for the pattern |
|
7203 // as the module definition. |
|
7204 found = p; |
|
7205 break; |
|
7206 } |
|
7207 } |
|
7208 } |
|
7209 } |
|
7210 |
|
7211 if (!m) { |
|
7212 if (found) { |
|
7213 if (p.action) { |
|
7214 // Y.log('executing pattern action: ' + pname); |
|
7215 p.action.call(this, mname, pname); |
|
7216 } else { |
|
7217 Y.log('Undefined module: ' + mname + ', matched a pattern: ' + |
|
7218 pname, 'info', 'loader'); |
|
7219 // ext true or false? |
|
7220 m = this.addModule(Y.merge(found), mname); |
|
7221 if (found.configFn) { |
|
7222 m.configFn = found.configFn; |
|
7223 } |
|
7224 m.temp = true; |
|
7225 } |
|
7226 } |
|
7227 } else { |
|
7228 if (found && m && found.configFn && !m.configFn) { |
|
7229 m.configFn = found.configFn; |
|
7230 m.configFn(m); |
|
7231 } |
|
7232 } |
|
7233 |
|
7234 return m; |
|
7235 }, |
|
7236 |
|
7237 // impl in rollup submodule |
|
7238 _rollup: function() { }, |
|
7239 |
|
7240 /** |
|
7241 * Remove superceded modules and loaded modules. Called by |
|
7242 * calculate() after we have the mega list of all dependencies |
|
7243 * @method _reduce |
|
7244 * @return {object} the reduced dependency hash. |
|
7245 * @private |
|
7246 */ |
|
7247 _reduce: function(r) { |
|
7248 |
|
7249 r = r || this.required; |
|
7250 |
|
7251 var i, j, s, m, type = this.loadType, |
|
7252 ignore = this.ignore ? yArray.hash(this.ignore) : false; |
|
7253 |
|
7254 for (i in r) { |
|
7255 if (r.hasOwnProperty(i)) { |
|
7256 m = this.getModule(i); |
|
7257 // remove if already loaded |
|
7258 if (((this.loaded[i] || ON_PAGE[i]) && |
|
7259 !this.forceMap[i] && !this.ignoreRegistered) || |
|
7260 (type && m && m.type !== type)) { |
|
7261 delete r[i]; |
|
7262 } |
|
7263 if (ignore && ignore[i]) { |
|
7264 delete r[i]; |
|
7265 } |
|
7266 // remove anything this module supersedes |
|
7267 s = m && m.supersedes; |
|
7268 if (s) { |
|
7269 for (j = 0; j < s.length; j++) { |
|
7270 if (s[j] in r) { |
|
7271 delete r[s[j]]; |
|
7272 } |
|
7273 } |
|
7274 } |
|
7275 } |
|
7276 } |
|
7277 |
|
7278 return r; |
|
7279 }, |
|
7280 /** |
|
7281 * Handles the queue when a module has been loaded for all cases |
|
7282 * @method _finish |
|
7283 * @private |
|
7284 * @param {String} msg The message from Loader |
|
7285 * @param {Boolean} success A boolean denoting success or failure |
|
7286 */ |
|
7287 _finish: function(msg, success) { |
|
7288 Y.log('loader finishing: ' + msg + ', ' + Y.id + ', ' + |
|
7289 this.data, 'info', 'loader'); |
|
7290 |
|
7291 _queue.running = false; |
|
7292 |
|
7293 var onEnd = this.onEnd; |
|
7294 if (onEnd) { |
|
7295 onEnd.call(this.context, { |
|
7296 msg: msg, |
|
7297 data: this.data, |
|
7298 success: success |
|
7299 }); |
|
7300 } |
|
7301 this._continue(); |
|
7302 }, |
|
7303 /** |
|
7304 * The default Loader onSuccess handler, calls this.onSuccess with a payload |
|
7305 * @method _onSuccess |
|
7306 * @private |
|
7307 */ |
|
7308 _onSuccess: function() { |
|
7309 var self = this, skipped = Y.merge(self.skipped), fn, |
|
7310 failed = [], rreg = self.requireRegistration, |
|
7311 success, msg, i, mod; |
|
7312 |
|
7313 for (i in skipped) { |
|
7314 if (skipped.hasOwnProperty(i)) { |
|
7315 delete self.inserted[i]; |
|
7316 } |
|
7317 } |
|
7318 |
|
7319 self.skipped = {}; |
|
7320 |
|
7321 for (i in self.inserted) { |
|
7322 if (self.inserted.hasOwnProperty(i)) { |
|
7323 mod = self.getModule(i); |
|
7324 if (mod && rreg && mod.type === JS && !(i in YUI.Env.mods)) { |
|
7325 failed.push(i); |
|
7326 } else { |
|
7327 Y.mix(self.loaded, self.getProvides(i)); |
|
7328 } |
|
7329 } |
|
7330 } |
|
7331 |
|
7332 fn = self.onSuccess; |
|
7333 msg = (failed.length) ? 'notregistered' : 'success'; |
|
7334 success = !(failed.length); |
|
7335 if (fn) { |
|
7336 fn.call(self.context, { |
|
7337 msg: msg, |
|
7338 data: self.data, |
|
7339 success: success, |
|
7340 failed: failed, |
|
7341 skipped: skipped |
|
7342 }); |
|
7343 } |
|
7344 self._finish(msg, success); |
|
7345 }, |
|
7346 /** |
|
7347 * The default Loader onProgress handler, calls this.onProgress with a payload |
|
7348 * @method _onProgress |
|
7349 * @private |
|
7350 */ |
|
7351 _onProgress: function(e) { |
|
7352 var self = this, i; |
|
7353 //set the internal cache to what just came in. |
|
7354 if (e.data && e.data.length) { |
|
7355 for (i = 0; i < e.data.length; i++) { |
|
7356 e.data[i] = self.getModule(e.data[i].name); |
|
7357 } |
|
7358 } |
|
7359 if (self.onProgress) { |
|
7360 self.onProgress.call(self.context, { |
|
7361 name: e.url, |
|
7362 data: e.data |
|
7363 }); |
|
7364 } |
|
7365 }, |
|
7366 /** |
|
7367 * The default Loader onFailure handler, calls this.onFailure with a payload |
|
7368 * @method _onFailure |
|
7369 * @private |
|
7370 */ |
|
7371 _onFailure: function(o) { |
|
7372 var f = this.onFailure, msg = [], i = 0, len = o.errors.length; |
|
7373 |
|
7374 for (i; i < len; i++) { |
|
7375 msg.push(o.errors[i].error); |
|
7376 } |
|
7377 |
|
7378 msg = msg.join(','); |
|
7379 |
|
7380 Y.log('load error: ' + msg + ', ' + Y.id, 'error', 'loader'); |
|
7381 |
|
7382 if (f) { |
|
7383 f.call(this.context, { |
|
7384 msg: msg, |
|
7385 data: this.data, |
|
7386 success: false |
|
7387 }); |
|
7388 } |
|
7389 |
|
7390 this._finish(msg, false); |
|
7391 |
|
7392 }, |
|
7393 |
|
7394 /** |
|
7395 * The default Loader onTimeout handler, calls this.onTimeout with a payload |
|
7396 * @method _onTimeout |
|
7397 * @param {Get.Transaction} transaction The Transaction object from `Y.Get` |
|
7398 * @private |
|
7399 */ |
|
7400 _onTimeout: function(transaction) { |
|
7401 Y.log('loader timeout: ' + Y.id, 'error', 'loader'); |
|
7402 var f = this.onTimeout; |
|
7403 if (f) { |
|
7404 f.call(this.context, { |
|
7405 msg: 'timeout', |
|
7406 data: this.data, |
|
7407 success: false, |
|
7408 transaction: transaction |
|
7409 }); |
|
7410 } |
|
7411 }, |
|
7412 |
|
7413 /** |
|
7414 * Sorts the dependency tree. The last step of calculate() |
|
7415 * @method _sort |
|
7416 * @private |
|
7417 */ |
|
7418 _sort: function() { |
|
7419 var name, |
|
7420 |
|
7421 // Object containing module names. |
|
7422 required = this.required, |
|
7423 |
|
7424 // Keep track of whether we've visited a module. |
|
7425 visited = {}; |
|
7426 |
|
7427 // Will contain modules names, in the correct order, |
|
7428 // according to dependencies. |
|
7429 this.sorted = []; |
|
7430 |
|
7431 for (name in required) { |
|
7432 if (!visited[name] && required.hasOwnProperty(name)) { |
|
7433 this._visit(name, visited); |
|
7434 } |
|
7435 } |
|
7436 }, |
|
7437 |
|
7438 /** |
|
7439 * Recursively visits the dependencies of the module name |
|
7440 * passed in, and appends each module name to the `sorted` property. |
|
7441 * @param {String} name The name of a module. |
|
7442 * @param {Object} visited Keeps track of whether a module was visited. |
|
7443 * @method _visit |
|
7444 * @private |
|
7445 */ |
|
7446 _visit: function (name, visited) { |
|
7447 var required, moduleInfo, dependency, dependencies, i, l; |
|
7448 |
|
7449 visited[name] = true; |
|
7450 required = this.required; |
|
7451 moduleInfo = this.moduleInfo[name]; |
|
7452 |
|
7453 if (moduleInfo) { |
|
7454 // Recurse on each dependency of this module, |
|
7455 // figuring out its dependencies, and so on. |
|
7456 dependencies = moduleInfo.requires; |
|
7457 for (i = 0, l = dependencies.length; i < l; ++i) { |
|
7458 dependency = dependencies[i]; |
|
7459 |
|
7460 // Is this module name in the required list of modules, |
|
7461 // and have we not already visited it? |
|
7462 if (required[dependency] && !visited[dependency]) { |
|
7463 this._visit(dependency, visited); |
|
7464 } |
|
7465 } |
|
7466 } |
|
7467 |
|
7468 this.sorted.push(name); |
|
7469 }, |
|
7470 |
|
7471 /** |
|
7472 * Handles the actual insertion of script/link tags |
|
7473 * @method _insert |
|
7474 * @private |
|
7475 * @param {Object} source The YUI instance the request came from |
|
7476 * @param {Object} o The metadata to include |
|
7477 * @param {String} type JS or CSS |
|
7478 * @param {Boolean} [skipcalc=false] Do a Loader.calculate on the meta |
|
7479 */ |
|
7480 _insert: function(source, o, type, skipcalc) { |
|
7481 |
|
7482 Y.log('private _insert() ' + (type || '') + ', ' + Y.id, "info", "loader"); |
|
7483 |
|
7484 // restore the state at the time of the request |
|
7485 if (source) { |
|
7486 this._config(source); |
|
7487 } |
|
7488 |
|
7489 // build the dependency list |
|
7490 // don't include type so we can process CSS and script in |
|
7491 // one pass when the type is not specified. |
|
7492 |
|
7493 var modules = this.resolve(!skipcalc), |
|
7494 self = this, comp = 0, actions = 0, |
|
7495 mods = {}, deps, complete; |
|
7496 |
|
7497 self._refetch = []; |
|
7498 |
|
7499 if (type) { |
|
7500 //Filter out the opposite type and reset the array so the checks later work |
|
7501 modules[((type === JS) ? CSS : JS)] = []; |
|
7502 } |
|
7503 if (!self.fetchCSS) { |
|
7504 modules.css = []; |
|
7505 } |
|
7506 if (modules.js.length) { |
|
7507 comp++; |
|
7508 } |
|
7509 if (modules.css.length) { |
|
7510 comp++; |
|
7511 } |
|
7512 |
|
7513 //console.log('Resolved Modules: ', modules); |
|
7514 |
|
7515 complete = function(d) { |
|
7516 actions++; |
|
7517 var errs = {}, i = 0, o = 0, u = '', fn, |
|
7518 modName, resMods; |
|
7519 |
|
7520 if (d && d.errors) { |
|
7521 for (i = 0; i < d.errors.length; i++) { |
|
7522 if (d.errors[i].request) { |
|
7523 u = d.errors[i].request.url; |
|
7524 } else { |
|
7525 u = d.errors[i]; |
|
7526 } |
|
7527 errs[u] = u; |
|
7528 } |
|
7529 } |
|
7530 |
|
7531 if (d && d.data && d.data.length && (d.type === 'success')) { |
|
7532 for (i = 0; i < d.data.length; i++) { |
|
7533 self.inserted[d.data[i].name] = true; |
|
7534 //If the external module has a skin or a lang, reprocess it |
|
7535 if (d.data[i].lang || d.data[i].skinnable) { |
|
7536 delete self.inserted[d.data[i].name]; |
|
7537 self._refetch.push(d.data[i].name); |
|
7538 } |
|
7539 } |
|
7540 } |
|
7541 |
|
7542 if (actions === comp) { |
|
7543 self._loading = null; |
|
7544 Y.log('Loader actions complete!', 'info', 'loader'); |
|
7545 if (self._refetch.length) { |
|
7546 //Get the deps for the new meta-data and reprocess |
|
7547 Y.log('Found potential modules to refetch', 'info', 'loader'); |
|
7548 for (i = 0; i < self._refetch.length; i++) { |
|
7549 deps = self.getRequires(self.getModule(self._refetch[i])); |
|
7550 for (o = 0; o < deps.length; o++) { |
|
7551 if (!self.inserted[deps[o]]) { |
|
7552 //We wouldn't be to this point without the module being here |
|
7553 mods[deps[o]] = deps[o]; |
|
7554 } |
|
7555 } |
|
7556 } |
|
7557 mods = Y.Object.keys(mods); |
|
7558 if (mods.length) { |
|
7559 Y.log('Refetching modules with new meta-data', 'info', 'loader'); |
|
7560 self.require(mods); |
|
7561 resMods = self.resolve(true); |
|
7562 if (resMods.cssMods.length) { |
|
7563 for (i=0; i < resMods.cssMods.length; i++) { |
|
7564 modName = resMods.cssMods[i].name; |
|
7565 delete YUI.Env._cssLoaded[modName]; |
|
7566 if (self.isCSSLoaded(modName)) { |
|
7567 self.inserted[modName] = true; |
|
7568 delete self.required[modName]; |
|
7569 } |
|
7570 } |
|
7571 self.sorted = []; |
|
7572 self._sort(); |
|
7573 } |
|
7574 d = null; //bail |
|
7575 self._insert(); //insert the new deps |
|
7576 } |
|
7577 } |
|
7578 if (d && d.fn) { |
|
7579 Y.log('Firing final Loader callback!', 'info', 'loader'); |
|
7580 fn = d.fn; |
|
7581 delete d.fn; |
|
7582 fn.call(self, d); |
|
7583 } |
|
7584 } |
|
7585 }; |
|
7586 |
|
7587 this._loading = true; |
|
7588 |
|
7589 if (!modules.js.length && !modules.css.length) { |
|
7590 Y.log('No modules resolved..', 'warn', 'loader'); |
|
7591 actions = -1; |
|
7592 complete({ |
|
7593 fn: self._onSuccess |
|
7594 }); |
|
7595 return; |
|
7596 } |
|
7597 |
|
7598 |
|
7599 if (modules.css.length) { //Load CSS first |
|
7600 Y.log('Loading CSS modules', 'info', 'loader'); |
|
7601 Y.Get.css(modules.css, { |
|
7602 data: modules.cssMods, |
|
7603 attributes: self.cssAttributes, |
|
7604 insertBefore: self.insertBefore, |
|
7605 charset: self.charset, |
|
7606 timeout: self.timeout, |
|
7607 context: self, |
|
7608 onProgress: function(e) { |
|
7609 self._onProgress.call(self, e); |
|
7610 }, |
|
7611 onTimeout: function(d) { |
|
7612 self._onTimeout.call(self, d); |
|
7613 }, |
|
7614 onSuccess: function(d) { |
|
7615 d.type = 'success'; |
|
7616 d.fn = self._onSuccess; |
|
7617 complete.call(self, d); |
|
7618 }, |
|
7619 onFailure: function(d) { |
|
7620 d.type = 'failure'; |
|
7621 d.fn = self._onFailure; |
|
7622 complete.call(self, d); |
|
7623 } |
|
7624 }); |
|
7625 } |
|
7626 |
|
7627 if (modules.js.length) { |
|
7628 Y.log('Loading JS modules', 'info', 'loader'); |
|
7629 Y.Get.js(modules.js, { |
|
7630 data: modules.jsMods, |
|
7631 insertBefore: self.insertBefore, |
|
7632 attributes: self.jsAttributes, |
|
7633 charset: self.charset, |
|
7634 timeout: self.timeout, |
|
7635 autopurge: false, |
|
7636 context: self, |
|
7637 async: self.async, |
|
7638 onProgress: function(e) { |
|
7639 self._onProgress.call(self, e); |
|
7640 }, |
|
7641 onTimeout: function(d) { |
|
7642 self._onTimeout.call(self, d); |
|
7643 }, |
|
7644 onSuccess: function(d) { |
|
7645 d.type = 'success'; |
|
7646 d.fn = self._onSuccess; |
|
7647 complete.call(self, d); |
|
7648 }, |
|
7649 onFailure: function(d) { |
|
7650 d.type = 'failure'; |
|
7651 d.fn = self._onFailure; |
|
7652 complete.call(self, d); |
|
7653 } |
|
7654 }); |
|
7655 } |
|
7656 }, |
|
7657 /** |
|
7658 * Once a loader operation is completely finished, process any additional queued items. |
|
7659 * @method _continue |
|
7660 * @private |
|
7661 */ |
|
7662 _continue: function() { |
|
7663 if (!(_queue.running) && _queue.size() > 0) { |
|
7664 _queue.running = true; |
|
7665 _queue.next()(); |
|
7666 } |
|
7667 }, |
|
7668 |
|
7669 /** |
|
7670 * inserts the requested modules and their dependencies. |
|
7671 * <code>type</code> can be "js" or "css". Both script and |
|
7672 * css are inserted if type is not provided. |
|
7673 * @method insert |
|
7674 * @param {object} o optional options object. |
|
7675 * @param {string} type the type of dependency to insert. |
|
7676 */ |
|
7677 insert: function(o, type, skipsort) { |
|
7678 Y.log('public insert() ' + (type || '') + ', ' + |
|
7679 Y.Object.keys(this.required), "info", "loader"); |
|
7680 var self = this, copy = Y.merge(this); |
|
7681 delete copy.require; |
|
7682 delete copy.dirty; |
|
7683 _queue.add(function() { |
|
7684 self._insert(copy, o, type, skipsort); |
|
7685 }); |
|
7686 this._continue(); |
|
7687 }, |
|
7688 |
|
7689 /** |
|
7690 * Executed every time a module is loaded, and if we are in a load |
|
7691 * cycle, we attempt to load the next script. Public so that it |
|
7692 * is possible to call this if using a method other than |
|
7693 * Y.register to determine when scripts are fully loaded |
|
7694 * @method loadNext |
|
7695 * @deprecated |
|
7696 * @param {string} mname optional the name of the module that has |
|
7697 * been loaded (which is usually why it is time to load the next |
|
7698 * one). |
|
7699 */ |
|
7700 loadNext: function() { |
|
7701 Y.log('loadNext was called..', 'error', 'loader'); |
|
7702 return; |
|
7703 }, |
|
7704 |
|
7705 /** |
|
7706 * Apply filter defined for this instance to a url/path |
|
7707 * @method _filter |
|
7708 * @param {string} u the string to filter. |
|
7709 * @param {string} name the name of the module, if we are processing |
|
7710 * a single module as opposed to a combined url. |
|
7711 * @return {string} the filtered string. |
|
7712 * @private |
|
7713 */ |
|
7714 _filter: function(u, name, group) { |
|
7715 var f = this.filter, |
|
7716 hasFilter = name && (name in this.filters), |
|
7717 modFilter = hasFilter && this.filters[name], |
|
7718 groupName = group || (this.moduleInfo[name] ? this.moduleInfo[name].group : null); |
|
7719 |
|
7720 if (groupName && this.groups[groupName] && this.groups[groupName].filter) { |
|
7721 modFilter = this.groups[groupName].filter; |
|
7722 hasFilter = true; |
|
7723 } |
|
7724 |
|
7725 if (u) { |
|
7726 if (hasFilter) { |
|
7727 f = (L.isString(modFilter)) ? this.FILTER_DEFS[modFilter.toUpperCase()] || null : modFilter; |
|
7728 } |
|
7729 if (f) { |
|
7730 u = u.replace(new RegExp(f.searchExp, 'g'), f.replaceStr); |
|
7731 } |
|
7732 } |
|
7733 return u; |
|
7734 }, |
|
7735 |
|
7736 /** |
|
7737 * Generates the full url for a module |
|
7738 * @method _url |
|
7739 * @param {string} path the path fragment. |
|
7740 * @param {String} name The name of the module |
|
7741 * @param {String} [base] The base url to use. Defaults to self.base |
|
7742 * @return {string} the full url. |
|
7743 * @private |
|
7744 */ |
|
7745 _url: function(path, name, base) { |
|
7746 return this._filter((base || this.base || '') + path, name); |
|
7747 }, |
|
7748 /** |
|
7749 * Returns an Object hash of file arrays built from `loader.sorted` or from an arbitrary list of sorted modules. |
|
7750 * @method resolve |
|
7751 * @param {Boolean} [calc=false] Perform a loader.calculate() before anything else |
|
7752 * @param {Array} [s] An override for the loader.sorted array. Defaults to |
|
7753 * `loader.sorted`. |
|
7754 * @return {Object} Object hash (js and css) of two arrays of file lists |
|
7755 * @example This method can be used as an off-line dep calculator |
|
7756 * |
|
7757 * var Y = YUI(); |
|
7758 * var loader = new Y.Loader({ |
|
7759 * filter: 'debug', |
|
7760 * base: '../../', |
|
7761 * root: 'build/', |
|
7762 * combine: true, |
|
7763 * require: ['node', 'dd', 'console'] |
|
7764 * }); |
|
7765 * var out = loader.resolve(true); |
|
7766 * |
|
7767 */ |
|
7768 resolve: function(calc, s) { |
|
7769 |
|
7770 var len, i, m, url, group, groupName, j, frag, |
|
7771 comboSource, comboSources, mods, comboBase, |
|
7772 base, urls, u = [], tmpBase, baseLen, resCombos = {}, |
|
7773 self = this, comboSep, maxURLLength, |
|
7774 inserted = (self.ignoreRegistered) ? {} : self.inserted, |
|
7775 resolved = { js: [], jsMods: [], css: [], cssMods: [] }, |
|
7776 type = self.loadType || 'js', addSingle; |
|
7777 |
|
7778 if (self.skin.overrides || self.skin.defaultSkin !== DEFAULT_SKIN || self.ignoreRegistered) { |
|
7779 self._resetModules(); |
|
7780 } |
|
7781 |
|
7782 if (calc) { |
|
7783 self.calculate(); |
|
7784 } |
|
7785 s = s || self.sorted; |
|
7786 |
|
7787 addSingle = function(m) { |
|
7788 |
|
7789 if (m) { |
|
7790 group = (m.group && self.groups[m.group]) || NOT_FOUND; |
|
7791 |
|
7792 //Always assume it's async |
|
7793 if (group.async === false) { |
|
7794 m.async = group.async; |
|
7795 } |
|
7796 |
|
7797 url = (m.fullpath) ? self._filter(m.fullpath, s[i]) : |
|
7798 self._url(m.path, s[i], group.base || m.base); |
|
7799 |
|
7800 if (m.attributes || m.async === false) { |
|
7801 url = { |
|
7802 url: url, |
|
7803 async: m.async |
|
7804 }; |
|
7805 if (m.attributes) { |
|
7806 url.attributes = m.attributes; |
|
7807 } |
|
7808 } |
|
7809 resolved[m.type].push(url); |
|
7810 resolved[m.type + 'Mods'].push(m); |
|
7811 } else { |
|
7812 Y.log('Undefined Module', 'warn', 'loader'); |
|
7813 } |
|
7814 |
|
7815 }; |
|
7816 |
|
7817 len = s.length; |
|
7818 |
|
7819 // the default combo base |
|
7820 comboBase = self.comboBase; |
|
7821 |
|
7822 url = comboBase; |
|
7823 |
|
7824 comboSources = {}; |
|
7825 |
|
7826 for (i = 0; i < len; i++) { |
|
7827 comboSource = comboBase; |
|
7828 m = self.getModule(s[i]); |
|
7829 groupName = m && m.group; |
|
7830 group = self.groups[groupName]; |
|
7831 if (groupName && group) { |
|
7832 |
|
7833 if (!group.combine || m.fullpath) { |
|
7834 //This is not a combo module, skip it and load it singly later. |
|
7835 addSingle(m); |
|
7836 continue; |
|
7837 } |
|
7838 m.combine = true; |
|
7839 if (group.comboBase) { |
|
7840 comboSource = group.comboBase; |
|
7841 } |
|
7842 |
|
7843 if ("root" in group && L.isValue(group.root)) { |
|
7844 m.root = group.root; |
|
7845 } |
|
7846 m.comboSep = group.comboSep || self.comboSep; |
|
7847 m.maxURLLength = group.maxURLLength || self.maxURLLength; |
|
7848 } else { |
|
7849 if (!self.combine) { |
|
7850 //This is not a combo module, skip it and load it singly later. |
|
7851 addSingle(m); |
|
7852 continue; |
|
7853 } |
|
7854 } |
|
7855 |
|
7856 comboSources[comboSource] = comboSources[comboSource] || []; |
|
7857 comboSources[comboSource].push(m); |
|
7858 } |
|
7859 |
|
7860 for (j in comboSources) { |
|
7861 if (comboSources.hasOwnProperty(j)) { |
|
7862 resCombos[j] = resCombos[j] || { js: [], jsMods: [], css: [], cssMods: [] }; |
|
7863 url = j; |
|
7864 mods = comboSources[j]; |
|
7865 len = mods.length; |
|
7866 |
|
7867 if (len) { |
|
7868 for (i = 0; i < len; i++) { |
|
7869 if (inserted[mods[i]]) { |
|
7870 continue; |
|
7871 } |
|
7872 m = mods[i]; |
|
7873 // Do not try to combine non-yui JS unless combo def |
|
7874 // is found |
|
7875 if (m && (m.combine || !m.ext)) { |
|
7876 resCombos[j].comboSep = m.comboSep; |
|
7877 resCombos[j].group = m.group; |
|
7878 resCombos[j].maxURLLength = m.maxURLLength; |
|
7879 frag = ((L.isValue(m.root)) ? m.root : self.root) + (m.path || m.fullpath); |
|
7880 frag = self._filter(frag, m.name); |
|
7881 resCombos[j][m.type].push(frag); |
|
7882 resCombos[j][m.type + 'Mods'].push(m); |
|
7883 } else { |
|
7884 //Add them to the next process.. |
|
7885 if (mods[i]) { |
|
7886 addSingle(mods[i]); |
|
7887 } |
|
7888 } |
|
7889 |
|
7890 } |
|
7891 } |
|
7892 } |
|
7893 } |
|
7894 |
|
7895 |
|
7896 for (j in resCombos) { |
|
7897 if (resCombos.hasOwnProperty(j)) { |
|
7898 base = j; |
|
7899 comboSep = resCombos[base].comboSep || self.comboSep; |
|
7900 maxURLLength = resCombos[base].maxURLLength || self.maxURLLength; |
|
7901 Y.log('Using maxURLLength of ' + maxURLLength, 'info', 'loader'); |
|
7902 for (type in resCombos[base]) { |
|
7903 if (type === JS || type === CSS) { |
|
7904 urls = resCombos[base][type]; |
|
7905 mods = resCombos[base][type + 'Mods']; |
|
7906 len = urls.length; |
|
7907 tmpBase = base + urls.join(comboSep); |
|
7908 baseLen = tmpBase.length; |
|
7909 if (maxURLLength <= base.length) { |
|
7910 Y.log('maxURLLength (' + maxURLLength + ') is lower than the comboBase length (' + base.length + '), resetting to default (' + MAX_URL_LENGTH + ')', 'error', 'loader'); |
|
7911 maxURLLength = MAX_URL_LENGTH; |
|
7912 } |
|
7913 |
|
7914 if (len) { |
|
7915 if (baseLen > maxURLLength) { |
|
7916 Y.log('Exceeded maxURLLength (' + maxURLLength + ') for ' + type + ', splitting', 'info', 'loader'); |
|
7917 u = []; |
|
7918 for (s = 0; s < len; s++) { |
|
7919 u.push(urls[s]); |
|
7920 tmpBase = base + u.join(comboSep); |
|
7921 |
|
7922 if (tmpBase.length > maxURLLength) { |
|
7923 m = u.pop(); |
|
7924 tmpBase = base + u.join(comboSep); |
|
7925 resolved[type].push(self._filter(tmpBase, null, resCombos[base].group)); |
|
7926 u = []; |
|
7927 if (m) { |
|
7928 u.push(m); |
|
7929 } |
|
7930 } |
|
7931 } |
|
7932 if (u.length) { |
|
7933 tmpBase = base + u.join(comboSep); |
|
7934 resolved[type].push(self._filter(tmpBase, null, resCombos[base].group)); |
|
7935 } |
|
7936 } else { |
|
7937 resolved[type].push(self._filter(tmpBase, null, resCombos[base].group)); |
|
7938 } |
|
7939 } |
|
7940 resolved[type + 'Mods'] = resolved[type + 'Mods'].concat(mods); |
|
7941 } |
|
7942 } |
|
7943 } |
|
7944 } |
|
7945 |
|
7946 resCombos = null; |
|
7947 |
|
7948 return resolved; |
|
7949 }, |
|
7950 /** |
|
7951 Shortcut to calculate, resolve and load all modules. |
|
7952 |
|
7953 var loader = new Y.Loader({ |
|
7954 ignoreRegistered: true, |
|
7955 modules: { |
|
7956 mod: { |
|
7957 path: 'mod.js' |
|
7958 } |
|
7959 }, |
|
7960 requires: [ 'mod' ] |
|
7961 }); |
|
7962 loader.load(function() { |
|
7963 console.log('All modules have loaded..'); |
|
7964 }); |
|
7965 |
|
7966 |
|
7967 @method load |
|
7968 @param {Function} cb Executed after all load operations are complete |
|
7969 */ |
|
7970 load: function(cb) { |
|
7971 if (!cb) { |
|
7972 Y.log('No callback supplied to load()', 'error', 'loader'); |
|
7973 return; |
|
7974 } |
|
7975 var self = this, |
|
7976 out = self.resolve(true); |
|
7977 |
|
7978 self.data = out; |
|
7979 |
|
7980 self.onEnd = function() { |
|
7981 cb.apply(self.context || self, arguments); |
|
7982 }; |
|
7983 |
|
7984 self.insert(); |
|
7985 } |
|
7986 }; |
|
7987 |
|
7988 |
|
7989 |
|
7990 }, '@VERSION@', {"requires": ["get", "features"]}); |
|
7991 YUI.add('loader-rollup', function (Y, NAME) { |
|
7992 |
|
7993 /** |
|
7994 * Optional automatic rollup logic for reducing http connections |
|
7995 * when not using a combo service. |
|
7996 * @module loader |
|
7997 * @submodule rollup |
|
7998 */ |
|
7999 |
|
8000 /** |
|
8001 * Look for rollup packages to determine if all of the modules a |
|
8002 * rollup supersedes are required. If so, include the rollup to |
|
8003 * help reduce the total number of connections required. Called |
|
8004 * by calculate(). This is an optional feature, and requires the |
|
8005 * appropriate submodule to function. |
|
8006 * @method _rollup |
|
8007 * @for Loader |
|
8008 * @private |
|
8009 */ |
|
8010 Y.Loader.prototype._rollup = function() { |
|
8011 var i, j, m, s, r = this.required, roll, |
|
8012 info = this.moduleInfo, rolled, c, smod; |
|
8013 |
|
8014 // find and cache rollup modules |
|
8015 if (this.dirty || !this.rollups) { |
|
8016 this.rollups = {}; |
|
8017 for (i in info) { |
|
8018 if (info.hasOwnProperty(i)) { |
|
8019 m = this.getModule(i); |
|
8020 // if (m && m.rollup && m.supersedes) { |
|
8021 if (m && m.rollup) { |
|
8022 this.rollups[i] = m; |
|
8023 } |
|
8024 } |
|
8025 } |
|
8026 } |
|
8027 |
|
8028 // make as many passes as needed to pick up rollup rollups |
|
8029 for (;;) { |
|
8030 rolled = false; |
|
8031 |
|
8032 // go through the rollup candidates |
|
8033 for (i in this.rollups) { |
|
8034 if (this.rollups.hasOwnProperty(i)) { |
|
8035 // there can be only one, unless forced |
|
8036 if (!r[i] && ((!this.loaded[i]) || this.forceMap[i])) { |
|
8037 m = this.getModule(i); |
|
8038 s = m.supersedes || []; |
|
8039 roll = false; |
|
8040 |
|
8041 // @TODO remove continue |
|
8042 if (!m.rollup) { |
|
8043 continue; |
|
8044 } |
|
8045 |
|
8046 c = 0; |
|
8047 |
|
8048 // check the threshold |
|
8049 for (j = 0; j < s.length; j++) { |
|
8050 smod = info[s[j]]; |
|
8051 |
|
8052 // if the superseded module is loaded, we can't |
|
8053 // load the rollup unless it has been forced. |
|
8054 if (this.loaded[s[j]] && !this.forceMap[s[j]]) { |
|
8055 roll = false; |
|
8056 break; |
|
8057 // increment the counter if this module is required. |
|
8058 // if we are beyond the rollup threshold, we will |
|
8059 // use the rollup module |
|
8060 } else if (r[s[j]] && m.type === smod.type) { |
|
8061 c++; |
|
8062 // Y.log("adding to thresh: " + c + ", " + s[j]); |
|
8063 roll = (c >= m.rollup); |
|
8064 if (roll) { |
|
8065 // Y.log("over thresh " + c + ", " + s[j]); |
|
8066 break; |
|
8067 } |
|
8068 } |
|
8069 } |
|
8070 |
|
8071 if (roll) { |
|
8072 // Y.log("adding rollup: " + i); |
|
8073 // add the rollup |
|
8074 r[i] = true; |
|
8075 rolled = true; |
|
8076 |
|
8077 // expand the rollup's dependencies |
|
8078 this.getRequires(m); |
|
8079 } |
|
8080 } |
|
8081 } |
|
8082 } |
|
8083 |
|
8084 // if we made it here w/o rolling up something, we are done |
|
8085 if (!rolled) { |
|
8086 break; |
|
8087 } |
|
8088 } |
|
8089 }; |
|
8090 |
|
8091 |
|
8092 }, '@VERSION@', {"requires": ["loader-base"]}); |
|
8093 YUI.add('loader-yui3', function (Y, NAME) { |
|
8094 |
|
8095 /* This file is auto-generated by (yogi loader --yes --mix --start ../) */ |
|
8096 |
|
8097 /*jshint maxlen:900, eqeqeq: false */ |
|
8098 |
|
8099 /** |
|
8100 * YUI 3 module metadata |
|
8101 * @module loader |
|
8102 * @submodule loader-yui3 |
|
8103 */ |
|
8104 YUI.Env[Y.version].modules = YUI.Env[Y.version].modules || {}; |
|
8105 Y.mix(YUI.Env[Y.version].modules, { |
|
8106 "align-plugin": { |
|
8107 "requires": [ |
|
8108 "node-screen", |
|
8109 "node-pluginhost" |
|
8110 ] |
|
8111 }, |
|
8112 "anim": { |
|
8113 "use": [ |
|
8114 "anim-base", |
|
8115 "anim-color", |
|
8116 "anim-curve", |
|
8117 "anim-easing", |
|
8118 "anim-node-plugin", |
|
8119 "anim-scroll", |
|
8120 "anim-xy" |
|
8121 ] |
|
8122 }, |
|
8123 "anim-base": { |
|
8124 "requires": [ |
|
8125 "base-base", |
|
8126 "node-style" |
|
8127 ] |
|
8128 }, |
|
8129 "anim-color": { |
|
8130 "requires": [ |
|
8131 "anim-base" |
|
8132 ] |
|
8133 }, |
|
8134 "anim-curve": { |
|
8135 "requires": [ |
|
8136 "anim-xy" |
|
8137 ] |
|
8138 }, |
|
8139 "anim-easing": { |
|
8140 "requires": [ |
|
8141 "anim-base" |
|
8142 ] |
|
8143 }, |
|
8144 "anim-node-plugin": { |
|
8145 "requires": [ |
|
8146 "node-pluginhost", |
|
8147 "anim-base" |
|
8148 ] |
|
8149 }, |
|
8150 "anim-scroll": { |
|
8151 "requires": [ |
|
8152 "anim-base" |
|
8153 ] |
|
8154 }, |
|
8155 "anim-shape": { |
|
8156 "requires": [ |
|
8157 "anim-base", |
|
8158 "anim-easing", |
|
8159 "anim-color", |
|
8160 "matrix" |
|
8161 ] |
|
8162 }, |
|
8163 "anim-shape-transform": { |
|
8164 "use": [ |
|
8165 "anim-shape" |
|
8166 ] |
|
8167 }, |
|
8168 "anim-xy": { |
|
8169 "requires": [ |
|
8170 "anim-base", |
|
8171 "node-screen" |
|
8172 ] |
|
8173 }, |
|
8174 "app": { |
|
8175 "use": [ |
|
8176 "app-base", |
|
8177 "app-content", |
|
8178 "app-transitions", |
|
8179 "lazy-model-list", |
|
8180 "model", |
|
8181 "model-list", |
|
8182 "model-sync-rest", |
|
8183 "model-sync-local", |
|
8184 "router", |
|
8185 "view", |
|
8186 "view-node-map" |
|
8187 ] |
|
8188 }, |
|
8189 "app-base": { |
|
8190 "requires": [ |
|
8191 "classnamemanager", |
|
8192 "pjax-base", |
|
8193 "router", |
|
8194 "view" |
|
8195 ] |
|
8196 }, |
|
8197 "app-content": { |
|
8198 "requires": [ |
|
8199 "app-base", |
|
8200 "pjax-content" |
|
8201 ] |
|
8202 }, |
|
8203 "app-transitions": { |
|
8204 "requires": [ |
|
8205 "app-base" |
|
8206 ] |
|
8207 }, |
|
8208 "app-transitions-css": { |
|
8209 "type": "css" |
|
8210 }, |
|
8211 "app-transitions-native": { |
|
8212 "condition": { |
|
8213 "name": "app-transitions-native", |
|
8214 "test": function (Y) { |
|
8215 var doc = Y.config.doc, |
|
8216 node = doc ? doc.documentElement : null; |
|
8217 |
|
8218 if (node && node.style) { |
|
8219 return ('MozTransition' in node.style || 'WebkitTransition' in node.style || 'transition' in node.style); |
|
8220 } |
|
8221 |
|
8222 return false; |
|
8223 }, |
|
8224 "trigger": "app-transitions" |
|
8225 }, |
|
8226 "requires": [ |
|
8227 "app-transitions", |
|
8228 "app-transitions-css", |
|
8229 "parallel", |
|
8230 "transition" |
|
8231 ] |
|
8232 }, |
|
8233 "array-extras": { |
|
8234 "requires": [ |
|
8235 "yui-base" |
|
8236 ] |
|
8237 }, |
|
8238 "array-invoke": { |
|
8239 "requires": [ |
|
8240 "yui-base" |
|
8241 ] |
|
8242 }, |
|
8243 "arraylist": { |
|
8244 "requires": [ |
|
8245 "yui-base" |
|
8246 ] |
|
8247 }, |
|
8248 "arraylist-add": { |
|
8249 "requires": [ |
|
8250 "arraylist" |
|
8251 ] |
|
8252 }, |
|
8253 "arraylist-filter": { |
|
8254 "requires": [ |
|
8255 "arraylist" |
|
8256 ] |
|
8257 }, |
|
8258 "arraysort": { |
|
8259 "requires": [ |
|
8260 "yui-base" |
|
8261 ] |
|
8262 }, |
|
8263 "async-queue": { |
|
8264 "requires": [ |
|
8265 "event-custom" |
|
8266 ] |
|
8267 }, |
|
8268 "attribute": { |
|
8269 "use": [ |
|
8270 "attribute-base", |
|
8271 "attribute-complex" |
|
8272 ] |
|
8273 }, |
|
8274 "attribute-base": { |
|
8275 "requires": [ |
|
8276 "attribute-core", |
|
8277 "attribute-observable", |
|
8278 "attribute-extras" |
|
8279 ] |
|
8280 }, |
|
8281 "attribute-complex": { |
|
8282 "requires": [ |
|
8283 "attribute-base" |
|
8284 ] |
|
8285 }, |
|
8286 "attribute-core": { |
|
8287 "requires": [ |
|
8288 "oop" |
|
8289 ] |
|
8290 }, |
|
8291 "attribute-events": { |
|
8292 "use": [ |
|
8293 "attribute-observable" |
|
8294 ] |
|
8295 }, |
|
8296 "attribute-extras": { |
|
8297 "requires": [ |
|
8298 "oop" |
|
8299 ] |
|
8300 }, |
|
8301 "attribute-observable": { |
|
8302 "requires": [ |
|
8303 "event-custom" |
|
8304 ] |
|
8305 }, |
|
8306 "autocomplete": { |
|
8307 "use": [ |
|
8308 "autocomplete-base", |
|
8309 "autocomplete-sources", |
|
8310 "autocomplete-list", |
|
8311 "autocomplete-plugin" |
|
8312 ] |
|
8313 }, |
|
8314 "autocomplete-base": { |
|
8315 "optional": [ |
|
8316 "autocomplete-sources" |
|
8317 ], |
|
8318 "requires": [ |
|
8319 "array-extras", |
|
8320 "base-build", |
|
8321 "escape", |
|
8322 "event-valuechange", |
|
8323 "node-base" |
|
8324 ] |
|
8325 }, |
|
8326 "autocomplete-filters": { |
|
8327 "requires": [ |
|
8328 "array-extras", |
|
8329 "text-wordbreak" |
|
8330 ] |
|
8331 }, |
|
8332 "autocomplete-filters-accentfold": { |
|
8333 "requires": [ |
|
8334 "array-extras", |
|
8335 "text-accentfold", |
|
8336 "text-wordbreak" |
|
8337 ] |
|
8338 }, |
|
8339 "autocomplete-highlighters": { |
|
8340 "requires": [ |
|
8341 "array-extras", |
|
8342 "highlight-base" |
|
8343 ] |
|
8344 }, |
|
8345 "autocomplete-highlighters-accentfold": { |
|
8346 "requires": [ |
|
8347 "array-extras", |
|
8348 "highlight-accentfold" |
|
8349 ] |
|
8350 }, |
|
8351 "autocomplete-list": { |
|
8352 "after": [ |
|
8353 "autocomplete-sources" |
|
8354 ], |
|
8355 "lang": [ |
|
8356 "en", |
|
8357 "es", |
|
8358 "hu", |
|
8359 "it" |
|
8360 ], |
|
8361 "requires": [ |
|
8362 "autocomplete-base", |
|
8363 "event-resize", |
|
8364 "node-screen", |
|
8365 "selector-css3", |
|
8366 "shim-plugin", |
|
8367 "widget", |
|
8368 "widget-position", |
|
8369 "widget-position-align" |
|
8370 ], |
|
8371 "skinnable": true |
|
8372 }, |
|
8373 "autocomplete-list-keys": { |
|
8374 "condition": { |
|
8375 "name": "autocomplete-list-keys", |
|
8376 "test": function (Y) { |
|
8377 // Only add keyboard support to autocomplete-list if this doesn't appear to |
|
8378 // be an iOS or Android-based mobile device. |
|
8379 // |
|
8380 // There's currently no feasible way to actually detect whether a device has |
|
8381 // a hardware keyboard, so this sniff will have to do. It can easily be |
|
8382 // overridden by manually loading the autocomplete-list-keys module. |
|
8383 // |
|
8384 // Worth noting: even though iOS supports bluetooth keyboards, Mobile Safari |
|
8385 // doesn't fire the keyboard events used by AutoCompleteList, so there's |
|
8386 // no point loading the -keys module even when a bluetooth keyboard may be |
|
8387 // available. |
|
8388 return !(Y.UA.ios || Y.UA.android); |
|
8389 }, |
|
8390 "trigger": "autocomplete-list" |
|
8391 }, |
|
8392 "requires": [ |
|
8393 "autocomplete-list", |
|
8394 "base-build" |
|
8395 ] |
|
8396 }, |
|
8397 "autocomplete-plugin": { |
|
8398 "requires": [ |
|
8399 "autocomplete-list", |
|
8400 "node-pluginhost" |
|
8401 ] |
|
8402 }, |
|
8403 "autocomplete-sources": { |
|
8404 "optional": [ |
|
8405 "io-base", |
|
8406 "json-parse", |
|
8407 "jsonp", |
|
8408 "yql" |
|
8409 ], |
|
8410 "requires": [ |
|
8411 "autocomplete-base" |
|
8412 ] |
|
8413 }, |
|
8414 "axes": { |
|
8415 "use": [ |
|
8416 "axis-numeric", |
|
8417 "axis-category", |
|
8418 "axis-time", |
|
8419 "axis-stacked" |
|
8420 ] |
|
8421 }, |
|
8422 "axes-base": { |
|
8423 "use": [ |
|
8424 "axis-numeric-base", |
|
8425 "axis-category-base", |
|
8426 "axis-time-base", |
|
8427 "axis-stacked-base" |
|
8428 ] |
|
8429 }, |
|
8430 "axis": { |
|
8431 "requires": [ |
|
8432 "dom", |
|
8433 "widget", |
|
8434 "widget-position", |
|
8435 "widget-stack", |
|
8436 "graphics", |
|
8437 "axis-base" |
|
8438 ] |
|
8439 }, |
|
8440 "axis-base": { |
|
8441 "requires": [ |
|
8442 "classnamemanager", |
|
8443 "datatype-number", |
|
8444 "datatype-date", |
|
8445 "base", |
|
8446 "event-custom" |
|
8447 ] |
|
8448 }, |
|
8449 "axis-category": { |
|
8450 "requires": [ |
|
8451 "axis", |
|
8452 "axis-category-base" |
|
8453 ] |
|
8454 }, |
|
8455 "axis-category-base": { |
|
8456 "requires": [ |
|
8457 "axis-base" |
|
8458 ] |
|
8459 }, |
|
8460 "axis-numeric": { |
|
8461 "requires": [ |
|
8462 "axis", |
|
8463 "axis-numeric-base" |
|
8464 ] |
|
8465 }, |
|
8466 "axis-numeric-base": { |
|
8467 "requires": [ |
|
8468 "axis-base" |
|
8469 ] |
|
8470 }, |
|
8471 "axis-stacked": { |
|
8472 "requires": [ |
|
8473 "axis-numeric", |
|
8474 "axis-stacked-base" |
|
8475 ] |
|
8476 }, |
|
8477 "axis-stacked-base": { |
|
8478 "requires": [ |
|
8479 "axis-numeric-base" |
|
8480 ] |
|
8481 }, |
|
8482 "axis-time": { |
|
8483 "requires": [ |
|
8484 "axis", |
|
8485 "axis-time-base" |
|
8486 ] |
|
8487 }, |
|
8488 "axis-time-base": { |
|
8489 "requires": [ |
|
8490 "axis-base" |
|
8491 ] |
|
8492 }, |
|
8493 "base": { |
|
8494 "use": [ |
|
8495 "base-base", |
|
8496 "base-pluginhost", |
|
8497 "base-build" |
|
8498 ] |
|
8499 }, |
|
8500 "base-base": { |
|
8501 "requires": [ |
|
8502 "attribute-base", |
|
8503 "base-core", |
|
8504 "base-observable" |
|
8505 ] |
|
8506 }, |
|
8507 "base-build": { |
|
8508 "requires": [ |
|
8509 "base-base" |
|
8510 ] |
|
8511 }, |
|
8512 "base-core": { |
|
8513 "requires": [ |
|
8514 "attribute-core" |
|
8515 ] |
|
8516 }, |
|
8517 "base-observable": { |
|
8518 "requires": [ |
|
8519 "attribute-observable", |
|
8520 "base-core" |
|
8521 ] |
|
8522 }, |
|
8523 "base-pluginhost": { |
|
8524 "requires": [ |
|
8525 "base-base", |
|
8526 "pluginhost" |
|
8527 ] |
|
8528 }, |
|
8529 "button": { |
|
8530 "requires": [ |
|
8531 "button-core", |
|
8532 "cssbutton", |
|
8533 "widget" |
|
8534 ] |
|
8535 }, |
|
8536 "button-core": { |
|
8537 "requires": [ |
|
8538 "attribute-core", |
|
8539 "classnamemanager", |
|
8540 "node-base", |
|
8541 "escape" |
|
8542 ] |
|
8543 }, |
|
8544 "button-group": { |
|
8545 "requires": [ |
|
8546 "button-plugin", |
|
8547 "cssbutton", |
|
8548 "widget" |
|
8549 ] |
|
8550 }, |
|
8551 "button-plugin": { |
|
8552 "requires": [ |
|
8553 "button-core", |
|
8554 "cssbutton", |
|
8555 "node-pluginhost" |
|
8556 ] |
|
8557 }, |
|
8558 "cache": { |
|
8559 "use": [ |
|
8560 "cache-base", |
|
8561 "cache-offline", |
|
8562 "cache-plugin" |
|
8563 ] |
|
8564 }, |
|
8565 "cache-base": { |
|
8566 "requires": [ |
|
8567 "base" |
|
8568 ] |
|
8569 }, |
|
8570 "cache-offline": { |
|
8571 "requires": [ |
|
8572 "cache-base", |
|
8573 "json" |
|
8574 ] |
|
8575 }, |
|
8576 "cache-plugin": { |
|
8577 "requires": [ |
|
8578 "plugin", |
|
8579 "cache-base" |
|
8580 ] |
|
8581 }, |
|
8582 "calendar": { |
|
8583 "requires": [ |
|
8584 "calendar-base", |
|
8585 "calendarnavigator" |
|
8586 ], |
|
8587 "skinnable": true |
|
8588 }, |
|
8589 "calendar-base": { |
|
8590 "lang": [ |
|
8591 "de", |
|
8592 "en", |
|
8593 "es", |
|
8594 "es-AR", |
|
8595 "fr", |
|
8596 "hu", |
|
8597 "it", |
|
8598 "ja", |
|
8599 "nb-NO", |
|
8600 "nl", |
|
8601 "pt-BR", |
|
8602 "ru", |
|
8603 "zh-Hans", |
|
8604 "zh-Hans-CN", |
|
8605 "zh-Hant", |
|
8606 "zh-Hant-HK", |
|
8607 "zh-HANT-TW" |
|
8608 ], |
|
8609 "requires": [ |
|
8610 "widget", |
|
8611 "datatype-date", |
|
8612 "datatype-date-math", |
|
8613 "cssgrids" |
|
8614 ], |
|
8615 "skinnable": true |
|
8616 }, |
|
8617 "calendarnavigator": { |
|
8618 "requires": [ |
|
8619 "plugin", |
|
8620 "classnamemanager", |
|
8621 "datatype-date", |
|
8622 "node" |
|
8623 ], |
|
8624 "skinnable": true |
|
8625 }, |
|
8626 "charts": { |
|
8627 "use": [ |
|
8628 "charts-base" |
|
8629 ] |
|
8630 }, |
|
8631 "charts-base": { |
|
8632 "requires": [ |
|
8633 "dom", |
|
8634 "event-mouseenter", |
|
8635 "event-touch", |
|
8636 "graphics-group", |
|
8637 "axes", |
|
8638 "series-pie", |
|
8639 "series-line", |
|
8640 "series-marker", |
|
8641 "series-area", |
|
8642 "series-spline", |
|
8643 "series-column", |
|
8644 "series-bar", |
|
8645 "series-areaspline", |
|
8646 "series-combo", |
|
8647 "series-combospline", |
|
8648 "series-line-stacked", |
|
8649 "series-marker-stacked", |
|
8650 "series-area-stacked", |
|
8651 "series-spline-stacked", |
|
8652 "series-column-stacked", |
|
8653 "series-bar-stacked", |
|
8654 "series-areaspline-stacked", |
|
8655 "series-combo-stacked", |
|
8656 "series-combospline-stacked" |
|
8657 ] |
|
8658 }, |
|
8659 "charts-legend": { |
|
8660 "requires": [ |
|
8661 "charts-base" |
|
8662 ] |
|
8663 }, |
|
8664 "classnamemanager": { |
|
8665 "requires": [ |
|
8666 "yui-base" |
|
8667 ] |
|
8668 }, |
|
8669 "clickable-rail": { |
|
8670 "requires": [ |
|
8671 "slider-base" |
|
8672 ] |
|
8673 }, |
|
8674 "collection": { |
|
8675 "use": [ |
|
8676 "array-extras", |
|
8677 "arraylist", |
|
8678 "arraylist-add", |
|
8679 "arraylist-filter", |
|
8680 "array-invoke" |
|
8681 ] |
|
8682 }, |
|
8683 "color": { |
|
8684 "use": [ |
|
8685 "color-base", |
|
8686 "color-hsl", |
|
8687 "color-harmony" |
|
8688 ] |
|
8689 }, |
|
8690 "color-base": { |
|
8691 "requires": [ |
|
8692 "yui-base" |
|
8693 ] |
|
8694 }, |
|
8695 "color-harmony": { |
|
8696 "requires": [ |
|
8697 "color-hsl" |
|
8698 ] |
|
8699 }, |
|
8700 "color-hsl": { |
|
8701 "requires": [ |
|
8702 "color-base" |
|
8703 ] |
|
8704 }, |
|
8705 "color-hsv": { |
|
8706 "requires": [ |
|
8707 "color-base" |
|
8708 ] |
|
8709 }, |
|
8710 "console": { |
|
8711 "lang": [ |
|
8712 "en", |
|
8713 "es", |
|
8714 "hu", |
|
8715 "it", |
|
8716 "ja" |
|
8717 ], |
|
8718 "requires": [ |
|
8719 "yui-log", |
|
8720 "widget" |
|
8721 ], |
|
8722 "skinnable": true |
|
8723 }, |
|
8724 "console-filters": { |
|
8725 "requires": [ |
|
8726 "plugin", |
|
8727 "console" |
|
8728 ], |
|
8729 "skinnable": true |
|
8730 }, |
|
8731 "content-editable": { |
|
8732 "requires": [ |
|
8733 "node-base", |
|
8734 "editor-selection", |
|
8735 "stylesheet", |
|
8736 "plugin" |
|
8737 ] |
|
8738 }, |
|
8739 "controller": { |
|
8740 "use": [ |
|
8741 "router" |
|
8742 ] |
|
8743 }, |
|
8744 "cookie": { |
|
8745 "requires": [ |
|
8746 "yui-base" |
|
8747 ] |
|
8748 }, |
|
8749 "createlink-base": { |
|
8750 "requires": [ |
|
8751 "editor-base" |
|
8752 ] |
|
8753 }, |
|
8754 "cssbase": { |
|
8755 "after": [ |
|
8756 "cssreset", |
|
8757 "cssfonts", |
|
8758 "cssgrids", |
|
8759 "cssreset-context", |
|
8760 "cssfonts-context", |
|
8761 "cssgrids-context" |
|
8762 ], |
|
8763 "type": "css" |
|
8764 }, |
|
8765 "cssbase-context": { |
|
8766 "after": [ |
|
8767 "cssreset", |
|
8768 "cssfonts", |
|
8769 "cssgrids", |
|
8770 "cssreset-context", |
|
8771 "cssfonts-context", |
|
8772 "cssgrids-context" |
|
8773 ], |
|
8774 "type": "css" |
|
8775 }, |
|
8776 "cssbutton": { |
|
8777 "type": "css" |
|
8778 }, |
|
8779 "cssfonts": { |
|
8780 "type": "css" |
|
8781 }, |
|
8782 "cssfonts-context": { |
|
8783 "type": "css" |
|
8784 }, |
|
8785 "cssgrids": { |
|
8786 "optional": [ |
|
8787 "cssnormalize" |
|
8788 ], |
|
8789 "type": "css" |
|
8790 }, |
|
8791 "cssgrids-base": { |
|
8792 "optional": [ |
|
8793 "cssnormalize" |
|
8794 ], |
|
8795 "type": "css" |
|
8796 }, |
|
8797 "cssgrids-responsive": { |
|
8798 "optional": [ |
|
8799 "cssnormalize" |
|
8800 ], |
|
8801 "requires": [ |
|
8802 "cssgrids", |
|
8803 "cssgrids-responsive-base" |
|
8804 ], |
|
8805 "type": "css" |
|
8806 }, |
|
8807 "cssgrids-units": { |
|
8808 "optional": [ |
|
8809 "cssnormalize" |
|
8810 ], |
|
8811 "requires": [ |
|
8812 "cssgrids-base" |
|
8813 ], |
|
8814 "type": "css" |
|
8815 }, |
|
8816 "cssnormalize": { |
|
8817 "type": "css" |
|
8818 }, |
|
8819 "cssnormalize-context": { |
|
8820 "type": "css" |
|
8821 }, |
|
8822 "cssreset": { |
|
8823 "type": "css" |
|
8824 }, |
|
8825 "cssreset-context": { |
|
8826 "type": "css" |
|
8827 }, |
|
8828 "dataschema": { |
|
8829 "use": [ |
|
8830 "dataschema-base", |
|
8831 "dataschema-json", |
|
8832 "dataschema-xml", |
|
8833 "dataschema-array", |
|
8834 "dataschema-text" |
|
8835 ] |
|
8836 }, |
|
8837 "dataschema-array": { |
|
8838 "requires": [ |
|
8839 "dataschema-base" |
|
8840 ] |
|
8841 }, |
|
8842 "dataschema-base": { |
|
8843 "requires": [ |
|
8844 "base" |
|
8845 ] |
|
8846 }, |
|
8847 "dataschema-json": { |
|
8848 "requires": [ |
|
8849 "dataschema-base", |
|
8850 "json" |
|
8851 ] |
|
8852 }, |
|
8853 "dataschema-text": { |
|
8854 "requires": [ |
|
8855 "dataschema-base" |
|
8856 ] |
|
8857 }, |
|
8858 "dataschema-xml": { |
|
8859 "requires": [ |
|
8860 "dataschema-base" |
|
8861 ] |
|
8862 }, |
|
8863 "datasource": { |
|
8864 "use": [ |
|
8865 "datasource-local", |
|
8866 "datasource-io", |
|
8867 "datasource-get", |
|
8868 "datasource-function", |
|
8869 "datasource-cache", |
|
8870 "datasource-jsonschema", |
|
8871 "datasource-xmlschema", |
|
8872 "datasource-arrayschema", |
|
8873 "datasource-textschema", |
|
8874 "datasource-polling" |
|
8875 ] |
|
8876 }, |
|
8877 "datasource-arrayschema": { |
|
8878 "requires": [ |
|
8879 "datasource-local", |
|
8880 "plugin", |
|
8881 "dataschema-array" |
|
8882 ] |
|
8883 }, |
|
8884 "datasource-cache": { |
|
8885 "requires": [ |
|
8886 "datasource-local", |
|
8887 "plugin", |
|
8888 "cache-base" |
|
8889 ] |
|
8890 }, |
|
8891 "datasource-function": { |
|
8892 "requires": [ |
|
8893 "datasource-local" |
|
8894 ] |
|
8895 }, |
|
8896 "datasource-get": { |
|
8897 "requires": [ |
|
8898 "datasource-local", |
|
8899 "get" |
|
8900 ] |
|
8901 }, |
|
8902 "datasource-io": { |
|
8903 "requires": [ |
|
8904 "datasource-local", |
|
8905 "io-base" |
|
8906 ] |
|
8907 }, |
|
8908 "datasource-jsonschema": { |
|
8909 "requires": [ |
|
8910 "datasource-local", |
|
8911 "plugin", |
|
8912 "dataschema-json" |
|
8913 ] |
|
8914 }, |
|
8915 "datasource-local": { |
|
8916 "requires": [ |
|
8917 "base" |
|
8918 ] |
|
8919 }, |
|
8920 "datasource-polling": { |
|
8921 "requires": [ |
|
8922 "datasource-local" |
|
8923 ] |
|
8924 }, |
|
8925 "datasource-textschema": { |
|
8926 "requires": [ |
|
8927 "datasource-local", |
|
8928 "plugin", |
|
8929 "dataschema-text" |
|
8930 ] |
|
8931 }, |
|
8932 "datasource-xmlschema": { |
|
8933 "requires": [ |
|
8934 "datasource-local", |
|
8935 "plugin", |
|
8936 "datatype-xml", |
|
8937 "dataschema-xml" |
|
8938 ] |
|
8939 }, |
|
8940 "datatable": { |
|
8941 "use": [ |
|
8942 "datatable-core", |
|
8943 "datatable-table", |
|
8944 "datatable-head", |
|
8945 "datatable-body", |
|
8946 "datatable-base", |
|
8947 "datatable-column-widths", |
|
8948 "datatable-message", |
|
8949 "datatable-mutable", |
|
8950 "datatable-sort", |
|
8951 "datatable-datasource" |
|
8952 ] |
|
8953 }, |
|
8954 "datatable-base": { |
|
8955 "requires": [ |
|
8956 "datatable-core", |
|
8957 "datatable-table", |
|
8958 "datatable-head", |
|
8959 "datatable-body", |
|
8960 "base-build", |
|
8961 "widget" |
|
8962 ], |
|
8963 "skinnable": true |
|
8964 }, |
|
8965 "datatable-body": { |
|
8966 "requires": [ |
|
8967 "datatable-core", |
|
8968 "view", |
|
8969 "classnamemanager" |
|
8970 ] |
|
8971 }, |
|
8972 "datatable-column-widths": { |
|
8973 "requires": [ |
|
8974 "datatable-base" |
|
8975 ] |
|
8976 }, |
|
8977 "datatable-core": { |
|
8978 "requires": [ |
|
8979 "escape", |
|
8980 "model-list", |
|
8981 "node-event-delegate" |
|
8982 ] |
|
8983 }, |
|
8984 "datatable-datasource": { |
|
8985 "requires": [ |
|
8986 "datatable-base", |
|
8987 "plugin", |
|
8988 "datasource-local" |
|
8989 ] |
|
8990 }, |
|
8991 "datatable-foot": { |
|
8992 "requires": [ |
|
8993 "datatable-core", |
|
8994 "view" |
|
8995 ] |
|
8996 }, |
|
8997 "datatable-formatters": { |
|
8998 "requires": [ |
|
8999 "datatable-body", |
|
9000 "datatype-number-format", |
|
9001 "datatype-date-format", |
|
9002 "escape" |
|
9003 ] |
|
9004 }, |
|
9005 "datatable-head": { |
|
9006 "requires": [ |
|
9007 "datatable-core", |
|
9008 "view", |
|
9009 "classnamemanager" |
|
9010 ] |
|
9011 }, |
|
9012 "datatable-highlight": { |
|
9013 "requires": [ |
|
9014 "datatable-base", |
|
9015 "event-hover" |
|
9016 ], |
|
9017 "skinnable": true |
|
9018 }, |
|
9019 "datatable-keynav": { |
|
9020 "requires": [ |
|
9021 "datatable-base" |
|
9022 ] |
|
9023 }, |
|
9024 "datatable-message": { |
|
9025 "lang": [ |
|
9026 "en", |
|
9027 "fr", |
|
9028 "es", |
|
9029 "hu", |
|
9030 "it" |
|
9031 ], |
|
9032 "requires": [ |
|
9033 "datatable-base" |
|
9034 ], |
|
9035 "skinnable": true |
|
9036 }, |
|
9037 "datatable-mutable": { |
|
9038 "requires": [ |
|
9039 "datatable-base" |
|
9040 ] |
|
9041 }, |
|
9042 "datatable-paginator": { |
|
9043 "lang": [ |
|
9044 "en", |
|
9045 "fr" |
|
9046 ], |
|
9047 "requires": [ |
|
9048 "model", |
|
9049 "view", |
|
9050 "paginator-core", |
|
9051 "datatable-foot", |
|
9052 "datatable-paginator-templates" |
|
9053 ], |
|
9054 "skinnable": true |
|
9055 }, |
|
9056 "datatable-paginator-templates": { |
|
9057 "requires": [ |
|
9058 "template" |
|
9059 ] |
|
9060 }, |
|
9061 "datatable-scroll": { |
|
9062 "requires": [ |
|
9063 "datatable-base", |
|
9064 "datatable-column-widths", |
|
9065 "dom-screen" |
|
9066 ], |
|
9067 "skinnable": true |
|
9068 }, |
|
9069 "datatable-sort": { |
|
9070 "lang": [ |
|
9071 "en", |
|
9072 "fr", |
|
9073 "es", |
|
9074 "hu" |
|
9075 ], |
|
9076 "requires": [ |
|
9077 "datatable-base" |
|
9078 ], |
|
9079 "skinnable": true |
|
9080 }, |
|
9081 "datatable-table": { |
|
9082 "requires": [ |
|
9083 "datatable-core", |
|
9084 "datatable-head", |
|
9085 "datatable-body", |
|
9086 "view", |
|
9087 "classnamemanager" |
|
9088 ] |
|
9089 }, |
|
9090 "datatype": { |
|
9091 "use": [ |
|
9092 "datatype-date", |
|
9093 "datatype-number", |
|
9094 "datatype-xml" |
|
9095 ] |
|
9096 }, |
|
9097 "datatype-date": { |
|
9098 "use": [ |
|
9099 "datatype-date-parse", |
|
9100 "datatype-date-format", |
|
9101 "datatype-date-math" |
|
9102 ] |
|
9103 }, |
|
9104 "datatype-date-format": { |
|
9105 "lang": [ |
|
9106 "ar", |
|
9107 "ar-JO", |
|
9108 "ca", |
|
9109 "ca-ES", |
|
9110 "da", |
|
9111 "da-DK", |
|
9112 "de", |
|
9113 "de-AT", |
|
9114 "de-DE", |
|
9115 "el", |
|
9116 "el-GR", |
|
9117 "en", |
|
9118 "en-AU", |
|
9119 "en-CA", |
|
9120 "en-GB", |
|
9121 "en-IE", |
|
9122 "en-IN", |
|
9123 "en-JO", |
|
9124 "en-MY", |
|
9125 "en-NZ", |
|
9126 "en-PH", |
|
9127 "en-SG", |
|
9128 "en-US", |
|
9129 "es", |
|
9130 "es-AR", |
|
9131 "es-BO", |
|
9132 "es-CL", |
|
9133 "es-CO", |
|
9134 "es-EC", |
|
9135 "es-ES", |
|
9136 "es-MX", |
|
9137 "es-PE", |
|
9138 "es-PY", |
|
9139 "es-US", |
|
9140 "es-UY", |
|
9141 "es-VE", |
|
9142 "fi", |
|
9143 "fi-FI", |
|
9144 "fr", |
|
9145 "fr-BE", |
|
9146 "fr-CA", |
|
9147 "fr-FR", |
|
9148 "hi", |
|
9149 "hi-IN", |
|
9150 "hu", |
|
9151 "id", |
|
9152 "id-ID", |
|
9153 "it", |
|
9154 "it-IT", |
|
9155 "ja", |
|
9156 "ja-JP", |
|
9157 "ko", |
|
9158 "ko-KR", |
|
9159 "ms", |
|
9160 "ms-MY", |
|
9161 "nb", |
|
9162 "nb-NO", |
|
9163 "nl", |
|
9164 "nl-BE", |
|
9165 "nl-NL", |
|
9166 "pl", |
|
9167 "pl-PL", |
|
9168 "pt", |
|
9169 "pt-BR", |
|
9170 "ro", |
|
9171 "ro-RO", |
|
9172 "ru", |
|
9173 "ru-RU", |
|
9174 "sv", |
|
9175 "sv-SE", |
|
9176 "th", |
|
9177 "th-TH", |
|
9178 "tr", |
|
9179 "tr-TR", |
|
9180 "vi", |
|
9181 "vi-VN", |
|
9182 "zh-Hans", |
|
9183 "zh-Hans-CN", |
|
9184 "zh-Hant", |
|
9185 "zh-Hant-HK", |
|
9186 "zh-Hant-TW" |
|
9187 ] |
|
9188 }, |
|
9189 "datatype-date-math": { |
|
9190 "requires": [ |
|
9191 "yui-base" |
|
9192 ] |
|
9193 }, |
|
9194 "datatype-date-parse": {}, |
|
9195 "datatype-number": { |
|
9196 "use": [ |
|
9197 "datatype-number-parse", |
|
9198 "datatype-number-format" |
|
9199 ] |
|
9200 }, |
|
9201 "datatype-number-format": {}, |
|
9202 "datatype-number-parse": { |
|
9203 "requires": [ |
|
9204 "escape" |
|
9205 ] |
|
9206 }, |
|
9207 "datatype-xml": { |
|
9208 "use": [ |
|
9209 "datatype-xml-parse", |
|
9210 "datatype-xml-format" |
|
9211 ] |
|
9212 }, |
|
9213 "datatype-xml-format": {}, |
|
9214 "datatype-xml-parse": {}, |
|
9215 "dd": { |
|
9216 "use": [ |
|
9217 "dd-ddm-base", |
|
9218 "dd-ddm", |
|
9219 "dd-ddm-drop", |
|
9220 "dd-drag", |
|
9221 "dd-proxy", |
|
9222 "dd-constrain", |
|
9223 "dd-drop", |
|
9224 "dd-scroll", |
|
9225 "dd-delegate" |
|
9226 ] |
|
9227 }, |
|
9228 "dd-constrain": { |
|
9229 "requires": [ |
|
9230 "dd-drag" |
|
9231 ] |
|
9232 }, |
|
9233 "dd-ddm": { |
|
9234 "requires": [ |
|
9235 "dd-ddm-base", |
|
9236 "event-resize" |
|
9237 ] |
|
9238 }, |
|
9239 "dd-ddm-base": { |
|
9240 "requires": [ |
|
9241 "node", |
|
9242 "base", |
|
9243 "yui-throttle", |
|
9244 "classnamemanager" |
|
9245 ] |
|
9246 }, |
|
9247 "dd-ddm-drop": { |
|
9248 "requires": [ |
|
9249 "dd-ddm" |
|
9250 ] |
|
9251 }, |
|
9252 "dd-delegate": { |
|
9253 "requires": [ |
|
9254 "dd-drag", |
|
9255 "dd-drop-plugin", |
|
9256 "event-mouseenter" |
|
9257 ] |
|
9258 }, |
|
9259 "dd-drag": { |
|
9260 "requires": [ |
|
9261 "dd-ddm-base" |
|
9262 ] |
|
9263 }, |
|
9264 "dd-drop": { |
|
9265 "requires": [ |
|
9266 "dd-drag", |
|
9267 "dd-ddm-drop" |
|
9268 ] |
|
9269 }, |
|
9270 "dd-drop-plugin": { |
|
9271 "requires": [ |
|
9272 "dd-drop" |
|
9273 ] |
|
9274 }, |
|
9275 "dd-gestures": { |
|
9276 "condition": { |
|
9277 "name": "dd-gestures", |
|
9278 "trigger": "dd-drag", |
|
9279 "ua": "touchEnabled" |
|
9280 }, |
|
9281 "requires": [ |
|
9282 "dd-drag", |
|
9283 "event-synthetic", |
|
9284 "event-gestures" |
|
9285 ] |
|
9286 }, |
|
9287 "dd-plugin": { |
|
9288 "optional": [ |
|
9289 "dd-constrain", |
|
9290 "dd-proxy" |
|
9291 ], |
|
9292 "requires": [ |
|
9293 "dd-drag" |
|
9294 ] |
|
9295 }, |
|
9296 "dd-proxy": { |
|
9297 "requires": [ |
|
9298 "dd-drag" |
|
9299 ] |
|
9300 }, |
|
9301 "dd-scroll": { |
|
9302 "requires": [ |
|
9303 "dd-drag" |
|
9304 ] |
|
9305 }, |
|
9306 "dial": { |
|
9307 "lang": [ |
|
9308 "en", |
|
9309 "es", |
|
9310 "hu" |
|
9311 ], |
|
9312 "requires": [ |
|
9313 "widget", |
|
9314 "dd-drag", |
|
9315 "event-mouseenter", |
|
9316 "event-move", |
|
9317 "event-key", |
|
9318 "transition", |
|
9319 "intl" |
|
9320 ], |
|
9321 "skinnable": true |
|
9322 }, |
|
9323 "dom": { |
|
9324 "use": [ |
|
9325 "dom-base", |
|
9326 "dom-screen", |
|
9327 "dom-style", |
|
9328 "selector-native", |
|
9329 "selector" |
|
9330 ] |
|
9331 }, |
|
9332 "dom-base": { |
|
9333 "requires": [ |
|
9334 "dom-core" |
|
9335 ] |
|
9336 }, |
|
9337 "dom-core": { |
|
9338 "requires": [ |
|
9339 "oop", |
|
9340 "features" |
|
9341 ] |
|
9342 }, |
|
9343 "dom-screen": { |
|
9344 "requires": [ |
|
9345 "dom-base", |
|
9346 "dom-style" |
|
9347 ] |
|
9348 }, |
|
9349 "dom-style": { |
|
9350 "requires": [ |
|
9351 "dom-base", |
|
9352 "color-base" |
|
9353 ] |
|
9354 }, |
|
9355 "dom-style-ie": { |
|
9356 "condition": { |
|
9357 "name": "dom-style-ie", |
|
9358 "test": function (Y) { |
|
9359 |
|
9360 var testFeature = Y.Features.test, |
|
9361 addFeature = Y.Features.add, |
|
9362 WINDOW = Y.config.win, |
|
9363 DOCUMENT = Y.config.doc, |
|
9364 DOCUMENT_ELEMENT = 'documentElement', |
|
9365 ret = false; |
|
9366 |
|
9367 addFeature('style', 'computedStyle', { |
|
9368 test: function() { |
|
9369 return WINDOW && 'getComputedStyle' in WINDOW; |
|
9370 } |
|
9371 }); |
|
9372 |
|
9373 addFeature('style', 'opacity', { |
|
9374 test: function() { |
|
9375 return DOCUMENT && 'opacity' in DOCUMENT[DOCUMENT_ELEMENT].style; |
|
9376 } |
|
9377 }); |
|
9378 |
|
9379 ret = (!testFeature('style', 'opacity') && |
|
9380 !testFeature('style', 'computedStyle')); |
|
9381 |
|
9382 return ret; |
|
9383 }, |
|
9384 "trigger": "dom-style" |
|
9385 }, |
|
9386 "requires": [ |
|
9387 "dom-style" |
|
9388 ] |
|
9389 }, |
|
9390 "dump": { |
|
9391 "requires": [ |
|
9392 "yui-base" |
|
9393 ] |
|
9394 }, |
|
9395 "editor": { |
|
9396 "use": [ |
|
9397 "frame", |
|
9398 "editor-selection", |
|
9399 "exec-command", |
|
9400 "editor-base", |
|
9401 "editor-para", |
|
9402 "editor-br", |
|
9403 "editor-bidi", |
|
9404 "editor-tab", |
|
9405 "createlink-base" |
|
9406 ] |
|
9407 }, |
|
9408 "editor-base": { |
|
9409 "requires": [ |
|
9410 "base", |
|
9411 "frame", |
|
9412 "node", |
|
9413 "exec-command", |
|
9414 "editor-selection" |
|
9415 ] |
|
9416 }, |
|
9417 "editor-bidi": { |
|
9418 "requires": [ |
|
9419 "editor-base" |
|
9420 ] |
|
9421 }, |
|
9422 "editor-br": { |
|
9423 "requires": [ |
|
9424 "editor-base" |
|
9425 ] |
|
9426 }, |
|
9427 "editor-inline": { |
|
9428 "requires": [ |
|
9429 "editor-base", |
|
9430 "content-editable" |
|
9431 ] |
|
9432 }, |
|
9433 "editor-lists": { |
|
9434 "requires": [ |
|
9435 "editor-base" |
|
9436 ] |
|
9437 }, |
|
9438 "editor-para": { |
|
9439 "requires": [ |
|
9440 "editor-para-base" |
|
9441 ] |
|
9442 }, |
|
9443 "editor-para-base": { |
|
9444 "requires": [ |
|
9445 "editor-base" |
|
9446 ] |
|
9447 }, |
|
9448 "editor-para-ie": { |
|
9449 "condition": { |
|
9450 "name": "editor-para-ie", |
|
9451 "trigger": "editor-para", |
|
9452 "ua": "ie", |
|
9453 "when": "instead" |
|
9454 }, |
|
9455 "requires": [ |
|
9456 "editor-para-base" |
|
9457 ] |
|
9458 }, |
|
9459 "editor-selection": { |
|
9460 "requires": [ |
|
9461 "node" |
|
9462 ] |
|
9463 }, |
|
9464 "editor-tab": { |
|
9465 "requires": [ |
|
9466 "editor-base" |
|
9467 ] |
|
9468 }, |
|
9469 "escape": { |
|
9470 "requires": [ |
|
9471 "yui-base" |
|
9472 ] |
|
9473 }, |
|
9474 "event": { |
|
9475 "after": [ |
|
9476 "node-base" |
|
9477 ], |
|
9478 "use": [ |
|
9479 "event-base", |
|
9480 "event-delegate", |
|
9481 "event-synthetic", |
|
9482 "event-mousewheel", |
|
9483 "event-mouseenter", |
|
9484 "event-key", |
|
9485 "event-focus", |
|
9486 "event-resize", |
|
9487 "event-hover", |
|
9488 "event-outside", |
|
9489 "event-touch", |
|
9490 "event-move", |
|
9491 "event-flick", |
|
9492 "event-valuechange", |
|
9493 "event-tap" |
|
9494 ] |
|
9495 }, |
|
9496 "event-base": { |
|
9497 "after": [ |
|
9498 "node-base" |
|
9499 ], |
|
9500 "requires": [ |
|
9501 "event-custom-base" |
|
9502 ] |
|
9503 }, |
|
9504 "event-base-ie": { |
|
9505 "after": [ |
|
9506 "event-base" |
|
9507 ], |
|
9508 "condition": { |
|
9509 "name": "event-base-ie", |
|
9510 "test": function(Y) { |
|
9511 var imp = Y.config.doc && Y.config.doc.implementation; |
|
9512 return (imp && (!imp.hasFeature('Events', '2.0'))); |
|
9513 }, |
|
9514 "trigger": "node-base" |
|
9515 }, |
|
9516 "requires": [ |
|
9517 "node-base" |
|
9518 ] |
|
9519 }, |
|
9520 "event-contextmenu": { |
|
9521 "requires": [ |
|
9522 "event-synthetic", |
|
9523 "dom-screen" |
|
9524 ] |
|
9525 }, |
|
9526 "event-custom": { |
|
9527 "use": [ |
|
9528 "event-custom-base", |
|
9529 "event-custom-complex" |
|
9530 ] |
|
9531 }, |
|
9532 "event-custom-base": { |
|
9533 "requires": [ |
|
9534 "oop" |
|
9535 ] |
|
9536 }, |
|
9537 "event-custom-complex": { |
|
9538 "requires": [ |
|
9539 "event-custom-base" |
|
9540 ] |
|
9541 }, |
|
9542 "event-delegate": { |
|
9543 "requires": [ |
|
9544 "node-base" |
|
9545 ] |
|
9546 }, |
|
9547 "event-flick": { |
|
9548 "requires": [ |
|
9549 "node-base", |
|
9550 "event-touch", |
|
9551 "event-synthetic" |
|
9552 ] |
|
9553 }, |
|
9554 "event-focus": { |
|
9555 "requires": [ |
|
9556 "event-synthetic" |
|
9557 ] |
|
9558 }, |
|
9559 "event-gestures": { |
|
9560 "use": [ |
|
9561 "event-flick", |
|
9562 "event-move" |
|
9563 ] |
|
9564 }, |
|
9565 "event-hover": { |
|
9566 "requires": [ |
|
9567 "event-mouseenter" |
|
9568 ] |
|
9569 }, |
|
9570 "event-key": { |
|
9571 "requires": [ |
|
9572 "event-synthetic" |
|
9573 ] |
|
9574 }, |
|
9575 "event-mouseenter": { |
|
9576 "requires": [ |
|
9577 "event-synthetic" |
|
9578 ] |
|
9579 }, |
|
9580 "event-mousewheel": { |
|
9581 "requires": [ |
|
9582 "node-base" |
|
9583 ] |
|
9584 }, |
|
9585 "event-move": { |
|
9586 "requires": [ |
|
9587 "node-base", |
|
9588 "event-touch", |
|
9589 "event-synthetic" |
|
9590 ] |
|
9591 }, |
|
9592 "event-outside": { |
|
9593 "requires": [ |
|
9594 "event-synthetic" |
|
9595 ] |
|
9596 }, |
|
9597 "event-resize": { |
|
9598 "requires": [ |
|
9599 "node-base", |
|
9600 "event-synthetic" |
|
9601 ] |
|
9602 }, |
|
9603 "event-simulate": { |
|
9604 "requires": [ |
|
9605 "event-base" |
|
9606 ] |
|
9607 }, |
|
9608 "event-synthetic": { |
|
9609 "requires": [ |
|
9610 "node-base", |
|
9611 "event-custom-complex" |
|
9612 ] |
|
9613 }, |
|
9614 "event-tap": { |
|
9615 "requires": [ |
|
9616 "node-base", |
|
9617 "event-base", |
|
9618 "event-touch", |
|
9619 "event-synthetic" |
|
9620 ] |
|
9621 }, |
|
9622 "event-touch": { |
|
9623 "requires": [ |
|
9624 "node-base" |
|
9625 ] |
|
9626 }, |
|
9627 "event-valuechange": { |
|
9628 "requires": [ |
|
9629 "event-focus", |
|
9630 "event-synthetic" |
|
9631 ] |
|
9632 }, |
|
9633 "exec-command": { |
|
9634 "requires": [ |
|
9635 "frame" |
|
9636 ] |
|
9637 }, |
|
9638 "features": { |
|
9639 "requires": [ |
|
9640 "yui-base" |
|
9641 ] |
|
9642 }, |
|
9643 "file": { |
|
9644 "requires": [ |
|
9645 "file-flash", |
|
9646 "file-html5" |
|
9647 ] |
|
9648 }, |
|
9649 "file-flash": { |
|
9650 "requires": [ |
|
9651 "base" |
|
9652 ] |
|
9653 }, |
|
9654 "file-html5": { |
|
9655 "requires": [ |
|
9656 "base" |
|
9657 ] |
|
9658 }, |
|
9659 "frame": { |
|
9660 "requires": [ |
|
9661 "base", |
|
9662 "node", |
|
9663 "plugin", |
|
9664 "selector-css3", |
|
9665 "yui-throttle" |
|
9666 ] |
|
9667 }, |
|
9668 "gesture-simulate": { |
|
9669 "requires": [ |
|
9670 "async-queue", |
|
9671 "event-simulate", |
|
9672 "node-screen" |
|
9673 ] |
|
9674 }, |
|
9675 "get": { |
|
9676 "requires": [ |
|
9677 "yui-base" |
|
9678 ] |
|
9679 }, |
|
9680 "graphics": { |
|
9681 "requires": [ |
|
9682 "node", |
|
9683 "event-custom", |
|
9684 "pluginhost", |
|
9685 "matrix", |
|
9686 "classnamemanager" |
|
9687 ] |
|
9688 }, |
|
9689 "graphics-canvas": { |
|
9690 "condition": { |
|
9691 "name": "graphics-canvas", |
|
9692 "test": function(Y) { |
|
9693 var DOCUMENT = Y.config.doc, |
|
9694 useCanvas = Y.config.defaultGraphicEngine && Y.config.defaultGraphicEngine == "canvas", |
|
9695 canvas = DOCUMENT && DOCUMENT.createElement("canvas"), |
|
9696 svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")); |
|
9697 return (!svg || useCanvas) && (canvas && canvas.getContext && canvas.getContext("2d")); |
|
9698 }, |
|
9699 "trigger": "graphics" |
|
9700 }, |
|
9701 "requires": [ |
|
9702 "graphics" |
|
9703 ] |
|
9704 }, |
|
9705 "graphics-canvas-default": { |
|
9706 "condition": { |
|
9707 "name": "graphics-canvas-default", |
|
9708 "test": function(Y) { |
|
9709 var DOCUMENT = Y.config.doc, |
|
9710 useCanvas = Y.config.defaultGraphicEngine && Y.config.defaultGraphicEngine == "canvas", |
|
9711 canvas = DOCUMENT && DOCUMENT.createElement("canvas"), |
|
9712 svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")); |
|
9713 return (!svg || useCanvas) && (canvas && canvas.getContext && canvas.getContext("2d")); |
|
9714 }, |
|
9715 "trigger": "graphics" |
|
9716 } |
|
9717 }, |
|
9718 "graphics-group": { |
|
9719 "requires": [ |
|
9720 "graphics" |
|
9721 ] |
|
9722 }, |
|
9723 "graphics-svg": { |
|
9724 "condition": { |
|
9725 "name": "graphics-svg", |
|
9726 "test": function(Y) { |
|
9727 var DOCUMENT = Y.config.doc, |
|
9728 useSVG = !Y.config.defaultGraphicEngine || Y.config.defaultGraphicEngine != "canvas", |
|
9729 canvas = DOCUMENT && DOCUMENT.createElement("canvas"), |
|
9730 svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")); |
|
9731 |
|
9732 return svg && (useSVG || !canvas); |
|
9733 }, |
|
9734 "trigger": "graphics" |
|
9735 }, |
|
9736 "requires": [ |
|
9737 "graphics" |
|
9738 ] |
|
9739 }, |
|
9740 "graphics-svg-default": { |
|
9741 "condition": { |
|
9742 "name": "graphics-svg-default", |
|
9743 "test": function(Y) { |
|
9744 var DOCUMENT = Y.config.doc, |
|
9745 useSVG = !Y.config.defaultGraphicEngine || Y.config.defaultGraphicEngine != "canvas", |
|
9746 canvas = DOCUMENT && DOCUMENT.createElement("canvas"), |
|
9747 svg = (DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")); |
|
9748 |
|
9749 return svg && (useSVG || !canvas); |
|
9750 }, |
|
9751 "trigger": "graphics" |
|
9752 } |
|
9753 }, |
|
9754 "graphics-vml": { |
|
9755 "condition": { |
|
9756 "name": "graphics-vml", |
|
9757 "test": function(Y) { |
|
9758 var DOCUMENT = Y.config.doc, |
|
9759 canvas = DOCUMENT && DOCUMENT.createElement("canvas"); |
|
9760 return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d"))); |
|
9761 }, |
|
9762 "trigger": "graphics" |
|
9763 }, |
|
9764 "requires": [ |
|
9765 "graphics" |
|
9766 ] |
|
9767 }, |
|
9768 "graphics-vml-default": { |
|
9769 "condition": { |
|
9770 "name": "graphics-vml-default", |
|
9771 "test": function(Y) { |
|
9772 var DOCUMENT = Y.config.doc, |
|
9773 canvas = DOCUMENT && DOCUMENT.createElement("canvas"); |
|
9774 return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d"))); |
|
9775 }, |
|
9776 "trigger": "graphics" |
|
9777 } |
|
9778 }, |
|
9779 "handlebars": { |
|
9780 "use": [ |
|
9781 "handlebars-compiler" |
|
9782 ] |
|
9783 }, |
|
9784 "handlebars-base": { |
|
9785 "requires": [] |
|
9786 }, |
|
9787 "handlebars-compiler": { |
|
9788 "requires": [ |
|
9789 "handlebars-base" |
|
9790 ] |
|
9791 }, |
|
9792 "highlight": { |
|
9793 "use": [ |
|
9794 "highlight-base", |
|
9795 "highlight-accentfold" |
|
9796 ] |
|
9797 }, |
|
9798 "highlight-accentfold": { |
|
9799 "requires": [ |
|
9800 "highlight-base", |
|
9801 "text-accentfold" |
|
9802 ] |
|
9803 }, |
|
9804 "highlight-base": { |
|
9805 "requires": [ |
|
9806 "array-extras", |
|
9807 "classnamemanager", |
|
9808 "escape", |
|
9809 "text-wordbreak" |
|
9810 ] |
|
9811 }, |
|
9812 "history": { |
|
9813 "use": [ |
|
9814 "history-base", |
|
9815 "history-hash", |
|
9816 "history-html5" |
|
9817 ] |
|
9818 }, |
|
9819 "history-base": { |
|
9820 "requires": [ |
|
9821 "event-custom-complex" |
|
9822 ] |
|
9823 }, |
|
9824 "history-hash": { |
|
9825 "after": [ |
|
9826 "history-html5" |
|
9827 ], |
|
9828 "requires": [ |
|
9829 "event-synthetic", |
|
9830 "history-base", |
|
9831 "yui-later" |
|
9832 ] |
|
9833 }, |
|
9834 "history-hash-ie": { |
|
9835 "condition": { |
|
9836 "name": "history-hash-ie", |
|
9837 "test": function (Y) { |
|
9838 var docMode = Y.config.doc && Y.config.doc.documentMode; |
|
9839 |
|
9840 return Y.UA.ie && (!('onhashchange' in Y.config.win) || |
|
9841 !docMode || docMode < 8); |
|
9842 }, |
|
9843 "trigger": "history-hash" |
|
9844 }, |
|
9845 "requires": [ |
|
9846 "history-hash", |
|
9847 "node-base" |
|
9848 ] |
|
9849 }, |
|
9850 "history-html5": { |
|
9851 "optional": [ |
|
9852 "json" |
|
9853 ], |
|
9854 "requires": [ |
|
9855 "event-base", |
|
9856 "history-base", |
|
9857 "node-base" |
|
9858 ] |
|
9859 }, |
|
9860 "imageloader": { |
|
9861 "requires": [ |
|
9862 "base-base", |
|
9863 "node-style", |
|
9864 "node-screen" |
|
9865 ] |
|
9866 }, |
|
9867 "intl": { |
|
9868 "requires": [ |
|
9869 "intl-base", |
|
9870 "event-custom" |
|
9871 ] |
|
9872 }, |
|
9873 "intl-base": { |
|
9874 "requires": [ |
|
9875 "yui-base" |
|
9876 ] |
|
9877 }, |
|
9878 "io": { |
|
9879 "use": [ |
|
9880 "io-base", |
|
9881 "io-xdr", |
|
9882 "io-form", |
|
9883 "io-upload-iframe", |
|
9884 "io-queue" |
|
9885 ] |
|
9886 }, |
|
9887 "io-base": { |
|
9888 "requires": [ |
|
9889 "event-custom-base", |
|
9890 "querystring-stringify-simple" |
|
9891 ] |
|
9892 }, |
|
9893 "io-form": { |
|
9894 "requires": [ |
|
9895 "io-base", |
|
9896 "node-base" |
|
9897 ] |
|
9898 }, |
|
9899 "io-nodejs": { |
|
9900 "condition": { |
|
9901 "name": "io-nodejs", |
|
9902 "trigger": "io-base", |
|
9903 "ua": "nodejs" |
|
9904 }, |
|
9905 "requires": [ |
|
9906 "io-base" |
|
9907 ] |
|
9908 }, |
|
9909 "io-queue": { |
|
9910 "requires": [ |
|
9911 "io-base", |
|
9912 "queue-promote" |
|
9913 ] |
|
9914 }, |
|
9915 "io-upload-iframe": { |
|
9916 "requires": [ |
|
9917 "io-base", |
|
9918 "node-base" |
|
9919 ] |
|
9920 }, |
|
9921 "io-xdr": { |
|
9922 "requires": [ |
|
9923 "io-base", |
|
9924 "datatype-xml-parse" |
|
9925 ] |
|
9926 }, |
|
9927 "json": { |
|
9928 "use": [ |
|
9929 "json-parse", |
|
9930 "json-stringify" |
|
9931 ] |
|
9932 }, |
|
9933 "json-parse": { |
|
9934 "requires": [ |
|
9935 "yui-base" |
|
9936 ] |
|
9937 }, |
|
9938 "json-parse-shim": { |
|
9939 "condition": { |
|
9940 "name": "json-parse-shim", |
|
9941 "test": function (Y) { |
|
9942 var _JSON = Y.config.global.JSON, |
|
9943 Native = Object.prototype.toString.call(_JSON) === '[object JSON]' && _JSON, |
|
9944 nativeSupport = Y.config.useNativeJSONParse !== false && !!Native; |
|
9945 |
|
9946 function workingNative( k, v ) { |
|
9947 return k === "ok" ? true : v; |
|
9948 } |
|
9949 |
|
9950 // Double check basic functionality. This is mainly to catch early broken |
|
9951 // implementations of the JSON API in Firefox 3.1 beta1 and beta2 |
|
9952 if ( nativeSupport ) { |
|
9953 try { |
|
9954 nativeSupport = ( Native.parse( '{"ok":false}', workingNative ) ).ok; |
|
9955 } |
|
9956 catch ( e ) { |
|
9957 nativeSupport = false; |
|
9958 } |
|
9959 } |
|
9960 |
|
9961 return !nativeSupport; |
|
9962 }, |
|
9963 "trigger": "json-parse" |
|
9964 }, |
|
9965 "requires": [ |
|
9966 "json-parse" |
|
9967 ] |
|
9968 }, |
|
9969 "json-stringify": { |
|
9970 "requires": [ |
|
9971 "yui-base" |
|
9972 ] |
|
9973 }, |
|
9974 "json-stringify-shim": { |
|
9975 "condition": { |
|
9976 "name": "json-stringify-shim", |
|
9977 "test": function (Y) { |
|
9978 var _JSON = Y.config.global.JSON, |
|
9979 Native = Object.prototype.toString.call(_JSON) === '[object JSON]' && _JSON, |
|
9980 nativeSupport = Y.config.useNativeJSONStringify !== false && !!Native; |
|
9981 |
|
9982 // Double check basic native functionality. This is primarily to catch broken |
|
9983 // early JSON API implementations in Firefox 3.1 beta1 and beta2. |
|
9984 if ( nativeSupport ) { |
|
9985 try { |
|
9986 nativeSupport = ( '0' === Native.stringify(0) ); |
|
9987 } catch ( e ) { |
|
9988 nativeSupport = false; |
|
9989 } |
|
9990 } |
|
9991 |
|
9992 |
|
9993 return !nativeSupport; |
|
9994 }, |
|
9995 "trigger": "json-stringify" |
|
9996 }, |
|
9997 "requires": [ |
|
9998 "json-stringify" |
|
9999 ] |
|
10000 }, |
|
10001 "jsonp": { |
|
10002 "requires": [ |
|
10003 "get", |
|
10004 "oop" |
|
10005 ] |
|
10006 }, |
|
10007 "jsonp-url": { |
|
10008 "requires": [ |
|
10009 "jsonp" |
|
10010 ] |
|
10011 }, |
|
10012 "lazy-model-list": { |
|
10013 "requires": [ |
|
10014 "model-list" |
|
10015 ] |
|
10016 }, |
|
10017 "loader": { |
|
10018 "use": [ |
|
10019 "loader-base", |
|
10020 "loader-rollup", |
|
10021 "loader-yui3" |
|
10022 ] |
|
10023 }, |
|
10024 "loader-base": { |
|
10025 "requires": [ |
|
10026 "get", |
|
10027 "features" |
|
10028 ] |
|
10029 }, |
|
10030 "loader-rollup": { |
|
10031 "requires": [ |
|
10032 "loader-base" |
|
10033 ] |
|
10034 }, |
|
10035 "loader-yui3": { |
|
10036 "requires": [ |
|
10037 "loader-base" |
|
10038 ] |
|
10039 }, |
|
10040 "matrix": { |
|
10041 "requires": [ |
|
10042 "yui-base" |
|
10043 ] |
|
10044 }, |
|
10045 "model": { |
|
10046 "requires": [ |
|
10047 "base-build", |
|
10048 "escape", |
|
10049 "json-parse" |
|
10050 ] |
|
10051 }, |
|
10052 "model-list": { |
|
10053 "requires": [ |
|
10054 "array-extras", |
|
10055 "array-invoke", |
|
10056 "arraylist", |
|
10057 "base-build", |
|
10058 "escape", |
|
10059 "json-parse", |
|
10060 "model" |
|
10061 ] |
|
10062 }, |
|
10063 "model-sync-local": { |
|
10064 "requires": [ |
|
10065 "model", |
|
10066 "json-stringify" |
|
10067 ] |
|
10068 }, |
|
10069 "model-sync-rest": { |
|
10070 "requires": [ |
|
10071 "model", |
|
10072 "io-base", |
|
10073 "json-stringify" |
|
10074 ] |
|
10075 }, |
|
10076 "node": { |
|
10077 "use": [ |
|
10078 "node-base", |
|
10079 "node-event-delegate", |
|
10080 "node-pluginhost", |
|
10081 "node-screen", |
|
10082 "node-style" |
|
10083 ] |
|
10084 }, |
|
10085 "node-base": { |
|
10086 "requires": [ |
|
10087 "event-base", |
|
10088 "node-core", |
|
10089 "dom-base", |
|
10090 "dom-style" |
|
10091 ] |
|
10092 }, |
|
10093 "node-core": { |
|
10094 "requires": [ |
|
10095 "dom-core", |
|
10096 "selector" |
|
10097 ] |
|
10098 }, |
|
10099 "node-event-delegate": { |
|
10100 "requires": [ |
|
10101 "node-base", |
|
10102 "event-delegate" |
|
10103 ] |
|
10104 }, |
|
10105 "node-event-html5": { |
|
10106 "requires": [ |
|
10107 "node-base" |
|
10108 ] |
|
10109 }, |
|
10110 "node-event-simulate": { |
|
10111 "requires": [ |
|
10112 "node-base", |
|
10113 "event-simulate", |
|
10114 "gesture-simulate" |
|
10115 ] |
|
10116 }, |
|
10117 "node-flick": { |
|
10118 "requires": [ |
|
10119 "classnamemanager", |
|
10120 "transition", |
|
10121 "event-flick", |
|
10122 "plugin" |
|
10123 ], |
|
10124 "skinnable": true |
|
10125 }, |
|
10126 "node-focusmanager": { |
|
10127 "requires": [ |
|
10128 "attribute", |
|
10129 "node", |
|
10130 "plugin", |
|
10131 "node-event-simulate", |
|
10132 "event-key", |
|
10133 "event-focus" |
|
10134 ] |
|
10135 }, |
|
10136 "node-load": { |
|
10137 "requires": [ |
|
10138 "node-base", |
|
10139 "io-base" |
|
10140 ] |
|
10141 }, |
|
10142 "node-menunav": { |
|
10143 "requires": [ |
|
10144 "node", |
|
10145 "classnamemanager", |
|
10146 "plugin", |
|
10147 "node-focusmanager" |
|
10148 ], |
|
10149 "skinnable": true |
|
10150 }, |
|
10151 "node-pluginhost": { |
|
10152 "requires": [ |
|
10153 "node-base", |
|
10154 "pluginhost" |
|
10155 ] |
|
10156 }, |
|
10157 "node-screen": { |
|
10158 "requires": [ |
|
10159 "dom-screen", |
|
10160 "node-base" |
|
10161 ] |
|
10162 }, |
|
10163 "node-scroll-info": { |
|
10164 "requires": [ |
|
10165 "array-extras", |
|
10166 "base-build", |
|
10167 "event-resize", |
|
10168 "node-pluginhost", |
|
10169 "plugin", |
|
10170 "selector" |
|
10171 ] |
|
10172 }, |
|
10173 "node-style": { |
|
10174 "requires": [ |
|
10175 "dom-style", |
|
10176 "node-base" |
|
10177 ] |
|
10178 }, |
|
10179 "oop": { |
|
10180 "requires": [ |
|
10181 "yui-base" |
|
10182 ] |
|
10183 }, |
|
10184 "overlay": { |
|
10185 "requires": [ |
|
10186 "widget", |
|
10187 "widget-stdmod", |
|
10188 "widget-position", |
|
10189 "widget-position-align", |
|
10190 "widget-stack", |
|
10191 "widget-position-constrain" |
|
10192 ], |
|
10193 "skinnable": true |
|
10194 }, |
|
10195 "paginator": { |
|
10196 "requires": [ |
|
10197 "paginator-core" |
|
10198 ] |
|
10199 }, |
|
10200 "paginator-core": { |
|
10201 "requires": [ |
|
10202 "base" |
|
10203 ] |
|
10204 }, |
|
10205 "paginator-url": { |
|
10206 "requires": [ |
|
10207 "paginator" |
|
10208 ] |
|
10209 }, |
|
10210 "panel": { |
|
10211 "requires": [ |
|
10212 "widget", |
|
10213 "widget-autohide", |
|
10214 "widget-buttons", |
|
10215 "widget-modality", |
|
10216 "widget-position", |
|
10217 "widget-position-align", |
|
10218 "widget-position-constrain", |
|
10219 "widget-stack", |
|
10220 "widget-stdmod" |
|
10221 ], |
|
10222 "skinnable": true |
|
10223 }, |
|
10224 "parallel": { |
|
10225 "requires": [ |
|
10226 "yui-base" |
|
10227 ] |
|
10228 }, |
|
10229 "pjax": { |
|
10230 "requires": [ |
|
10231 "pjax-base", |
|
10232 "pjax-content" |
|
10233 ] |
|
10234 }, |
|
10235 "pjax-base": { |
|
10236 "requires": [ |
|
10237 "classnamemanager", |
|
10238 "node-event-delegate", |
|
10239 "router" |
|
10240 ] |
|
10241 }, |
|
10242 "pjax-content": { |
|
10243 "requires": [ |
|
10244 "io-base", |
|
10245 "node-base", |
|
10246 "router" |
|
10247 ] |
|
10248 }, |
|
10249 "pjax-plugin": { |
|
10250 "requires": [ |
|
10251 "node-pluginhost", |
|
10252 "pjax", |
|
10253 "plugin" |
|
10254 ] |
|
10255 }, |
|
10256 "plugin": { |
|
10257 "requires": [ |
|
10258 "base-base" |
|
10259 ] |
|
10260 }, |
|
10261 "pluginhost": { |
|
10262 "use": [ |
|
10263 "pluginhost-base", |
|
10264 "pluginhost-config" |
|
10265 ] |
|
10266 }, |
|
10267 "pluginhost-base": { |
|
10268 "requires": [ |
|
10269 "yui-base" |
|
10270 ] |
|
10271 }, |
|
10272 "pluginhost-config": { |
|
10273 "requires": [ |
|
10274 "pluginhost-base" |
|
10275 ] |
|
10276 }, |
|
10277 "promise": { |
|
10278 "requires": [ |
|
10279 "timers" |
|
10280 ] |
|
10281 }, |
|
10282 "querystring": { |
|
10283 "use": [ |
|
10284 "querystring-parse", |
|
10285 "querystring-stringify" |
|
10286 ] |
|
10287 }, |
|
10288 "querystring-parse": { |
|
10289 "requires": [ |
|
10290 "yui-base", |
|
10291 "array-extras" |
|
10292 ] |
|
10293 }, |
|
10294 "querystring-parse-simple": { |
|
10295 "requires": [ |
|
10296 "yui-base" |
|
10297 ] |
|
10298 }, |
|
10299 "querystring-stringify": { |
|
10300 "requires": [ |
|
10301 "yui-base" |
|
10302 ] |
|
10303 }, |
|
10304 "querystring-stringify-simple": { |
|
10305 "requires": [ |
|
10306 "yui-base" |
|
10307 ] |
|
10308 }, |
|
10309 "queue-promote": { |
|
10310 "requires": [ |
|
10311 "yui-base" |
|
10312 ] |
|
10313 }, |
|
10314 "range-slider": { |
|
10315 "requires": [ |
|
10316 "slider-base", |
|
10317 "slider-value-range", |
|
10318 "clickable-rail" |
|
10319 ] |
|
10320 }, |
|
10321 "recordset": { |
|
10322 "use": [ |
|
10323 "recordset-base", |
|
10324 "recordset-sort", |
|
10325 "recordset-filter", |
|
10326 "recordset-indexer" |
|
10327 ] |
|
10328 }, |
|
10329 "recordset-base": { |
|
10330 "requires": [ |
|
10331 "base", |
|
10332 "arraylist" |
|
10333 ] |
|
10334 }, |
|
10335 "recordset-filter": { |
|
10336 "requires": [ |
|
10337 "recordset-base", |
|
10338 "array-extras", |
|
10339 "plugin" |
|
10340 ] |
|
10341 }, |
|
10342 "recordset-indexer": { |
|
10343 "requires": [ |
|
10344 "recordset-base", |
|
10345 "plugin" |
|
10346 ] |
|
10347 }, |
|
10348 "recordset-sort": { |
|
10349 "requires": [ |
|
10350 "arraysort", |
|
10351 "recordset-base", |
|
10352 "plugin" |
|
10353 ] |
|
10354 }, |
|
10355 "resize": { |
|
10356 "use": [ |
|
10357 "resize-base", |
|
10358 "resize-proxy", |
|
10359 "resize-constrain" |
|
10360 ] |
|
10361 }, |
|
10362 "resize-base": { |
|
10363 "requires": [ |
|
10364 "base", |
|
10365 "widget", |
|
10366 "event", |
|
10367 "oop", |
|
10368 "dd-drag", |
|
10369 "dd-delegate", |
|
10370 "dd-drop" |
|
10371 ], |
|
10372 "skinnable": true |
|
10373 }, |
|
10374 "resize-constrain": { |
|
10375 "requires": [ |
|
10376 "plugin", |
|
10377 "resize-base" |
|
10378 ] |
|
10379 }, |
|
10380 "resize-plugin": { |
|
10381 "optional": [ |
|
10382 "resize-constrain" |
|
10383 ], |
|
10384 "requires": [ |
|
10385 "resize-base", |
|
10386 "plugin" |
|
10387 ] |
|
10388 }, |
|
10389 "resize-proxy": { |
|
10390 "requires": [ |
|
10391 "plugin", |
|
10392 "resize-base" |
|
10393 ] |
|
10394 }, |
|
10395 "router": { |
|
10396 "optional": [ |
|
10397 "querystring-parse" |
|
10398 ], |
|
10399 "requires": [ |
|
10400 "array-extras", |
|
10401 "base-build", |
|
10402 "history" |
|
10403 ] |
|
10404 }, |
|
10405 "scrollview": { |
|
10406 "requires": [ |
|
10407 "scrollview-base", |
|
10408 "scrollview-scrollbars" |
|
10409 ] |
|
10410 }, |
|
10411 "scrollview-base": { |
|
10412 "requires": [ |
|
10413 "widget", |
|
10414 "event-gestures", |
|
10415 "event-mousewheel", |
|
10416 "transition" |
|
10417 ], |
|
10418 "skinnable": true |
|
10419 }, |
|
10420 "scrollview-base-ie": { |
|
10421 "condition": { |
|
10422 "name": "scrollview-base-ie", |
|
10423 "trigger": "scrollview-base", |
|
10424 "ua": "ie" |
|
10425 }, |
|
10426 "requires": [ |
|
10427 "scrollview-base" |
|
10428 ] |
|
10429 }, |
|
10430 "scrollview-list": { |
|
10431 "requires": [ |
|
10432 "plugin", |
|
10433 "classnamemanager" |
|
10434 ], |
|
10435 "skinnable": true |
|
10436 }, |
|
10437 "scrollview-paginator": { |
|
10438 "requires": [ |
|
10439 "plugin", |
|
10440 "classnamemanager" |
|
10441 ] |
|
10442 }, |
|
10443 "scrollview-scrollbars": { |
|
10444 "requires": [ |
|
10445 "classnamemanager", |
|
10446 "transition", |
|
10447 "plugin" |
|
10448 ], |
|
10449 "skinnable": true |
|
10450 }, |
|
10451 "selector": { |
|
10452 "requires": [ |
|
10453 "selector-native" |
|
10454 ] |
|
10455 }, |
|
10456 "selector-css2": { |
|
10457 "condition": { |
|
10458 "name": "selector-css2", |
|
10459 "test": function (Y) { |
|
10460 var DOCUMENT = Y.config.doc, |
|
10461 ret = DOCUMENT && !('querySelectorAll' in DOCUMENT); |
|
10462 |
|
10463 return ret; |
|
10464 }, |
|
10465 "trigger": "selector" |
|
10466 }, |
|
10467 "requires": [ |
|
10468 "selector-native" |
|
10469 ] |
|
10470 }, |
|
10471 "selector-css3": { |
|
10472 "requires": [ |
|
10473 "selector-native", |
|
10474 "selector-css2" |
|
10475 ] |
|
10476 }, |
|
10477 "selector-native": { |
|
10478 "requires": [ |
|
10479 "dom-base" |
|
10480 ] |
|
10481 }, |
|
10482 "series-area": { |
|
10483 "requires": [ |
|
10484 "series-cartesian", |
|
10485 "series-fill-util" |
|
10486 ] |
|
10487 }, |
|
10488 "series-area-stacked": { |
|
10489 "requires": [ |
|
10490 "series-stacked", |
|
10491 "series-area" |
|
10492 ] |
|
10493 }, |
|
10494 "series-areaspline": { |
|
10495 "requires": [ |
|
10496 "series-area", |
|
10497 "series-curve-util" |
|
10498 ] |
|
10499 }, |
|
10500 "series-areaspline-stacked": { |
|
10501 "requires": [ |
|
10502 "series-stacked", |
|
10503 "series-areaspline" |
|
10504 ] |
|
10505 }, |
|
10506 "series-bar": { |
|
10507 "requires": [ |
|
10508 "series-marker", |
|
10509 "series-histogram-base" |
|
10510 ] |
|
10511 }, |
|
10512 "series-bar-stacked": { |
|
10513 "requires": [ |
|
10514 "series-stacked", |
|
10515 "series-bar" |
|
10516 ] |
|
10517 }, |
|
10518 "series-base": { |
|
10519 "requires": [ |
|
10520 "graphics", |
|
10521 "axis-base" |
|
10522 ] |
|
10523 }, |
|
10524 "series-candlestick": { |
|
10525 "requires": [ |
|
10526 "series-range" |
|
10527 ] |
|
10528 }, |
|
10529 "series-cartesian": { |
|
10530 "requires": [ |
|
10531 "series-base" |
|
10532 ] |
|
10533 }, |
|
10534 "series-column": { |
|
10535 "requires": [ |
|
10536 "series-marker", |
|
10537 "series-histogram-base" |
|
10538 ] |
|
10539 }, |
|
10540 "series-column-stacked": { |
|
10541 "requires": [ |
|
10542 "series-stacked", |
|
10543 "series-column" |
|
10544 ] |
|
10545 }, |
|
10546 "series-combo": { |
|
10547 "requires": [ |
|
10548 "series-cartesian", |
|
10549 "series-line-util", |
|
10550 "series-plot-util", |
|
10551 "series-fill-util" |
|
10552 ] |
|
10553 }, |
|
10554 "series-combo-stacked": { |
|
10555 "requires": [ |
|
10556 "series-stacked", |
|
10557 "series-combo" |
|
10558 ] |
|
10559 }, |
|
10560 "series-combospline": { |
|
10561 "requires": [ |
|
10562 "series-combo", |
|
10563 "series-curve-util" |
|
10564 ] |
|
10565 }, |
|
10566 "series-combospline-stacked": { |
|
10567 "requires": [ |
|
10568 "series-combo-stacked", |
|
10569 "series-curve-util" |
|
10570 ] |
|
10571 }, |
|
10572 "series-curve-util": {}, |
|
10573 "series-fill-util": {}, |
|
10574 "series-histogram-base": { |
|
10575 "requires": [ |
|
10576 "series-cartesian", |
|
10577 "series-plot-util" |
|
10578 ] |
|
10579 }, |
|
10580 "series-line": { |
|
10581 "requires": [ |
|
10582 "series-cartesian", |
|
10583 "series-line-util" |
|
10584 ] |
|
10585 }, |
|
10586 "series-line-stacked": { |
|
10587 "requires": [ |
|
10588 "series-stacked", |
|
10589 "series-line" |
|
10590 ] |
|
10591 }, |
|
10592 "series-line-util": {}, |
|
10593 "series-marker": { |
|
10594 "requires": [ |
|
10595 "series-cartesian", |
|
10596 "series-plot-util" |
|
10597 ] |
|
10598 }, |
|
10599 "series-marker-stacked": { |
|
10600 "requires": [ |
|
10601 "series-stacked", |
|
10602 "series-marker" |
|
10603 ] |
|
10604 }, |
|
10605 "series-ohlc": { |
|
10606 "requires": [ |
|
10607 "series-range" |
|
10608 ] |
|
10609 }, |
|
10610 "series-pie": { |
|
10611 "requires": [ |
|
10612 "series-base", |
|
10613 "series-plot-util" |
|
10614 ] |
|
10615 }, |
|
10616 "series-plot-util": {}, |
|
10617 "series-range": { |
|
10618 "requires": [ |
|
10619 "series-cartesian" |
|
10620 ] |
|
10621 }, |
|
10622 "series-spline": { |
|
10623 "requires": [ |
|
10624 "series-line", |
|
10625 "series-curve-util" |
|
10626 ] |
|
10627 }, |
|
10628 "series-spline-stacked": { |
|
10629 "requires": [ |
|
10630 "series-stacked", |
|
10631 "series-spline" |
|
10632 ] |
|
10633 }, |
|
10634 "series-stacked": { |
|
10635 "requires": [ |
|
10636 "axis-stacked" |
|
10637 ] |
|
10638 }, |
|
10639 "shim-plugin": { |
|
10640 "requires": [ |
|
10641 "node-style", |
|
10642 "node-pluginhost" |
|
10643 ] |
|
10644 }, |
|
10645 "slider": { |
|
10646 "use": [ |
|
10647 "slider-base", |
|
10648 "slider-value-range", |
|
10649 "clickable-rail", |
|
10650 "range-slider" |
|
10651 ] |
|
10652 }, |
|
10653 "slider-base": { |
|
10654 "requires": [ |
|
10655 "widget", |
|
10656 "dd-constrain", |
|
10657 "event-key" |
|
10658 ], |
|
10659 "skinnable": true |
|
10660 }, |
|
10661 "slider-value-range": { |
|
10662 "requires": [ |
|
10663 "slider-base" |
|
10664 ] |
|
10665 }, |
|
10666 "sortable": { |
|
10667 "requires": [ |
|
10668 "dd-delegate", |
|
10669 "dd-drop-plugin", |
|
10670 "dd-proxy" |
|
10671 ] |
|
10672 }, |
|
10673 "sortable-scroll": { |
|
10674 "requires": [ |
|
10675 "dd-scroll", |
|
10676 "sortable" |
|
10677 ] |
|
10678 }, |
|
10679 "stylesheet": { |
|
10680 "requires": [ |
|
10681 "yui-base" |
|
10682 ] |
|
10683 }, |
|
10684 "substitute": { |
|
10685 "optional": [ |
|
10686 "dump" |
|
10687 ], |
|
10688 "requires": [ |
|
10689 "yui-base" |
|
10690 ] |
|
10691 }, |
|
10692 "swf": { |
|
10693 "requires": [ |
|
10694 "event-custom", |
|
10695 "node", |
|
10696 "swfdetect", |
|
10697 "escape" |
|
10698 ] |
|
10699 }, |
|
10700 "swfdetect": { |
|
10701 "requires": [ |
|
10702 "yui-base" |
|
10703 ] |
|
10704 }, |
|
10705 "tabview": { |
|
10706 "requires": [ |
|
10707 "widget", |
|
10708 "widget-parent", |
|
10709 "widget-child", |
|
10710 "tabview-base", |
|
10711 "node-pluginhost", |
|
10712 "node-focusmanager" |
|
10713 ], |
|
10714 "skinnable": true |
|
10715 }, |
|
10716 "tabview-base": { |
|
10717 "requires": [ |
|
10718 "node-event-delegate", |
|
10719 "classnamemanager" |
|
10720 ] |
|
10721 }, |
|
10722 "tabview-plugin": { |
|
10723 "requires": [ |
|
10724 "tabview-base" |
|
10725 ] |
|
10726 }, |
|
10727 "template": { |
|
10728 "use": [ |
|
10729 "template-base", |
|
10730 "template-micro" |
|
10731 ] |
|
10732 }, |
|
10733 "template-base": { |
|
10734 "requires": [ |
|
10735 "yui-base" |
|
10736 ] |
|
10737 }, |
|
10738 "template-micro": { |
|
10739 "requires": [ |
|
10740 "escape" |
|
10741 ] |
|
10742 }, |
|
10743 "test": { |
|
10744 "requires": [ |
|
10745 "event-simulate", |
|
10746 "event-custom", |
|
10747 "json-stringify" |
|
10748 ] |
|
10749 }, |
|
10750 "test-console": { |
|
10751 "requires": [ |
|
10752 "console-filters", |
|
10753 "test", |
|
10754 "array-extras" |
|
10755 ], |
|
10756 "skinnable": true |
|
10757 }, |
|
10758 "text": { |
|
10759 "use": [ |
|
10760 "text-accentfold", |
|
10761 "text-wordbreak" |
|
10762 ] |
|
10763 }, |
|
10764 "text-accentfold": { |
|
10765 "requires": [ |
|
10766 "array-extras", |
|
10767 "text-data-accentfold" |
|
10768 ] |
|
10769 }, |
|
10770 "text-data-accentfold": { |
|
10771 "requires": [ |
|
10772 "yui-base" |
|
10773 ] |
|
10774 }, |
|
10775 "text-data-wordbreak": { |
|
10776 "requires": [ |
|
10777 "yui-base" |
|
10778 ] |
|
10779 }, |
|
10780 "text-wordbreak": { |
|
10781 "requires": [ |
|
10782 "array-extras", |
|
10783 "text-data-wordbreak" |
|
10784 ] |
|
10785 }, |
|
10786 "timers": { |
|
10787 "requires": [ |
|
10788 "yui-base" |
|
10789 ] |
|
10790 }, |
|
10791 "transition": { |
|
10792 "requires": [ |
|
10793 "node-style" |
|
10794 ] |
|
10795 }, |
|
10796 "transition-timer": { |
|
10797 "condition": { |
|
10798 "name": "transition-timer", |
|
10799 "test": function (Y) { |
|
10800 var DOCUMENT = Y.config.doc, |
|
10801 node = (DOCUMENT) ? DOCUMENT.documentElement: null, |
|
10802 ret = true; |
|
10803 |
|
10804 if (node && node.style) { |
|
10805 ret = !('MozTransition' in node.style || 'WebkitTransition' in node.style || 'transition' in node.style); |
|
10806 } |
|
10807 |
|
10808 return ret; |
|
10809 }, |
|
10810 "trigger": "transition" |
|
10811 }, |
|
10812 "requires": [ |
|
10813 "transition" |
|
10814 ] |
|
10815 }, |
|
10816 "tree": { |
|
10817 "requires": [ |
|
10818 "base-build", |
|
10819 "tree-node" |
|
10820 ] |
|
10821 }, |
|
10822 "tree-labelable": { |
|
10823 "requires": [ |
|
10824 "tree" |
|
10825 ] |
|
10826 }, |
|
10827 "tree-lazy": { |
|
10828 "requires": [ |
|
10829 "base-pluginhost", |
|
10830 "plugin", |
|
10831 "tree" |
|
10832 ] |
|
10833 }, |
|
10834 "tree-node": {}, |
|
10835 "tree-openable": { |
|
10836 "requires": [ |
|
10837 "tree" |
|
10838 ] |
|
10839 }, |
|
10840 "tree-selectable": { |
|
10841 "requires": [ |
|
10842 "tree" |
|
10843 ] |
|
10844 }, |
|
10845 "tree-sortable": { |
|
10846 "requires": [ |
|
10847 "tree" |
|
10848 ] |
|
10849 }, |
|
10850 "uploader": { |
|
10851 "requires": [ |
|
10852 "uploader-html5", |
|
10853 "uploader-flash" |
|
10854 ] |
|
10855 }, |
|
10856 "uploader-flash": { |
|
10857 "requires": [ |
|
10858 "swfdetect", |
|
10859 "escape", |
|
10860 "widget", |
|
10861 "base", |
|
10862 "cssbutton", |
|
10863 "node", |
|
10864 "event-custom", |
|
10865 "uploader-queue" |
|
10866 ] |
|
10867 }, |
|
10868 "uploader-html5": { |
|
10869 "requires": [ |
|
10870 "widget", |
|
10871 "node-event-simulate", |
|
10872 "file-html5", |
|
10873 "uploader-queue" |
|
10874 ] |
|
10875 }, |
|
10876 "uploader-queue": { |
|
10877 "requires": [ |
|
10878 "base" |
|
10879 ] |
|
10880 }, |
|
10881 "view": { |
|
10882 "requires": [ |
|
10883 "base-build", |
|
10884 "node-event-delegate" |
|
10885 ] |
|
10886 }, |
|
10887 "view-node-map": { |
|
10888 "requires": [ |
|
10889 "view" |
|
10890 ] |
|
10891 }, |
|
10892 "widget": { |
|
10893 "use": [ |
|
10894 "widget-base", |
|
10895 "widget-htmlparser", |
|
10896 "widget-skin", |
|
10897 "widget-uievents" |
|
10898 ] |
|
10899 }, |
|
10900 "widget-anim": { |
|
10901 "requires": [ |
|
10902 "anim-base", |
|
10903 "plugin", |
|
10904 "widget" |
|
10905 ] |
|
10906 }, |
|
10907 "widget-autohide": { |
|
10908 "requires": [ |
|
10909 "base-build", |
|
10910 "event-key", |
|
10911 "event-outside", |
|
10912 "widget" |
|
10913 ] |
|
10914 }, |
|
10915 "widget-base": { |
|
10916 "requires": [ |
|
10917 "attribute", |
|
10918 "base-base", |
|
10919 "base-pluginhost", |
|
10920 "classnamemanager", |
|
10921 "event-focus", |
|
10922 "node-base", |
|
10923 "node-style" |
|
10924 ], |
|
10925 "skinnable": true |
|
10926 }, |
|
10927 "widget-base-ie": { |
|
10928 "condition": { |
|
10929 "name": "widget-base-ie", |
|
10930 "trigger": "widget-base", |
|
10931 "ua": "ie" |
|
10932 }, |
|
10933 "requires": [ |
|
10934 "widget-base" |
|
10935 ] |
|
10936 }, |
|
10937 "widget-buttons": { |
|
10938 "requires": [ |
|
10939 "button-plugin", |
|
10940 "cssbutton", |
|
10941 "widget-stdmod" |
|
10942 ] |
|
10943 }, |
|
10944 "widget-child": { |
|
10945 "requires": [ |
|
10946 "base-build", |
|
10947 "widget" |
|
10948 ] |
|
10949 }, |
|
10950 "widget-htmlparser": { |
|
10951 "requires": [ |
|
10952 "widget-base" |
|
10953 ] |
|
10954 }, |
|
10955 "widget-modality": { |
|
10956 "requires": [ |
|
10957 "base-build", |
|
10958 "event-outside", |
|
10959 "widget" |
|
10960 ], |
|
10961 "skinnable": true |
|
10962 }, |
|
10963 "widget-parent": { |
|
10964 "requires": [ |
|
10965 "arraylist", |
|
10966 "base-build", |
|
10967 "widget" |
|
10968 ] |
|
10969 }, |
|
10970 "widget-position": { |
|
10971 "requires": [ |
|
10972 "base-build", |
|
10973 "node-screen", |
|
10974 "widget" |
|
10975 ] |
|
10976 }, |
|
10977 "widget-position-align": { |
|
10978 "requires": [ |
|
10979 "widget-position" |
|
10980 ] |
|
10981 }, |
|
10982 "widget-position-constrain": { |
|
10983 "requires": [ |
|
10984 "widget-position" |
|
10985 ] |
|
10986 }, |
|
10987 "widget-skin": { |
|
10988 "requires": [ |
|
10989 "widget-base" |
|
10990 ] |
|
10991 }, |
|
10992 "widget-stack": { |
|
10993 "requires": [ |
|
10994 "base-build", |
|
10995 "widget" |
|
10996 ], |
|
10997 "skinnable": true |
|
10998 }, |
|
10999 "widget-stdmod": { |
|
11000 "requires": [ |
|
11001 "base-build", |
|
11002 "widget" |
|
11003 ] |
|
11004 }, |
|
11005 "widget-uievents": { |
|
11006 "requires": [ |
|
11007 "node-event-delegate", |
|
11008 "widget-base" |
|
11009 ] |
|
11010 }, |
|
11011 "yql": { |
|
11012 "requires": [ |
|
11013 "oop" |
|
11014 ] |
|
11015 }, |
|
11016 "yql-jsonp": { |
|
11017 "condition": { |
|
11018 "name": "yql-jsonp", |
|
11019 "test": function (Y) { |
|
11020 /* Only load the JSONP module when not in nodejs or winjs |
|
11021 TODO Make the winjs module a CORS module |
|
11022 */ |
|
11023 return (!Y.UA.nodejs && !Y.UA.winjs); |
|
11024 }, |
|
11025 "trigger": "yql", |
|
11026 "when": "after" |
|
11027 }, |
|
11028 "requires": [ |
|
11029 "jsonp", |
|
11030 "jsonp-url" |
|
11031 ] |
|
11032 }, |
|
11033 "yql-nodejs": { |
|
11034 "condition": { |
|
11035 "name": "yql-nodejs", |
|
11036 "trigger": "yql", |
|
11037 "ua": "nodejs", |
|
11038 "when": "after" |
|
11039 } |
|
11040 }, |
|
11041 "yql-winjs": { |
|
11042 "condition": { |
|
11043 "name": "yql-winjs", |
|
11044 "trigger": "yql", |
|
11045 "ua": "winjs", |
|
11046 "when": "after" |
|
11047 } |
|
11048 }, |
|
11049 "yui": {}, |
|
11050 "yui-base": {}, |
|
11051 "yui-later": { |
|
11052 "requires": [ |
|
11053 "yui-base" |
|
11054 ] |
|
11055 }, |
|
11056 "yui-log": { |
|
11057 "requires": [ |
|
11058 "yui-base" |
|
11059 ] |
|
11060 }, |
|
11061 "yui-throttle": { |
|
11062 "requires": [ |
|
11063 "yui-base" |
|
11064 ] |
|
11065 } |
|
11066 }); |
|
11067 YUI.Env[Y.version].md5 = '8e471689779fc84718f6dad481790b59'; |
|
11068 |
|
11069 |
|
11070 }, '@VERSION@', {"requires": ["loader-base"]}); |
|
11071 YUI.add('yui', function (Y, NAME) {}, '@VERSION@', { |
|
11072 "use": [ |
|
11073 "get", |
|
11074 "features", |
|
11075 "intl-base", |
|
11076 "yui-log", |
|
11077 "yui-log-nodejs", |
|
11078 "yui-later", |
|
11079 "loader-base", |
|
11080 "loader-rollup", |
|
11081 "loader-yui3" |
|
11082 ] |
|
11083 }); |