juice 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. data/{History.txt → History.txt } +0 -0
  2. data/Manifest.txt +37 -0
  3. data/{PostInstall.txt → PostInstall.txt } +0 -0
  4. data/{README.rdoc → README.rdoc } +0 -0
  5. data/StarterApplication/Framework/Juice.Alert.js +59 -0
  6. data/StarterApplication/Framework/Juice.Application.js +33 -0
  7. data/StarterApplication/Framework/Juice.Button.js +25 -0
  8. data/StarterApplication/Framework/Juice.Confirm.js +42 -0
  9. data/StarterApplication/Framework/Juice.Cookie.js +50 -0
  10. data/StarterApplication/Framework/Juice.DOM.js +223 -0
  11. data/StarterApplication/Framework/Juice.Event.js +57 -0
  12. data/StarterApplication/Framework/Juice.Image.js +38 -0
  13. data/StarterApplication/Framework/Juice.JSONPConnection.js +42 -0
  14. data/StarterApplication/Framework/Juice.Layout.js +29 -0
  15. data/StarterApplication/Framework/Juice.Window.js +73 -0
  16. data/StarterApplication/Framework/Juice.i18n.js +46 -0
  17. data/StarterApplication/Framework/Juice.js +324 -0
  18. data/StarterApplication/Framework/Resources/Themes/Default.css +85 -0
  19. data/StarterApplication/Framework/Resources/Themes/Default/images/Thumbs.db +0 -0
  20. data/StarterApplication/Framework/Resources/Themes/Default/images/button-sprite.png +0 -0
  21. data/StarterApplication/Framework/Resources/Themes/Default/images/spinner.gif +0 -0
  22. data/StarterApplication/Framework/Resources/images/Thumbs.db +0 -0
  23. data/StarterApplication/Framework/Resources/images/spinner.gif +0 -0
  24. data/StarterApplication/LICENSE +20 -0
  25. data/StarterApplication/README +6 -0
  26. data/StarterApplication/appController.js +18 -0
  27. data/StarterApplication/index.html +26 -0
  28. data/StarterApplication/juice.app +5 -0
  29. data/bin/juice +78 -0
  30. data/lib/{JSquish.rb → JSquish.rb } +0 -0
  31. data/lib/{juice.rb → juice.rb } +1 -1
  32. data/script/{console → console } +0 -0
  33. data/script/{console.cmd → console.cmd } +0 -0
  34. data/script/{destroy → destroy } +0 -0
  35. data/script/{destroy.cmd → destroy.cmd } +0 -0
  36. data/script/{generate → generate } +0 -0
  37. data/script/{generate.cmd → generate.cmd } +0 -0
  38. metadata +41 -20
  39. data/Manifest.txt +0 -14
  40. data/Rakefile +0 -20
