aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/views/submit.js
diff options
context:
space:
mode:
authorJedidiah Broadbent <hello@jedidiah.eu>2013-08-06 10:45:51 +0100
committerJedidiah Broadbent <hello@jedidiah.eu>2013-08-06 10:45:51 +0100
commitbf03d5d7697aa41dcc9de39ab6ac3e5e8f79aa9a (patch)
tree90419a714381c458c583eac1bc40d79cdfb638d4 /src/js/views/submit.js
parent1b6cf6dcc2758b2c3ca5e8a5ff4b06d83132d072 (diff)
parent3cb1cc455210fa60fb44fbb105e733378699c2a9 (diff)
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/fixmystreet-mobile
Diffstat (limited to 'src/js/views/submit.js')
-rw-r--r--src/js/views/submit.js34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/js/views/submit.js b/src/js/views/submit.js
index 3e11dd6..5a45de2 100644
--- a/src/js/views/submit.js
+++ b/src/js/views/submit.js
@@ -98,6 +98,7 @@
}
}
errorList += '</ul>';
+ $('p.top').hide();
$('#errors').html(errorList).show();
}
},
@@ -139,10 +140,23 @@
});
})(FMS, Backbone, _, $);
+(function (FMS, Backbone, _, $) {
+ _.extend( FMS, {
+ SubmitInitialPageView: FMS.SubmitView.extend({
+ onClickButtonPrev: function() {
+ if ( this.model.get('hasExtras') == 1 ) {
+ this.navigate( 'details_extra', true );
+ } else {
+ this.navigate( 'details', true );
+ }
+ }
+ })
+ });
+})(FMS, Backbone, _, $);
(function (FMS, Backbone, _, $) {
_.extend( FMS, {
- SubmitEmailView: FMS.SubmitView.extend({
+ SubmitEmailView: FMS.SubmitInitialPageView.extend({
template: 'submit_email',
id: 'submit-email-page',
prev: 'details',
@@ -236,7 +250,7 @@
this.validationError('form_name', FMS.validationStrings.name.required );
} else {
var validNamePat = /\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i;
- if ( name.length < 6 || !name.match( /\S/ ) || name.match( validNamePat ) ) {
+ if ( name.length < 6 || !name.match( /\s/ ) || !name.match( /\S/ ) || name.match( validNamePat ) ) {
isValid = 0;
this.validationError('form_name', FMS.validationStrings.name.validName);
}
@@ -253,6 +267,8 @@
},
beforeSubmit: function() {
+ $('#errors').hide();
+ $('p.top').show();
this.model.set('name', $('#form_name').val());
this.model.set('phone', $('#form_phone').val());
this.model.set('may_show_name', $('#form_may_show_name').val());
@@ -362,12 +378,14 @@
onClickContinue: function(e) {
e.preventDefault();
- $('#continue').focus();
- if ( ! this.model.get('submit_clicked') ) {
- this.model.set('submit_clicked', 'submit_sign_in');
+ if ( this.validate() ) {
+ $('#continue').focus();
+ if ( ! this.model.get('submit_clicked') ) {
+ this.model.set('submit_clicked', 'submit_sign_in');
+ }
+ FMS.currentUser.set('password', $('#form_password').val());
+ this.navigate( this.next );
}
- FMS.currentUser.set('password', $('#form_password').val());
- this.navigate( this.next );
}
})
});
@@ -375,7 +393,7 @@
(function (FMS, Backbone, _, $) {
_.extend( FMS, {
- SubmitConfirmView: FMS.SubmitView.extend({
+ SubmitConfirmView: FMS.SubmitInitialPageView.extend({
template: 'submit_confirm',
id: 'submit-confirm-page',
prev: 'details',