Mercurial > bugzilla-dashboard
annotate js/require.js @ 83:c38db28b48f5
replaced jquery-ui.css with custom theming.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Mon, 26 Apr 2010 05:35:46 -0700 |
parents | d3ed74176b4d |
children |
rev | line source |
---|---|
36
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
1 var Require = { |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
2 modules: {}, |
43
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
36
diff
changeset
|
3 build: function build(modules, moduleExports) { |
36
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
4 if (!modules) |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
5 modules = this.modules; |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
6 |
43
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
36
diff
changeset
|
7 if (!moduleExports) |
0974c1df3714
moved lots of app ui logic to require('app/ui')
Atul Varma <avarma@mozilla.com>
parents:
36
diff
changeset
|
8 moduleExports = {}; |
36
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
9 |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
10 return function require(module) { |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
11 if (!(module in moduleExports)) { |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
12 if (!(module in modules)) |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
13 throw new Error("module not found: " + module); |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
14 var exports = {}; |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
15 var globalScope = {}; |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
16 modules[module].call(globalScope, exports, require); |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
17 moduleExports[module] = exports; |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
18 } |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
19 return moduleExports[module]; |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
20 }; |
44
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
21 }, |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
22 preload: function preload(document, scripts, cb) { |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
23 var scriptsLeft = scripts.length; |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
24 |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
25 function onScriptLoaded() { |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
26 scriptsLeft--; |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
27 if (!scriptsLeft) |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
28 cb(); |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
29 }; |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
30 |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
31 scripts.forEach( |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
32 function(scriptName) { |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
33 var script = document.createElement("script"); |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
34 |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
35 script.src = scriptName; |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
36 script.onload = onScriptLoaded; |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
37 document.body.appendChild(script); |
d3ed74176b4d
added module preloading and loading screen
Atul Varma <avarma@mozilla.com>
parents:
43
diff
changeset
|
38 }); |
36
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
39 } |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
40 }; |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
41 |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
42 function require(module) { |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
43 throw new Error("require() not available at global scope: " + module); |
eb2cc1f89869
Added a test suite, basic CommonJS module loader, and a new main.html file that will be a unified UI to all three pages (dashboard, user-finder, bug-filer).
Atul Varma <avarma@mozilla.com>
parents:
diff
changeset
|
44 } |