12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- parasails.registerPage('contact', {
- // ╦╔╗╔╦╔╦╗╦╔═╗╦ ╔═╗╔╦╗╔═╗╔╦╗╔═╗
- // ║║║║║ ║ ║╠═╣║ ╚═╗ ║ ╠═╣ ║ ║╣
- // ╩╝╚╝╩ ╩ ╩╩ ╩╩═╝ ╚═╝ ╩ ╩ ╩ ╩ ╚═╝
- data: {
- // Main syncing/loading state for this page.
- syncing: false,
- // Form data
- formData: { /* … */ },
- // For tracking client-side validation errors in our form.
- // > Has property set to `true` for each invalid property in `formData`.
- formErrors: { /* … */ },
- // Server error state for the form
- cloudError: '',
- // Success state when form has been submitted
- cloudSuccess: false,
- },
- // ╦ ╦╔═╗╔═╗╔═╗╦ ╦╔═╗╦ ╔═╗
- // ║ ║╠╣ ║╣ ║ ╚╦╝║ ║ ║╣
- // ╩═╝╩╚ ╚═╝╚═╝ ╩ ╚═╝╩═╝╚═╝
- mounted: function() {
- this.$focus('[autofocus]');
- },
- // ╦╔╗╔╔╦╗╔═╗╦═╗╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
- // ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗
- // ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝
- methods: {
- handleParsingForm: function() {
- // Clear out any pre-existing error messages.
- this.formErrors = {};
- var argins = this.formData;
- // Validate email:
- if(!argins.emailAddress) {
- this.formErrors.emailAddress = true;
- }
- // Validate name:
- if(!argins.fullName) {
- this.formErrors.fullName = true;
- }
- // Validate topic:
- if(!argins.topic) {
- this.formErrors.topic = true;
- }
- // Validate message:
- if(!argins.message) {
- this.formErrors.message = true;
- }
- // If there were any issues, they've already now been communicated to the user,
- // so simply return undefined. (This signifies that the submission should be
- // cancelled.)
- if (Object.keys(this.formErrors).length > 0) {
- return;
- }
- return argins;
- },
- submittedForm: function() {
- // Show the success message.
- this.cloudSuccess = true;
- },
- }
- });
|