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 = [
47 if (typeof(JSAN) != 'undefined' || typeof(dojo) != 'undefined') {
48 if (typeof(dojo) != 'undefined') {
49 dojo.provide('MochiKit.MochiKit');
50 dojo.require("MochiKit.*");
52 if (typeof(JSAN) != 'undefined') {
54 for (var i = 0; i < lst.length; i++) {
55 JSAN.use("MochiKit." + lst[i], []);
57 })(MochiKit.MochiKit.SUBMODULES);
60 var extend = MochiKit.Base.extend;
61 var self = MochiKit.MochiKit;
62 var modules = self.SUBMODULES;
67 for (i = 0; i < modules.length; i++) {
68 m = MochiKit[modules[i]];
69 extend(EXPORT, m.EXPORT);
70 extend(EXPORT_OK, m.EXPORT_OK);
71 for (k in m.EXPORT_TAGS) {
72 EXPORT_TAGS[k] = extend(EXPORT_TAGS[k], m.EXPORT_TAGS[k]);
74 all = m.EXPORT_TAGS[":all"];
76 all = extend(null, m.EXPORT, m.EXPORT_OK);
79 for (j = 0; j < all.length; j++) {
85 self.EXPORT_OK = EXPORT_OK;
86 self.EXPORT_TAGS = EXPORT_TAGS;
90 if (typeof(MochiKit.__compat__) == 'undefined') {
91 MochiKit.__compat__ = true;
94 if (typeof(document) == "undefined") {
97 var scripts = document.getElementsByTagName("script");
98 var kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
103 for (i = 0; i < scripts.length; i++) {
104 var src = scripts[i].getAttribute("src");
108 allScripts[src] = true;
109 if (src.match(/MochiKit.js$/)) {
110 base = src.substring(0, src.lastIndexOf('MochiKit.js'));
111 baseElem = scripts[i];
117 var modules = MochiKit.MochiKit.SUBMODULES;
118 for (var i = 0; i < modules.length; i++) {
119 if (MochiKit[modules[i]]) {
122 var uri = base + modules[i] + '.js';
123 if (uri in allScripts) {
126 if (document.documentElement &&
127 document.documentElement.namespaceURI == kXULNSURI) {
129 var s = document.createElementNS(kXULNSURI, 'script');
130 s.setAttribute("id", "MochiKit_" + base + modules[i]);
131 s.setAttribute("src", uri);
132 s.setAttribute("type", "application/x-javascript");
133 baseElem.parentNode.appendChild(s);
137 DOM can not be used here because Safari does
138 deferred loading of scripts unless they are
139 in the document or inserted with document.write
141 This is not XHTML compliant. If you want XHTML
142 compliance then you must use the packed version of MochiKit
143 or include each script individually (basically unroll
144 these document.write calls into your XHTML source)
147 document.write('<script src="' + uri +
148 '" type="text/javascript"></script>');