calatrava 0.0.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +7 -1
- data/calatrava.gemspec +2 -2
- data/features/sample_app.feature +27 -0
- data/features/step_definitions/app_steps.rb +3 -0
- data/features/support/calatrava_app.rb +31 -0
- data/features/support/env.rb +18 -0
- data/lib/calatrava/project.rb +5 -2
- data/lib/calatrava/tasks/apache.rb +20 -10
- data/lib/calatrava/tasks/droid.rb +1 -1
- data/lib/calatrava/tasks/web.rb +5 -0
- data/lib/calatrava/templates/droid/app/bridge.coffee +21 -120
- data/lib/calatrava/templates/droid/calatrava/{src/com/CALATRAVA_TMPL → CALATRAVA_TMPL}/AndroidManifest.xml.calatrava +2 -2
- data/lib/calatrava/templates/droid/calatrava/{calatrava-build.xml → CALATRAVA_TMPL/build.xml.calatrava} +1 -1
- data/lib/calatrava/templates/droid/calatrava/src/com/CALATRAVA_TMPL/ConversionForm.java.calatrava +4 -4
- data/lib/calatrava/templates/droid/calatrava/src/com/CALATRAVA_TMPL/Title.java.calatrava +2 -2
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/KernelBridge.java +1 -0
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/PageRegistry.java +13 -1
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RegisteredActivity.java +7 -1
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/bridge/RhinoService.java +12 -7
- data/lib/calatrava/templates/droid/calatrava/src/com/calatrava/shell/WebViewActivity.java +2 -4
- data/lib/calatrava/templates/ios/src/ConversionFormViewController.h +4 -0
- data/lib/calatrava/templates/ios/src/ConversionFormViewController.m +36 -3
- data/lib/calatrava/templates/ios/src/ConversionFormViewController.xib +144 -20
- data/lib/calatrava/templates/kernel/app/calatrava.coffee +171 -3
- data/lib/calatrava/templates/kernel/app/converter/controller.converter.coffee +37 -42
- data/lib/calatrava/templates/kernel/app/converter/init.converter.coffee +4 -4
- data/lib/calatrava/templates/kernel/spec/converter/controller.converter.spec.coffee +6 -6
- data/lib/calatrava/templates/kernel/spec/stubView.coffee +18 -2
- data/lib/calatrava/templates/package.json +0 -1
- data/lib/calatrava/templates/shell/pages/converter/conversionForm.haml +6 -4
- data/lib/calatrava/templates/shell/pages/converter/page.conversionForm.coffee +18 -24
- data/lib/calatrava/templates/shell/stylesheets/shell.scss +0 -0
- data/lib/calatrava/templates/web/app/source/bridge.coffee +61 -93
- data/lib/calatrava/version.rb +1 -1
- metadata +39 -34
- data/lib/calatrava/templates/ios/res/js/bridge.js +0 -249
- data/lib/calatrava/templates/shell/shell.scss +0 -1
@@ -17,11 +17,14 @@
|
|
17
17
|
@property (retain, nonatomic) IBOutlet UIPickerView *inCurrencyPicker;
|
18
18
|
|
19
19
|
- (void)updateCurrencyPickerSelection:(UIPickerView *)pickerView usingData:(NSArray *)currencyData;
|
20
|
+
- (void)hideKeyboard;
|
20
21
|
@end
|
21
22
|
|
22
23
|
@implementation ConversionFormViewController
|
23
24
|
@synthesize outCurrencyPicker;
|
24
25
|
@synthesize inCurrencyPicker;
|
26
|
+
@synthesize inAmount;
|
27
|
+
@synthesize outAmount;
|
25
28
|
|
26
29
|
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
|
27
30
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
@@ -37,6 +40,8 @@
|
|
37
40
|
[inCurrencyPicker release];
|
38
41
|
[_inCurrencyData release];
|
39
42
|
[_outCurrencyData release];
|
43
|
+
[inAmount release];
|
44
|
+
[outAmount release];
|
40
45
|
[super dealloc];
|
41
46
|
}
|
42
47
|
|
@@ -56,9 +61,22 @@
|
|
56
61
|
{
|
57
62
|
[self setOutCurrencyPicker:nil];
|
58
63
|
[self setInCurrencyPicker:nil];
|
64
|
+
[self setInAmount:nil];
|
65
|
+
[self setOutAmount:nil];
|
59
66
|
[super viewDidUnload];
|
60
67
|
}
|
61
68
|
|
69
|
+
- (id)valueForField:(NSString *)field
|
70
|
+
{
|
71
|
+
if ([field isEqualToString:@"in_currency"]) {
|
72
|
+
return [[_inCurrencyData objectAtIndex:[inCurrencyPicker selectedRowInComponent:0]] objectForKey:@"code"];
|
73
|
+
} else if ([field isEqualToString:@"out_currency"]) {
|
74
|
+
return [[_outCurrencyData objectAtIndex:[outCurrencyPicker selectedRowInComponent:0]] objectForKey:@"code"];
|
75
|
+
} else if ([field isEqualToString:@"in_amount"]) {
|
76
|
+
return [NSNumber numberWithInt:[[inAmount text] integerValue]];
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
62
80
|
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
63
81
|
{
|
64
82
|
return (interfaceOrientation == UIInterfaceOrientationPortrait);
|
@@ -76,6 +94,11 @@
|
|
76
94
|
}
|
77
95
|
}
|
78
96
|
|
97
|
+
- (void)hideKeyboard
|
98
|
+
{
|
99
|
+
[inAmount resignFirstResponder];
|
100
|
+
}
|
101
|
+
|
79
102
|
- (void)renderCurrencyPicker:(UIPickerView *)pickerView usingData:(NSArray *)currencyData to:(NSArray **)pickerStore
|
80
103
|
{
|
81
104
|
[*pickerStore release];
|
@@ -86,16 +109,25 @@
|
|
86
109
|
}
|
87
110
|
}
|
88
111
|
|
112
|
+
- (IBAction)convert:(id)sender {
|
113
|
+
[self hideKeyboard];
|
114
|
+
[self dispatchEvent:@"convert" withArgs:@[]];
|
115
|
+
return self;
|
116
|
+
}
|
117
|
+
|
89
118
|
- (void)render:(NSDictionary *)jsViewObject
|
90
119
|
{
|
91
120
|
for (NSString *key in jsViewObject)
|
92
121
|
{
|
93
122
|
id value = [jsViewObject objectForKey:key];
|
94
|
-
if(
|
95
|
-
{
|
123
|
+
if ([key isEqualToString:@"inCurrencies"]) {
|
96
124
|
[self renderCurrencyPicker:inCurrencyPicker usingData:value to:&_inCurrencyData];
|
97
|
-
}else if(
|
125
|
+
} else if ([key isEqualToString:@"outCurrencies"]) {
|
98
126
|
[self renderCurrencyPicker:outCurrencyPicker usingData:value to:&_outCurrencyData];
|
127
|
+
} else if ([key isEqualToString:@"in_amount"]) {
|
128
|
+
[outAmount setText:[NSString stringWithFormat:@"%@", [jsViewObject objectForKey:@"in_amount"]]];
|
129
|
+
} else if ([key isEqualToString:@"out_amount"]) {
|
130
|
+
[outAmount setText:[NSString stringWithFormat:@"%@", [jsViewObject objectForKey:@"out_amount"]]];
|
99
131
|
}
|
100
132
|
}
|
101
133
|
}
|
@@ -135,6 +167,7 @@
|
|
135
167
|
NSString *event = picker == inCurrencyPicker ? @"selectedInCurrency" : @"selectedOutCurrency";
|
136
168
|
|
137
169
|
NSString *currencyCode = [details objectForKey:@"code"];
|
170
|
+
[self hideKeyboard];
|
138
171
|
[self dispatchEvent:event withArgs:[NSArray arrayWithObject:currencyCode]];
|
139
172
|
}
|
140
173
|
|
@@ -1,21 +1,22 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
|
3
3
|
<data>
|
4
|
-
<int key="IBDocument.SystemTarget">
|
5
|
-
<string key="IBDocument.SystemVersion">
|
6
|
-
<string key="IBDocument.InterfaceBuilderVersion">
|
7
|
-
<string key="IBDocument.AppKitVersion">
|
8
|
-
<string key="IBDocument.HIToolboxVersion">
|
4
|
+
<int key="IBDocument.SystemTarget">1536</int>
|
5
|
+
<string key="IBDocument.SystemVersion">12C54</string>
|
6
|
+
<string key="IBDocument.InterfaceBuilderVersion">2840</string>
|
7
|
+
<string key="IBDocument.AppKitVersion">1187.34</string>
|
8
|
+
<string key="IBDocument.HIToolboxVersion">625.00</string>
|
9
9
|
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
10
10
|
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
11
|
-
<string key="NS.object.0">
|
11
|
+
<string key="NS.object.0">1926</string>
|
12
12
|
</object>
|
13
13
|
<array key="IBDocument.IntegratedClassDependencies">
|
14
|
+
<string>IBProxyObject</string>
|
15
|
+
<string>IBUIButton</string>
|
16
|
+
<string>IBUILabel</string>
|
14
17
|
<string>IBUIPickerView</string>
|
15
18
|
<string>IBUITextField</string>
|
16
19
|
<string>IBUIView</string>
|
17
|
-
<string>IBUILabel</string>
|
18
|
-
<string>IBProxyObject</string>
|
19
20
|
</array>
|
20
21
|
<array key="IBDocument.PluginDependencies">
|
21
22
|
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
@@ -43,7 +44,6 @@
|
|
43
44
|
<string key="NSFrame">{{20, 344}, {203, 96}}</string>
|
44
45
|
<reference key="NSSuperview" ref="191373211"/>
|
45
46
|
<reference key="NSWindow"/>
|
46
|
-
<reference key="NSNextKeyView"/>
|
47
47
|
<string key="NSReuseIdentifierKey">_NS:9</string>
|
48
48
|
<bool key="IBUIOpaque">NO</bool>
|
49
49
|
<bool key="IBUIClipsSubviews">YES</bool>
|
@@ -68,11 +68,12 @@
|
|
68
68
|
<double key="NSSize">17</double>
|
69
69
|
<int key="NSfFlags">16</int>
|
70
70
|
</object>
|
71
|
+
<double key="preferredMaxLayoutWidth">203</double>
|
71
72
|
</object>
|
72
73
|
<object class="IBUILabel" id="671683200">
|
73
74
|
<reference key="NSNextResponder" ref="191373211"/>
|
74
75
|
<int key="NSvFlags">292</int>
|
75
|
-
<string key="NSFrame">{{139,
|
76
|
+
<string key="NSFrame">{{139, 118}, {43, 90}}</string>
|
76
77
|
<reference key="NSSuperview" ref="191373211"/>
|
77
78
|
<reference key="NSWindow"/>
|
78
79
|
<reference key="NSNextKeyView" ref="463978271"/>
|
@@ -102,6 +103,7 @@
|
|
102
103
|
<int key="NSfFlags">16</int>
|
103
104
|
</object>
|
104
105
|
<bool key="IBUIAdjustsFontSizeToFit">NO</bool>
|
106
|
+
<double key="preferredMaxLayoutWidth">43</double>
|
105
107
|
</object>
|
106
108
|
<object class="IBUILabel" id="544627895">
|
107
109
|
<reference key="NSNextResponder" ref="191373211"/>
|
@@ -120,6 +122,7 @@
|
|
120
122
|
<object class="NSColor" key="IBUITextColor">
|
121
123
|
<int key="NSColorSpace">1</int>
|
122
124
|
<bytes key="NSRGB">MCAwIDAAA</bytes>
|
125
|
+
<string key="IBUIColorCocoaTouchKeyPath">darkTextColor</string>
|
123
126
|
</object>
|
124
127
|
<nil key="IBUIHighlightedColor"/>
|
125
128
|
<int key="IBUIBaselineAdjustment">0</int>
|
@@ -130,7 +133,7 @@
|
|
130
133
|
<object class="IBUIPickerView" id="313683017">
|
131
134
|
<reference key="NSNextResponder" ref="191373211"/>
|
132
135
|
<int key="NSvFlags">290</int>
|
133
|
-
<string key="NSFrame">{{20,
|
136
|
+
<string key="NSFrame">{{20, 55}, {110, 216}}</string>
|
134
137
|
<reference key="NSSuperview" ref="191373211"/>
|
135
138
|
<reference key="NSWindow"/>
|
136
139
|
<reference key="NSNextKeyView" ref="544627895"/>
|
@@ -141,7 +144,7 @@
|
|
141
144
|
<object class="IBUIPickerView" id="463978271">
|
142
145
|
<reference key="NSNextResponder" ref="191373211"/>
|
143
146
|
<int key="NSvFlags">290</int>
|
144
|
-
<string key="NSFrame">{{190,
|
147
|
+
<string key="NSFrame">{{190, 55}, {110, 216}}</string>
|
145
148
|
<reference key="NSSuperview" ref="191373211"/>
|
146
149
|
<reference key="NSWindow"/>
|
147
150
|
<reference key="NSNextKeyView" ref="557227880"/>
|
@@ -152,7 +155,7 @@
|
|
152
155
|
<object class="IBUITextField" id="557227880">
|
153
156
|
<reference key="NSNextResponder" ref="191373211"/>
|
154
157
|
<int key="NSvFlags">292</int>
|
155
|
-
<string key="NSFrame">{{
|
158
|
+
<string key="NSFrame">{{27, 20}, {97, 31}}</string>
|
156
159
|
<reference key="NSSuperview" ref="191373211"/>
|
157
160
|
<reference key="NSWindow"/>
|
158
161
|
<reference key="NSNextKeyView" ref="278875700"/>
|
@@ -176,16 +179,77 @@
|
|
176
179
|
<object class="IBUITextInputTraits" key="IBUITextInputTraits">
|
177
180
|
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
178
181
|
</object>
|
179
|
-
<object class="IBUIFontDescription" key="IBUIFontDescription">
|
182
|
+
<object class="IBUIFontDescription" key="IBUIFontDescription" id="792499153">
|
180
183
|
<int key="type">1</int>
|
181
184
|
<double key="pointSize">14</double>
|
182
185
|
</object>
|
183
|
-
<object class="NSFont" key="IBUIFont">
|
186
|
+
<object class="NSFont" key="IBUIFont" id="1807837">
|
184
187
|
<string key="NSName">Helvetica</string>
|
185
188
|
<double key="NSSize">14</double>
|
186
189
|
<int key="NSfFlags">16</int>
|
187
190
|
</object>
|
188
191
|
</object>
|
192
|
+
<object class="IBUIButton" id="427187250">
|
193
|
+
<reference key="NSNextResponder" ref="191373211"/>
|
194
|
+
<int key="NSvFlags">292</int>
|
195
|
+
<string key="NSFrame">{{138, 198}, {45, 44}}</string>
|
196
|
+
<reference key="NSSuperview" ref="191373211"/>
|
197
|
+
<reference key="NSWindow"/>
|
198
|
+
<string key="NSReuseIdentifierKey">_NS:9</string>
|
199
|
+
<bool key="IBUIOpaque">NO</bool>
|
200
|
+
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
201
|
+
<int key="IBUIContentHorizontalAlignment">0</int>
|
202
|
+
<int key="IBUIContentVerticalAlignment">0</int>
|
203
|
+
<int key="IBUIButtonType">1</int>
|
204
|
+
<string key="IBUINormalTitle">Go</string>
|
205
|
+
<object class="NSColor" key="IBUIHighlightedTitleColor">
|
206
|
+
<int key="NSColorSpace">3</int>
|
207
|
+
<bytes key="NSWhite">MQA</bytes>
|
208
|
+
</object>
|
209
|
+
<object class="NSColor" key="IBUINormalTitleColor">
|
210
|
+
<int key="NSColorSpace">1</int>
|
211
|
+
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
|
212
|
+
</object>
|
213
|
+
<object class="NSColor" key="IBUINormalTitleShadowColor">
|
214
|
+
<int key="NSColorSpace">3</int>
|
215
|
+
<bytes key="NSWhite">MC41AA</bytes>
|
216
|
+
</object>
|
217
|
+
<object class="IBUIFontDescription" key="IBUIFontDescription">
|
218
|
+
<int key="type">2</int>
|
219
|
+
<double key="pointSize">15</double>
|
220
|
+
</object>
|
221
|
+
<object class="NSFont" key="IBUIFont">
|
222
|
+
<string key="NSName">Helvetica-Bold</string>
|
223
|
+
<double key="NSSize">15</double>
|
224
|
+
<int key="NSfFlags">16</int>
|
225
|
+
</object>
|
226
|
+
</object>
|
227
|
+
<object class="IBUITextField" id="793142264">
|
228
|
+
<reference key="NSNextResponder" ref="191373211"/>
|
229
|
+
<int key="NSvFlags">292</int>
|
230
|
+
<string key="NSFrame">{{197, 21}, {97, 30}}</string>
|
231
|
+
<reference key="NSSuperview" ref="191373211"/>
|
232
|
+
<reference key="NSWindow"/>
|
233
|
+
<string key="NSReuseIdentifierKey">_NS:9</string>
|
234
|
+
<bool key="IBUIOpaque">NO</bool>
|
235
|
+
<bool key="IBUIClipsSubviews">YES</bool>
|
236
|
+
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
237
|
+
<int key="IBUIContentVerticalAlignment">0</int>
|
238
|
+
<string key="IBUIText"/>
|
239
|
+
<int key="IBUIBorderStyle">3</int>
|
240
|
+
<object class="NSColor" key="IBUITextColor">
|
241
|
+
<int key="NSColorSpace">3</int>
|
242
|
+
<bytes key="NSWhite">MAA</bytes>
|
243
|
+
<reference key="NSCustomColorSpace" ref="348585157"/>
|
244
|
+
</object>
|
245
|
+
<bool key="IBUIAdjustsFontSizeToFit">YES</bool>
|
246
|
+
<float key="IBUIMinimumFontSize">17</float>
|
247
|
+
<object class="IBUITextInputTraits" key="IBUITextInputTraits">
|
248
|
+
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
249
|
+
</object>
|
250
|
+
<reference key="IBUIFontDescription" ref="792499153"/>
|
251
|
+
<reference key="IBUIFont" ref="1807837"/>
|
252
|
+
</object>
|
189
253
|
</array>
|
190
254
|
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
|
191
255
|
<reference key="NSSuperview"/>
|
@@ -226,6 +290,31 @@
|
|
226
290
|
</object>
|
227
291
|
<int key="connectionID">12</int>
|
228
292
|
</object>
|
293
|
+
<object class="IBConnectionRecord">
|
294
|
+
<object class="IBCocoaTouchOutletConnection" key="connection">
|
295
|
+
<string key="label">inAmount</string>
|
296
|
+
<reference key="source" ref="372490531"/>
|
297
|
+
<reference key="destination" ref="557227880"/>
|
298
|
+
</object>
|
299
|
+
<int key="connectionID">13</int>
|
300
|
+
</object>
|
301
|
+
<object class="IBConnectionRecord">
|
302
|
+
<object class="IBCocoaTouchOutletConnection" key="connection">
|
303
|
+
<string key="label">outAmount</string>
|
304
|
+
<reference key="source" ref="372490531"/>
|
305
|
+
<reference key="destination" ref="793142264"/>
|
306
|
+
</object>
|
307
|
+
<int key="connectionID">20</int>
|
308
|
+
</object>
|
309
|
+
<object class="IBConnectionRecord">
|
310
|
+
<object class="IBCocoaTouchEventConnection" key="connection">
|
311
|
+
<string key="label">convert:</string>
|
312
|
+
<reference key="source" ref="427187250"/>
|
313
|
+
<reference key="destination" ref="372490531"/>
|
314
|
+
<int key="IBEventType">7</int>
|
315
|
+
</object>
|
316
|
+
<int key="connectionID">15</int>
|
317
|
+
</object>
|
229
318
|
</array>
|
230
319
|
<object class="IBMutableOrderedSet" key="objectRecords">
|
231
320
|
<array key="orderedObjects">
|
@@ -241,10 +330,12 @@
|
|
241
330
|
<array class="NSMutableArray" key="children">
|
242
331
|
<reference ref="278875700"/>
|
243
332
|
<reference ref="544627895"/>
|
333
|
+
<reference ref="557227880"/>
|
334
|
+
<reference ref="793142264"/>
|
244
335
|
<reference ref="313683017"/>
|
245
|
-
<reference ref="671683200"/>
|
246
336
|
<reference ref="463978271"/>
|
247
|
-
<reference ref="
|
337
|
+
<reference ref="671683200"/>
|
338
|
+
<reference ref="427187250"/>
|
248
339
|
</array>
|
249
340
|
<reference key="parent" ref="0"/>
|
250
341
|
</object>
|
@@ -289,6 +380,16 @@
|
|
289
380
|
<reference key="object" ref="557227880"/>
|
290
381
|
<reference key="parent" ref="191373211"/>
|
291
382
|
</object>
|
383
|
+
<object class="IBObjectRecord">
|
384
|
+
<int key="objectID">14</int>
|
385
|
+
<reference key="object" ref="427187250"/>
|
386
|
+
<reference key="parent" ref="191373211"/>
|
387
|
+
</object>
|
388
|
+
<object class="IBObjectRecord">
|
389
|
+
<int key="objectID">19</int>
|
390
|
+
<reference key="object" ref="793142264"/>
|
391
|
+
<reference key="parent" ref="191373211"/>
|
392
|
+
</object>
|
292
393
|
</array>
|
293
394
|
</object>
|
294
395
|
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
@@ -297,6 +398,8 @@
|
|
297
398
|
<string key="-2.CustomClassName">UIResponder</string>
|
298
399
|
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
299
400
|
<string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
401
|
+
<string key="14.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
402
|
+
<string key="19.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
300
403
|
<string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
301
404
|
<string key="5.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
302
405
|
<string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
|
@@ -308,7 +411,7 @@
|
|
308
411
|
<nil key="activeLocalization"/>
|
309
412
|
<dictionary class="NSMutableDictionary" key="localizations"/>
|
310
413
|
<nil key="sourceID"/>
|
311
|
-
<int key="maxID">
|
414
|
+
<int key="maxID">20</int>
|
312
415
|
</object>
|
313
416
|
<object class="IBClassDescriber" key="IBDocument.Classes">
|
314
417
|
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
@@ -323,15 +426,36 @@
|
|
323
426
|
<object class="IBPartialClassDescription">
|
324
427
|
<string key="className">ConversionFormViewController</string>
|
325
428
|
<string key="superclassName">BaseUIViewController</string>
|
429
|
+
<object class="NSMutableDictionary" key="actions">
|
430
|
+
<string key="NS.key.0">convert:</string>
|
431
|
+
<string key="NS.object.0">id</string>
|
432
|
+
</object>
|
433
|
+
<object class="NSMutableDictionary" key="actionInfosByName">
|
434
|
+
<string key="NS.key.0">convert:</string>
|
435
|
+
<object class="IBActionInfo" key="NS.object.0">
|
436
|
+
<string key="name">convert:</string>
|
437
|
+
<string key="candidateClassName">id</string>
|
438
|
+
</object>
|
439
|
+
</object>
|
326
440
|
<dictionary class="NSMutableDictionary" key="outlets">
|
441
|
+
<string key="inAmount">UITextField</string>
|
327
442
|
<string key="inCurrencyPicker">UIPickerView</string>
|
443
|
+
<string key="outAmount">UITextField</string>
|
328
444
|
<string key="outCurrencyPicker">UIPickerView</string>
|
329
445
|
</dictionary>
|
330
446
|
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
|
447
|
+
<object class="IBToOneOutletInfo" key="inAmount">
|
448
|
+
<string key="name">inAmount</string>
|
449
|
+
<string key="candidateClassName">UITextField</string>
|
450
|
+
</object>
|
331
451
|
<object class="IBToOneOutletInfo" key="inCurrencyPicker">
|
332
452
|
<string key="name">inCurrencyPicker</string>
|
333
453
|
<string key="candidateClassName">UIPickerView</string>
|
334
454
|
</object>
|
455
|
+
<object class="IBToOneOutletInfo" key="outAmount">
|
456
|
+
<string key="name">outAmount</string>
|
457
|
+
<string key="candidateClassName">UITextField</string>
|
458
|
+
</object>
|
335
459
|
<object class="IBToOneOutletInfo" key="outCurrencyPicker">
|
336
460
|
<string key="name">outCurrencyPicker</string>
|
337
461
|
<string key="candidateClassName">UIPickerView</string>
|
@@ -348,10 +472,10 @@
|
|
348
472
|
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
|
349
473
|
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
|
350
474
|
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
|
351
|
-
<real value="
|
475
|
+
<real value="1536" key="NS.object.0"/>
|
352
476
|
</object>
|
353
477
|
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
354
478
|
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
355
|
-
<string key="IBCocoaTouchPluginVersion">
|
479
|
+
<string key="IBCocoaTouchPluginVersion">1926</string>
|
356
480
|
</data>
|
357
481
|
</archive>
|
@@ -1,8 +1,176 @@
|
|
1
1
|
calatrava ?= {}
|
2
|
+
calatrava.bridge ?= {}
|
2
3
|
|
3
|
-
|
4
|
+
calatravaId = () ->
|
5
|
+
str = ''
|
6
|
+
_.times 32, () ->
|
7
|
+
r = Math.floor(Math.random() * 16)
|
8
|
+
str = str + r.toString(16)
|
9
|
+
str.toUpperCase()
|
4
10
|
|
5
|
-
calatrava.
|
11
|
+
calatrava.inbound =
|
12
|
+
dispatchEvent: (proxyId) ->
|
13
|
+
extraArgs = _.map(_.toArray(arguments).slice(1), ((obj) -> obj.valueOf() if obj?))
|
14
|
+
proxyPage = calatrava.bridge.pages.pageByProxyId(proxyId)
|
15
|
+
proxyPage.dispatch.apply(proxyPage, extraArgs)
|
6
16
|
|
7
|
-
|
17
|
+
fieldRead: (proxyId, getId, fieldValue) ->
|
18
|
+
proxyPage = calatrava.bridge.pages.pageByProxyId(proxyId)
|
19
|
+
proxyPage.fieldRead(getId, fieldValue)
|
8
20
|
|
21
|
+
successfulRespone: (requestId, response) ->
|
22
|
+
calatrava.bridge.requests.successfulResponse(requestId, response)
|
23
|
+
|
24
|
+
failureResponse: (requestId, errorCode, response) ->
|
25
|
+
calatrava.bridge.requests.failureResponse(requestId,errorCode, response)
|
26
|
+
|
27
|
+
fireTimer: (timerId) ->
|
28
|
+
calatrava.bridge.timers.fireTimer(timerId)
|
29
|
+
|
30
|
+
invokeCallback: (widgetName) ->
|
31
|
+
extraArgs = _.map(_.toArray(arguments).slice(1), ((obj) -> obj.valueOf() if obj?))
|
32
|
+
calatrava.bridge.widgets.callback(widgetName).apply(this, extraArgs)
|
33
|
+
|
34
|
+
calatrava.bridge.changePage = (target) ->
|
35
|
+
calatrava.bridge.runtime.changePage(target)
|
36
|
+
target
|
37
|
+
|
38
|
+
calatrava.bridge.alert = (message) ->
|
39
|
+
calatrava.bridge.runtime.alert(message)
|
40
|
+
|
41
|
+
calatrava.bridge.openUrl = (url) ->
|
42
|
+
calatrava.bridge.runtime.openUrl(url)
|
43
|
+
|
44
|
+
calatrava.bridge.log = (message) ->
|
45
|
+
calatrava.bridge.runtime.log(message)
|
46
|
+
|
47
|
+
calatrava.bridge.request = (options) ->
|
48
|
+
if options.contentType?
|
49
|
+
options.customHeaders ||= {}
|
50
|
+
options.customHeaders['Content-Type'] = options.contentType
|
51
|
+
calatrava.bridge.requests.issue(
|
52
|
+
options.url,
|
53
|
+
options.method,
|
54
|
+
options.body,
|
55
|
+
options.success,
|
56
|
+
options.failure,
|
57
|
+
options.customHeaders
|
58
|
+
)
|
59
|
+
|
60
|
+
calatrava.bridge.widgets = (() ->
|
61
|
+
callbacks = {}
|
62
|
+
|
63
|
+
display: (name, options, callback) ->
|
64
|
+
# Runtime call to display the widget
|
65
|
+
callbacks[name] = callback
|
66
|
+
|
67
|
+
callback: (name) ->
|
68
|
+
callbacks[name]
|
69
|
+
)()
|
70
|
+
|
71
|
+
calatrava.bridge.pageObject = (pageName) ->
|
72
|
+
proxyId = calatravaId()
|
73
|
+
handlerRegistry = {}
|
74
|
+
outstandingGets = {}
|
75
|
+
|
76
|
+
calatrava.bridge.runtime.registerProxyForPage(proxyId, pageName)
|
77
|
+
|
78
|
+
bind: (event, handler) ->
|
79
|
+
handlerRegistry[event] = handler
|
80
|
+
calatrava.bridge.runtime.attachProxyEventHandler(proxyId, event)
|
81
|
+
|
82
|
+
bindAll: (options) ->
|
83
|
+
_.each options, (handler, event) => pageObject.bind event, handler
|
84
|
+
|
85
|
+
dispatch: (event) ->
|
86
|
+
args = _.toArray(arguments).slice(1)
|
87
|
+
handlerRegistry[event]?.apply(this, args)
|
88
|
+
|
89
|
+
get: (field, callback) ->
|
90
|
+
getId = calatravaId()
|
91
|
+
outstandingGets[getId] = callback
|
92
|
+
calatrava.bridge.runtime.valueOfProxyField(proxyId, field, getId)
|
93
|
+
|
94
|
+
fieldRead: (getId, fieldValue) ->
|
95
|
+
outstandingGets[getId](fieldValue)
|
96
|
+
delete outstandingGets[getId]
|
97
|
+
|
98
|
+
getMany: (fields, callback) ->
|
99
|
+
results = {}
|
100
|
+
getManyPrime = (remaining) =>
|
101
|
+
if (remaining.length > 0)
|
102
|
+
field = _.first(remaining)
|
103
|
+
@get field, (fieldValue) ->
|
104
|
+
results[field] = fieldValue
|
105
|
+
getManyPrime(_.rest(remaining))
|
106
|
+
else
|
107
|
+
callback(results)
|
108
|
+
getManyPrime(fields)
|
109
|
+
|
110
|
+
render: (viewObject) -> calatrava.bridge.runtime.renderProxy(viewObject, proxyId)
|
111
|
+
proxyId: proxyId
|
112
|
+
|
113
|
+
calatrava.bridge.pages = (()->
|
114
|
+
pagesByName = {}
|
115
|
+
pagesByProxyId = {}
|
116
|
+
|
117
|
+
pageNamed: (pageName) ->
|
118
|
+
if !pagesByName[pageName]?
|
119
|
+
page = calatrava.bridge.pageObject(pageName)
|
120
|
+
pagesByName[pageName] = page
|
121
|
+
pagesByProxyId[page.proxyId] = page
|
122
|
+
pagesByName[pageName]
|
123
|
+
|
124
|
+
pageByProxyId: (proxyId) ->
|
125
|
+
pagesByProxyId[proxyId]
|
126
|
+
)()
|
127
|
+
|
128
|
+
calatrava.bridge.requests = (() ->
|
129
|
+
successHandlersById = {}
|
130
|
+
failureHandlersById = {}
|
131
|
+
|
132
|
+
clearHandlers = (requestId) ->
|
133
|
+
delete successHandlersById[requestId]
|
134
|
+
delete failureHandlersById[requestId]
|
135
|
+
|
136
|
+
issue: (url, method, body, success, failure, customHeaders) ->
|
137
|
+
requestId = calatravaId()
|
138
|
+
bodyStr = body
|
139
|
+
|
140
|
+
if bodyStr? && bodyStr.constructor != String
|
141
|
+
bodyStr = JSON.stringify(body)
|
142
|
+
|
143
|
+
successHandlersById[requestId] = success
|
144
|
+
failureHandlersById[requestId] = failure
|
145
|
+
|
146
|
+
calatrava.bridge.runtime.issueRequest
|
147
|
+
requestId: requestId
|
148
|
+
url: url
|
149
|
+
method: method
|
150
|
+
body: bodyStr
|
151
|
+
headers: customHeaders
|
152
|
+
|
153
|
+
successfulResponse: (requestId, response) ->
|
154
|
+
successHandlersById[requestId](response)
|
155
|
+
clearHandlers(requestId)
|
156
|
+
|
157
|
+
failureResponse: (requestId, response) ->
|
158
|
+
failureHandlersById[requestId](response)
|
159
|
+
clearHandlers(requestId)
|
160
|
+
)()
|
161
|
+
|
162
|
+
calatrava.bridge.timers = (() ->
|
163
|
+
callbacks= {}
|
164
|
+
|
165
|
+
start: (timeout, callback) ->
|
166
|
+
timerId = calatravaId()
|
167
|
+
callbacks[timerId] = callback
|
168
|
+
calatrava.bridge.runtime.startTimerWithTimeout(timerId, timeout)
|
169
|
+
timerId
|
170
|
+
|
171
|
+
fireTimer: (timerId) ->
|
172
|
+
callbacks[timerId]() if callbacks[timerId]
|
173
|
+
|
174
|
+
clearTimer: (timerId) ->
|
175
|
+
delete callbacks[timerId]
|
176
|
+
)()
|
@@ -2,49 +2,44 @@ example ?= {}
|
|
2
2
|
example.converter ?= {}
|
3
3
|
|
4
4
|
example.converter.controller = ({views, changePage, ajax}) ->
|
5
|
+
currencies = ['USD', 'AUD', 'GBP', 'INR']
|
6
|
+
currencyRate =
|
7
|
+
USD: 1
|
8
|
+
AUD: 0.96
|
9
|
+
GBP: 0.62
|
10
|
+
INR: 55
|
5
11
|
|
6
|
-
currencies = ['USD','AUD','GBP']
|
7
12
|
inCurrency = "USD"
|
8
13
|
outCurrency = "AUD"
|
9
14
|
|
10
|
-
currencyDropdownViewMessage = (selectedCurrency,unselectableCurrency) ->
|
11
|
-
_.map
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
inCurrency = selectedCurrency
|
42
|
-
renderOutCurrencyList()
|
43
|
-
|
44
|
-
|
45
|
-
views.conversionForm.bind 'selectedOutCurrency', (selectedCurrency) ->
|
46
|
-
outCurrency = selectedCurrency
|
47
|
-
renderInCurrencyList()
|
48
|
-
|
49
|
-
renderInCurrencyList()
|
50
|
-
renderOutCurrencyList()
|
15
|
+
currencyDropdownViewMessage = (selectedCurrency, unselectableCurrency) ->
|
16
|
+
_.map currencies, (c) ->
|
17
|
+
code: c,
|
18
|
+
enabled: c != unselectableCurrency
|
19
|
+
selected: c == selectedCurrency
|
20
|
+
|
21
|
+
convert = () ->
|
22
|
+
views.conversionForm.get 'in_amount', (inAmount) ->
|
23
|
+
outRate = currencyRate[outCurrency]
|
24
|
+
inRate = currencyRate[inCurrency]
|
25
|
+
views.conversionForm.render
|
26
|
+
out_amount: (Math.round(inAmount * (outRate / inRate) * 100)) / 100
|
27
|
+
|
28
|
+
views.conversionForm.bind 'convert', convert
|
29
|
+
|
30
|
+
views.conversionForm.bind 'selectedInCurrency', ->
|
31
|
+
views.conversionForm.get 'in_currency', (in_currency) ->
|
32
|
+
inCurrency = in_currency
|
33
|
+
views.conversionForm.render
|
34
|
+
outCurrencies: currencyDropdownViewMessage outCurrency, inCurrency
|
35
|
+
|
36
|
+
views.conversionForm.bind 'selectedOutCurrency', ->
|
37
|
+
views.conversionForm.get 'out_currency', (out_currency) ->
|
38
|
+
outCurrency = out_currency
|
39
|
+
views.conversionForm.render
|
40
|
+
inCurrencies: currencyDropdownViewMessage inCurrency, outCurrency
|
41
|
+
|
42
|
+
views.conversionForm.render
|
43
|
+
inCurrencies: currencyDropdownViewMessage inCurrency, outCurrency
|
44
|
+
outCurrencies: currencyDropdownViewMessage outCurrency, inCurrency
|
45
|
+
in_amount: 1
|