Last change
on this file since 33100 was 12011, checked in by shaoqun, 18 years ago |
javascript package for berry basket
|
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.5 KB
|
Line | |
---|
1 | /*
|
---|
2 | Copyright (c) 2006 Yahoo! Inc. All rights reserved.
|
---|
3 | version 0.9.0
|
---|
4 | */
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * @class The Yahoo global namespace
|
---|
8 | */
|
---|
9 | var YAHOO = function() {
|
---|
10 |
|
---|
11 | return {
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * Yahoo presentation platform utils namespace
|
---|
15 | */
|
---|
16 | util: {},
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Yahoo presentation platform widgets namespace
|
---|
20 | */
|
---|
21 | widget: {},
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Yahoo presentation platform examples namespace
|
---|
25 | */
|
---|
26 | example: {},
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Returns the namespace specified and creates it if it doesn't exist
|
---|
30 | *
|
---|
31 | * YAHOO.namespace("property.package");
|
---|
32 | * YAHOO.namespace("YAHOO.property.package");
|
---|
33 | *
|
---|
34 | * Either of the above would create YAHOO.property, then
|
---|
35 | * YAHOO.property.package
|
---|
36 | *
|
---|
37 | * @param {String} sNameSpace String representation of the desired
|
---|
38 | * namespace
|
---|
39 | * @return {Object} A reference to the namespace object
|
---|
40 | */
|
---|
41 | namespace: function( sNameSpace ) {
|
---|
42 |
|
---|
43 | if (!sNameSpace || !sNameSpace.length) {
|
---|
44 | return null;
|
---|
45 | }
|
---|
46 |
|
---|
47 | var levels = sNameSpace.split(".");
|
---|
48 |
|
---|
49 | var currentNS = YAHOO;
|
---|
50 |
|
---|
51 | // YAHOO is implied, so it is ignored if it is included
|
---|
52 | for (var i=(levels[0] == "YAHOO") ? 1 : 0; i<levels.length; ++i) {
|
---|
53 | currentNS[levels[i]] = currentNS[levels[i]] || {};
|
---|
54 | currentNS = currentNS[levels[i]];
|
---|
55 | }
|
---|
56 |
|
---|
57 | return currentNS;
|
---|
58 |
|
---|
59 | }
|
---|
60 | };
|
---|
61 |
|
---|
62 | } ();
|
---|
63 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.