juice 0.2.1 → 0.2.2

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.
@@ -13,13 +13,10 @@ script/destroy.cmd
13
13
  script/destroy
14
14
  script/console.cmd
15
15
  script/console
16
- StarterApplication/Views/example.juice
17
16
  StarterApplication/README.rdoc
18
17
  StarterApplication/LICENSE
19
18
  StarterApplication/index.html
20
19
  StarterApplication/Framework/Window.js
21
- StarterApplication/Framework/View.js
22
- StarterApplication/Framework/Template.js
23
20
  StarterApplication/Framework/Resources/Themes/Default.css
24
21
  StarterApplication/Framework/Resources/Themes/Default/images/Thumbs.db
25
22
  StarterApplication/Framework/Resources/Themes/Default/images/spinner.gif
@@ -36,6 +33,7 @@ StarterApplication/Framework/i18n.js
36
33
  StarterApplication/Framework/Event.js
37
34
  StarterApplication/Framework/DOM.js
38
35
  StarterApplication/Framework/Cookie.js
36
+ StarterApplication/Framework/Console.js
39
37
  StarterApplication/Framework/Confirm.js
40
38
  StarterApplication/Framework/Button.js
41
39
  StarterApplication/Framework/Application.js
@@ -4,7 +4,7 @@
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- This is version 0.2.0 of Juice Js Framework
7
+ This is version 0.2.2 of Juice Js Framework
8
8
 
9
9
  Juice is a framework similar to Sproutcore and Cappuccino in that it is centered towards
10
10
  creating desktop applications that run in the browser.
@@ -49,11 +49,11 @@ Juice.Application.prototype = {
49
49
  };
50
50
  Juice.Application.observer = new Juice.Observer();
