testing/mochitest/tests/MochiKit-1.4.2/MochiKit/MochiKit.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /***
michael@0 2
michael@0 3 MochiKit.MochiKit 1.4.2
michael@0 4
michael@0 5 See <http://mochikit.com/> for documentation, downloads, license, etc.
michael@0 6
michael@0 7 (c) 2005 Bob Ippolito. All rights Reserved.
michael@0 8
michael@0 9 ***/
michael@0 10
michael@0 11 if (typeof(MochiKit) == 'undefined') {
michael@0 12 MochiKit = {};
michael@0 13 }
michael@0 14
michael@0 15 if (typeof(MochiKit.MochiKit) == 'undefined') {
michael@0 16 /** @id MochiKit.MochiKit */
michael@0 17 MochiKit.MochiKit = {};
michael@0 18 }
michael@0 19
michael@0 20 MochiKit.MochiKit.NAME = "MochiKit.MochiKit";
michael@0 21 MochiKit.MochiKit.VERSION = "1.4.2";
michael@0 22 MochiKit.MochiKit.__repr__ = function () {
michael@0 23 return "[" + this.NAME + " " + this.VERSION + "]";
michael@0 24 };
michael@0 25
michael@0 26 /** @id MochiKit.MochiKit.toString */
michael@0 27 MochiKit.MochiKit.toString = function () {
michael@0 28 return this.__repr__();
michael@0 29 };
michael@0 30
michael@0 31 /** @id MochiKit.MochiKit.SUBMODULES */
michael@0 32 MochiKit.MochiKit.SUBMODULES = [
michael@0 33 "Base",
michael@0 34 "Iter",
michael@0 35 "Logging",
michael@0 36 "DateTime",
michael@0 37 "Format",
michael@0 38 "Async",
michael@0 39 "DOM",
michael@0 40 "Selector",
michael@0 41 "Style",
michael@0 42 "LoggingPane",
michael@0 43 "Color",
michael@0 44 "Signal",
michael@0 45 "Position",
michael@0 46 "Visual",
michael@0 47 "DragAndDrop",
michael@0 48 "Sortable"
michael@0 49 ];
michael@0 50
michael@0 51 if (typeof(JSAN) != 'undefined' || typeof(dojo) != 'undefined') {
michael@0 52 if (typeof(dojo) != 'undefined') {
michael@0 53 dojo.provide('MochiKit.MochiKit');
michael@0 54 (function (lst) {
michael@0 55 for (var i = 0; i < lst.length; i++) {
michael@0 56 dojo.require("MochiKit." + lst[i]);
michael@0 57 }
michael@0 58 })(MochiKit.MochiKit.SUBMODULES);
michael@0 59 }
michael@0 60 if (typeof(JSAN) != 'undefined') {
michael@0 61 (function (lst) {
michael@0 62 for (var i = 0; i < lst.length; i++) {
michael@0 63 JSAN.use("MochiKit." + lst[i], []);
michael@0 64 }
michael@0 65 })(MochiKit.MochiKit.SUBMODULES);
michael@0 66 }
michael@0 67 (function () {
michael@0 68 var extend = MochiKit.Base.extend;
michael@0 69 var self = MochiKit.MochiKit;
michael@0 70 var modules = self.SUBMODULES;
michael@0 71 var EXPORT = [];
michael@0 72 var EXPORT_OK = [];
michael@0 73 var EXPORT_TAGS = {};
michael@0 74 var i, k, m, all;
michael@0 75 for (i = 0; i < modules.length; i++) {
michael@0 76 m = MochiKit[modules[i]];
michael@0 77 extend(EXPORT, m.EXPORT);
michael@0 78 extend(EXPORT_OK, m.EXPORT_OK);
michael@0 79 for (k in m.EXPORT_TAGS) {
michael@0 80 EXPORT_TAGS[k] = extend(EXPORT_TAGS[k], m.EXPORT_TAGS[k]);
michael@0 81 }
michael@0 82 all = m.EXPORT_TAGS[":all"];
michael@0 83 if (!all) {
michael@0 84 all = extend(null, m.EXPORT, m.EXPORT_OK);
michael@0 85 }
michael@0 86 var j;
michael@0 87 for (j = 0; j < all.length; j++) {
michael@0 88 k = all[j];
michael@0 89 self[k] = m[k];
michael@0 90 }
michael@0 91 }
michael@0 92 self.EXPORT = EXPORT;
michael@0 93 self.EXPORT_OK = EXPORT_OK;
michael@0 94 self.EXPORT_TAGS = EXPORT_TAGS;
michael@0 95 }());
michael@0 96
michael@0 97 } else {
michael@0 98 if (typeof(MochiKit.__compat__) == 'undefined') {
michael@0 99 MochiKit.__compat__ = true;
michael@0 100 }
michael@0 101 (function () {
michael@0 102 if (typeof(document) == "undefined") {
michael@0 103 return;
michael@0 104 }
michael@0 105 var scripts = document.getElementsByTagName("script");
michael@0 106 var kXHTMLNSURI = "http://www.w3.org/1999/xhtml";
michael@0 107 var kSVGNSURI = "http://www.w3.org/2000/svg";
michael@0 108 var kXLINKNSURI = "http://www.w3.org/1999/xlink";
michael@0 109 var kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
michael@0 110 var base = null;
michael@0 111 var baseElem = null;
michael@0 112 var allScripts = {};
michael@0 113 var i;
michael@0 114 var src;
michael@0 115 for (i = 0; i < scripts.length; i++) {
michael@0 116 src = null;
michael@0 117 switch (scripts[i].namespaceURI) {
michael@0 118 case kSVGNSURI:
michael@0 119 src = scripts[i].getAttributeNS(kXLINKNSURI, "href");
michael@0 120 break;
michael@0 121 /*
michael@0 122 case null: // HTML
michael@0 123 case '': // HTML
michael@0 124 case kXHTMLNSURI:
michael@0 125 case kXULNSURI:
michael@0 126 */
michael@0 127 default:
michael@0 128 src = scripts[i].getAttribute("src");
michael@0 129 break;
michael@0 130 }
michael@0 131 if (!src) {
michael@0 132 continue;
michael@0 133 }
michael@0 134 allScripts[src] = true;
michael@0 135 if (src.match(/MochiKit.js(\?.*)?$/)) {
michael@0 136 base = src.substring(0, src.lastIndexOf('MochiKit.js'));
michael@0 137 baseElem = scripts[i];
michael@0 138 }
michael@0 139 }
michael@0 140 if (base === null) {
michael@0 141 return;
michael@0 142 }
michael@0 143 var modules = MochiKit.MochiKit.SUBMODULES;
michael@0 144 for (var i = 0; i < modules.length; i++) {
michael@0 145 if (MochiKit[modules[i]]) {
michael@0 146 continue;
michael@0 147 }
michael@0 148 var uri = base + modules[i] + '.js';
michael@0 149 if (uri in allScripts) {
michael@0 150 continue;
michael@0 151 }
michael@0 152 if (baseElem.namespaceURI == kSVGNSURI ||
michael@0 153 baseElem.namespaceURI == kXULNSURI) {
michael@0 154 // SVG, XUL
michael@0 155 /*
michael@0 156 SVG does not support document.write, so if Safari wants to
michael@0 157 support SVG tests it should fix its deferred loading bug
michael@0 158 (see following below).
michael@0 159
michael@0 160 */
michael@0 161 var s = document.createElementNS(baseElem.namespaceURI, 'script');
michael@0 162 s.setAttribute("id", "MochiKit_" + base + modules[i]);
michael@0 163 if (baseElem.namespaceURI == kSVGNSURI) {
michael@0 164 s.setAttributeNS(kXLINKNSURI, 'href', uri);
michael@0 165 } else {
michael@0 166 s.setAttribute('src', uri);
michael@0 167 }
michael@0 168 s.setAttribute("type", "application/x-javascript");
michael@0 169 baseElem.parentNode.appendChild(s);
michael@0 170 } else {
michael@0 171 // HTML, XHTML
michael@0 172 /*
michael@0 173 DOM can not be used here because Safari does
michael@0 174 deferred loading of scripts unless they are
michael@0 175 in the document or inserted with document.write
michael@0 176
michael@0 177 This is not XHTML compliant. If you want XHTML
michael@0 178 compliance then you must use the packed version of MochiKit
michael@0 179 or include each script individually (basically unroll
michael@0 180 these document.write calls into your XHTML source)
michael@0 181
michael@0 182 */
michael@0 183 document.write('<' + baseElem.nodeName + ' src="' + uri +
michael@0 184 '" type="text/javascript"></script>');
michael@0 185 }
michael@0 186 };
michael@0 187 })();
michael@0 188 }

mercurial