160
161
o.doc = w.document;
161
162
o.debug = ('debug' in o) ? o.debug : true;
162
o.useConsole = ('useConsole' in o) ? o.useConsole: true;
164
// @TODO default throwFail to true in PR2
165
// o.throwFail = ('throwFail' in o) ? o.debug : true;
163
o.useBrowserConsole = ('useBrowserConsole' in o) ? o.useBrowserConsole : true;
164
o.throwFail = ('throwFail' in o) ? o.throwFail : true;
167
166
// add a reference to o for anything that needs it
168
167
// before _setup is called.
371
369
// Y.log('loader before: ' + a.join(','));
374
// use loader to optimize and sort the requirements if it
372
// use loader to expand dependencies and sort the
373
// requirements if it is available.
378
376
loader = new Y.Loader(Y.config);
379
377
loader.require(a);
380
378
loader.ignoreRegistered = true;
379
loader.allowRollup = false;
381
380
loader.calculate();
382
381
a = loader.sorted;
475
474
* Returns the namespace specified and creates it if it doesn't exist
477
476
* YUI.namespace("property.package");
478
* YUI.namespace("YUI.property.package");
477
* YUI.namespace("YAHOO.property.package");
480
* Either of the above would create YUI.property, then
479
* Either of the above would create YAHOO.property, then
481
480
* YUI.property.package
483
482
* Be careful when naming packages. Reserved words may work in some browsers
604
603
* If the 'debug' config is true, a 'yui:log' event will be
605
604
* dispatched, which the logger widget and anything else
606
* can consume. If the 'useConsole' config is true, it will
605
* can consume. If the 'useBrowserConsole' config is true, it will
607
606
* write to the browser console if available.
613
612
* categories are "info", "warn", "error", time".
614
613
* Custom categories can be used as well. (opt)
615
614
* @param {String} src The source of the the message (opt)
615
* @param {boolean} silent If true, the log event won't fire
616
616
* @return {YUI} YUI instance
618
instance.log = function(msg, cat, src) {
618
instance.log = function(msg, cat, src, silent) {
620
620
var Y = instance, c = Y.config, es = Y.Env._eventstack,
621
bail = (es && es.logging);
621
// bail = (es && es.logging);
623
624
// suppress log message if the config is off or the event stack
624
625
// or the event call stack contains a consumer of the yui:log event
645
if (c.useConsole && typeof console != 'undefined') {
646
var f = (cat && console[cat]) ? cat : 'log',
647
m = (src) ? src + ': ' + msg : msg;
646
if (c.useBrowserConsole) {
647
var m = (src) ? src + ': ' + msg : msg;
648
if (typeof console != 'undefined') {
649
var f = (cat && console[cat]) ? cat : 'log';
651
} else if (typeof opera != 'undefined') {
651
if (Y.fire && !bail) {
656
if (Y.fire && !bail && !silent) {
652
657
Y.fire('yui:log', msg, cat, src);
687
700
* @param o The object to test
688
701
* @return {boolean} true if o is an array
690
L.isArray = function(o) {
692
//return L.isNumber(o.length) && L.isFunction(o.splice);
693
return (o[SPLICE] && L.isNumber(o[LENGTH]));
703
L.isArray = function(o) {
704
return OP.toString.apply(o) === ARRAY_TOSTRING;
703
712
* @return {boolean} true if o is a boolean
705
714
L.isBoolean = function(o) {
706
return typeof o === 'boolean';
715
return typeof o === BOOLEAN;
710
719
* Determines whether or not the provided object is a function
720
* Note: Internet Explorer thinks certain functions are objects:
722
* var obj = document.createElement("object");
723
* Y.Lang.isFunction(obj.getAttribute) // reports false in IE
725
* var input = document.createElement("input"); // append to body
726
* Y.Lang.isFunction(input.focus) // reports false in IE
728
* You will have to implement additional tests if these functions
711
731
* @method isFunction
713
733
* @param o The object to test
714
734
* @return {boolean} true if o is a function
716
736
L.isFunction = function(o) {
717
return typeof o === 'function';
737
return OP.toString.apply(o) === FUNCTION_TOSTRING;
861
881
Y.Array = function(o, i, al) {
862
882
var t = (al) ? 2 : Y.Array.test(o);
865
return (i) ? o.slice(o, i) : o;
867
return Native.slice.call(o, i || 0);
886
// // return (i) ? o.slice(i) : o;
888
// return Native.slice.call(o, i || 0);
894
return Native.slice.call(o, i || 0);
963
* Executes the supplied function on each item in the array.
964
* Returning true from the processing function will stop the
965
* processing of the remaining
968
* @param a {Array} the array to iterate
969
* @param f {Function} the function to execute on each item
970
* @param o Optional context object
972
* @return {boolean} true if the
974
A.some = (Native.forEach) ?
976
Native.some.call(a, f, o || Y);
981
for (var i = 0; i < l; i=i+1) {
982
if (f.call(o, a[i], i, a)) {
929
990
* Returns an object using the first array as keys, and
930
991
* the second as values. If the second array is not
931
992
* provided the value is set to true for each.
1069
1130
for (var i in fs) {
1071
// We never want to overwrite the prototype
1072
// if (PROTO === i) {
1073
if (PROTO === i || '_yuid' === i) {
1077
// Y.log('i: ' + i + ", " + fs[i]);
1078
// @TODO deal with the hasownprop issue
1080
// check white list if it was supplied
1081
if (!w || iwl || (i in w)) {
1082
// if the receiver has this property, it is an object,
1083
// and merge is specified, merge the two objects.
1084
if (m && L.isObject(fr[i], true)) {
1085
// console.log('aggregate RECURSE: ' + i);
1086
// @TODO recursive or no?
1087
// Y.mix(fr[i], fs[i]); // not recursive
1088
f(fr[i], fs[i], proto, true); // recursive
1089
// otherwise apply the property only if overwrite
1090
// is specified or the receiver doesn't have one.
1091
// @TODO make sure the 'arr' check isn't desructive
1092
} else if (!arr && (ov || !(i in fr))) {
1093
// console.log('hash: ' + i);
1095
// if merge is specified and the receiver is an array,
1096
// append the array item
1098
// console.log('array: ' + i);
1099
// @TODO probably will need to remove dups
1132
if (fs.hasOwnProperty(i)) {
1134
// We never want to overwrite the prototype
1135
// if (PROTO === i) {
1136
if (PROTO === i || '_yuid' === i) {
1140
// Y.log('i: ' + i + ", " + fs[i]);
1141
// @TODO deal with the hasownprop issue
1143
// check white list if it was supplied
1144
if (!w || iwl || (i in w)) {
1145
// if the receiver has this property, it is an object,
1146
// and merge is specified, merge the two objects.
1147
if (m && L.isObject(fr[i], true)) {
1148
// console.log('aggregate RECURSE: ' + i);
1149
// @TODO recursive or no?
1150
// Y.mix(fr[i], fs[i]); // not recursive
1151
f(fr[i], fs[i], proto, true); // recursive
1152
// otherwise apply the property only if overwrite
1153
// is specified or the receiver doesn't have one.
1154
// @TODO make sure the 'arr' check isn't desructive
1155
} else if (!arr && (ov || !(i in fr))) {
1156
// console.log('hash: ' + i);
1158
// if merge is specified and the receiver is an array,
1159
// append the array item
1161
// console.log('array: ' + i);
1162
// @TODO probably will need to remove dups