-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
178 lines (162 loc) · 7.19 KB
/
app.js
File metadata and controls
178 lines (162 loc) · 7.19 KB
1
2
3
4
5
6
7
8
9
10
11
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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*!
*
* Bancha : Seamlessly integrates CakePHP with Ext JS and Sencha Touch (http://bancha.io)
* Copyright 2011-2014 codeQ e.U.
*
* @package BanchaTouchClient
* @copyright Copyright 2011-2014 codeQ e.U.
* @link http://bancha.io Bancha
* @author Roland Schuetz <mail@rolandschuetz.at>
*
* For more information go to http://bancha.io
*/
// include Bancha
Ext.Loader.setConfig('enabled', true);
Ext.Loader.setPath('Bancha','/bancha/js');
Ext.syncRequire('Bancha.Initializer');
/**
* This is a simple Sencha Touch app, showing how to
* retrieve & submit data from CakePHP using Bancha.
*/
Ext.application({
name: 'BanchaTouch',
// stlying
icon: 'resources/images/iTunesArtwork.png',
isIconPrecomposed: false, // apply glossy effect to icon
startupImage: {
'320x460' : 'resources/loading/phone_startup.png',
'640x920' : 'resources/loading/phone_startup.png',
'640x1096' : 'resources/loading/phone_startup.png',
'768x1004' : 'resources/loading/tablet_startup.png',
'748x1024' : 'resources/loading/tablet_startup.png',
'1536x2008': 'resources/loading/tablet_startup.png',
'1496x2048': 'resources/loading/tablet_startup.png'
},
// require Bancha model
models: [
'Bancha.model.User'
],
// build viewport
launch: function() {
Ext.create('Ext.tab.Panel', {
fullscreen: true,
tabBarPosition: 'bottom',
ui: 'dark',
items: [
// This is the home page, just some simple html
{
title: 'Home',
iconCls: 'home',
cls: 'home',
scrollable: true,
html: [
'<img height="173" src="http://bancha.io/tl_files/Bancha/images/logo.png" />',
'<p>This little App demonstrates how you can use Bancha with Sencha Touch 2</p>'
].join('')
},
// This page loads data from the CakePHP model User, using Bancha
{
xtype: 'list',
title: 'Store Sample',
iconCls: 'star',
cls: 'users',
itemTpl: '<div>{name}</div>',
store: Ext.create('Ext.data.Store', {
model: 'Bancha.model.User',
autoLoad: true
}),
onItemDisclosure: (function() {
var tpl = new Ext.XTemplate([
'Name: {name}<br/>',
'E-Mail: {email}<br/>',
'Height: {height}cm<br/>'
].join(''));
return function(record, btn, index) {
Ext.Msg.alert('Additional Information',tpl.apply(record.data),Ext.emptyFn);
};
}()),
detailCard: {
xtype: 'panel',
scrollable: true,
styleHtmlContent: true
}
},
// This is the contact page, which features a form and a button. The button submits the form
{
xtype: 'formpanel',
title: 'Controller',
iconCls: 'user',
cls: 'controller',
layout: 'vbox',
items: [
{
xtype: 'fieldset',
title: 'Exposed Remote Method',
instructions: [
'Just type in a name and get the appropriate greeting for the current day time.',
'If your name is Judas the server will return with an unsucessfull response.'
].join(''),
items: [
{
xtype: 'textfield',
label: 'Name',
name: 'name',
require: true
}
]
},
{
xtype: 'button',
text: 'Get Greetings',
ui: 'confirm',
// The handler is called when the button is tapped
handler: function() {
// This looks up the items stack above, getting a reference to the first form it see
var textfield = this.up('formpanel').down('textfield');
if(textfield.getValue()) {
// send the request to the server
var unixTimestamp = (Date.now()/1000).toString();
Bancha.getStub('Hello').getGreeting(unixTimestamp, textfield.getValue(),function(result) {
// this is the result callback
if(result.success) {
Ext.Msg.alert('Greetings', result.data);
} else {
Ext.Msg.alert('Error', 'The server does not want to talk to you.');
}
});
} else {
Ext.Msg.alert(
'Name not defined',
'Please write your name before asking for a greeting.', function() {
textfield.focus();
});
}
}
}
]
},
// This is the home page, just some simple html
{
title: 'About Bancha',
iconCls: 'info',
cls: 'info',
scrollable: true,
html: [
'<img height="85" src="http://bancha.io/tl_files/Bancha/images/logo.png" />',
'<p style="height:85px; padding-top:20px;">Bancha makes creating Apps with a CakePHP backend beautifull and easy.</p>',
'<p><br />The code can be found <a href="https://github.com/Bancha/BanchaTouchClient" target="_blank">on GitHub</a>.</p>',
'<p>For more information go to <a href="http://bancha.io" target="_blank">bancha.io</a></p>'
].join('')
}
],
listeners: {
painted: function() {
// if it's not a mobile screen, we have more space
if(Ext.Viewport.getWindowHeight() > 450) {
Ext.Viewport.addCls('big-screen');
}
}
}
});
} //eo launch
});