juice 0.2.0 → 0.2.1

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.
@@ -5,6 +5,8 @@ README.rdoc
5
5
  bin/juice
6
6
  lib/juice.rb
7
7
  lib/JSquish.rb
8
+ examples/controls/controls.js
9
+ examples/classes/Person.js
8
10
  script/generate.cmd
9
11
  script/generate
10
12
  script/destroy.cmd
@@ -12,7 +14,7 @@ script/destroy
12
14
  script/console.cmd
13
15
  script/console
14
16
  StarterApplication/Views/example.juice
15
- StarterApplication/README
17
+ StarterApplication/README.rdoc
16
18
  StarterApplication/LICENSE
17
19
  StarterApplication/index.html
18
20
  StarterApplication/Framework/Window.js
@@ -24,7 +26,9 @@ StarterApplication/Framework/Resources/Themes/Default/images/spinner.gif
24
26
  StarterApplication/Framework/Resources/Themes/Default/images/button-sprite.png
25
27
  StarterApplication/Framework/Resources/images/Thumbs.db
26
28
  StarterApplication/Framework/Resources/images/spinner.gif
29
+ StarterApplication/Framework/Observer.js
27
30
  StarterApplication/Framework/Layout.js
31
+ StarterApplication/Framework/Label.js
28
32
  StarterApplication/Framework/Juice.js
29
33
  StarterApplication/Framework/JSONPConnection.js
30
34
  StarterApplication/Framework/Image.js
@@ -11,13 +11,13 @@ creating desktop applications that run in the browser.
11
11
 
12
12
  == INSTALL:
13
13
 
14
- gem install juice
14
+ $ gem install juice
15
15
 
16
16
  == Getting Started:
17
17
 
18
- juice app \n
19
- cd app \n
20
- juice server \n\n
18
+ $ juice app
19
+ $ cd app
20
+ $ juice server
21
21
 
22
22
  Then navigate to http://localhost:338 in your favorite web browser!
23
23
 