@@ -0,0 +1,57 @@
1
+ /*
2
+ Copyright (c) 2009 Justin Baker
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ Juice.Event = Juice.Class.create();
24
+ Juice.Event.prototype = {
25
+ initialize: function(obj,name,fn,options){
26
+ this.obj = obj,this.name = name,this.fn = fn,this.options = options || {};
27
+ if(this.options.startImmediately){
28
+ this.create();
29
+ }
30
+ },
31
+ create:function(){
32
+ if(this.obj.addEventListener){
33
+ this.obj.addEventListener(this.name,this.fn,false);
34
+ return true;
35
+ }
36
+ else if(this.obj.attachEvent){
37
+ var f = this.obj.attachEvent("on"+this.name,this.fn,false);
38
+ return f;
39
+ }
40
+ else{
41
+ throw new Error("EventCreationFailed");
42
+ }
43
+ },
44
+ remove:function(){
45
+ if(this.obj.addEventListener){
46
+ this.obj.removeEventListener(this.name,this.fn,false);
47
+ return true;
48
+ }
49
+ else if(this.obj.attachEvent){
50
+ var f = this.obj.detachEvent("on"+this.name,this.fn);
51
+ return f;
52
+ }
53
+ else{
54
+ throw new Error("EventDeletionFailed");
55
+ }
56
+ }
57
+ };
@@ -0,0 +1,38 @@
1
+ /*
2
+ Copyright (c) 2009 Justin Baker
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ Juice.Image = Juice.Class.create();
24
+ Juice.Image.prototype = {
25
+ initialize:function(src,options){
26
+ this.name = (10).toRandomString(), this.src = src;
27
+ this.options = options || {};
28
+ this.alt = this.options.alt;
29
+ var img = document.createElement('img');
30
+ img.writeAttributes({
31
+ id: this.name
32
+ 'src':this.src
33
+ alt: this.alt
34
+ });
35
+ return img;
36
+ }
37
+ };
38
+
@@ -0,0 +1,42 @@
1
+ /*
2
+ Copyright (c) 2009 Justin Baker
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ Juice.JSONPConnection = Juice.Class.create();
24
+ Juice.JSONPConnection.prototype = {
25
+ initialize: function(url,callback){
26
+ url = url+"callback="+callback;
27
+ this.element = document.createElement('script');
28
+ this.element .setAttribute('src', url);
29
+ this.element .setAttribute('type', "text/javascript");
30
+ },
31
+ send: function(){
32
+ try{
33
+ document.getElementsByTagName('head')[0].appendChild(this.element);
34
+ }
35
+ catch(e){
36
+ this.removeScript();
37
+ }
38
+ },
39
+ removeScript: function(){
40
+ document.getElementsByTagName('head')[0].removeChild(this.element);
41
+ }
42
+ };
@@ -0,0 +1,29 @@
1
+ /*
2
+ Copyright (c) 2009 Justin Baker
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ Juice.Layout = Juice.Class.create();
24
+
25
+ Juice.Object.extend(Juice.Layout,{
26
+ body:Juice.$('juice-body'),
27
+ fullWidth:(typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth),
28
+ fullHeight:(typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight)
29
+ });
@@ -0,0 +1,73 @@
1
+ /*
2
+ Copyright (c) 2009 Justin Baker
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ Juice.Window = Juice.Class.create();
24
+ Juice.Window.prototype = {
25
+ initialize: function(){
26
+ this.name = (10).toRandomString();
27
+ this.theDiv = document.createElement("div");
28
+ var theclass = Juice._classes._window;
29
+ this.theDiv.setAttribute("id",this.name);
30
+ this.theDiv.setAttribute("class",theclass);
31
+ return this;
32
+ },
33
+ addSubview: function(view){
34
+ Juice.$(this.name).appendChild(view);
35
+ return this;
36
+ },
37
+ contentView: function(){
38
+ return this.theDiv;
39
+ },
40
+ setSizing: function(width,height){
41
+ if(width){
42
+ Juice.$(this.name).style.width = width+'px';
43
+ }
44
+ if(height){
45
+ Juice.$(this.name).style.height = height+'px';
46
+ }
47
+ return this;
48
+ },
49
+ setStringValue: function(text){
50
+ Juice.$(this.name).innerHTML = text;
51
+ return this;
52
+ },
53
+ setCenter: function(boolean){
54
+ if(boolean){
55
+ Juice.$(this.name).setStyle({
56
+ marginLeft:"auto",
57
+ marginRight:"auto"
58
+ });
59
+ }
60
+ },
61
+ setBackground: function(color){
62
+ Juice.$(this.name).style.background = color;
63
+ return this;
64
+ },
65
+ setForeground: function(color){
66
+ Juice.$(this.name).style.color = color;
67
+ return this;
68
+ },
69
+ element: function(){
70
+ return this.theDiv;
71
+ }
72
+ };
73
+
@@ -0,0 +1,46 @@
1
+ /*
2
+ Copyright (c) 2009 Justin Baker
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+ Juice.i18n = {
24
+ DEFAULT_LANGUAGE: "en-us",
25
+ languages:{}
26
+ };
27
+ Juice.i18n.getString = function(value){
28
+ return Juice.i18n.languages[Juice.i18n.preferredLanguage][value];
29
+ };
30
+ Juice.i18n.setPreferredLanguage = function(value){
31
+ return Juice.i18n.preferredLanguage = value;
32
+ };
33
+ Juice.i18n.stringsFor = Juice.Class.create();
34
+ Juice.i18n.stringsFor.prototype = {
35
+ initialize:function(language,values){
36
+ this.language = language, Juice.i18n.languages[language] = values;
37
+ return Juice.i18n;
38
+ },
39
+ get: function(value){
40
+ return Juice.i18n.languages[this.language][value];
41
+ },
42
+ set: function(value){
43
+ return Juice.i18n.languages[language][value] = value;
44
+ }
45
+ };
46
+ Juice.i18n.setPreferredLanguage(Juice.i18n.DEFAULT_LANGUAGE);
@@ -0,0 +1,324 @@
1
+ /*
2
+ Copyright (c) 2009 Justin Baker
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ */
24
+ (function(){
25
+ /* Globals are declared here.
26
+ * They are: NO,YES,nil, and Juice.
27
+ */
28
+ NO = false;
29
+ YES = true;
30
+ nil = null;
31
+ Juice = {
32
+ // Here we define a method to extend our objects
33
+ Object: {
34
+ extend: function(d, s) { for (var p in s) d[p] = s[p]; return d;}
35
+ },
36
+ // Classes are great, are they not?
37
+ Class: {
38
+ create: function() {
39
+ return function() {;
40
+ this.initialize.apply(this, arguments);
41
+ }
42
+ }
43
+ },
44
+ // These are the classes used in our elements
45
+ _classes: {
46
+ _window:"JuiceWindow",
47
+ _alert:"JuiceAlert",
48
+ button:'JuiceButton'
49
+ },
50
+ // Modules. You can define custom ones.
51
+ _modules: ['i18n','DOM','Event','JSONPConnection','Layout','Application','Window','Button','Alert','Confirm'],
52
+ _fileExtensions: {
53
+ css: "css",
54
+ js: "js"
55
+ },
56
+ // Set our version information
57
+ version: "0.0.2"
58
+ };
59
+
60
+ // Here we add our helper methods to globals.
61
+ Juice.Object.extend(Juice.Object,{
62
+ // isString, isNumber, isFloat, isObject, isHash
63
+ isString:function(){
64
+ return typeof this == 'string';
65
+ },
66
+ isNumber:function(){
67
+ return typeof this == 'number';
68
+ },
69
+ isObject:function(){
70
+ return typeof this == 'object';
71
+ },
72
+ isUndefined:function(){
73
+ return typeof this == 'undefined';
74
+ },
75
+ isFunction:function(){
76
+ return typeof this == 'function';
77
+ },
78
+ inspect: function(){
79
+ try {
80
+ if (isUndefined(object)) return 'undefined';
81
+ if (object === null) return 'null';
82
+ return object.inspect ? object.inspect() : String(object);
83
+ }
84
+ catch (e) {
85
+ if (e instanceof RangeError) return '...';
86
+ throw e;
87
+ }
88
+ },
89
+ toArray:function(item,iterator,context){
90
+ iterator = iterator || function(x){ return x;};
91
+ var results = [];
92
+ item.each(function(value, index) {
93
+ results.push(iterator.call(context, value, index));
94
+ });
95
+ return results;
96
+ }
97
+ });
98
+ // Extend the Array object
99
+ Juice.Object.extend(Array.prototype,{
100
+ clear:function(){
101
+ this.length = 0;
102
+ return this;
103
+ },
104
+ clone: function(){
105
+ return [].concat(this);
106
+ },
107
+ first: function(){
108
+ return this[0];
109
+ },
110
+ last: function(){
111
+ return this[this.length - 1];
112
+ },
113
+ size: function(){
114
+ return this.length;
115
+ },
116
+ each: function(iterator) {
117
+ for (var i = 0, theLength = this.length; i < theLength; i++){
118
+ iterator(this[i]);
119
+ }
120
+ },
121
+ select: function(iterator,context){
122
+ var results = [];
123
+ this.each(function(value, index) {
124
+ if (iterator.call(context, value, index)){
125
+ results.push(value);
126
+ }
127
+ });
128
+ return results;
129
+ },
130
+ compact: function(){
131
+ return this.select(function(value) {
132
+ return value != null;
133
+ });
134
+ }
135
+ });
136
+ // Extend the String object
137
+ Juice.Object.extend(String.prototype,{
138
+ empty :function(){
139
+ return this.length == 0;
140
+ },
141
+ size: function(){
142
+ return this.length;
143
+ },
144
+ fromHex: function(){
145
+ return parseInt(this,16);
146
+ }
147
+ });
148
+ Juice.Object.extend(Function.prototype,{
149
+ unless:function(fn){
150
+ if(fn.isFunction()){
151
+ var cond = fn.call();
152
+ }
153
+ else var cond = fn;
154
+ if(cond){
155
+ var args = arguments;
156
+ alert(args);
157
+ this.call(args);
158
+ }
159
+ }
160
+ });
161
+ Juice.Object.extend(Number.prototype,{
162
+ toRandomString: function(){
163
+ var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
164
+ var string_length = this || 8;
165
+ var random = '';
166
+ for (var i=0; i<string_length; i++) {
167
+ var rnum = Math.floor(Math.random() * chars.length);
168
+ random += chars.substring(rnum,rnum+1);
169
+ }
170
+ return random;
171
+ },
172
+ toHex: function(){
173
+ return this.toString(16);
174
+ }
175
+ });
176
+
177
+ // Get back to the Juice object..
178
+ Juice.Object.extend(Juice,{
179
+ readyList:[],
180
+ isReady:false,
181
+ Ready: function(){
182
+ Juice.isReady = true;
183
+ Juice.appDidLoad();
184
+ },
185
+ bindReady:function(){
186
+ // Mozilla, Opera and webkit nightlies currently support this event
187
+ if (document.addEventListener) {
188
+ // Use the handy event callback
189
+ document.addEventListener("DOMContentLoaded", function(){
190
+ document.removeEventListener("DOMContentLoaded", arguments.callee, false);
191
+ Juice.Ready();
192
+ }, false);
193
+ }
194
+ // If IE event model is used
195
+ else{
196
+ if (document.attachEvent) {
197
+ // ensure firing before onload,
198
+ // maybe late but safe also for iframes
199
+ document.attachEvent("onreadystatechange", function(){
200
+ if (document.readyState === "complete") {
201
+ document.detachEvent("onreadystatechange", arguments.callee);
202
+ Juice.Ready();
203
+ }
204
+ });
205
+ // If IE and not an iframe
206
+ // continually check to see if the document is ready
207
+ if (document.documentElement.doScroll && window == window.top)
208
+ (function(){
209
+ if (Juice.isReady)
210
+ return;
211
+ try {
212
+ // If IE is used, use the trick by Diego Perini
213
+ // http://javascript.nwbox.com/IEContentLoaded/
214
+ document.documentElement.doScroll("left");
215
+ }
216
+ catch (error) {
217
+ setTimeout(arguments.callee, 0);
218
+ return;
219
+ }
220
+ // and execute any waiting functions
221
+ Juice.Ready();
222
+ })();
223
+ }
224
+ var setOnload = new Juice.Event(window,"load",Juice.Ready, false);
225
+ setOnload.create();
226
+ }
227
+ },
228
+ Event: function(obj,name,fn){
229
+ this.create = function(){
230
+ if(obj.addEventListener){
231
+ obj.addEventListener(name,fn,false);
232
+ return true;
233
+ }
234
+ else if(obj.attachEvent){
235
+ var f = obj.attachEvent("on"+name,fn,false);
236
+ return f;
237
+ }
238
+ else{
239
+ throw new Error("EventCreationFailed");
240
+ }
241
+ };
242
+ this.remove = function(){
243
+ if(obj.addEventListener){
244
+ obj.removeEventListener(name,fn,false);
245
+ return true;
246
+ }
247
+ else if(obj.attachEvent){
248
+ var f = obj.detachEvent("on"+name,fn);
249
+ return f;
250
+ }
251
+ else{
252
+ throw new Error("EventDeletionFailed");
253
+ }
254
+ }
255
+ },
256
+ appDidLoad: function(fn){
257
+ // Make sure that the DOM is not already loaded
258
+ if (Juice.isReady) {
259
+ Juice.$('juiceloadingcontainer').style.display = "none";
260
+ Juice.loadModules();
261
+ Juice.Require('appController');
262
+ eval(fn);
263
+ // Remember that the DOM is ready
264
+ Juice.isReady = true;
265
+ // If there are functions bound, to execute
266
+ if (Juice.readyList) {
267
+ // Execute all of them
268
+ Juice.readyList.each(function(item){
269
+ item.call();
270
+ });
271
+ // Reset the list of functions
272
+ Juice.readyList = null;
273
+ }
274
+ }
275
+ else Juice.readyList.push(fn);
276
+
277
+ },
278
+ setAppTitle: function(str){
279
+ document.title = str;
280
+ },
281
+ $: function(sel){
282
+ return document.getElementById(sel);
283
+ },
284
+
285
+ Require: function(name){
286
+ var jsname = name+"js";
287
+ var head = document.getElementsByTagName('head')[0];
288
+ if(!Juice.$(jsname)){
289
+ var theName = name+"."+Juice._fileExtensions.js;
290
+ var s = document.createElement('script');
291
+ s.setAttribute('src', theName);
292
+ s.setAttribute('type', "text/javascript");
293
+ s.setAttribute('id', jsname);
294
+ head.appendChild(s);
295
+ }
296
+ },
297
+ loadAppCSS: function(name){
298
+ name = name || "application.css";
299
+ var link = document.createElement('link');
300
+ link.setAttribute("href",name);
301
+ link.setAttribute("type","text/css");
302
+ link.setAttribute("rel","stylesheet");
303
+ document.getElementsByTagName('head')[0].appendChild(link);
304
+ },
305
+ useTheme: function(name){
306
+ name = "Framework/Resources/Themes/" +name;
307
+ Juice.loadAppCSS(name+"."+Juice._fileExtensions.css);
308
+ },
309
+ loadModules: function(){
310
+ if(Juice.DOM){
311
+ return 'Bye';
312
+ }
313
+ else{
314
+ Juice._modules.each( function(file){
315
+ Juice.Require('Framework/Juice.' + file);
316
+ });
317
+ }
318
+ }
319
+ });
320
+
321
+ Juice.bindReady();
322
+ Juice.loadAppCSS();
323
+
324
+ })();