Code:
//<debug>
Ext.Loader.setPath({
'Ext': '../../src'
});
//</debug>
/**
* This is the output of the Sencha Touch 2.0 Getting Started Guide. It sets up a simple application
* with Sencha Touch, creating a Tab Panel with 3 tabs - home, blog and contact. The home page just
* shows html, the blog page uses a nested list to display recent blog posts, and the contact page
* uses a form to wire up user feedback.
*/
Ext.application({
name: 'Sencha',
startupImage: {
'320x460': 'resources/startup/Default.jpg', // Non-retina iPhone, iPod touch, and all Android devices
'640x920': 'resources/startup/640x920.png', // Retina iPhone and iPod touch
'640x1096': 'resources/startup/640x1096.png', // iPhone 5 and iPod touch (fifth generation)
'768x1004': 'resources/startup/768x1004.png', // Non-retina iPad (first and second generation) in portrait orientation
'748x1024': 'resources/startup/748x1024.png', // Non-retina iPad (first and second generation) in landscape orientation
'1536x2008': 'resources/startup/1536x2008.png', // : Retina iPad (third generation) in portrait orientation
'1496x2048': 'resources/startup/1496x2048.png' // : Retina iPad (third generation) in landscape orientation
},
isIconPrecomposed: false,
icon: {
57: 'resources/icons/icon.png',
72: 'resources/icons/icon@72.png',
114: 'resources/icons/icon@2x.png',
144: 'resources/icons/icon@144.png'
},
requires: [
'Ext.tab.Panel',
'Ext.form.*',
'Ext.field.*',
'Ext.data.*',
'Ext.data.proxy.JsonP'
],
launch: function() {
//The whole app UI lives in this tab panel
Ext.Viewport.add({
xtype: 'tabpanel',
fullscreen: true,
tabBarPosition: 'bottom',
items: [
// This is the home page, just some simple html
{
title: 'Home',
iconCls: 'home',
cls: 'home',
scrollable: true,
html: [
'<img height=260 src="http://staging.sencha.com/img/sencha.png" />',
'<h1>Welcome to Sencha Touch</h1>',
"<p>Building the Getting Started app</p>",
'<h2>Sencha Touch (2.0.0)</h2>'
].join("")
},
// This is the recent blogs page. It uses a tree store to load its data from blog.json
{
xtype: 'nestedlist',
title: 'Blog',
iconCls: 'star',
cls: 'blog',
displayField: 'title',
store: {
type: 'tree',
autoLoad: false,
fields: ['title', 'content'],
proxy: {
type: 'jsonp',
url: 'http://www.clickagencia.com.br/modelo/prata/wp-json/posts?type=pastorais',
reader: {
type: 'json',
rootProperty: 'posts'
}
}
},
detailCard: {
xtype: 'panel',
scrollable: true,
styleHtmlContent: true
},
listeners: {
itemtap: function(nestedList, list, index, element, post) {
this.getDetailCard().setHtml(post.get('content'));
}
}
},
// This is the contact page, which features a form and a button. The button submits the form
{
xtype: 'formpanel',
title: 'Contact Us',
iconCls: 'user',
url: 'contact.php',
layout: 'vbox',
items: [
{
xtype: 'fieldset',
title: 'Contact Us',
instructions: 'Email address is optional',
items: [
{
xtype: 'textfield',
label: 'Name',
name: 'name'
},
{
xtype: 'emailfield',
label: 'Email',
name: 'email'
},
{
xtype: 'textareafield',
label: 'Message',
name: 'message',
height: 90
}
]
},
{
xtype: 'button',
text: 'Send',
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 form = this.up('formpanel');
// Sends an AJAX request with the form data to the url specified above (contact.php).
// The success callback is called if we get a non-error response from the server
form.submit({
success: function() {
// The callback function is run when the user taps the 'ok' button
Ext.Msg.alert('Thank You', 'Your message has been received', function() {
form.reset();
});
}
});
}
}
]
}
]
});
}
});