@@ -40,9 +40,8 @@ Juice.Alert.prototype = {
40
40
  insideDiv.innerHTML = this.options.text;
41
41
  var body = Juice.Layout.body;
42
42
  body.appendChild(div);
43
- var half_height = (Juice.Layout.fullHeight/2)-(div.getHeight()/2);
44
- var half_width = (Juice.Layout.fullWidth/2)-(div.getWidth()/2);
45
-
43
+ var half_height = (Juice.Layout.fullHeight()/2)-(div.getHeight()/2);
44
+ var half_width = (Juice.Layout.fullWidth()/2)-(div.getWidth()/2);
46
45
  div.setStyle({
47
46
  top: half_height+'px',
48
47
  left:half_width+"px",
@@ -22,12 +22,38 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
  Juice.Application = Juice.Class.create();
24
24
  Juice.Application.prototype = {
25
- initialize: function Application_initialize(){
25
+ initialize: function Application_initialize(){
26
+ this.starter = document.createElement("div");
27
+ Juice.Layout.body.appendChild(this.starter);
28
+ this.starter.setStyle({
29
+ height: Juice.Layout.fullHeight()+"px",
30
+ width: Juice.Layout.fullWidth()+"px",
31
+ position:'relative',
32
+ overflow:'hidden'
33
+ });
34
+ var starter = this.starter;
35
+ Juice.Application.observer.subscribe(function Resize_starter(data){
36
+ starter.setStyle({
37
+ height: data.height+"px",
38
+ width: data.width+"px"
39
+ });
40
+ });
26
41
  return this;
27
42
  },
28
43
  addSubview: function Application_addSubview(view){
29
- var body = Juice.Layout.body;
30
- body.appendChild(view);
44
+ this.starter.appendChild(view);
45
+ },
46
+ getConfig: function Application_getConfig(key){
47
+ // todo
31
48
  }
32
49
  };
33
-
50
+ Juice.Application.observer = new Juice.Observer();
51
+ Juice.Application._bindEvent = function(){
52
+ var event = new Juice.Event(window,"resize",function SetNewBounds(){
53
+ console.log("Window Resize");
54
+ Juice.Application.observer.fire({height:Juice.Layout.fullHeight(),width:Juice.Layout.fullWidth()});
55
+ Juice.Layout.body.setStyle({height:Juice.Layout.fullHeight()+'px',width:Juice.Layout.fullWidth()+'px'});
56
+ });
57
+ event.create();
58
+ }
59
+ Juice.Application._bindEvent();
@@ -63,7 +63,7 @@ function Juice_DOM_init(){
63
63
  }
64
64
  return height+pt+pb+bt+bb;
65
65
  },
66
- getWidth: function Element_getWidth(element){
66
+ getWidth: function Element_getWidth(element){
67
67
  var el = element || this;
68
68
  var width = el.getStyle("width");
69
69
  if(width=='auto'){
@@ -23,18 +23,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  Juice.Event = Juice.Class.create();
24
24
  Juice.Event.prototype = {
25
25
  initialize: function Event_initialize(obj,name,fn,options){
26
- this.obj = obj,this.name = name,this.fn = fn,this.options = options || {};
26
+ this.obj = obj,this.name = name,this.options = options || {};
27
27
  if(this.options.startImmediately){
28
28
  this.create();
29
29
  }
30
+ this.callEvent = function(){
31
+ fn.call(this);
32
+ }
30
33
  },
31
34
  create:function Event_create(){
32
35
  if(this.obj.addEventListener){
33
- this.obj.addEventListener(this.name,this.fn,false);
36
+ this.obj.addEventListener(this.name,this.callEvent,false);
34
37
  return true;
35
38
  }
36
39
  else if(this.obj.attachEvent){
37
- var f = this.obj.attachEvent("on"+this.name,this.fn,false);
40
+ var f = this.obj.attachEvent("on"+this.name,this.callEvent,false);
38
41
  return f;
39
42
  }
40
43
  else{
@@ -43,11 +46,11 @@ Juice.Event.prototype = {
43
46
  },
44
47
  remove:function Event_remove(){
45
48
  if(this.obj.addEventListener){
46
- this.obj.removeEventListener(this.name,this.fn,false);
49
+ this.obj.removeEventListener(this.name,this.callEvent,false);
47
50
  return true;
48
51
  }
49
52
  else if(this.obj.attachEvent){
50
- var f = this.obj.detachEvent("on"+this.name,this.fn);
53
+ var f = this.obj.detachEvent("on"+this.name,this.callEvent);
51
54
  return f;
52
55
  }
53
56
  else{
@@ -23,10 +23,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  Juice.JSONPConnection = Juice.Class.create();
24
24
  Juice.JSONPConnection.prototype = {
25
25
  initialize: function(url,callback){
26
- url = url+"callback="+callback;
27
26
  this.element = document.createElement('script');
28
27
  this.element .setAttribute('src', url);
29
- this.element .setAttribute('type', "text/javascript");
28
+ this.element .setAttribute('type', "text/javascript");
29
+ this.callback = callback;
30
+ window.callback = callback;
30
31
  },
31
32
  send: function(){
32
33
  try{
@@ -38,5 +39,6 @@ Juice.JSONPConnection.prototype = {
38
39
  },
39
40
  removeScript: function(){
40
41
  document.getElementsByTagName('head')[0].removeChild(this.element);
42
+ window.callback = nil;
41
43
  }
42
44
  };
@@ -45,10 +45,12 @@ Juice = {
45
45
  _classes: {
46
46
  _window:"JuiceWindow",
47
47
  _alert:"JuiceAlert",
48
- button:'JuiceButton'
48
+ button:'JuiceButton',
49
+ label:'JuiceLabel'
49
50
  },
50
51
  // Modules. You can define custom ones.
51
- _modules: ['i18n','DOM','Event','Ajax','JSONPConnection','Layout','Template','Application','Window','Button','Alert','Confirm'],
52
+ _modules: ['i18n','DOM','Event','Observer','Ajax','JSONPConnection','Layout','Template','Application','Window','Button','Alert','Confirm','Label'],
53
+ // File Extensions for css, javascript, and views.
52
54
  _fileExtensions: {
53
55
  css: "css",
54
56
  js: "js",
@@ -56,7 +58,12 @@ Juice = {
56
58
  viewDir:"Views"
57
59
  },
58
60
  // Set our version information
59
- version: "0.2.0"
61
+ version: "0.2.0",
62
+
63
+ // Extend the Juice object quickly
64
+ extend: function Juice_extend(obj){
65
+ return Juice.Object.extend(Juice,obj);
66
+ }
60
67
  };
61
68
 
62
69
  // Here we add our helper methods to globals.
@@ -133,6 +140,35 @@ Juice.Object.extend(Array.prototype,{
133
140
  return this.select(function Array_compact_select(value) {
134
141
  return value != null;
135
142
  });
143
+ },
144
+ every:function Array_every(fn, thisObj) {
145
+ var scope = thisObj || window;
146
+ for ( var i=0, j=this.length; i < j; ++i ) {
147
+ if ( !fn.call(scope, this[i], i, this) ) {
148
+ return false;
149
+ }
150
+ }
151
+ return true;
152
+ },
153
+ some: function Array_some(fn, thisObj) {
154
+ var scope = thisObj || window;
155
+ for ( var i=0, j=this.length; i < j; ++i ) {
156
+ if ( fn.call(scope, this[i], i, this) ) {
157
+ return true;
158
+ }
159
+ }
160
+ return false;
161
+ },
162
+ filter: function Array_filter(fn, thisObj) {
163
+ var scope = thisObj || window;
164
+ var a = [];
165
+ for ( var i=0, j=this.length; i < j; ++i ) {
166
+ if ( !fn.call(scope, this[i], i, this) ) {
167
+ continue;
168
+ }
169
+ a.push(this[i]);
170
+ }
171
+ return a;
136
172
  }
137
173
  });
138
174
  // Extend the String object
@@ -160,6 +196,7 @@ Juice.Object.extend(Function.prototype,{
160
196
  }
161
197
  }
162
198
  });
199
+ // Our number object
163
200
  Juice.Object.extend(Number.prototype,{
164
201
  toRandomString: function Number_toRandomString(){
165
202
  var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
@@ -171,16 +208,25 @@ Juice.Object.extend(Number.prototype,{
171
208
  }
172
209
  return random;
173
210
  },
211
+ // Convert numbers into hex, base 16
212
+ base: function Number_base(b){
213
+ return this.toString(b);
214
+ },
174
215
  toHex: function Number_toHex(){
175
- return this.toString(16);
176
- }
216
+ return this.base(16);
217
+ },
218
+ toBinary: function Number_toBinary(){
219
+ return this.base(2);
220
+ },
177
221
  });
178
222
 
179
223
  // Get back to the Juice object..
180
- Juice.Object.extend(Juice,{
224
+ Juice.extend({
225
+ // Split strings separated by spaces into an array
181
226
  $W: function Juice_W(str){
182
227
  return str.split(' ');
183
228
  },
229
+ // this is all the code to bind dom loaded event
184
230
  readyList:[],
185
231
  isReady:false,
186
232
  Ready: function Juice_Ready(){
@@ -252,22 +298,24 @@ Juice.Object.extend(Juice,{
252
298
  else Juice.readyList.push(fn);
253
299
 
254
300
  },
301
+ // Set Application title
255
302
  setAppTitle: function Juice_setAppTitle(str){
256
303
  document.title = str;
257
304
  },
305
+ // Select elements by their id
258
306
  $: function Juice_$(sel){
259
307
  return document.getElementById(sel);
260
308
  },
261
-
309
+ // require files, once and only once.
262
310
  Require: function Juice_Require(name){
263
311
  var jsname = name+"js";
264
312
  var head = document.getElementsByTagName('head')[0];
265
313
  if(!Juice.$(jsname)){
266
314
  var theName = name+"."+Juice._fileExtensions.js;
267
315
  var s = document.createElement('script');
268
- s.setAttribute('src', theName);
269
- s.setAttribute('type', "text/javascript");
270
- s.setAttribute('id', jsname);
316
+ s.setAttribute('src',theName);
317
+ s.setAttribute('type',"text/javascript");
318
+ s.setAttribute('id',jsname);
271
319
  head.appendChild(s);
272
320
  }
273
321
  },
@@ -277,7 +325,7 @@ Juice.Object.extend(Juice,{
277
325
  link.setAttribute("href",name);
278
326
  link.setAttribute("type","text/css");
279
327
  link.setAttribute("rel","stylesheet");
280
- document.getElementsByTagName('head')[0].appendChild(link);
328
+ document.getElementsByTagName('head')[0].appendChild(link);
281
329
  },
282
330
  useTheme: function Juice_useTheme(name){
283
331
  name = "Framework/Resources/Themes/" +name;
@@ -285,7 +333,7 @@ Juice.Object.extend(Juice,{
285
333
  },
286
334
  loadModules: function Juice_loadModules(){
287
335
  if(Juice.DOM){
288
- return 'Bye';
336
+ return false;
289
337
  }
290
338
  else{
291
339
  Juice._modules.each(function Juice__modules_each(file){
@@ -294,10 +342,18 @@ Juice.Object.extend(Juice,{
294
342
  }
295
343
  }
296
344
  });
345
+
297
346
  // Bind ready event to add onload event
298
347
  Juice.bindReady();
348
+
299
349
  // Load our app's css
300
350
  Juice.loadAppCSS();
301
- // Alias Juice to JC
302
- window.J = window.JC = window.Juice = Juice;
351
+
352
+ // Alias Juice to JC and put in the global namespace
353
+ window.JC = window.Juice = Juice;
354
+
355
+ // Add yes, no, and nil to global namespace
356
+ window.nil = nil;
357
+ window.NO = NO;
358
+ window.YES = YES;
303
359
  } Juice_init();
@@ -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
+
24
+ Juice.Label = Juice.Class.create();
25
+ Juice.Label.prototype = {
26
+ initialize: function Label_initialize(text,options){
27
+ this.name = (10).toRandomString();
28
+ this.options = options || {};
29
+ var div = document.createElement("div");
30
+ div.setAttribute('id',this.name);
31
+ div.setAttribute('class',Juice._classes.label);
32
+ div.update(text);
33
+ this.element = div;
34
+ },
35
+ contentView: function Label_contentView(){
36
+ return this.element;
37
+ }
38
+ };
@@ -25,6 +25,43 @@ Juice.Layout = Juice.Class.create();
25
25
  Juice.Object.extend(Juice.Layout,{
26
26
  body:document.getElementsByTagName('body')[0],
27
27
  head: document.getElementsByTagName('head')[0],
28
- fullWidth:(typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth),
29
- fullHeight:(typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight)
28
+ fullWidth: function Layout_fullWidth(){return (typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth);},
29
+ fullHeight:function Layout_fullHeight(){ return (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight); },
30
+ getPageSize: function getPageSize(){
31
+ var xScroll, yScroll;
32
+ if (window.innerHeight && window.scrollMaxY) {
33
+ xScroll = document.body.scrollWidth;
34
+ yScroll = window.innerHeight + window.scrollMaxY;
35
+ } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
36
+ xScroll = document.body.scrollWidth;
37
+ yScroll = document.body.scrollHeight;
38
+ } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
39
+ xScroll = document.body.offsetWidth;
40
+ yScroll = document.body.offsetHeight;
41
+ }
42
+ var windowWidth, windowHeight;
43
+ if (self.innerHeight) { // all except Explorer
44
+ windowWidth = self.innerWidth;
45
+ windowHeight = self.innerHeight;
46
+ } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
47
+ windowWidth = document.documentElement.clientWidth;
48
+ windowHeight = document.documentElement.clientHeight;
49
+ } else if (document.body) { // other Explorers
50
+ windowWidth = document.body.clientWidth;
51
+ windowHeight = document.body.clientHeight;
52
+ }
53
+ // for small pages with total height less then height of the viewport
54
+ if(yScroll < windowHeight){
55
+ pageHeight = windowHeight;
56
+ } else {
57
+ pageHeight = yScroll;
58
+ }
59
+ // for small pages with total width less then width of the viewport
60
+ if(xScroll < windowWidth){
61
+ pageWidth = windowWidth;
62
+ } else {
63
+ pageWidth = xScroll;
64
+ }
65
+ return [pageWidth,pageHeight,windowWidth,windowHeight] ;
66
+ }
30
67
  });
@@ -0,0 +1,49 @@
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
+ Juice.Observer = Juice.Class.create();
25
+ Juice.Observer.prototype = {
26
+ initialize: function(){
27
+ this.fns = [];
28
+ },
29
+ subscribe : function(fn) {
30
+ this.fns.push(fn);
31
+ },
32
+ unsubscribe : function(fn) {
33
+ this.fns = this.fns.filter(
34
+ function(el) {
35
+ if ( el !== fn ) {
36
+ return el;
37
+ }
38
+ }
39
+ );
40
+ },
41
+ fire : function(o, thisObj) {
42
+ var scope = thisObj || window;
43
+ this.fns.each(
44
+ function(el) {
45
+ el.call(scope, o);
46
+ }
47
+ );
48
+ }
49
+ };
@@ -53,7 +53,15 @@ body{
53
53
  font-family:Arial,sans-serif;
54
54
  position:relative;
55
55
  }
56
-
56
+ /* Labels */
57
+ .JuiceLabel{
58
+ cursor:default;
59
+ font-family:'Arial';
60
+ line-height:normal;
61
+ white-space:pre;
62
+ font-size:24px;
63
+ font-weight:bold;
64
+ }
57
65
  /* Alerts */
58
66
  .JuiceAlert{
59
67
  background:#FFF;
@@ -24,20 +24,30 @@ Juice.Window = Juice.Class.create();
24
24
  Juice.Window.prototype = {
25
25
  initialize: function Window_initialize(){
26
26
  this.name = (10).toRandomString();
27
- this.theDiv = document.createElement("div");
27
+ this.theDivSuper = document.createElement("div");
28
+ this.theDiv = document.createElement("div");
29
+ this.theDivSuper.appendChild(this.theDiv);
28
30
  var theclass = Juice._classes._window;
29
31
  this.theDiv.setAttribute("id",this.name);
30
32
  this.theDiv.setAttribute("class",theclass);
33
+ var hex_id = this.name;
34
+ var event = new Juice.Event(window,"resize",function SetNewBounds(){
35
+ Juice.$(hex_id).parentNode.setStyle({
36
+ height: Juice.$(hex_id).parentNode.parentNode.getHeight()+"px",
37
+ width: Juice.$(hex_id).parentNode.parentNode.getWidth()+"px"
38
+ });
39
+ });
40
+ event.create();
31
41
  return this;
32
42
  },
33
43
  addSubview: function Window_addSubview(view){
34
44
  Juice.$(this.name).appendChild(view);
35
45
  return this;
36
46
  },
37
- contentView: function Window_contentVoew(){
38
- return this.theDiv;
47
+ contentView: function Window_contentView(){
48
+ return this.theDivSuper;
39
49
  },
40
- setSizing: function Window_setSiting(width,height){
50
+ setSizing: function Window_setSizing(width,height){
41
51
  if(width){
42
52
  Juice.$(this.name).style.width = width+'px';
43
53
  }
@@ -45,6 +55,67 @@ Juice.Window.prototype = {
45
55
  Juice.$(this.name).style.height = height+'px';
46
56
  }
47
57
  return this;
58
+ },
59
+ setPositioning: function Window_setPositioning(top,left){
60
+ var hex_id = this.name;
61
+ var the_super_height = Juice.$(hex_id ).parentNode.parentNode.getHeight();
62
+ var the_super_width = Juice.$(hex_id ).parentNode.parentNode.getWidth();
63
+ Juice.$(hex_id ).parentNode.setStyle({
64
+ height: the_super_height +'px',
65
+ width: the_super_width +'px',
66
+ position:'relative'
67
+ });
68
+ Juice.$(hex_id ).parentNode.parentNode.setStyle({display:'block','z-index':200,position:'relative'});
69
+ Juice.$(hex_id ).setStyle({position:'absolute'});
70
+ if(Juice.Object.isString(top)){
71
+ switch(top){
72
+ case("top"):
73
+ top = 10;
74
+ break;
75
+ case("center"):
76
+ top = (Juice.$(this.name).parentNode.parentNode.getHeight()-Juice.$(this.name).getHeight())/2;
77
+ break;
78
+ case("bottom"):
79
+ top = Juice.$(this.name).parentNode.parentNode.getHeight()-10;
80
+ break;
81
+ }
82
+ }
83
+ // This doesn't create width unless explicit for some reason. please fix?
84
+ if(Juice.Object.isString(left)){
85
+ switch(left){
86
+ case("left"):
87
+ left = parseInt(10)
88
+ break;
89
+ case("center"):
90
+ left = (Juice.$(this.name).parentNode.parentNode.getWidth()/2)-(Juice.$(this.name).getWidth()/2);
91
+ break;
92
+ case("right"):
93
+ left = (Juice.$(this.name).parentNode.parentNode.getWidth()/2)-(Juice.$(this.name).getWidth());
94
+ break;
95
+ }
96
+ }
97
+ Juice.Application.observer.subscribe(function Resize_item(data){
98
+ var top = (Juice.$(hex_id).parentNode.parentNode.getHeight()-Juice.$(hex_id).getHeight())/2;
99
+ var left = (Juice.$(hex_id).parentNode.parentNode.getWidth()/2)-(Juice.$(hex_id).getWidth()/2);
100
+ Juice.$(hex_id ).setStyle({
101
+ top:top+"px",
102
+ left:left+"px"
103
+ });
104
+ });
105
+ var event = new Juice.Event(window,"load",function SetPos(){
106
+ if(top){
107
+ Juice.$(hex_id ).setStyle({top:top+'px'});
108
+ }
109
+ if(left){
110
+ Juice.$(hex_id ).setStyle({left:left+'px'});
111
+ }
112
+ });
113
+ event.create();
114
+ return this;
115
+ },
116
+ setTextAlign: function Window_setTextAlign(str){
117
+ Juice.$(this.name).style.textAlign = str;
118
+ return this;
48
119
  },
49
120
  setStringValue: function Window_setStringValue(text){
50
121
  Juice.$(this.name).innerHTML = text;
@@ -59,15 +130,15 @@ Juice.Window.prototype = {
59
130
  }
60
131
  },
61
132
  setBackground: function Window_setBackground(color){
62
- Juice.$(this.name).style.background = color;
133
+ Juice.$(this.name).parentNode.setStyle({background:color});
63
134
  return this;
64
135
  },
65
136
  setForeground: function Window_setForeground(color){
66
- Juice.$(this.name).style.color = color;
137
+ Juice.$(this.name).setStyle({color:color});
67
138
  return this;
68
139
  },
69
140
  element: function Window_element(){
70
- return this.theDiv;
141
+ return Juice.$(this.name);
71
142
  }
72
143
  };
73
144
 
@@ -11,13 +11,13 @@ creating desktop applications that run in the browser.
11
11
 
12
12
  == INSTALL:
13
13
 
14
- gem install juice
14
+ $ gem install juice
15
15
 
16
16
  == Getting Started:
17
17
 
18
- juice app \n
19
- cd app \n
20
- juice server \n\n
18
+ $ juice app
19
+ $ cd app
20
+ $ juice server
21
21
 
22
22
  Then navigate to http://localhost:338 in your favorite web browser!
23
23
 
@@ -1,18 +1,20 @@
1
+ // This is required by all Juice Applications
2
+
3
+ // Create the application
1
4
  var app = new Juice.Application();
2
- var theWindow = new Juice.Window("theWindow");
3
- app.addSubview(theWindow.contentView());
4
- theWindow.setStringValue("this is test").setSizing(Juice.Layout.fullWidth,Juice.Layout.fullHeight).setForeground("white");
5
5
 
6
- var alert_button = new Juice.Button('Test Alert',function AlertButtonClick(){
7
- var alert = new Juice.Alert({title: 'Alert Test', text:'This demonstrates how to use an alert'});
8
- alert.addButton('Cancel',function(){alert.remove();});
9
- });
6
+ // This is not required by Juice Applications, but if you want to see anything then you'll do it!
7
+
8
+ // Create the main window
9
+ var theWindow = new Juice.Window();
10
+ // and add it to the root of the application
11
+ app.addSubview(theWindow.contentView());
10
12
 
11
- var confirm_button = new Juice.Button('Test Confirm',function AlertButtonClick(){
12
- var confirm = new Juice.Confirm({text:'This demonstrates how to use a confirm',callback:function ConfirmButtonCallback(bool){
13
- alert(bool);
14
- }});
15
- });
13
+ // Here you can set the properties of the window
14
+ theWindow.setTextAlign("center");
15
+ // You can also chain them since each function returns the window object
16
+ theWindow.setSizing(200).setPositioning("center","center").setBackground("white").setForeground("black");
16
17
 
17
- theWindow.addSubview(alert_button.contentView());
18
- theWindow.addSubview(confirm_button.contentView());
18
+ // and say something
19
+ var label = new Juice.Label("Hello, World!");
20
+ theWindow.addSubview(label.contentView());
@@ -1,26 +1,4 @@
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
- var JuiceApp = {
24
- developer: "Justin Baker",
25
- files:['NewFile.js'] // This is a list of files not in Framework/Juice.*.js, or appController.js .
26
- };
1
+ callback({
2
+ 'developer': "Justin Baker",
3
+ 'files':['NewFile.js']
4
+ });
@@ -0,0 +1,28 @@
1
+ /* This example shows a simple example of Juice's class system */
2
+
3
+ // Create a new class
4
+ var Person = Juice.Class.create();
5
+
6
+ // Add instance methods
7
+ Person.prototype = {
8
+
9
+ // initialize is the function called when an instance of the class is created
10
+ initialize: function(name){
11
+ this.name = name;
12
+ },
13
+ shout: function(){
14
+ alert(this.name+' says AHHH!!');
15
+ }
16
+ };
17
+
18
+ var jeff = new Person("Jeff");
19
+ jeff.shout(); // Jeff says AHHH!!
20
+
21
+ // Static methods for the class can be directly assigned to it
22
+
23
+ Person.country = "United States";
24
+
25
+ // and now you can access it through
26
+ Person.country;
27
+
28
+ // but not instances
@@ -0,0 +1,11 @@
1
+ var alert_button = new Juice.Button('Test Alert',function AlertButtonClick(){
2
+ var alert = new Juice.Alert({title: 'Alert Test', text:'This demonstrates how to use an alert'});
3
+ alert.addButton('Cancel',function(){alert.remove();});
4
+ });
5
+
6
+ var confirm_button = new Juice.Button('Test Confirm',function AlertButtonClick(){
7
+ var confirm = new Juice.Confirm({text:'This demonstrates how to use a confirm',callback:function ConfirmButtonCallback(bool){
8
+ alert(bool);
9
+ }});
10
+ });
11
+ s
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module Juice
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.1'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: juice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Baker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-21 00:00:00 -05:00
12
+ date: 2010-01-23 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -53,6 +53,8 @@ files:
53
53
  - "bin/juice "
54
54
  - "lib/juice.rb "
55
55
  - "lib/JSquish.rb "
56
+ - "examples/controls/controls.js "
57
+ - "examples/classes/Person.js "
56
58
  - "script/generate.cmd "
57
59
  - "script/generate "
58
60
  - "script/destroy.cmd "
@@ -60,7 +62,7 @@ files:
60
62
  - "script/console.cmd "
61
63
  - "script/console "
62
64
  - "StarterApplication/Views/example.juice "
63
- - "StarterApplication/README "
65
+ - "StarterApplication/README.rdoc "
64
66
  - "StarterApplication/LICENSE "
65
67
  - "StarterApplication/index.html "
66
68
  - "StarterApplication/Framework/Window.js "
@@ -72,7 +74,9 @@ files:
72
74
  - "StarterApplication/Framework/Resources/Themes/Default/images/button-sprite.png "
73
75
  - "StarterApplication/Framework/Resources/images/Thumbs.db "
74
76
  - "StarterApplication/Framework/Resources/images/spinner.gif "
77
+ - "StarterApplication/Framework/Observer.js "
75
78
  - "StarterApplication/Framework/Layout.js "
79
+ - "StarterApplication/Framework/Label.js "
76
80
  - "StarterApplication/Framework/Juice.js "
77
81
  - "StarterApplication/Framework/JSONPConnection.js "
78
82
  - "StarterApplication/Framework/Image.js "