aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/js/views/around.js22
-rw-r--r--src/js/views/submit.js14
2 files changed, 29 insertions, 7 deletions
diff --git a/src/js/views/around.js b/src/js/views/around.js
index 1315710..eae53ff 100644
--- a/src/js/views/around.js
+++ b/src/js/views/around.js
@@ -140,6 +140,23 @@
// is up so we probably should not recenter
if ( FMS.currentPosition ) {
fixmystreet.map.panTo(this.projectCoords( FMS.currentPosition ));
+
+ // If we've confirmed the report position then we should be able
+ // to reposition it if we've moved the map.
+ if ( $('#confirm').css('display') == 'block' ) {
+ var currentPos = this.projectCoords(FMS.currentPosition);
+ var markerPos = this.getMarkerPosition(true);
+
+ // Displaying the button if the report is in the same place as the
+ // GPS location could be confusing so check they are different.
+ // The slight margin of error is there to account for both rounding
+ // wiggle in the projectCoords and also so that small changes due to
+ // GPS noise are ignored
+ if ( Math.abs(markerPos.lat - currentPos.lat) > 1 ||
+ Math.abs(markerPos.lon - currentPos.lon) > 1 ) {
+ $('#reposition').show();
+ }
+ }
}
},
@@ -420,10 +437,13 @@
return position;
},
- getMarkerPosition: function() {
+ getMarkerPosition: function(skipTransform) {
var marker = fixmystreet.report_location.features[0].geometry;
var position = new OpenLayers.LonLat( marker.x, marker.y );
+ if ( skipTransform ) {
+ return position;
+ }
position.transform(
fixmystreet.map.getProjectionObject(),
new OpenLayers.Projection("EPSG:4326")
diff --git a/src/js/views/submit.js b/src/js/views/submit.js
index 3e11dd6..0a66236 100644
--- a/src/js/views/submit.js
+++ b/src/js/views/submit.js
@@ -236,7 +236,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);
}
@@ -362,12 +362,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 );
}
})
});