contact-form.js
4.46 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
Ext.require([
'Ext.form.*',
'Ext.tip.QuickTipManager'
]);
Ext.onReady(function() {
var required = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';
var win;
Ext.QuickTips.init();
function showContactForm() {
if (!win) {
var form = Ext.widget('form', {
layout: {
type: 'vbox',
align: 'stretch'
},
border: false,
bodyPadding: 10,
fieldDefaults: {
labelAlign: 'top',
labelWidth: 100,
labelStyle: 'font-weight:bold'
},
items: [{
xtype: 'fieldcontainer',
fieldLabel: 'Your Name',
labelStyle: 'font-weight:bold;padding:0',
layout: 'hbox',
defaultType: 'textfield',
fieldDefaults: {
labelAlign: 'top'
},
items: [{
flex: 1,
name: 'firstName',
afterLabelTextTpl: required,
fieldLabel: 'First',
allowBlank: false
}, {
width: 30,
name: 'middleInitial',
fieldLabel: 'MI',
margins: '0 0 0 5'
}, {
flex: 2,
name: 'lastName',
afterLabelTextTpl: required,
fieldLabel: 'Last',
allowBlank: false,
margins: '0 0 0 5'
}]
}, {
xtype: 'textfield',
fieldLabel: 'Your Email Address',
afterLabelTextTpl: required,
vtype: 'email',
allowBlank: false
}, {
xtype: 'textfield',
fieldLabel: 'Subject',
afterLabelTextTpl: required,
allowBlank: false
}, {
xtype: 'textareafield',
fieldLabel: 'Message',
labelAlign: 'top',
flex: 1,
margins: '0',
afterLabelTextTpl: required,
allowBlank: false
}],
buttons: [{
text: 'Cancel',
handler: function() {
this.up('form').getForm().reset();
this.up('window').hide();
}
}, {
text: 'Send',
handler: function() {
if (this.up('form').getForm().isValid()) {
// In a real application, this would submit the form to the configured url
// this.up('form').getForm().submit();
this.up('form').getForm().reset();
this.up('window').hide();
Ext.MessageBox.alert('Thank you!', 'Your inquiry has been sent. We will respond as soon as possible.');
}
}
}]
});
win = Ext.widget('window', {
title: 'Contact Us',
closeAction: 'hide',
width: 400,
height: 400,
layout: 'fit',
resizable: true,
modal: true,
items: form
});
}
win.show();
}
var mainPanel = Ext.widget('panel', {
renderTo: Ext.getBody(),
title: 'Welcome!',
width: 500,
bodyPadding: 20,
items: [{
xtype: 'component',
html: 'Thank you for visiting our site! We welcome your feedback; please click the button below to ' +
'send us a message. We will respond to your inquiry as quickly as possible.',
style: 'margin-bottom: 20px;'
}, {
xtype: 'container',
style: 'text-align:center',
items: [{
xtype: 'button',
cls: 'contactBtn',
scale: 'large',
text: 'Contact Us',
handler: showContactForm
}]
}]
});
});