Revision 1263
Added by Dietmar over 14 years ago
yahoo.js | ||
---|---|---|
1 | 1 |
/* |
2 |
Copyright (c) 2007, Yahoo! Inc. All rights reserved.
|
|
2 |
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
|
3 | 3 |
Code licensed under the BSD License: |
4 | 4 |
http://developer.yahoo.net/yui/license.txt |
5 |
version: 2.4.1
|
|
5 |
version: 2.8.0r4
|
|
6 | 6 |
*/ |
7 | 7 |
/** |
8 | 8 |
* The YAHOO object is the single global object used by YUI Library. It |
... | ... | |
88 | 88 |
* </pre> |
89 | 89 |
* This fails because "long" is a future reserved word in ECMAScript |
90 | 90 |
* |
91 |
* For implementation code that uses YUI, do not create your components |
|
92 |
* in the namespaces defined by YUI ( |
|
93 |
* <code>YAHOO.util</code>, |
|
94 |
* <code>YAHOO.widget</code>, |
|
95 |
* <code>YAHOO.lang</code>, |
|
96 |
* <code>YAHOO.tool</code>, |
|
97 |
* <code>YAHOO.example</code>, |
|
98 |
* <code>YAHOO.env</code>) -- create your own namespace (e.g., 'companyname'). |
|
99 |
* |
|
91 | 100 |
* @method namespace |
92 | 101 |
* @static |
93 | 102 |
* @param {String*} arguments 1-n namespaces to create |
... | ... | |
96 | 105 |
YAHOO.namespace = function() { |
97 | 106 |
var a=arguments, o=null, i, j, d; |
98 | 107 |
for (i=0; i<a.length; i=i+1) { |
99 |
d=a[i].split(".");
|
|
108 |
d=(""+a[i]).split(".");
|
|
100 | 109 |
o=YAHOO; |
101 | 110 |
|
102 | 111 |
// YAHOO is implied, so it is ignored if it is included |
... | ... | |
146 | 155 |
* and a "build" property at minimum. |
147 | 156 |
*/ |
148 | 157 |
YAHOO.register = function(name, mainClass, data) { |
149 |
var mods = YAHOO.env.modules; |
|
158 |
var mods = YAHOO.env.modules, m, v, b, ls, i; |
|
159 |
|
|
150 | 160 |
if (!mods[name]) { |
151 |
mods[name] = { versions:[], builds:[] }; |
|
161 |
mods[name] = { |
|
162 |
versions:[], |
|
163 |
builds:[] |
|
164 |
}; |
|
152 | 165 |
} |
153 |
var m=mods[name],v=data.version,b=data.build,ls=YAHOO.env.listeners; |
|
166 |
|
|
167 |
m = mods[name]; |
|
168 |
v = data.version; |
|
169 |
b = data.build; |
|
170 |
ls = YAHOO.env.listeners; |
|
171 |
|
|
154 | 172 |
m.name = name; |
155 | 173 |
m.version = v; |
156 | 174 |
m.build = b; |
157 | 175 |
m.versions.push(v); |
158 | 176 |
m.builds.push(b); |
159 | 177 |
m.mainClass = mainClass; |
178 |
|
|
160 | 179 |
// fire the module load listeners |
161 |
for (var i=0;i<ls.length;i=i+1) {
|
|
180 |
for (i=0;i<ls.length;i=i+1) { |
|
162 | 181 |
ls[i](m); |
163 | 182 |
} |
164 | 183 |
// label the main class |
... | ... | |
231 | 250 |
* @static |
232 | 251 |
*/ |
233 | 252 |
YAHOO.env.ua = function() { |
234 |
var o={ |
|
235 | 253 |
|
254 |
var numberfy = function(s) { |
|
255 |
var c = 0; |
|
256 |
return parseFloat(s.replace(/\./g, function() { |
|
257 |
return (c++ == 1) ? '' : '.'; |
|
258 |
})); |
|
259 |
}, |
|
260 |
|
|
261 |
nav = navigator, |
|
262 |
|
|
263 |
o = { |
|
264 |
|
|
236 | 265 |
/** |
237 | 266 |
* Internet Explorer version number or 0. Example: 6 |
238 | 267 |
* @property ie |
239 | 268 |
* @type float |
240 | 269 |
*/ |
241 |
ie:0, |
|
270 |
ie: 0,
|
|
242 | 271 |
|
243 | 272 |
/** |
244 | 273 |
* Opera version number or 0. Example: 9.2 |
245 | 274 |
* @property opera |
246 | 275 |
* @type float |
247 | 276 |
*/ |
248 |
opera:0, |
|
277 |
opera: 0,
|
|
249 | 278 |
|
250 | 279 |
/** |
251 | 280 |
* Gecko engine revision number. Will evaluate to 1 if Gecko |
... | ... | |
260 | 289 |
* @property gecko |
261 | 290 |
* @type float |
262 | 291 |
*/ |
263 |
gecko:0, |
|
292 |
gecko: 0,
|
|
264 | 293 |
|
265 | 294 |
/** |
266 | 295 |
* AppleWebKit version. KHTML browsers that are not WebKit browsers |
... | ... | |
272 | 301 |
* Safari 2.0.4: 418 <-- preventDefault fixed |
273 | 302 |
* Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run |
274 | 303 |
* different versions of webkit |
275 |
* Safari 2.0.4 (419.3): 419 <-- Current Safari release |
|
276 |
* Webkit 212 nightly: 522+ <-- Safari 3.0 (with native SVG) should |
|
277 |
* be higher than this |
|
304 |
* Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been |
|
305 |
* updated, but not updated |
|
306 |
* to the latest patch. |
|
307 |
* Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native SVG |
|
308 |
* and many major issues fixed). |
|
309 |
* 3.x yahoo.com, flickr:422 <-- Safari 3.x hacks the user agent |
|
310 |
* string when hitting yahoo.com and |
|
311 |
* flickr.com. |
|
312 |
* Safari 3.0.4 (523.12):523.12 <-- First Tiger release - automatic update |
|
313 |
* from 2.x via the 10.4.11 OS patch |
|
314 |
* Webkit nightly 1/2008:525+ <-- Supports DOMContentLoaded event. |
|
315 |
* yahoo.com user agent hack removed. |
|
278 | 316 |
* |
279 | 317 |
* </pre> |
280 | 318 |
* http://developer.apple.com/internet/safari/uamatrix.html |
281 | 319 |
* @property webkit |
282 | 320 |
* @type float |
283 | 321 |
*/ |
284 |
webkit:0, |
|
322 |
webkit: 0,
|
|
285 | 323 |
|
286 | 324 |
/** |
287 | 325 |
* The mobile property will be set to a string containing any relevant |
... | ... | |
291 | 329 |
* @property mobile |
292 | 330 |
* @type string |
293 | 331 |
*/ |
294 |
mobile: null |
|
295 |
}; |
|
332 |
mobile: null, |
|
296 | 333 |
|
297 |
var ua=navigator.userAgent, m; |
|
334 |
/** |
|
335 |
* Adobe AIR version number or 0. Only populated if webkit is detected. |
|
336 |
* Example: 1.0 |
|
337 |
* @property air |
|
338 |
* @type float |
|
339 |
*/ |
|
340 |
air: 0, |
|
298 | 341 |
|
299 |
// Modern KHTML browsers should qualify as Safari X-Grade |
|
300 |
if ((/KHTML/).test(ua)) { |
|
301 |
o.webkit=1; |
|
302 |
} |
|
303 |
// Modern WebKit browsers are at least X-Grade |
|
304 |
m=ua.match(/AppleWebKit\/([^\s]*)/); |
|
305 |
if (m&&m[1]) { |
|
306 |
o.webkit=parseFloat(m[1]); |
|
342 |
/** |
|
343 |
* Google Caja version number or 0. |
|
344 |
* @property caja |
|
345 |
* @type float |
|
346 |
*/ |
|
347 |
caja: nav.cajaVersion, |
|
307 | 348 |
|
308 |
// Mobile browser check |
|
309 |
if (/ Mobile\//.test(ua)) { |
|
310 |
o.mobile = "Apple"; // iPhone or iPod Touch |
|
311 |
} else { |
|
312 |
m=ua.match(/NokiaN[^\/]*/); |
|
313 |
if (m) { |
|
314 |
o.mobile = m[0]; // Nokia N-series, ex: NokiaN95 |
|
315 |
} |
|
349 |
/** |
|
350 |
* Set to true if the page appears to be in SSL |
|
351 |
* @property secure |
|
352 |
* @type boolean |
|
353 |
* @static |
|
354 |
*/ |
|
355 |
secure: false, |
|
356 |
|
|
357 |
/** |
|
358 |
* The operating system. Currently only detecting windows or macintosh |
|
359 |
* @property os |
|
360 |
* @type string |
|
361 |
* @static |
|
362 |
*/ |
|
363 |
os: null |
|
364 |
|
|
365 |
}, |
|
366 |
|
|
367 |
ua = navigator && navigator.userAgent, |
|
368 |
|
|
369 |
loc = window && window.location, |
|
370 |
|
|
371 |
href = loc && loc.href, |
|
372 |
|
|
373 |
m; |
|
374 |
|
|
375 |
o.secure = href && (href.toLowerCase().indexOf("https") === 0); |
|
376 |
|
|
377 |
if (ua) { |
|
378 |
|
|
379 |
if ((/windows|win32/i).test(ua)) { |
|
380 |
o.os = 'windows'; |
|
381 |
} else if ((/macintosh/i).test(ua)) { |
|
382 |
o.os = 'macintosh'; |
|
316 | 383 |
} |
384 |
|
|
385 |
// Modern KHTML browsers should qualify as Safari X-Grade |
|
386 |
if ((/KHTML/).test(ua)) { |
|
387 |
o.webkit=1; |
|
388 |
} |
|
317 | 389 |
|
318 |
} |
|
390 |
// Modern WebKit browsers are at least X-Grade |
|
391 |
m=ua.match(/AppleWebKit\/([^\s]*)/); |
|
392 |
if (m&&m[1]) { |
|
393 |
o.webkit=numberfy(m[1]); |
|
319 | 394 |
|
320 |
if (!o.webkit) { // not webkit |
|
321 |
// @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr) |
|
322 |
m=ua.match(/Opera[\s\/]([^\s]*)/); |
|
323 |
if (m&&m[1]) { |
|
324 |
o.opera=parseFloat(m[1]); |
|
325 |
m=ua.match(/Opera Mini[^;]*/); |
|
395 |
// Mobile browser check |
|
396 |
if (/ Mobile\//.test(ua)) { |
|
397 |
o.mobile = "Apple"; // iPhone or iPod Touch |
|
398 |
} else { |
|
399 |
m=ua.match(/NokiaN[^\/]*/); |
|
400 |
if (m) { |
|
401 |
o.mobile = m[0]; // Nokia N-series, ex: NokiaN95 |
|
402 |
} |
|
403 |
} |
|
404 |
|
|
405 |
m=ua.match(/AdobeAIR\/([^\s]*)/); |
|
326 | 406 |
if (m) { |
327 |
o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316
|
|
407 |
o.air = m[0]; // Adobe AIR 1.0 or better
|
|
328 | 408 |
} |
329 |
} else { // not opera or webkit |
|
330 |
m=ua.match(/MSIE\s([^;]*)/); |
|
409 |
|
|
410 |
} |
|
411 |
|
|
412 |
if (!o.webkit) { // not webkit |
|
413 |
// @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr) |
|
414 |
m=ua.match(/Opera[\s\/]([^\s]*)/); |
|
331 | 415 |
if (m&&m[1]) { |
332 |
o.ie=parseFloat(m[1]); |
|
333 |
} else { // not opera, webkit, or ie |
|
334 |
m=ua.match(/Gecko\/([^\s]*)/); |
|
416 |
o.opera=numberfy(m[1]); |
|
417 |
m=ua.match(/Opera Mini[^;]*/); |
|
335 | 418 |
if (m) { |
336 |
o.gecko=1; // Gecko detected, look for revision |
|
337 |
m=ua.match(/rv:([^\s\)]*)/); |
|
338 |
if (m&&m[1]) { |
|
339 |
o.gecko=parseFloat(m[1]); |
|
419 |
o.mobile = m[0]; // ex: Opera Mini/2.0.4509/1316 |
|
420 |
} |
|
421 |
} else { // not opera or webkit |
|
422 |
m=ua.match(/MSIE\s([^;]*)/); |
|
423 |
if (m&&m[1]) { |
|
424 |
o.ie=numberfy(m[1]); |
|
425 |
} else { // not opera, webkit, or ie |
|
426 |
m=ua.match(/Gecko\/([^\s]*)/); |
|
427 |
if (m) { |
|
428 |
o.gecko=1; // Gecko detected, look for revision |
|
429 |
m=ua.match(/rv:([^\s\)]*)/); |
|
430 |
if (m&&m[1]) { |
|
431 |
o.gecko=numberfy(m[1]); |
|
432 |
} |
|
340 | 433 |
} |
341 | 434 |
} |
342 | 435 |
} |
343 | 436 |
} |
344 | 437 |
} |
345 |
|
|
438 |
|
|
346 | 439 |
return o; |
347 | 440 |
}(); |
348 | 441 |
|
... | ... | |
356 | 449 |
*/ |
357 | 450 |
(function() { |
358 | 451 |
YAHOO.namespace("util", "widget", "example"); |
452 |
/*global YAHOO_config*/ |
|
359 | 453 |
if ("undefined" !== typeof YAHOO_config) { |
360 |
var l=YAHOO_config.listener,ls=YAHOO.env.listeners,unique=true,i;
|
|
454 |
var l=YAHOO_config.listener, ls=YAHOO.env.listeners,unique=true, i;
|
|
361 | 455 |
if (l) { |
362 | 456 |
// if YAHOO is loaded multiple times we need to check to see if |
363 | 457 |
// this is a new config object. If it is, add the new component |
364 | 458 |
// load listener to the stack |
365 |
for (i=0;i<ls.length;i=i+1) {
|
|
366 |
if (ls[i]==l) {
|
|
367 |
unique=false;
|
|
459 |
for (i=0; i<ls.length; i++) {
|
|
460 |
if (ls[i] == l) {
|
|
461 |
unique = false;
|
|
368 | 462 |
break; |
369 | 463 |
} |
370 | 464 |
} |
465 |
|
|
371 | 466 |
if (unique) { |
372 | 467 |
ls.push(l); |
373 | 468 |
} |
... | ... | |
378 | 473 |
* Provides the language utilites and extensions used by the library |
379 | 474 |
* @class YAHOO.lang |
380 | 475 |
*/ |
381 |
YAHOO.lang = YAHOO.lang || { |
|
476 |
YAHOO.lang = YAHOO.lang || {}; |
|
477 |
|
|
478 |
(function() { |
|
479 |
|
|
480 |
|
|
481 |
var L = YAHOO.lang, |
|
482 |
|
|
483 |
OP = Object.prototype, |
|
484 |
ARRAY_TOSTRING = '[object Array]', |
|
485 |
FUNCTION_TOSTRING = '[object Function]', |
|
486 |
OBJECT_TOSTRING = '[object Object]', |
|
487 |
NOTHING = [], |
|
488 |
|
|
489 |
// ADD = ["toString", "valueOf", "hasOwnProperty"], |
|
490 |
ADD = ["toString", "valueOf"], |
|
491 |
|
|
492 |
OB = { |
|
493 |
|
|
382 | 494 |
/** |
383 |
* Determines whether or not the provided object is an array. |
|
384 |
* Testing typeof/instanceof/constructor of arrays across frame |
|
385 |
* boundaries isn't possible in Safari unless you have a reference |
|
386 |
* to the other frame to test against its Array prototype. To |
|
387 |
* handle this case, we test well-known array properties instead. |
|
388 |
* properties. |
|
495 |
* Determines wheather or not the provided object is an array. |
|
389 | 496 |
* @method isArray |
390 | 497 |
* @param {any} o The object being testing |
391 |
* @return Boolean
|
|
498 |
* @return {boolean} the result
|
|
392 | 499 |
*/ |
393 | 500 |
isArray: function(o) { |
394 |
|
|
395 |
if (o) { |
|
396 |
var l = YAHOO.lang; |
|
397 |
return l.isNumber(o.length) && l.isFunction(o.splice); |
|
398 |
} |
|
399 |
return false; |
|
501 |
return OP.toString.apply(o) === ARRAY_TOSTRING; |
|
400 | 502 |
}, |
401 | 503 |
|
402 | 504 |
/** |
403 | 505 |
* Determines whether or not the provided object is a boolean |
404 | 506 |
* @method isBoolean |
405 | 507 |
* @param {any} o The object being testing |
406 |
* @return Boolean
|
|
508 |
* @return {boolean} the result
|
|
407 | 509 |
*/ |
408 | 510 |
isBoolean: function(o) { |
409 | 511 |
return typeof o === 'boolean'; |
410 | 512 |
}, |
411 | 513 |
|
412 | 514 |
/** |
413 |
* Determines whether or not the provided object is a function |
|
515 |
* Determines whether or not the provided object is a function. |
|
516 |
* Note: Internet Explorer thinks certain functions are objects: |
|
517 |
* |
|
518 |
* var obj = document.createElement("object"); |
|
519 |
* YAHOO.lang.isFunction(obj.getAttribute) // reports false in IE |
|
520 |
* |
|
521 |
* var input = document.createElement("input"); // append to body |
|
522 |
* YAHOO.lang.isFunction(input.focus) // reports false in IE |
|
523 |
* |
|
524 |
* You will have to implement additional tests if these functions |
|
525 |
* matter to you. |
|
526 |
* |
|
414 | 527 |
* @method isFunction |
415 | 528 |
* @param {any} o The object being testing |
416 |
* @return Boolean
|
|
529 |
* @return {boolean} the result
|
|
417 | 530 |
*/ |
418 | 531 |
isFunction: function(o) { |
419 |
return typeof o === 'function';
|
|
532 |
return (typeof o === 'function') || OP.toString.apply(o) === FUNCTION_TOSTRING;
|
|
420 | 533 |
}, |
421 | 534 |
|
422 | 535 |
/** |
423 | 536 |
* Determines whether or not the provided object is null |
424 | 537 |
* @method isNull |
425 | 538 |
* @param {any} o The object being testing |
426 |
* @return Boolean
|
|
539 |
* @return {boolean} the result
|
|
427 | 540 |
*/ |
428 | 541 |
isNull: function(o) { |
429 | 542 |
return o === null; |
... | ... | |
433 | 546 |
* Determines whether or not the provided object is a legal number |
434 | 547 |
* @method isNumber |
435 | 548 |
* @param {any} o The object being testing |
436 |
* @return Boolean
|
|
549 |
* @return {boolean} the result
|
|
437 | 550 |
*/ |
438 | 551 |
isNumber: function(o) { |
439 | 552 |
return typeof o === 'number' && isFinite(o); |
... | ... | |
444 | 557 |
* or function |
445 | 558 |
* @method isObject |
446 | 559 |
* @param {any} o The object being testing |
447 |
* @return Boolean
|
|
560 |
* @return {boolean} the result
|
|
448 | 561 |
*/ |
449 | 562 |
isObject: function(o) { |
450 |
return (o && (typeof o === 'object' || YAHOO.lang.isFunction(o))) || false;
|
|
563 |
return (o && (typeof o === 'object' || L.isFunction(o))) || false;
|
|
451 | 564 |
}, |
452 | 565 |
|
453 | 566 |
/** |
454 | 567 |
* Determines whether or not the provided object is a string |
455 | 568 |
* @method isString |
456 | 569 |
* @param {any} o The object being testing |
457 |
* @return Boolean
|
|
570 |
* @return {boolean} the result
|
|
458 | 571 |
*/ |
459 | 572 |
isString: function(o) { |
460 | 573 |
return typeof o === 'string'; |
... | ... | |
464 | 577 |
* Determines whether or not the provided object is undefined |
465 | 578 |
* @method isUndefined |
466 | 579 |
* @param {any} o The object being testing |
467 |
* @return Boolean
|
|
580 |
* @return {boolean} the result
|
|
468 | 581 |
*/ |
469 | 582 |
isUndefined: function(o) { |
470 | 583 |
return typeof o === 'undefined'; |
471 | 584 |
}, |
472 | 585 |
|
473 |
/** |
|
474 |
* Determines whether or not the property was added |
|
475 |
* to the object instance. Returns false if the property is not present |
|
476 |
* in the object, or was inherited from the prototype. |
|
477 |
* This abstraction is provided to enable hasOwnProperty for Safari 1.3.x. |
|
478 |
* There is a discrepancy between YAHOO.lang.hasOwnProperty and |
|
479 |
* Object.prototype.hasOwnProperty when the property is a primitive added to |
|
480 |
* both the instance AND prototype with the same value: |
|
481 |
* <pre> |
|
482 |
* var A = function() {}; |
|
483 |
* A.prototype.foo = 'foo'; |
|
484 |
* var a = new A(); |
|
485 |
* a.foo = 'foo'; |
|
486 |
* alert(a.hasOwnProperty('foo')); // true |
|
487 |
* alert(YAHOO.lang.hasOwnProperty(a, 'foo')); // false when using fallback |
|
488 |
* </pre> |
|
489 |
* @method hasOwnProperty |
|
490 |
* @param {any} o The object being testing |
|
491 |
* @return Boolean |
|
492 |
*/ |
|
493 |
hasOwnProperty: function(o, prop) { |
|
494 |
if (Object.prototype.hasOwnProperty) { |
|
495 |
return o.hasOwnProperty(prop); |
|
496 |
} |
|
497 |
|
|
498 |
return !YAHOO.lang.isUndefined(o[prop]) && |
|
499 |
o.constructor.prototype[prop] !== o[prop]; |
|
500 |
}, |
|
501 | 586 |
|
502 | 587 |
/** |
503 | 588 |
* IE will not enumerate native functions in a derived object even if the |
... | ... | |
509 | 594 |
* @static |
510 | 595 |
* @private |
511 | 596 |
*/ |
512 |
_IEEnumFix: function(r, s) { |
|
513 |
if (YAHOO.env.ua.ie) { |
|
514 |
var add=["toString", "valueOf"], i; |
|
515 |
for (i=0;i<add.length;i=i+1) { |
|
516 |
var fname=add[i],f=s[fname]; |
|
517 |
if (YAHOO.lang.isFunction(f) && f!=Object.prototype[fname]) { |
|
597 |
_IEEnumFix: (YAHOO.env.ua.ie) ? function(r, s) { |
|
598 |
var i, fname, f; |
|
599 |
for (i=0;i<ADD.length;i=i+1) { |
|
600 |
|
|
601 |
fname = ADD[i]; |
|
602 |
f = s[fname]; |
|
603 |
|
|
604 |
if (L.isFunction(f) && f!=OP[fname]) { |
|
518 | 605 |
r[fname]=f; |
519 | 606 |
} |
520 | 607 |
} |
521 |
} |
|
522 |
}, |
|
608 |
} : function(){}, |
|
523 | 609 |
|
524 | 610 |
/** |
525 | 611 |
* Utility to set up the prototype, constructor and superclass properties to |
... | ... | |
537 | 623 |
*/ |
538 | 624 |
extend: function(subc, superc, overrides) { |
539 | 625 |
if (!superc||!subc) { |
540 |
throw new Error("YAHOO.lang.extend failed, please check that " +
|
|
626 |
throw new Error("extend failed, please check that " + |
|
541 | 627 |
"all dependencies are included."); |
542 | 628 |
} |
543 |
var F = function() {}; |
|
629 |
var F = function() {}, i;
|
|
544 | 630 |
F.prototype=superc.prototype; |
545 | 631 |
subc.prototype=new F(); |
546 | 632 |
subc.prototype.constructor=subc; |
547 | 633 |
subc.superclass=superc.prototype; |
548 |
if (superc.prototype.constructor == Object.prototype.constructor) {
|
|
634 |
if (superc.prototype.constructor == OP.constructor) {
|
|
549 | 635 |
superc.prototype.constructor=superc; |
550 | 636 |
} |
551 | 637 |
|
552 | 638 |
if (overrides) { |
553 |
for (var i in overrides) { |
|
554 |
subc.prototype[i]=overrides[i]; |
|
639 |
for (i in overrides) { |
|
640 |
if (L.hasOwnProperty(overrides, i)) { |
|
641 |
subc.prototype[i]=overrides[i]; |
|
642 |
} |
|
555 | 643 |
} |
556 | 644 |
|
557 |
YAHOO.lang._IEEnumFix(subc.prototype, overrides);
|
|
645 |
L._IEEnumFix(subc.prototype, overrides);
|
|
558 | 646 |
} |
559 | 647 |
}, |
560 | 648 |
|
... | ... | |
584 | 672 |
if (!s||!r) { |
585 | 673 |
throw new Error("Absorb failed, verify dependencies."); |
586 | 674 |
} |
587 |
var a=arguments, i, p, override=a[2]; |
|
588 |
if (override && override!==true) { // only absorb the specified properties
|
|
675 |
var a=arguments, i, p, overrideList=a[2];
|
|
676 |
if (overrideList && overrideList!==true) { // only absorb the specified properties
|
|
589 | 677 |
for (i=2; i<a.length; i=i+1) { |
590 | 678 |
r[a[i]] = s[a[i]]; |
591 | 679 |
} |
592 | 680 |
} else { // take everything, overwriting only if the third parameter is true |
593 | 681 |
for (p in s) { |
594 |
if (override || !r[p]) {
|
|
682 |
if (overrideList || !(p in r)) {
|
|
595 | 683 |
r[p] = s[p]; |
596 | 684 |
} |
597 | 685 |
} |
598 | 686 |
|
599 |
YAHOO.lang._IEEnumFix(r, s);
|
|
687 |
L._IEEnumFix(r, s);
|
|
600 | 688 |
} |
601 | 689 |
}, |
602 | 690 |
|
... | ... | |
619 | 707 |
throw new Error("Augment failed, verify dependencies."); |
620 | 708 |
} |
621 | 709 |
//var a=[].concat(arguments); |
622 |
var a=[r.prototype,s.prototype]; |
|
623 |
for (var i=2;i<arguments.length;i=i+1) {
|
|
710 |
var a=[r.prototype,s.prototype], i;
|
|
711 |
for (i=2;i<arguments.length;i=i+1) { |
|
624 | 712 |
a.push(arguments[i]); |
625 | 713 |
} |
626 |
YAHOO.lang.augmentObject.apply(this, a);
|
|
714 |
L.augmentObject.apply(this, a);
|
|
627 | 715 |
}, |
628 | 716 |
|
629 | 717 |
|
... | ... | |
639 | 727 |
* @return {String} the dump result |
640 | 728 |
*/ |
641 | 729 |
dump: function(o, d) { |
642 |
var l=YAHOO.lang,i,len,s=[],OBJ="{...}",FUN="f(){...}",
|
|
730 |
var i,len,s=[],OBJ="{...}",FUN="f(){...}", |
|
643 | 731 |
COMMA=', ', ARROW=' => '; |
644 | 732 |
|
645 | 733 |
// Cast non-objects to string |
646 | 734 |
// Skip dates because the std toString is what we want |
647 | 735 |
// Skip HTMLElement-like objects because trying to dump |
648 | 736 |
// an element will cause an unhandled exception in FF 2.x |
649 |
if (!l.isObject(o)) {
|
|
737 |
if (!L.isObject(o)) {
|
|
650 | 738 |
return o + ""; |
651 | 739 |
} else if (o instanceof Date || ("nodeType" in o && "tagName" in o)) { |
652 | 740 |
return o; |
653 |
} else if (l.isFunction(o)) {
|
|
741 |
} else if (L.isFunction(o)) {
|
|
654 | 742 |
return FUN; |
655 | 743 |
} |
656 | 744 |
|
657 | 745 |
// dig into child objects the depth specifed. Default 3 |
658 |
d = (l.isNumber(d)) ? d : 3;
|
|
746 |
d = (L.isNumber(d)) ? d : 3;
|
|
659 | 747 |
|
660 | 748 |
// arrays [1, 2, 3] |
661 |
if (l.isArray(o)) {
|
|
749 |
if (L.isArray(o)) {
|
|
662 | 750 |
s.push("["); |
663 | 751 |
for (i=0,len=o.length;i<len;i=i+1) { |
664 |
if (l.isObject(o[i])) {
|
|
665 |
s.push((d > 0) ? l.dump(o[i], d-1) : OBJ);
|
|
752 |
if (L.isObject(o[i])) {
|
|
753 |
s.push((d > 0) ? L.dump(o[i], d-1) : OBJ);
|
|
666 | 754 |
} else { |
667 | 755 |
s.push(o[i]); |
668 | 756 |
} |
... | ... | |
676 | 764 |
} else { |
677 | 765 |
s.push("{"); |
678 | 766 |
for (i in o) { |
679 |
if (l.hasOwnProperty(o, i)) {
|
|
767 |
if (L.hasOwnProperty(o, i)) {
|
|
680 | 768 |
s.push(i + ARROW); |
681 |
if (l.isObject(o[i])) {
|
|
682 |
s.push((d > 0) ? l.dump(o[i], d-1) : OBJ);
|
|
769 |
if (L.isObject(o[i])) {
|
|
770 |
s.push((d > 0) ? L.dump(o[i], d-1) : OBJ);
|
|
683 | 771 |
} else { |
684 | 772 |
s.push(o[i]); |
685 | 773 |
} |
... | ... | |
719 | 807 |
* @return {String} the substituted string |
720 | 808 |
*/ |
721 | 809 |
substitute: function (s, o, f) { |
722 |
var i, j, k, key, v, meta, l=YAHOO.lang, saved=[], token, |
|
723 |
DUMP='dump', SPACE=' ', LBRACE='{', RBRACE='}'; |
|
810 |
var i, j, k, key, v, meta, saved=[], token, |
|
811 |
DUMP='dump', SPACE=' ', LBRACE='{', RBRACE='}', |
|
812 |
dump, objstr; |
|
724 | 813 |
|
725 | 814 |
|
726 | 815 |
for (;;) { |
... | ... | |
751 | 840 |
v = f(key, v, meta); |
752 | 841 |
} |
753 | 842 |
|
754 |
if (l.isObject(v)) {
|
|
755 |
if (l.isArray(v)) {
|
|
756 |
v = l.dump(v, parseInt(meta, 10));
|
|
843 |
if (L.isObject(v)) {
|
|
844 |
if (L.isArray(v)) {
|
|
845 |
v = L.dump(v, parseInt(meta, 10));
|
|
757 | 846 |
} else { |
758 | 847 |
meta = meta || ""; |
759 | 848 |
|
760 | 849 |
// look for the keyword 'dump', if found force obj dump |
761 |
var dump = meta.indexOf(DUMP);
|
|
850 |
dump = meta.indexOf(DUMP); |
|
762 | 851 |
if (dump > -1) { |
763 | 852 |
meta = meta.substring(4); |
764 | 853 |
} |
765 | 854 |
|
855 |
objstr = v.toString(); |
|
856 |
|
|
766 | 857 |
// use the toString if it is not the Object toString |
767 | 858 |
// and the 'dump' meta info was not found |
768 |
if (v.toString===Object.prototype.toString||dump>-1) {
|
|
769 |
v = l.dump(v, parseInt(meta, 10));
|
|
859 |
if (objstr === OBJECT_TOSTRING || dump > -1) {
|
|
860 |
v = L.dump(v, parseInt(meta, 10));
|
|
770 | 861 |
} else { |
771 |
v = v.toString();
|
|
862 |
v = objstr;
|
|
772 | 863 |
} |
773 | 864 |
} |
774 |
} else if (!l.isString(v) && !l.isNumber(v)) {
|
|
865 |
} else if (!L.isString(v) && !L.isNumber(v)) {
|
|
775 | 866 |
// This {block} has no replace string. Save it for later. |
776 | 867 |
v = "~-" + saved.length + "-~"; |
777 | 868 |
saved[saved.length] = token; |
... | ... | |
819 | 910 |
* @return the new merged object |
820 | 911 |
*/ |
821 | 912 |
merge: function() { |
822 |
var o={}, a=arguments; |
|
823 |
for (var i=0, l=a.length; i<l; i=i+1) {
|
|
824 |
YAHOO.lang.augmentObject(o, a[i], true);
|
|
913 |
var o={}, a=arguments, l=a.length, i;
|
|
914 |
for (i=0; i<l; i=i+1) {
|
|
915 |
L.augmentObject(o, a[i], true);
|
|
825 | 916 |
} |
826 | 917 |
return o; |
827 | 918 |
}, |
828 | 919 |
|
829 | 920 |
/** |
830 |
* Executes the supplied function in the scope of the supplied
|
|
921 |
* Executes the supplied function in the context of the supplied
|
|
831 | 922 |
* object 'when' milliseconds later. Executes the function a |
832 | 923 |
* single time unless periodic is set to true. |
833 | 924 |
* @method later |
834 | 925 |
* @since 2.4.0 |
835 | 926 |
* @param when {int} the number of milliseconds to wait until the fn |
836 | 927 |
* is executed |
837 |
* @param o the scope object
|
|
928 |
* @param o the context object
|
|
838 | 929 |
* @param fn {Function|String} the function to execute or the name of |
839 | 930 |
* the method in the 'o' object to execute |
840 | 931 |
* @param data [Array] data that is provided to the function. This accepts |
... | ... | |
852 | 943 |
o = o || {}; |
853 | 944 |
var m=fn, d=data, f, r; |
854 | 945 |
|
855 |
if (YAHOO.lang.isString(fn)) {
|
|
946 |
if (L.isString(fn)) {
|
|
856 | 947 |
m = o[fn]; |
857 | 948 |
} |
858 | 949 |
|
... | ... | |
860 | 951 |
throw new TypeError("method undefined"); |
861 | 952 |
} |
862 | 953 |
|
863 |
if (!YAHOO.lang.isArray(d)) {
|
|
954 |
if (d && !L.isArray(d)) {
|
|
864 | 955 |
d = [data]; |
865 | 956 |
} |
866 | 957 |
|
867 | 958 |
f = function() { |
868 |
m.apply(o, d); |
|
959 |
m.apply(o, d || NOTHING);
|
|
869 | 960 |
}; |
870 | 961 |
|
871 | 962 |
r = (periodic) ? setInterval(f, when) : setTimeout(f, when); |
... | ... | |
881 | 972 |
} |
882 | 973 |
}; |
883 | 974 |
}, |
884 |
|
|
975 |
|
|
885 | 976 |
/** |
886 | 977 |
* A convenience method for detecting a legitimate non-null value. |
887 | 978 |
* Returns false for null/undefined/NaN, true for other values, |
... | ... | |
893 | 984 |
*/ |
894 | 985 |
isValue: function(o) { |
895 | 986 |
// return (o || o === false || o === 0 || o === ''); // Infinity fails |
896 |
var l = YAHOO.lang; |
|
897 |
return (l.isObject(o) || l.isString(o) || l.isNumber(o) || l.isBoolean(o)); |
|
987 |
return (L.isObject(o) || L.isString(o) || L.isNumber(o) || L.isBoolean(o)); |
|
898 | 988 |
} |
899 | 989 |
|
900 | 990 |
}; |
901 | 991 |
|
992 |
/** |
|
993 |
* Determines whether or not the property was added |
|
994 |
* to the object instance. Returns false if the property is not present |
|
995 |
* in the object, or was inherited from the prototype. |
|
996 |
* This abstraction is provided to enable hasOwnProperty for Safari 1.3.x. |
|
997 |
* There is a discrepancy between YAHOO.lang.hasOwnProperty and |
|
998 |
* Object.prototype.hasOwnProperty when the property is a primitive added to |
|
999 |
* both the instance AND prototype with the same value: |
|
1000 |
* <pre> |
|
1001 |
* var A = function() {}; |
|
1002 |
* A.prototype.foo = 'foo'; |
|
1003 |
* var a = new A(); |
|
1004 |
* a.foo = 'foo'; |
|
1005 |
* alert(a.hasOwnProperty('foo')); // true |
|
1006 |
* alert(YAHOO.lang.hasOwnProperty(a, 'foo')); // false when using fallback |
|
1007 |
* </pre> |
|
1008 |
* @method hasOwnProperty |
|
1009 |
* @param {any} o The object being testing |
|
1010 |
* @param prop {string} the name of the property to test |
|
1011 |
* @return {boolean} the result |
|
1012 |
*/ |
|
1013 |
L.hasOwnProperty = (OP.hasOwnProperty) ? |
|
1014 |
function(o, prop) { |
|
1015 |
return o && o.hasOwnProperty(prop); |
|
1016 |
} : function(o, prop) { |
|
1017 |
return !L.isUndefined(o[prop]) && |
|
1018 |
o.constructor.prototype[prop] !== o[prop]; |
|
1019 |
}; |
|
1020 |
|
|
1021 |
// new lang wins |
|
1022 |
OB.augmentObject(L, OB, true); |
|
1023 |
|
|
902 | 1024 |
/* |
903 | 1025 |
* An alias for <a href="YAHOO.lang.html">YAHOO.lang</a> |
904 | 1026 |
* @class YAHOO.util.Lang |
905 | 1027 |
*/ |
906 |
YAHOO.util.Lang = YAHOO.lang;
|
|
1028 |
YAHOO.util.Lang = L;
|
|
907 | 1029 |
|
908 | 1030 |
/** |
909 | 1031 |
* Same as YAHOO.lang.augmentObject, except it only applies prototype |
... | ... | |
921 | 1043 |
* be applied and will overwrite an existing property in |
922 | 1044 |
* the receiver |
923 | 1045 |
*/ |
924 |
YAHOO.lang.augment = YAHOO.lang.augmentProto;
|
|
1046 |
L.augment = L.augmentProto;
|
|
925 | 1047 |
|
926 | 1048 |
/** |
927 | 1049 |
* An alias for <a href="YAHOO.lang.html#augment">YAHOO.lang.augment</a> |
... | ... | |
935 | 1057 |
* in the supplier will be used unless it would |
936 | 1058 |
* overwrite an existing property in the receiver |
937 | 1059 |
*/ |
938 |
YAHOO.augment = YAHOO.lang.augmentProto;
|
|
1060 |
YAHOO.augment = L.augmentProto;
|
|
939 | 1061 |
|
940 | 1062 |
/** |
941 | 1063 |
* An alias for <a href="YAHOO.lang.html#extend">YAHOO.lang.extend</a> |
... | ... | |
947 | 1069 |
* subclass prototype. These will override the |
948 | 1070 |
* matching items obtained from the superclass if present. |
949 | 1071 |
*/ |
950 |
YAHOO.extend = YAHOO.lang.extend;
|
|
1072 |
YAHOO.extend = L.extend;
|
|
951 | 1073 |
|
952 |
YAHOO.register("yahoo", YAHOO, {version: "2.4.1", build: "742"}); |
|
1074 |
})(); |
|
1075 |
YAHOO.register("yahoo", YAHOO, {version: "2.8.0r4", build: "2449"}); |
Also available in: Unified diff
updated YUI 2.4.1 to 2.8.0r4