yahoo.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. This file is part of the DITA Open Toolkit project.
  3. See the accompanying LICENSE file for applicable license.
  4. Copyright (c) 2006, Yahoo! Inc. All rights reserved.
  5. Code licensed under the BSD License:
  6. http://developer.yahoo.net/yui/license.txt
  7. version: 0.10.0
  8. */
  9. /* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
  10. /**
  11. * The Yahoo global namespace
  12. * @constructor
  13. */
  14. var YAHOO = window.YAHOO || {};
  15. /**
  16. * Returns the namespace specified and creates it if it doesn't exist
  17. *
  18. * YAHOO.namespace("property.package");
  19. * YAHOO.namespace("YAHOO.property.package");
  20. *
  21. * Either of the above would create YAHOO.property, then
  22. * YAHOO.property.package
  23. *
  24. * @param {String} sNameSpace String representation of the desired
  25. * namespace
  26. * @return {Object} A reference to the namespace object
  27. */
  28. YAHOO.namespace = function( sNameSpace ) {
  29. if (!sNameSpace || !sNameSpace.length) {
  30. return null;
  31. }
  32. var levels = sNameSpace.split(".");
  33. var currentNS = YAHOO;
  34. // YAHOO is implied, so it is ignored if it is included
  35. for (var i=(levels[0] == "YAHOO") ? 1 : 0; i<levels.length; ++i) {
  36. currentNS[levels[i]] = currentNS[levels[i]] || {};
  37. currentNS = currentNS[levels[i]];
  38. }
  39. return currentNS;
  40. };
  41. /**
  42. * Global log method.
  43. */
  44. YAHOO.log = function(sMsg,sCategory) {
  45. if(YAHOO.widget.Logger) {
  46. YAHOO.widget.Logger.log(null, sMsg, sCategory);
  47. } else {
  48. return false;
  49. }
  50. };
  51. YAHOO.namespace("util");
  52. YAHOO.namespace("widget");
  53. YAHOO.namespace("example");