update contact form

This commit is contained in:
rolux 2011-11-02 10:22:19 +00:00
parent ec0a33bfdb
commit 19a6eb66f8
2 changed files with 117 additions and 45 deletions

View file

@ -1,57 +1,123 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.contactForm = function() { pandora.ui.contactForm = function() {
var that = Ox.Element(), var that = Ox.Element(),
width = getWidth(),
$receiptCheckbox = Ox.Checkbox({
checked: true,
id: 'receipt',
title: 'Send me a receipt',
width: width - 136
})
.bindEvent({
change: function(data) {
$receiptCheckbox.options({
title: (data.checked ? 'Send' : 'Don\'t send')
+ ' me a receipt'
});
}
}),
$form = Ox.Form({ $form = Ox.Form({
items: [ items: [
Ox.Input({
id: 'name',
label: 'Your Name',
labelWidth: 128,
value: pandora.user.username,
width: width
}),
Ox.Input({ Ox.Input({
id: 'email', id: 'email',
label: 'E-Mail', label: 'Your E-Mail Address',
labelWidth: 60, labelWidth: 128,
value: pandora.user.email, value: pandora.user.email,
width: 240 width: width
}), }),
Ox.Input({ Ox.Input({
id: 'subject', id: 'subject',
label: 'Subject', label: 'Subject',
labelWidth: 60, labelWidth: 128,
value: '', value: '',
width: 240 width: width
}), }),
Ox.Input({ Ox.Input({
height: 120, height: 256,
id: 'message', id: 'message',
placeholder: 'Message', placeholder: 'Message',
type: 'textarea', type: 'textarea',
value: '', value: '',
width: 240 width: width
}) }),
.css({height: '240px'}) $receiptCheckbox
], ],
submit: function(data, callback) { submit: function(data, callback) {
pandora.api.contact({ pandora.api.contact({
name: data.name,
email: data.email, email: data.email,
subject: data.subject, subject: data.subject,
message: data.message message: data.message,
receipt: data.receipt
}, function(result) { }, function(result) {
callback && callback(result); callback && callback(result);
}); });
}, },
width: 240 width: 240
}) })
.css({margin: '8px'})
.bindEvent({ .bindEvent({
change: function(event) { change: function(event) {
} }
}) })
.appendTo(that); .appendTo(that),
Ox.Button({ $sendButton = Ox.Button({
title: 'Send' title: 'Send Message',
width: 128
}) })
.css({position: 'absolute', left: width - 112 + 'px', top: '352px'})
.bindEvent({ .bindEvent({
click: function() { click: function() {
$form.submit(); $form.submit();
} }
}).appendTo(that); })
.appendTo(that);
$text = $('<div>')
.css({float: 'left', width: width + 'px'})
.html(
'Alternatively, you can contact us via <a href="mailto:'
+ pandora.site.site.email.contact + '">'
+ pandora.site.site.email.contact + '</a>'
);
$('<div>')
.css({marginTop: '8px'})
.append($text)
.append(
)
.appendTo(that);
function getWidth() {
return Math.min((
pandora.$ui.siteDialog
? parseInt(pandora.$ui.siteDialog.css('width'))
: Math.round(window.innerWidth * 0.75)
) - 304, 512);
}
that.resize = function() {
var width = getWidth();
$form.options('items').forEach(function($input, i) {
i < 4 && $input.options({width: width});
});
$receiptCheckbox.options({width: width - 136})
$sendButton.css({left: width - 112 + 'px'})
$text.css({width: width + 'px'});
}
return that; return that;
}; };

View file

@ -10,10 +10,9 @@ pandora.ui.siteDialog = function(section) {
content: function(id) { content: function(id) {
var $content = Ox.Element().css({padding: '16px', overflowY: 'auto'}); var $content = Ox.Element().css({padding: '16px', overflowY: 'auto'});
if (id == 'contact') { if (id == 'contact') {
$content.append(pandora.ui.contactForm()); $content.append(pandora.$ui.contactForm = pandora.ui.contactForm());
} else { } else {
pandora.api.getPage({name: id}, function(result) { pandora.api.getPage({name: id}, function(result) {
Ox.print('DATA::', result.data)
Ox.Editable({ Ox.Editable({
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
editable: pandora.site.capabilities.canEditSitePages[pandora.user.level], editable: pandora.site.capabilities.canEditSitePages[pandora.user.level],
@ -84,9 +83,16 @@ pandora.ui.siteDialog = function(section) {
height: Math.round((window.innerHeight - 24) * 0.75), height: Math.round((window.innerHeight - 24) * 0.75),
//maximizeButton: true, //maximizeButton: true,
minHeight: 256, minHeight: 256,
minWidth: 640, minWidth: 688, // 16 + 256 + 16 + 384 + 16
title: 'About', title: 'About',
width: Math.round(window.innerWidth * 0.75), width: Math.round(window.innerWidth * 0.75),
})
.bindEvent({
resize: function(data) {
if ($tabPanel.selected() == 'contact') {
pandora.$ui.contactForm.resize();
}
}
}); });
return $dialog; return $dialog;