Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding the start of example8, the real-time chat example

  • Loading branch information...
commit 925fa200f40f5e64ffd6ea7b0fe5d1ef8fd67d32 1 parent 4aa7124
@enygma authored
View
1  zfapp/public/js/examples/example8/README.md
@@ -0,0 +1 @@
+unit testing extjs with jasmine
View
23 zfapp/public/js/examples/example8/app.js
@@ -0,0 +1,23 @@
+Ext.application({
+ name: 'example8',
+
+ appFolder: '/js/examples/example8/app',
+
+ controllers: [
+ 'Index'
+ ],
+
+ launch: function() {
+ console.log('Launch application "example8"');
+
+ Ext.create('Ext.container.Viewport', {
+ layout: 'fit',
+ items: [
+ {
+ xtype : 'userwin'
+ }
+ ]
+ });
+ }
+
+});
View
21 zfapp/public/js/examples/example8/app/controller/Index.js
@@ -0,0 +1,21 @@
+Ext.define('example8.controller.Index', {
+
+ extend: 'Ext.app.Controller',
+
+ models: [
+ 'User'
+ ],
+ views: [
+ 'index.Userwin'
+ ],
+ stores: [
+ 'Currentuser'
+ ],
+
+ init: function() {
+ console.log('init Index controller');
+
+ indexController = this;
+ }
+
+});
View
6 zfapp/public/js/examples/example8/app/model/User.js
@@ -0,0 +1,6 @@
+Ext.define('example8.model.User', {
+
+ extend: 'Ext.data.Model',
+ fields: ['name','id']
+
+});
View
6 zfapp/public/js/examples/example8/app/store/Currentuser.js
@@ -0,0 +1,6 @@
+Ext.define('example8.store.Currentuser', {
+
+ extend: 'Ext.data.Store',
+ model: 'example8.model.User'
+
+});
View
64 zfapp/public/js/examples/example8/app/view/index/Userwin.js
@@ -0,0 +1,64 @@
+Ext.define('example8.view.index.Userwin', {
+
+ extend: 'Ext.window.Window',
+ alias: 'widget.userwin',
+ title: 'Please enter a username',
+ autoShow : true,
+ layout: 'anchor',
+ id: 'userwin',
+ width: 300,
+
+ items: [
+ {
+ xtype: 'form',
+ url: '/example/example8submit/format/json',
+ id: 'userform',
+ bodyStyle: 'padding: 5px',
+ items: [
+ {
+ xtype : 'textfield',
+ name : 'username',
+ fieldLabel : 'Username',
+ allowBlank : false,
+ minLength : 5
+ }
+ ]
+ }
+ ],
+
+ buttons: [
+ {
+ text : 'Enter',
+ handler : function() {
+ Ext.getCmp('userwin').submitForm();
+ }
+ }
+ ],
+
+ submitForm: function() {
+ var form = Ext.getCmp('userform').getForm();
+ var currentWin = Ext.getCmp('userwin');
+
+ if (form.isValid()) {
+ form.submit({
+ success: function(form,action) {
+ console.log('Form submit success! Response: '+action.result.message);
+
+ var formValues = form.getValues();
+ console.log(formValues);
+
+ // set the user information into our currentuser store
+ var cuser = indexController.getStore('Currentuser');
+ console.log(cuser);
+ cuser.add({
+ name: formValues.username,
+ id: 1
+ });
+ },
+ failure: function(form,action) {
+ console.log('Form submit failure! Response: '+action.result.message);
+ }
+ });
+ }
+ }
+});
Please sign in to comment.
Something went wrong with that request. Please try again.