summaryrefslogtreecommitdiff
path: root/frontend/beta/js/YUI/yahoo.js
Unidiff
Diffstat (limited to 'frontend/beta/js/YUI/yahoo.js') (more/less context) (show whitespace changes)
-rw-r--r--frontend/beta/js/YUI/yahoo.js145
1 files changed, 145 insertions, 0 deletions
diff --git a/frontend/beta/js/YUI/yahoo.js b/frontend/beta/js/YUI/yahoo.js
new file mode 100644
index 0000000..8a44a91
--- a/dev/null
+++ b/frontend/beta/js/YUI/yahoo.js
@@ -0,0 +1,145 @@
1/*
2Copyright (c) 2006, Yahoo! Inc. All rights reserved.
3Code licensed under the BSD License:
4http://developer.yahoo.net/yui/license.txt
5version: 0.12.0
6*/
7
8/**
9 * The YAHOO object is the single global object used by YUI Library. It
10 * contains utility function for setting up namespaces, inheritance, and
11 * logging. YAHOO.util, YAHOO.widget, and YAHOO.example are namespaces
12 * created automatically for and used by the library.
13 * @module yahoo
14 * @title YAHOO Global
15 */
16
17/**
18 * The YAHOO global namespace object
19 * @class YAHOO
20 * @static
21 */
22if (typeof YAHOO == "undefined") {
23 var YAHOO = {};
24}
25
26/**
27 * Returns the namespace specified and creates it if it doesn't exist
28 * <pre>
29 * YAHOO.namespace("property.package");
30 * YAHOO.namespace("YAHOO.property.package");
31 * </pre>
32 * Either of the above would create YAHOO.property, then
33 * YAHOO.property.package
34 *
35 * Be careful when naming packages. Reserved words may work in some browsers
36 * and not others. For instance, the following will fail in Safari:
37 * <pre>
38 * YAHOO.namespace("really.long.nested.namespace");
39 * </pre>
40 * This fails because "long" is a future reserved word in ECMAScript
41 *
42 * @method namespace
43 * @static
44 * @param {String*} arguments 1-n namespaces to create
45 * @return {Object} A reference to the last namespace object created
46 */
47YAHOO.namespace = function() {
48 var a=arguments, o=null, i, j, d;
49 for (i=0; i<a.length; ++i) {
50 d=a[i].split(".");
51 o=YAHOO;
52
53 // YAHOO is implied, so it is ignored if it is included
54 for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; ++j) {
55 o[d[j]]=o[d[j]] || {};
56 o=o[d[j]];
57 }
58 }
59
60 return o;
61};
62
63/**
64 * Uses YAHOO.widget.Logger to output a log message, if the widget is available.
65 *
66 * @method log
67 * @static
68 * @param {String} msg The message to log.
69 * @param {String} cat The log category for the message. Default
70 * categories are "info", "warn", "error", time".
71 * Custom categories can be used as well. (opt)
72 * @param {String} src The source of the the message (opt)
73 * @return {Boolean} True if the log operation was successful.
74 */
75YAHOO.log = function(msg, cat, src) {
76 var l=YAHOO.widget.Logger;
77 if(l && l.log) {
78 return l.log(msg, cat, src);
79 } else {
80 return false;
81 }
82};
83
84/**
85 * Utility to set up the prototype, constructor and superclass properties to
86 * support an inheritance strategy that can chain constructors and methods.
87 *
88 * @method extend
89 * @static
90 * @param {Function} subc the object to modify
91 * @param {Function} superc the object to inherit
92 * @param {String[]} overrides additional properties/methods to add to the
93 * subclass prototype. These will override the
94 * matching items obtained from the superclass
95 * if present.
96 */
97YAHOO.extend = function(subc, superc, overrides) {
98 var F = function() {};
99 F.prototype=superc.prototype;
100 subc.prototype=new F();
101 subc.prototype.constructor=subc;
102 subc.superclass=superc.prototype;
103 if (superc.prototype.constructor == Object.prototype.constructor) {
104 superc.prototype.constructor=superc;
105 }
106
107 if (overrides) {
108 for (var i in overrides) {
109 subc.prototype[i]=overrides[i];
110 }
111 }
112};
113
114/**
115 * Applies all prototype properties in the supplier to the receiver if the
116 * receiver does not have these properties yet. Optionally, one or more
117 * methods/properties can be specified (as additional parameters). This
118 * option will overwrite the property if receiver has it already.
119 *
120 * @method augment
121 * @static
122 * @param {Function} r the object to receive the augmentation
123 * @param {Function} s the object that supplies the properties to augment
124 * @param {String*} arguments zero or more properties methods to augment the
125 * receiver with. If none specified, everything
126 * in the supplier will be used unless it would
127 * overwrite an existing property in the receiver
128 */
129YAHOO.augment = function(r, s) {
130 var rp=r.prototype, sp=s.prototype, a=arguments, i, p;
131 if (a[2]) {
132 for (i=2; i<a.length; ++i) {
133 rp[a[i]] = sp[a[i]];
134 }
135 } else {
136 for (p in sp) {
137 if (!rp[p]) {
138 rp[p] = sp[p];
139 }
140 }
141 }
142};
143
144YAHOO.namespace("util", "widget", "example");
145