juice 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +4 -0
- data/StarterApplication/Framework/Juice.Ajax.js +67 -0
- data/StarterApplication/Framework/Juice.Alert.js +3 -3
- data/StarterApplication/Framework/Juice.Application.js +2 -2
- data/StarterApplication/Framework/Juice.Button.js +4 -4
- data/StarterApplication/Framework/Juice.Confirm.js +2 -2
- data/StarterApplication/Framework/Juice.Cookie.js +3 -3
- data/StarterApplication/Framework/Juice.DOM.js +79 -59
- data/StarterApplication/Framework/Juice.Event.js +3 -3
- data/StarterApplication/Framework/Juice.Image.js +1 -1
- data/StarterApplication/Framework/Juice.Layout.js +2 -1
- data/StarterApplication/Framework/Juice.Template.js +82 -0
- data/StarterApplication/Framework/Juice.View.js +51 -0
- data/StarterApplication/Framework/Juice.Window.js +9 -9
- data/StarterApplication/Framework/Juice.i18n.js +5 -5
- data/StarterApplication/Framework/Juice.js +53 -77
- data/StarterApplication/Views/example.juice +1 -0
- data/StarterApplication/appController.js +3 -3
- data/StarterApplication/index.html +1 -1
- data/StarterApplication/juice.app +23 -2
- data/bin/juice +9 -5
- data/bin/juice +9 -5
- data/lib/juice.rb +1 -1
- metadata +6 -2
data/Manifest.txt
CHANGED
@@ -11,6 +11,7 @@ script/destroy.cmd
|
|
11
11
|
script/destroy
|
12
12
|
script/console.cmd
|
13
13
|
script/console
|
14
|
+
StarterApplication/Views/example.juice
|
14
15
|
StarterApplication/README
|
15
16
|
StarterApplication/LICENSE
|
16
17
|
StarterApplication/juice.app
|
@@ -22,6 +23,8 @@ StarterApplication/Framework/Resources/Themes/Default/images/button-sprite.png
|
|
22
23
|
StarterApplication/Framework/Resources/images/Thumbs.db
|
23
24
|
StarterApplication/Framework/Resources/images/spinner.gif
|
24
25
|
StarterApplication/Framework/Juice.Window.js
|
26
|
+
StarterApplication/Framework/Juice.View.js
|
27
|
+
StarterApplication/Framework/Juice.Template.js
|
25
28
|
StarterApplication/Framework/Juice.Layout.js
|
26
29
|
StarterApplication/Framework/Juice.JSONPConnection.js
|
27
30
|
StarterApplication/Framework/Juice.js
|
@@ -34,4 +37,5 @@ StarterApplication/Framework/Juice.Confirm.js
|
|
34
37
|
StarterApplication/Framework/Juice.Button.js
|
35
38
|
StarterApplication/Framework/Juice.Application.js
|
36
39
|
StarterApplication/Framework/Juice.Alert.js
|
40
|
+
StarterApplication/Framework/Juice.Ajax.js
|
37
41
|
StarterApplication/appController.js
|
@@ -0,0 +1,67 @@
|
|
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.Ajax = Juice.Class.create();
|
25
|
+
Juice.Ajax.prototype = {
|
26
|
+
initialize: function Ajax_initialize(url,options){
|
27
|
+
this.url = url;
|
28
|
+
default_options = {
|
29
|
+
method: 'get',
|
30
|
+
asynchronous: false,
|
31
|
+
contentType: 'application/x-www-form-urlencoded',
|
32
|
+
encoding: 'UTF-8',
|
33
|
+
parameters: {},
|
34
|
+
evalJSON: true,
|
35
|
+
evalJS: true
|
36
|
+
};
|
37
|
+
this.options = options || default_options;
|
38
|
+
var _request,params ='',parameters = this.options.parameters;
|
39
|
+
for(var prop in parameters){
|
40
|
+
var first = function(){
|
41
|
+
var first = [];
|
42
|
+
for(var prop in parameters){
|
43
|
+
first.push(prop)
|
44
|
+
}
|
45
|
+
return first[0];
|
46
|
+
};
|
47
|
+
var sep = (prop == first()) ? "?" : "&";
|
48
|
+
params += sep+prop+"="+this.options.parameters[prop];
|
49
|
+
}
|
50
|
+
if(XMLHttpRequest){
|
51
|
+
// Support ajax good!
|
52
|
+
_request = new XMLHttpRequest();
|
53
|
+
}
|
54
|
+
else if(ActiveXObject('Msxml2.XMLHTTP')){
|
55
|
+
_request = new ActiveXObject('Msxml2.XMLHTTP');
|
56
|
+
}
|
57
|
+
else if(ActiveXObject('Microsoft.XMLHTTP')){
|
58
|
+
_request = new ActiveXObject('Microsoft.XMLHTTP');
|
59
|
+
}
|
60
|
+
_request.open(this.options.method,url,this.options.asynchronous);
|
61
|
+
_request.send(null);
|
62
|
+
this._request = _request;
|
63
|
+
},
|
64
|
+
response: function(){
|
65
|
+
return this._request;
|
66
|
+
}
|
67
|
+
};
|
@@ -23,7 +23,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
|
24
24
|
Juice.Alert = Juice.Class.create();
|
25
25
|
Juice.Alert.prototype = {
|
26
|
-
initialize: function(options){
|
26
|
+
initialize: function Alert_initialize(options){
|
27
27
|
this.name = (10).toRandomString();
|
28
28
|
this.options = options || {};
|
29
29
|
this.options.text = this.options.text || "Empty";
|
@@ -49,10 +49,10 @@ Juice.Alert.prototype = {
|
|
49
49
|
display:'block'
|
50
50
|
});
|
51
51
|
},
|
52
|
-
remove: function(){
|
52
|
+
remove: function Alert_remove(){
|
53
53
|
this.element.remove();
|
54
54
|
},
|
55
|
-
addButton: function(content,fn){
|
55
|
+
addButton: function Alert_addButton(content,fn){
|
56
56
|
var button = new Juice.Button(content,fn);
|
57
57
|
this.element.appendChild(button.contentView());
|
58
58
|
}
|
@@ -22,10 +22,10 @@ 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(){
|
25
|
+
initialize: function Application_initialize(){
|
26
26
|
return this;
|
27
27
|
},
|
28
|
-
addSubview: function(view){
|
28
|
+
addSubview: function Application_addSubview(view){
|
29
29
|
var body = Juice.Layout.body;
|
30
30
|
body.appendChild(view);
|
31
31
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Juice.Button = Juice.Class.create();
|
2
2
|
Juice.Button.prototype={
|
3
|
-
initialize: function(content,fn){
|
3
|
+
initialize: function Button_initialize(content,fn){
|
4
4
|
this.name = (10).toRandomString();
|
5
5
|
this.content = content || "Click"
|
6
6
|
var button = document.createElement("button");
|
@@ -9,17 +9,17 @@ Juice.Button.prototype={
|
|
9
9
|
id:this.name
|
10
10
|
});
|
11
11
|
if(fn){
|
12
|
-
button.observe("click",function(event){
|
12
|
+
button.observe("click",function Button_call_fn(event){
|
13
13
|
fn.call();
|
14
14
|
});
|
15
15
|
}
|
16
16
|
button.innerHTML = this.content;
|
17
17
|
this.button = button;
|
18
18
|
},
|
19
|
-
remove: function(){
|
19
|
+
remove: function Button_remove(){
|
20
20
|
Juice.$(this.name).remove();
|
21
21
|
},
|
22
|
-
contentView: function(){
|
22
|
+
contentView: function Button_contentView(){
|
23
23
|
return this.button;
|
24
24
|
}
|
25
25
|
};
|
@@ -23,7 +23,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
|
24
24
|
Juice.Confirm = Juice.Class.create();
|
25
25
|
Juice.Confirm.prototype = {
|
26
|
-
initialize: function(options){
|
26
|
+
initialize: function Confirm_initialize(options){
|
27
27
|
options.title = 'Confirm';
|
28
28
|
var alert = new Juice.Alert(options);
|
29
29
|
alert.addButton('Okay',function(){
|
@@ -36,7 +36,7 @@ Juice.Confirm.prototype = {
|
|
36
36
|
});
|
37
37
|
|
38
38
|
},
|
39
|
-
remove: function(){
|
39
|
+
remove: function Confirm_remove(){
|
40
40
|
this.element.remove();
|
41
41
|
}
|
42
42
|
};
|
@@ -22,7 +22,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
23
23
|
Juice.Cookie = Juice.Class.create();
|
24
24
|
Juice.Cookie.prototype = {
|
25
|
-
initialize:function(name,value,days) {
|
25
|
+
initialize:function Cookie_initialize(name,value,days) {
|
26
26
|
this.name = name;
|
27
27
|
this.value = value;
|
28
28
|
if (days) {
|
@@ -33,7 +33,7 @@ Juice.Cookie.prototype = {
|
|
33
33
|
else var expires = "";
|
34
34
|
document.cookie = this.name+"="+this.value+expires+"; path=/";
|
35
35
|
},
|
36
|
-
read:function() {
|
36
|
+
read:function Cookie_read() {
|
37
37
|
var nameEQ = this.name + "=";
|
38
38
|
var ca = document.cookie.split(';');
|
39
39
|
for(var i=0;i < ca.length;i++) {
|
@@ -43,7 +43,7 @@ Juice.Cookie.prototype = {
|
|
43
43
|
}
|
44
44
|
return null;
|
45
45
|
},
|
46
|
-
erase:function() {
|
46
|
+
erase:function Cookie_erase() {
|
47
47
|
new Juice.Cookie(this.name,"",-1);
|
48
48
|
}
|
49
49
|
};
|
@@ -20,50 +20,50 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
20
20
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
*/
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
getWidth: function(element){
|
23
|
+
function Juice_DOM_init(){
|
24
|
+
var core_functions = {
|
25
|
+
getHeight: function Element_getHeight(element){
|
26
|
+
var el = element || this;
|
27
|
+
var height = el.getStyle("height");
|
28
|
+
if(height=='auto'){
|
29
|
+
height = el.offsetHeight;
|
30
|
+
}
|
31
|
+
else{
|
32
|
+
height = parseInt(height);
|
33
|
+
}
|
34
|
+
var pt = parseInt(el.getStyle("padding-top"));
|
35
|
+
var pb = parseInt(el.getStyle("padding-bottom"));
|
36
|
+
var bt = el.getStyle("border-top-width");
|
37
|
+
var bb = el.getStyle("border-bottom-width");
|
38
|
+
switch(bt){
|
39
|
+
case 'thin':
|
40
|
+
bt=2;
|
41
|
+
break;
|
42
|
+
case 'medium':
|
43
|
+
bt=4;
|
44
|
+
break;
|
45
|
+
case 'thick':
|
46
|
+
bt=6;
|
47
|
+
break;
|
48
|
+
default:
|
49
|
+
bt = parseInt(bt);
|
50
|
+
}
|
51
|
+
switch(bb){
|
52
|
+
case 'thin':
|
53
|
+
bb=2;
|
54
|
+
break;
|
55
|
+
case 'medium':
|
56
|
+
bb=4;
|
57
|
+
break;
|
58
|
+
case 'thick':
|
59
|
+
bb=6;
|
60
|
+
break;
|
61
|
+
default:
|
62
|
+
bb = parseInt(bb);
|
63
|
+
}
|
64
|
+
return height+pt+pb+bt+bb;
|
65
|
+
},
|
66
|
+
getWidth: function Element_getWidth(element){
|
67
67
|
var el = element || this;
|
68
68
|
var width = el.getStyle("width");
|
69
69
|
if(width=='auto'){
|
@@ -104,12 +104,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
104
104
|
}
|
105
105
|
return width+pl+pr+bl+br;
|
106
106
|
},
|
107
|
-
observe: function(name,fn){
|
107
|
+
observe: function Element_observe(name,fn){
|
108
108
|
var event = new Juice.Event(this,name,fn);
|
109
109
|
event.create();
|
110
110
|
return this;
|
111
111
|
},
|
112
|
-
getStyle: function(strCssRule){
|
112
|
+
getStyle: function Element_getStyle(strCssRule){
|
113
113
|
var strValue;
|
114
114
|
if(document.defaultView && document.defaultView.getComputedStyle){
|
115
115
|
strValue = document.defaultView.getComputedStyle(this, "").getPropertyValue(strCssRule);
|
@@ -122,35 +122,35 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
122
122
|
}
|
123
123
|
return strValue;
|
124
124
|
},
|
125
|
-
remove: function(){
|
125
|
+
remove: function Element_remove(){
|
126
126
|
this.parentNode.removeChild(this);
|
127
127
|
},
|
128
|
-
visible: function() {
|
128
|
+
visible: function Element_visible() {
|
129
129
|
return this.style.display != 'none';
|
130
130
|
},
|
131
|
-
toggle: function() {
|
131
|
+
toggle: function Element_toggle() {
|
132
132
|
core_functions[this.visible() ? 'hide' : 'show'](this);
|
133
133
|
return this;
|
134
134
|
},
|
135
|
-
hide: function() {
|
135
|
+
hide: function Element_hide() {
|
136
136
|
this.style.display = 'none';
|
137
137
|
return this;
|
138
138
|
},
|
139
|
-
show: function() {
|
139
|
+
show: function Element_show() {
|
140
140
|
this.style.display = '';
|
141
141
|
return this;
|
142
142
|
},
|
143
|
-
setStyle:function(styles){
|
143
|
+
setStyle:function Element_setStyle(styles){
|
144
144
|
for(var prop in styles){
|
145
145
|
this.style[prop] = styles[prop];
|
146
146
|
}
|
147
147
|
},
|
148
|
-
writeAttributes:function(attr){
|
148
|
+
writeAttributes:function Element_writeAttributes(attr){
|
149
149
|
for(var prop in attr){
|
150
150
|
this.setAttribute(prop,attr[prop])
|
151
151
|
}
|
152
152
|
},
|
153
|
-
getChildren: function(){
|
153
|
+
getChildren: function Element_getChildren(){
|
154
154
|
var results=[], elements = this.childNodes;
|
155
155
|
for(var element in elements){
|
156
156
|
if(elements[element].nodeType==1){
|
@@ -159,19 +159,39 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
159
159
|
};
|
160
160
|
return Juice.Object.toArray(results);
|
161
161
|
},
|
162
|
-
descendents:function(){
|
162
|
+
descendents:function Element_descendents(){
|
163
163
|
return Juice.Object.toArray(this.getElementsByTagName('*'));
|
164
164
|
},
|
165
|
-
inspect: function(){
|
165
|
+
inspect: function Element_inspect(){
|
166
166
|
var tag = this.tagName.toLowerCase();
|
167
167
|
var id = "#"+this.id;
|
168
168
|
var classN = "."+this.className;
|
169
169
|
return "#<HTMLElement:"+tag+classN+id;
|
170
|
-
}
|
170
|
+
},
|
171
|
+
update: function Element_update(str){
|
172
|
+
this.innerHTML = str;
|
173
|
+
// needs to be more robust
|
174
|
+
},
|
175
|
+
// Borrowed from jQuery
|
176
|
+
hover: function Element_hover( fnOver, fnOut ) {
|
177
|
+
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
|
178
|
+
},
|
179
|
+
|
171
180
|
};
|
181
|
+
function bind_events(){
|
182
|
+
var events = "blur focus focusin focusout load resize scroll unload click dblclick " +
|
183
|
+
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
|
184
|
+
"change select submit keydown keypress keyup error";
|
185
|
+
Juice.$W(events).each(function bind_single_event(event){
|
186
|
+
core_functions[event] = function(fn){
|
187
|
+
this.observe(event,fn);
|
188
|
+
};
|
189
|
+
});
|
190
|
+
}
|
191
|
+
bind_events();
|
172
192
|
Juice.Object.extend(Juice,{DOM:{}});
|
173
193
|
Juice.Object.extend(Juice.DOM,{
|
174
|
-
extend: function(fns){
|
194
|
+
extend: function Juice_DOM_element(fns){
|
175
195
|
var isIE = (window.navigator.userAgent.indexOf("MSIE") > 0);
|
176
196
|
if(!isIE){
|
177
197
|
Juice.Object.extend(HTMLElement.prototype,fns);
|
@@ -220,4 +240,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
220
240
|
});
|
221
241
|
// This is also our method exposed to extend the dom
|
222
242
|
Juice.DOM.extend(core_functions);
|
223
|
-
}
|
243
|
+
} Juice_DOM_init();
|
@@ -22,13 +22,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
23
23
|
Juice.Event = Juice.Class.create();
|
24
24
|
Juice.Event.prototype = {
|
25
|
-
initialize: function(obj,name,fn,options){
|
25
|
+
initialize: function Event_initialize(obj,name,fn,options){
|
26
26
|
this.obj = obj,this.name = name,this.fn = fn,this.options = options || {};
|
27
27
|
if(this.options.startImmediately){
|
28
28
|
this.create();
|
29
29
|
}
|
30
30
|
},
|
31
|
-
create:function(){
|
31
|
+
create:function Event_create(){
|
32
32
|
if(this.obj.addEventListener){
|
33
33
|
this.obj.addEventListener(this.name,this.fn,false);
|
34
34
|
return true;
|
@@ -41,7 +41,7 @@ Juice.Event.prototype = {
|
|
41
41
|
throw new Error("EventCreationFailed");
|
42
42
|
}
|
43
43
|
},
|
44
|
-
remove:function(){
|
44
|
+
remove:function Event_remove(){
|
45
45
|
if(this.obj.addEventListener){
|
46
46
|
this.obj.removeEventListener(this.name,this.fn,false);
|
47
47
|
return true;
|
@@ -22,7 +22,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
23
23
|
Juice.Image = Juice.Class.create();
|
24
24
|
Juice.Image.prototype = {
|
25
|
-
initialize:function(src,options){
|
25
|
+
initialize:function Image_initialize(src,options){
|
26
26
|
this.name = (10).toRandomString(), this.src = src;
|
27
27
|
this.options = options || {};
|
28
28
|
this.alt = this.options.alt;
|
@@ -23,7 +23,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
23
|
Juice.Layout = Juice.Class.create();
|
24
24
|
|
25
25
|
Juice.Object.extend(Juice.Layout,{
|
26
|
-
body:
|
26
|
+
body:document.getElementsByTagName('body')[0],
|
27
|
+
head: document.getElementsByTagName('head')[0],
|
27
28
|
fullWidth:(typeof window.innerWidth != 'undefined' ? window.innerWidth : document.body.offsetWidth),
|
28
29
|
fullHeight:(typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight)
|
29
30
|
});
|
@@ -0,0 +1,82 @@
|
|
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
|
+
};
|
@@ -0,0 +1,51 @@
|
|
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
|
+
|
@@ -22,7 +22,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
23
23
|
Juice.Window = Juice.Class.create();
|
24
24
|
Juice.Window.prototype = {
|
25
|
-
initialize: function(){
|
25
|
+
initialize: function Window_initialize(){
|
26
26
|
this.name = (10).toRandomString();
|
27
27
|
this.theDiv = document.createElement("div");
|
28
28
|
var theclass = Juice._classes._window;
|
@@ -30,14 +30,14 @@ Juice.Window.prototype = {
|
|
30
30
|
this.theDiv.setAttribute("class",theclass);
|
31
31
|
return this;
|
32
32
|
},
|
33
|
-
addSubview: function(view){
|
33
|
+
addSubview: function Window_addSubview(view){
|
34
34
|
Juice.$(this.name).appendChild(view);
|
35
35
|
return this;
|
36
36
|
},
|
37
|
-
contentView: function(){
|
37
|
+
contentView: function Window_contentVoew(){
|
38
38
|
return this.theDiv;
|
39
39
|
},
|
40
|
-
setSizing: function(width,height){
|
40
|
+
setSizing: function Window_setSiting(width,height){
|
41
41
|
if(width){
|
42
42
|
Juice.$(this.name).style.width = width+'px';
|
43
43
|
}
|
@@ -46,11 +46,11 @@ Juice.Window.prototype = {
|
|
46
46
|
}
|
47
47
|
return this;
|
48
48
|
},
|
49
|
-
setStringValue: function(text){
|
49
|
+
setStringValue: function Window_setStringValue(text){
|
50
50
|
Juice.$(this.name).innerHTML = text;
|
51
51
|
return this;
|
52
52
|
},
|
53
|
-
setCenter: function(boolean){
|
53
|
+
setCenter: function Window_setCenter(boolean){
|
54
54
|
if(boolean){
|
55
55
|
Juice.$(this.name).setStyle({
|
56
56
|
marginLeft:"auto",
|
@@ -58,15 +58,15 @@ Juice.Window.prototype = {
|
|
58
58
|
});
|
59
59
|
}
|
60
60
|
},
|
61
|
-
setBackground: function(color){
|
61
|
+
setBackground: function Window_setBackground(color){
|
62
62
|
Juice.$(this.name).style.background = color;
|
63
63
|
return this;
|
64
64
|
},
|
65
|
-
setForeground: function(color){
|
65
|
+
setForeground: function Window_setForeground(color){
|
66
66
|
Juice.$(this.name).style.color = color;
|
67
67
|
return this;
|
68
68
|
},
|
69
|
-
element: function(){
|
69
|
+
element: function Window_element(){
|
70
70
|
return this.theDiv;
|
71
71
|
}
|
72
72
|
};
|
@@ -24,22 +24,22 @@ Juice.i18n = {
|
|
24
24
|
DEFAULT_LANGUAGE: "en-us",
|
25
25
|
languages:{}
|
26
26
|
};
|
27
|
-
Juice.i18n.getString = function(value){
|
27
|
+
Juice.i18n.getString = function Juice_i18n_getString(value){
|
28
28
|
return Juice.i18n.languages[Juice.i18n.preferredLanguage][value];
|
29
29
|
};
|
30
|
-
Juice.i18n.setPreferredLanguage = function(value){
|
30
|
+
Juice.i18n.setPreferredLanguage = function Juice_i18n_setPreferredLanguage(value){
|
31
31
|
return Juice.i18n.preferredLanguage = value;
|
32
32
|
};
|
33
33
|
Juice.i18n.stringsFor = Juice.Class.create();
|
34
34
|
Juice.i18n.stringsFor.prototype = {
|
35
|
-
initialize:function(language,values){
|
35
|
+
initialize:function Juice_i18n_stringsFor_initialize(language,values){
|
36
36
|
this.language = language, Juice.i18n.languages[language] = values;
|
37
37
|
return Juice.i18n;
|
38
38
|
},
|
39
|
-
get: function(value){
|
39
|
+
get: function Juice_i18n_stringsFor_get(value){
|
40
40
|
return Juice.i18n.languages[this.language][value];
|
41
41
|
},
|
42
|
-
set: function(value){
|
42
|
+
set: function Juice_i18n_stringsFor_set(value){
|
43
43
|
return Juice.i18n.languages[language][value] = value;
|
44
44
|
}
|
45
45
|
};
|
@@ -21,7 +21,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
21
21
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
22
|
|
23
23
|
*/
|
24
|
-
|
24
|
+
function Juice_init(){
|
25
25
|
/* Globals are declared here.
|
26
26
|
* They are: NO,YES,nil, and Juice.
|
27
27
|
*/
|
@@ -31,12 +31,12 @@ nil = null;
|
|
31
31
|
Juice = {
|
32
32
|
// Here we define a method to extend our objects
|
33
33
|
Object: {
|
34
|
-
extend: function(d, s) { for (var p in s) d[p] = s[p]; return d;}
|
34
|
+
extend: function Juice_Object_extend(d, s) { for (var p in s) d[p] = s[p]; return d;}
|
35
35
|
},
|
36
36
|
// Classes are great, are they not?
|
37
37
|
Class: {
|
38
|
-
create: function() {
|
39
|
-
return function() {;
|
38
|
+
create: function Class_create() {
|
39
|
+
return function Class_new() {;
|
40
40
|
this.initialize.apply(this, arguments);
|
41
41
|
}
|
42
42
|
}
|
@@ -48,34 +48,33 @@ Juice = {
|
|
48
48
|
button:'JuiceButton'
|
49
49
|
},
|
50
50
|
// Modules. You can define custom ones.
|
51
|
-
_modules: ['i18n','DOM','Event','JSONPConnection','Layout','Application','Window','Button','Alert','Confirm'],
|
51
|
+
_modules: ['i18n','DOM','Event','Ajax','JSONPConnection','Layout','Template','Application','Window','Button','Alert','Confirm'],
|
52
52
|
_fileExtensions: {
|
53
53
|
css: "css",
|
54
|
-
js: "js"
|
54
|
+
js: "js",
|
55
|
+
view:"juice",
|
56
|
+
viewDir:"Views"
|
55
57
|
},
|
56
58
|
// Set our version information
|
57
|
-
version: "0.
|
59
|
+
version: "0.1.8"
|
58
60
|
};
|
59
61
|
|
60
62
|
// Here we add our helper methods to globals.
|
61
63
|
Juice.Object.extend(Juice.Object,{
|
62
|
-
// isString, isNumber,
|
63
|
-
isString:function(){
|
64
|
+
// isString, isNumber, isUndefined, isFunction
|
65
|
+
isString:function Juice_Object_isString(){
|
64
66
|
return typeof this == 'string';
|
65
67
|
},
|
66
|
-
isNumber:function(){
|
68
|
+
isNumber:function Juice_Object_isNumber(){
|
67
69
|
return typeof this == 'number';
|
68
70
|
},
|
69
|
-
|
70
|
-
return typeof this == 'object';
|
71
|
-
},
|
72
|
-
isUndefined:function(){
|
71
|
+
isUndefined:function Juice_Object_isUndefined(){
|
73
72
|
return typeof this == 'undefined';
|
74
73
|
},
|
75
|
-
isFunction:function(){
|
74
|
+
isFunction:function Juice_Object_isFunction(){
|
76
75
|
return typeof this == 'function';
|
77
76
|
},
|
78
|
-
inspect: function(){
|
77
|
+
inspect: function Juice_Object_inspect(){
|
79
78
|
try {
|
80
79
|
if (isUndefined(object)) return 'undefined';
|
81
80
|
if (object === null) return 'null';
|
@@ -86,10 +85,10 @@ Juice.Object.extend(Juice.Object,{
|
|
86
85
|
throw e;
|
87
86
|
}
|
88
87
|
},
|
89
|
-
toArray:function(item,iterator,context){
|
88
|
+
toArray:function Juice_Object_toArray(item,iterator,context){
|
90
89
|
iterator = iterator || function(x){ return x;};
|
91
90
|
var results = [];
|
92
|
-
item.each(function(value, index) {
|
91
|
+
item.each(function Juice_Object_toArray_each(value, index) {
|
93
92
|
results.push(iterator.call(context, value, index));
|
94
93
|
});
|
95
94
|
return results;
|
@@ -97,56 +96,56 @@ Juice.Object.extend(Juice.Object,{
|
|
97
96
|
});
|
98
97
|
// Extend the Array object
|
99
98
|
Juice.Object.extend(Array.prototype,{
|
100
|
-
clear:function(){
|
99
|
+
clear:function Array_clear(){
|
101
100
|
this.length = 0;
|
102
101
|
return this;
|
103
102
|
},
|
104
|
-
clone: function(){
|
103
|
+
clone: function Array_clone(){
|
105
104
|
return [].concat(this);
|
106
105
|
},
|
107
|
-
first: function(){
|
106
|
+
first: function Array_first(){
|
108
107
|
return this[0];
|
109
108
|
},
|
110
|
-
last: function(){
|
109
|
+
last: function Array_last(){
|
111
110
|
return this[this.length - 1];
|
112
111
|
},
|
113
|
-
size: function(){
|
112
|
+
size: function Array_size(){
|
114
113
|
return this.length;
|
115
114
|
},
|
116
|
-
each: function(iterator) {
|
115
|
+
each: function Array_each(iterator) {
|
117
116
|
for (var i = 0, theLength = this.length; i < theLength; i++){
|
118
117
|
iterator(this[i]);
|
119
118
|
}
|
120
119
|
},
|
121
|
-
select: function(iterator,context){
|
120
|
+
select: function Array_select(iterator,context){
|
122
121
|
var results = [];
|
123
|
-
this.each(function(value, index) {
|
122
|
+
this.each(function Arrat_select_each(value, index) {
|
124
123
|
if (iterator.call(context, value, index)){
|
125
124
|
results.push(value);
|
126
125
|
}
|
127
126
|
});
|
128
127
|
return results;
|
129
128
|
},
|
130
|
-
compact: function(){
|
131
|
-
return this.select(function(value) {
|
129
|
+
compact: function Array_compact(){
|
130
|
+
return this.select(function Array_compact_select(value) {
|
132
131
|
return value != null;
|
133
132
|
});
|
134
133
|
}
|
135
134
|
});
|
136
135
|
// Extend the String object
|
137
136
|
Juice.Object.extend(String.prototype,{
|
138
|
-
empty
|
137
|
+
empty:function String_empty(){
|
139
138
|
return this.length == 0;
|
140
139
|
},
|
141
|
-
size: function(){
|
140
|
+
size: function String_size(){
|
142
141
|
return this.length;
|
143
142
|
},
|
144
|
-
fromHex: function(){
|
143
|
+
fromHex: function String_fromHex(){
|
145
144
|
return parseInt(this,16);
|
146
145
|
}
|
147
146
|
});
|
148
147
|
Juice.Object.extend(Function.prototype,{
|
149
|
-
unless:function(fn){
|
148
|
+
unless:function Function_unless(fn){
|
150
149
|
if(fn.isFunction()){
|
151
150
|
var cond = fn.call();
|
152
151
|
}
|
@@ -159,7 +158,7 @@ Juice.Object.extend(Function.prototype,{
|
|
159
158
|
}
|
160
159
|
});
|
161
160
|
Juice.Object.extend(Number.prototype,{
|
162
|
-
toRandomString: function(){
|
161
|
+
toRandomString: function Number_toRandomString(){
|
163
162
|
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
|
164
163
|
var string_length = this || 8;
|
165
164
|
var random = '';
|
@@ -169,24 +168,27 @@ Juice.Object.extend(Number.prototype,{
|
|
169
168
|
}
|
170
169
|
return random;
|
171
170
|
},
|
172
|
-
toHex: function(){
|
171
|
+
toHex: function Number_toHex(){
|
173
172
|
return this.toString(16);
|
174
173
|
}
|
175
174
|
});
|
176
175
|
|
177
176
|
// Get back to the Juice object..
|
178
177
|
Juice.Object.extend(Juice,{
|
178
|
+
$W: function Juice_W(str){
|
179
|
+
return str.split(' ');
|
180
|
+
},
|
179
181
|
readyList:[],
|
180
182
|
isReady:false,
|
181
|
-
Ready: function(){
|
183
|
+
Ready: function Juice_Ready(){
|
182
184
|
Juice.isReady = true;
|
183
185
|
Juice.appDidLoad();
|
184
186
|
},
|
185
|
-
bindReady:function(){
|
187
|
+
bindReady:function Juice_bindReady(){
|
186
188
|
// Mozilla, Opera and webkit nightlies currently support this event
|
187
189
|
if (document.addEventListener) {
|
188
190
|
// Use the handy event callback
|
189
|
-
document.addEventListener("DOMContentLoaded", function(){
|
191
|
+
document.addEventListener("DOMContentLoaded", function Juice_bindReady_addEventListener(){
|
190
192
|
document.removeEventListener("DOMContentLoaded", arguments.callee, false);
|
191
193
|
Juice.Ready();
|
192
194
|
}, false);
|
@@ -225,35 +227,7 @@ Juice.Object.extend(Juice,{
|
|
225
227
|
setOnload.create();
|
226
228
|
}
|
227
229
|
},
|
228
|
-
|
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){
|
230
|
+
appDidLoad: function Juice_appDidLoad(fn){
|
257
231
|
// Make sure that the DOM is not already loaded
|
258
232
|
if (Juice.isReady) {
|
259
233
|
Juice.$('juiceloadingcontainer').style.display = "none";
|
@@ -265,7 +239,7 @@ Juice.Object.extend(Juice,{
|
|
265
239
|
// If there are functions bound, to execute
|
266
240
|
if (Juice.readyList) {
|
267
241
|
// Execute all of them
|
268
|
-
Juice.readyList.each(function(item){
|
242
|
+
Juice.readyList.each(function Juice_readyList_each(item){
|
269
243
|
item.call();
|
270
244
|
});
|
271
245
|
// Reset the list of functions
|
@@ -275,14 +249,14 @@ Juice.Object.extend(Juice,{
|
|
275
249
|
else Juice.readyList.push(fn);
|
276
250
|
|
277
251
|
},
|
278
|
-
setAppTitle: function(str){
|
252
|
+
setAppTitle: function Juice_setAppTitle(str){
|
279
253
|
document.title = str;
|
280
254
|
},
|
281
|
-
$: function(sel){
|
255
|
+
$: function Juice_$(sel){
|
282
256
|
return document.getElementById(sel);
|
283
257
|
},
|
284
258
|
|
285
|
-
Require: function(name){
|
259
|
+
Require: function Juice_Require(name){
|
286
260
|
var jsname = name+"js";
|
287
261
|
var head = document.getElementsByTagName('head')[0];
|
288
262
|
if(!Juice.$(jsname)){
|
@@ -294,7 +268,7 @@ Juice.Object.extend(Juice,{
|
|
294
268
|
head.appendChild(s);
|
295
269
|
}
|
296
270
|
},
|
297
|
-
loadAppCSS: function(name){
|
271
|
+
loadAppCSS: function Juice_loadAppCss(name){
|
298
272
|
name = name || "application.css";
|
299
273
|
var link = document.createElement('link');
|
300
274
|
link.setAttribute("href",name);
|
@@ -302,23 +276,25 @@ Juice.Object.extend(Juice,{
|
|
302
276
|
link.setAttribute("rel","stylesheet");
|
303
277
|
document.getElementsByTagName('head')[0].appendChild(link);
|
304
278
|
},
|
305
|
-
useTheme: function(name){
|
279
|
+
useTheme: function Juice_useTheme(name){
|
306
280
|
name = "Framework/Resources/Themes/" +name;
|
307
281
|
Juice.loadAppCSS(name+"."+Juice._fileExtensions.css);
|
308
282
|
},
|
309
|
-
loadModules: function(){
|
283
|
+
loadModules: function Juice_loadModules(){
|
310
284
|
if(Juice.DOM){
|
311
285
|
return 'Bye';
|
312
286
|
}
|
313
287
|
else{
|
314
|
-
Juice._modules.each(
|
288
|
+
Juice._modules.each(function Juice__modules_each(file){
|
315
289
|
Juice.Require('Framework/Juice.' + file);
|
316
290
|
});
|
317
291
|
}
|
318
292
|
}
|
319
293
|
});
|
320
|
-
|
294
|
+
// Bind ready event to add onload event
|
321
295
|
Juice.bindReady();
|
296
|
+
// Load our app's css
|
322
297
|
Juice.loadAppCSS();
|
323
|
-
|
324
|
-
|
298
|
+
// Alias Juice to JC
|
299
|
+
JC = Juice;
|
300
|
+
} Juice_init();
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= hi %>
|
@@ -3,13 +3,13 @@ var theWindow = new Juice.Window("theWindow");
|
|
3
3
|
app.addSubview(theWindow.contentView());
|
4
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(){
|
6
|
+
var alert_button = new Juice.Button('Test Alert',function AlertButtonClick(){
|
7
7
|
var alert = new Juice.Alert({title: 'Alert Test', text:'This demonstrates how to use an alert'});
|
8
8
|
alert.addButton('Cancel',function(){alert.remove();});
|
9
9
|
});
|
10
10
|
|
11
|
-
var confirm_button = new Juice.Button('Test Confirm',function(){
|
12
|
-
var confirm = new Juice.Confirm({text:'This demonstrates how to use a confirm',callback:function(bool){
|
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
13
|
alert(bool);
|
14
14
|
}});
|
15
15
|
});
|
@@ -1,5 +1,26 @@
|
|
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
|
+
*/
|
1
23
|
var JuiceApp = {
|
2
24
|
developer: "Justin Baker",
|
3
|
-
|
4
|
-
files:['File.js']
|
25
|
+
files:['NewFile.js'] // This is a list of files not in Framework/Juice.*.js, or appController.js .
|
5
26
|
};
|
data/bin/juice
CHANGED
@@ -33,7 +33,7 @@ module Juice
|
|
33
33
|
|
34
34
|
def self.create
|
35
35
|
name = ARGV[0]
|
36
|
-
|
36
|
+
Juice::Base.exit_message('No Application name given') if name.nil?
|
37
37
|
start = Dir.getwd
|
38
38
|
Dir.chdir(File.dirname(__FILE__))
|
39
39
|
Dir.chdir('../')
|
@@ -78,13 +78,17 @@ module Juice
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def self.server
|
81
|
-
port = ARGV[1].nil? ?
|
81
|
+
port = ARGV[1].nil? ? 338: ARGV[1]
|
82
82
|
puts "Starting webrick on #{Dir.getwd} \n "
|
83
83
|
Juice::Base.start_webrick(port,:DocumentRoot => Dir.getwd)
|
84
84
|
end
|
85
|
-
|
86
|
-
def self.
|
87
|
-
|
85
|
+
|
86
|
+
def self.exit_message(mes)
|
87
|
+
puts mes
|
88
|
+
exit
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.start_webrick(port,config = {})
|
88
92
|
config.update(:Port => port)
|
89
93
|
server = HTTPServer.new(config)
|
90
94
|
yield server if block_given?
|
data/bin/juice
CHANGED
@@ -33,7 +33,7 @@ module Juice
|
|
33
33
|
|
34
34
|
def self.create
|
35
35
|
name = ARGV[0]
|
36
|
-
|
36
|
+
Juice::Base.exit_message('No Application name given') if name.nil?
|
37
37
|
start = Dir.getwd
|
38
38
|
Dir.chdir(File.dirname(__FILE__))
|
39
39
|
Dir.chdir('../')
|
@@ -78,13 +78,17 @@ module Juice
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def self.server
|
81
|
-
port = ARGV[1].nil? ?
|
81
|
+
port = ARGV[1].nil? ? 338: ARGV[1]
|
82
82
|
puts "Starting webrick on #{Dir.getwd} \n "
|
83
83
|
Juice::Base.start_webrick(port,:DocumentRoot => Dir.getwd)
|
84
84
|
end
|
85
|
-
|
86
|
-
def self.
|
87
|
-
|
85
|
+
|
86
|
+
def self.exit_message(mes)
|
87
|
+
puts mes
|
88
|
+
exit
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.start_webrick(port,config = {})
|
88
92
|
config.update(:Port => port)
|
89
93
|
server = HTTPServer.new(config)
|
90
94
|
yield server if block_given?
|
data/lib/juice.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.8
|
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-
|
12
|
+
date: 2010-01-19 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- "script/destroy "
|
56
56
|
- "script/console.cmd "
|
57
57
|
- "script/console "
|
58
|
+
- "StarterApplication/Views/example.juice "
|
58
59
|
- "StarterApplication/README "
|
59
60
|
- "StarterApplication/LICENSE "
|
60
61
|
- "StarterApplication/juice.app "
|
@@ -66,6 +67,8 @@ files:
|
|
66
67
|
- "StarterApplication/Framework/Resources/images/Thumbs.db "
|
67
68
|
- "StarterApplication/Framework/Resources/images/spinner.gif "
|
68
69
|
- "StarterApplication/Framework/Juice.Window.js "
|
70
|
+
- "StarterApplication/Framework/Juice.View.js "
|
71
|
+
- "StarterApplication/Framework/Juice.Template.js "
|
69
72
|
- "StarterApplication/Framework/Juice.Layout.js "
|
70
73
|
- "StarterApplication/Framework/Juice.JSONPConnection.js "
|
71
74
|
- "StarterApplication/Framework/Juice.js "
|
@@ -78,6 +81,7 @@ files:
|
|
78
81
|
- "StarterApplication/Framework/Juice.Button.js "
|
79
82
|
- "StarterApplication/Framework/Juice.Application.js "
|
80
83
|
- "StarterApplication/Framework/Juice.Alert.js "
|
84
|
+
- "StarterApplication/Framework/Juice.Ajax.js "
|
81
85
|
- "StarterApplication/appController.js "
|
82
86
|
has_rdoc: true
|
83
87
|
homepage: http://juicejs.com
|