51
51
  Juice.Application._bindEvent = function(){
52
- var event = new Juice.Event(window,"resize",function SetNewBounds(){
53
- console.log("Window Resize");
52
+
53
+ var event = new Juice.Event(window,"resize",function set_new_bounds(){
54
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
55
  });
56
+
57
57
  event.create();
58
58
  }
59
59
  Juice.Application._bindEvent();
@@ -0,0 +1,70 @@
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.Console = Juice.Class.create();
24
+ Juice.Console.prototype = {
25
+ initialize: function Console_initialize(){
26
+ this.container = document.createElement("div");
27
+ this.error_list = document.createElement("ul");
28
+ this.title = document.createElement("h2");
29
+ this.title.setAttribute('id','JuiceConsoleTitle');
30
+ this.title.innerHTML = "Juice Error Console";
31
+ this.error_list.setAttribute('id','JuiceConsoleList');
32
+ this.container.setAttribute('id','JuiceConsole');
33
+ this.container.appendChild(this.title);
34
+ this.container.appendChild(this.error_list);
35
+ document.getElementsByTagName('body')[0].appendChild(this.container);
36
+ Juice.$('JuiceConsoleTitle').setStyle({
37
+ fontSize:"20px",
38
+ marginBottom:"20px"
39
+ });
40
+ Juice.$('JuiceConsole').setStyle({
41
+ top:"80px",
42
+ right:"40px",
43
+ width:"400px",
44
+ position:"absolute",
45
+ background:"rgba(0,0,0,0.8)",
46
+ "zIndex":"10000",
47
+ padding:"20px",
48
+ MozBorderRadius:"5px",
49
+ color:"#FFF",
50
+ });
51
+ }
52
+ };
53
+ Juice.Console.addError = function Juice_Console_addError(text,options){
54
+ var error = document.createElement("li");
55
+ error.innerHTML = text;
56
+ Juice.$('JuiceConsoleList').appendChild(error);
57
+ error.style.padding = "10px ";
58
+ error.style.listStyle="none" ;
59
+ error.style.display='block';
60
+ error.style.background="rgba(0,0,0,0.8)";
61
+ error.style.MozBorderRadius="5px";
62
+ error.style.marginBottom="5px";
63
+ };
64
+ if(Juice._debug){
65
+ new Juice.Console();
66
+ window.onerror = function Init_Console(_message,_file,_line){
67
+ Juice.Console.addError("Error: "+_message);
68
+ console.log('error');
69
+ }
70
+ }
@@ -49,7 +49,7 @@ Juice = {
49
49
  label:'JuiceLabel'
50
50
  },
51
51
  // Modules. You can define custom ones.
52
- _modules: ['i18n','DOM','Event','Observer','Ajax','JSONPConnection','Layout','Template','Application','Window','Button','Alert','Confirm','Label'],
52
+ _modules: ['DOM','Console','i18n','Event','Observer','Ajax','JSONPConnection','Layout','Application','Window','Button','Alert','Confirm','Label'],
53
53
  // File Extensions for css, javascript, and views.
54
54
  _fileExtensions: {
55
55
  css: "css",
@@ -58,8 +58,9 @@ Juice = {
58
58
  viewDir:"Views"
59
59
  },
60
60
  // Set our version information
61
- version: "0.2.0",
62
-
61
+ version: "0.2.2",
62
+ // Set debugging to true
63
+ _debug:true,
63
64
  // Extend the Juice object quickly
64
65
  extend: function Juice_extend(obj){
65
66
  return Juice.Object.extend(Juice,obj);
@@ -183,19 +184,6 @@ Juice.Object.extend(String.prototype,{
183
184
  return parseInt(this,16);
184
185
  }
185
186
  });
186
- Juice.Object.extend(Function.prototype,{
187
- unless:function Function_unless(fn){
188
- if(fn.isFunction()){
189
- var cond = fn.call();
190
- }
191
- else var cond = fn;
192
- if(cond){
193
- var args = arguments;
194
- alert(args);
195
- this.call(args);
196
- }
197
- }
198
- });
199
187
  // Our number object
200
188
  Juice.Object.extend(Number.prototype,{
201
189
  toRandomString: function Number_toRandomString(){
@@ -303,8 +291,8 @@ Juice.extend({
303
291
  document.title = str;
304
292
  },
305
293
  // Select elements by their id
306
- $: function Juice_$(sel){
307
- return document.getElementById(sel);
294
+ $: function Juice_$(id){
295
+ return document.getElementById(id);
308
296
  },
309
297
  // require files, once and only once.
310
298
  Require: function Juice_Require(name){
@@ -31,7 +31,7 @@ Juice.Window.prototype = {
31
31
  this.theDiv.setAttribute("id",this.name);
32
32
  this.theDiv.setAttribute("class",theclass);
33
33
  var hex_id = this.name;
34
- var event = new Juice.Event(window,"resize",function SetNewBounds(){
34
+ var event = new Juice.Event(window,"resize",function set_new_bounds(){
35
35
  Juice.$(hex_id).parentNode.setStyle({
36
36
  height: Juice.$(hex_id).parentNode.parentNode.getHeight()+"px",
37
37
  width: Juice.$(hex_id).parentNode.parentNode.getWidth()+"px"
@@ -94,7 +94,7 @@ Juice.Window.prototype = {
94
94
  break;
95
95
  }
96
96
  }
97
- Juice.Application.observer.subscribe(function Resize_item(data){
97
+ Juice.Application.observer.subscribe(function Window_centering(data){
98
98
  var top = (Juice.$(hex_id).parentNode.parentNode.getHeight()-Juice.$(hex_id).getHeight())/2;
99
99
  var left = (Juice.$(hex_id).parentNode.parentNode.getWidth()/2)-(Juice.$(hex_id).getWidth()/2);
100
100
  Juice.$(hex_id ).setStyle({
@@ -102,7 +102,7 @@ Juice.Window.prototype = {
102
102
  left:left+"px"
103
103
  });
104
104
  });
105
- var event = new Juice.Event(window,"load",function SetPos(){
105
+ var event = new Juice.Event(window,"load",function object_position_set(){
106
106
  if(top){
107
107
  Juice.$(hex_id ).setStyle({top:top+'px'});
108
108
  }
@@ -118,11 +118,16 @@ Juice.Window.prototype = {
118
118
  return this;
119
119
  },
120
120
  setStringValue: function Window_setStringValue(text){
121
- Juice.$(this.name).innerHTML = text;
121
+ try{
122
+ Juice.$(this.name).innerHTML = text;
123
+ }
124
+ catch(e){
125
+ Juice.Console.addError(e);
126
+ }
122
127
  return this;
123
128
  },
124
- setCenter: function Window_setCenter(boolean){
125
- if(boolean){
129
+ setCenter: function Window_setCenter(aBoolean){
130
+ if(aBoolean){
126
131
  Juice.$(this.name).setStyle({
127
132
  marginLeft:"auto",
128
133
  marginRight:"auto"
@@ -130,7 +135,7 @@ Juice.Window.prototype = {
130
135
  }
131
136
  },
132
137
  setBackground: function Window_setBackground(color){
133
- Juice.$(this.name).parentNode.setStyle({background:color});
138
+ Juice.$(this.name).parentNode.setStyle({background:color});
134
139
  return this;
135
140
  },
136
141
  setForeground: function Window_setForeground(color){
@@ -4,7 +4,7 @@
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- This is version 0.2.0 of Juice Js Framework
7
+ This is version 0.2.2 of Juice Js Framework
8
8
 
9
9
  Juice is a framework similar to Sproutcore and Cappuccino in that it is centered towards
10
10
  creating desktop applications that run in the browser.
@@ -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.1'
5
+ VERSION = '0.2.2'
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.1
4
+ version: 0.2.2
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-23 00:00:00 -05:00
12
+ date: 2010-01-28 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 2.3.2
34
34
  version:
35
35
  description: |-
36
- This is version 0.2.0 of Juice Js Framework
36
+ This is version 0.2.2 of Juice Js Framework
37
37
 
38
38
  Juice is a framework similar to Sproutcore and Cappuccino in that it is centered towards
39
39
  creating desktop applications that run in the browser.
@@ -61,13 +61,10 @@ files:
61
61
  - "script/destroy "
62
62
  - "script/console.cmd "
63
63
  - "script/console "
64
- - "StarterApplication/Views/example.juice "
65
64
  - "StarterApplication/README.rdoc "
66
65
  - "StarterApplication/LICENSE "
67
66
  - "StarterApplication/index.html "
68
67
  - "StarterApplication/Framework/Window.js "
69
- - "StarterApplication/Framework/View.js "
70
- - "StarterApplication/Framework/Template.js "
71
68
  - "StarterApplication/Framework/Resources/Themes/Default.css "
72
69
  - "StarterApplication/Framework/Resources/Themes/Default/images/Thumbs.db "
73
70
  - "StarterApplication/Framework/Resources/Themes/Default/images/spinner.gif "
@@ -84,6 +81,7 @@ files:
84
81
  - "StarterApplication/Framework/Event.js "
85
82
  - "StarterApplication/Framework/DOM.js "
86
83
  - "StarterApplication/Framework/Cookie.js "
84
+ - "StarterApplication/Framework/Console.js "
87
85
  - "StarterApplication/Framework/Confirm.js "
88
86
  - "StarterApplication/Framework/Button.js "
89
87
  - "StarterApplication/Framework/Application.js "
@@ -119,6 +117,6 @@ rubyforge_project: juice
119
117
  rubygems_version: 1.3.5
120
118
  signing_key:
121
119
  specification_version: 3
122
- summary: This is version 0.2.0 of Juice Js Framework Juice is a framework similar to Sproutcore and Cappuccino in that it is centered towards creating desktop applications that run in the browser.
120
+ summary: This is version 0.2.2 of Juice Js Framework Juice is a framework similar to Sproutcore and Cappuccino in that it is centered towards creating desktop applications that run in the browser.
123
121
  test_files: []
124
122
 
@@ -1,82 +0,0 @@
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 O\\THERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
-
23
- */
24
- Juice.Template = Juice.Class.create();
25
- Juice.Template.prototype = {
26
- initialize: function Template_initialize(url,data){
27
- // url is taken from example to views/example.juice
28
- url = Juice._fileExtensions.viewDir+"/"+url+"."+Juice._fileExtensions.view;
29
- // Request the template data
30
- var request = new Juice.Ajax(url);
31
- // Get the response
32
- var final_parsed_text = request.response().responseText;
33
-
34
- // This bit was taken from j.resig's mini templates . Thanks John!
35
- final_parsed_text = final_parsed_text.replace(/[\r\t\n]/g, " ")
36
- .split("<%").join("\t")
37
- .replace(/((^|%>)[^\t]*)'/g, "$1\r")
38
- .replace(/\t=(.*?)%>/g, "puts($1);")
39
- .split("%>").join("")
40
- .split("\r").join("\\'");
41
- // Because we love ruby, no ()'s in fors. now do for.. do.. end..
42
- final_parsed_text = final_parsed_text.replace(/for(.*|\s)do(.*|\s)end/,"for($1){$2}");
43
- // Because we love ruby, no ()'s in each's. now do for.. do.. end..
44
- final_parsed_text = final_parsed_text.replace(/each(.*|\s)do(.*|\s) \|([a-zA-Z]+)\|(.*|\s)end/,"each(function($3){$4});");
45
- // Create the script, add text/javascript type
46
- var script = document.createElement('script');
47
- script.writeAttributes({
48
- type: 'text/javascript'
49
- });
50
- // Begin the code, copy all in data to local namespace
51
- var code = "(function(data){ for(var prop in data){this[prop] = data[prop];}";
52
- // define functions used in templates
53
- var our_functions = {
54
- puts: function(str){
55
- alert(str);
56
- },
57
- link_to: function(text,href){
58
- var a = document.createElement("a");
59
- a.writeAttributes({
60
- href:href
61
- }).update(text);
62
- return a;
63
- }
64
- };
65
- // Copy functions
66
- for(var value in our_functions){
67
- code+= "var "+value+"="+our_functions[value].toSource()+";";;
68
- }
69
- // Take the data and get code
70
- data = data || {};
71
- code+=final_parsed_text+"})("+data.toSource()+");";
72
- // code is now parsed
73
- script.update(code);
74
- Juice.Layout.head.appendChild(script);
75
- this.script = script;
76
- console.log(code);
77
- },
78
- remove: function(){
79
- this.script.remove();
80
- }
81
-
82
- };
@@ -1,51 +0,0 @@
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.View = Juice.Class.create();
24
- Juice.View.prototype = {
25
- initialize: function View_initialize(url,data){
26
- this.url = url;
27
- this.data = data;
28
- },
29
- render: function View_render(){
30
- var data = this.data || {};
31
- var url = "/"+Juice._fileExtensions.viewDir+this.url+"."+Juice._fileExtensions.view;
32
- var _request;
33
- if (window.XMLHttpRequest){
34
- // code for IE7+, Firefox, Chrome, Opera, Safari
35
- _request=new XMLHttpRequest();
36
- }
37
- else{
38
- // code for IE6, IE5
39
- _request=new ActiveXObject("Microsoft.XMLHTTP");
40
- }
41
- _request.open("GET",url,false);
42
- _request.send(null);
43
- var template = _request.responseText;
44
- return template.replace(/\{([\w\.]*)}/g, function(str, key){
45
- var keys = key.split("."), value = data[keys.shift()];
46
- keys.each( function(){ value = value[this] })
47
- return value
48
- })
49
- }
50
- };
51
-
@@ -1 +0,0 @@
1
- <%= hi %>