5 See <http://mochikit.com/> for documentation, downloads, license, etc.
7 (c) 2005 Bob Ippolito. All rights Reserved.
11 if (typeof(MochiKit) == 'undefined') {
15 if (typeof(MochiKit.MochiKit) == 'undefined') {
16 /** @id MochiKit.MochiKit */
17 MochiKit.MochiKit = {};
20 MochiKit.MochiKit.NAME = "MochiKit.MochiKit";
21 MochiKit.MochiKit.VERSION = "1.4";
22 MochiKit.MochiKit.__repr__ = function () {
23 return "[" + this.NAME + " " + this.VERSION + "]";
26 /** @id MochiKit.MochiKit.toString */
27 MochiKit.MochiKit.toString = function () {
28 return this.__repr__();
31 /** @id MochiKit.MochiKit.SUBMODULES */
32 MochiKit.MochiKit.SUBMODULES = [
49 if (typeof(JSAN) != 'undefined' || typeof(dojo) != 'undefined') {
50 if (typeof(dojo) != 'undefined') {
51 dojo.provide('MochiKit.MochiKit');
52 dojo.require("MochiKit.*");
54 if (typeof(JSAN) != 'undefined') {
55 JSAN.use("MochiKit.Base", []);
56 JSAN.use("MochiKit.Iter", []);
57 JSAN.use("MochiKit.Logging", []);
58 JSAN.use("MochiKit.DateTime", []);
59 JSAN.use("MochiKit.Format", []);
60 JSAN.use("MochiKit.Async", []);
61 JSAN.use("MochiKit.DOM", []);
62 JSAN.use("MochiKit.Selector", []);
63 JSAN.use("MochiKit.Style", []);
64 JSAN.use("MochiKit.LoggingPane", []);
65 JSAN.use("MochiKit.Color", []);
66 JSAN.use("MochiKit.Signal", []);
67 JSAN.use("MochiKit.Position", []);
68 JSAN.use("MochiKit.Visual", []);
71 var extend = MochiKit.Base.extend;
72 var self = MochiKit.MochiKit;
73 var modules = self.SUBMODULES;
78 for (i = 0; i < modules.length; i++) {
79 m = MochiKit[modules[i]];
80 extend(EXPORT, m.EXPORT);
81 extend(EXPORT_OK, m.EXPORT_OK);
82 for (k in m.EXPORT_TAGS) {
83 EXPORT_TAGS[k] = extend(EXPORT_TAGS[k], m.EXPORT_TAGS[k]);
85 all = m.EXPORT_TAGS[":all"];
87 all = extend(null, m.EXPORT, m.EXPORT_OK);
90 for (j = 0; j < all.length; j++) {
96 self.EXPORT_OK = EXPORT_OK;
97 self.EXPORT_TAGS = EXPORT_TAGS;
101 if (typeof(MochiKit.__compat__) == 'undefined') {
102 MochiKit.__compat__ = true;
105 if (typeof(document) == "undefined") {
108 var scripts = document.getElementsByTagName("script");
109 var kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
114 for (i = 0; i < scripts.length; i++) {
115 var src = scripts[i].getAttribute("src");
119 allScripts[src] = true;
120 if (src.match(/MochiKit.js$/)) {
121 base = src.substring(0, src.lastIndexOf('MochiKit.js'));
122 baseElem = scripts[i];
128 var modules = MochiKit.MochiKit.SUBMODULES;
129 for (var i = 0; i < modules.length; i++) {
130 if (MochiKit[modules[i]]) {
133 var uri = base + modules[i] + '.js';
134 if (uri in allScripts) {
137 if (document.documentElement &&
138 document.documentElement.namespaceURI == kXULNSURI) {
140 var s = document.createElementNS(kXULNSURI, 'script');
141 s.setAttribute("id", "MochiKit_" + base + modules[i]);
142 s.setAttribute("src", uri);
143 s.setAttribute("type", "application/x-javascript");
144 baseElem.parentNode.appendChild(s);
148 DOM can not be used here because Safari does
149 deferred loading of scripts unless they are
150 in the document or inserted with document.write
152 This is not XHTML compliant. If you want XHTML
153 compliance then you must use the packed version of MochiKit
154 or include each script individually (basically unroll
155 these document.write calls into your XHTML source)
158 document.write('<script src="' + uri +
159 '" type="text/javascript"></script>');