PageRenderTime 20ms CodeModel.GetById 15ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/hippo/src/main/webapp/js/form/NewExperimentForm.js

http://hdbc.googlecode.com/
JavaScript | 63 lines | 57 code | 6 blank | 0 comment | 0 complexity | ad0404f4bdbcd7cb05042cb7dc255473 MD5 | raw file
 1
 2Ext.namespace('Hippo.form');
 3
 4Hippo.form.NewExperimentForm = Ext.extend(Ext.form.FormPanel, {
 5
 6	submitHandler: function(e, t) {
 7		this.getForm().submit({
 8			url: 'console/experiments'
 9			,method: 'post'
10			,timeout: 5000
11			,success: this.onSubmitSuccess.createDelegate(this)
12			,failure: this.onSubmitFail
13		});
14	}
15	,onSubmitSuccess: function(frm, action) {
16		var jsonRsp = Ext.util.JSON.decode(action.response.responseText);
17		Ext.getCmp('viewport').fireEvent("on_newExperimentSaved", jsonRsp, this.ownerCt);
18	}
19	,onSubmitFail: function(frm, act) {
20		Ext.Msg.alert('Failure', act.response.statusText);
21	}
22	,initComponent : function() {
23		Ext.apply(this, {
24			id: 'newexpmntform'
25			,bodyStyle: 'padding: 5px 5px 5px 5px'
26			,frame: true
27			,method: 'post'
28			,buttons: [{id: 'create' ,text: 'create' ,xtype: 'button'
29				,listeners: {
30					'click': {
31						fn: this.submitHandler
32						,scope: this
33					}
34				}
35			}
36			,{
37				id: 'cancel'
38				,text: 'cancel'
39				,xtype: 'button'
40				,listeners: {
41					'click': {
42						fn: function(e, t) {
43							this.ownerCt.ownerCt.ownerCt.destroy();
44						}
45					}
46				}
47			}]
48			,defaults: {
49				allowBlank: false
50				,width: 325
51			}
52			,items: [
53				{id: 'title', name: 'title', fieldLabel: 'title', maxLength: 64, xtype: 'textfield'}
54				,{id: 'purpose', name: 'purpose', fieldLabel: 'purpose', maxLength: 128, xtype: 'textarea'}
55			]
56
57		});
58		
59		Hippo.form.NewExperimentForm.superclass.initComponent.apply(this, arguments);
60	}
61});
62
63Ext.reg('form.NewExperimentForm', Hippo.form.NewExperimentForm);