aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/app.js5
-rw-r--r--www/js/views/details.js22
-rw-r--r--www/js/views/login.js12
-rw-r--r--www/js/views/search.js11
-rw-r--r--www/js/views/submit.js7
5 files changed, 48 insertions, 9 deletions
diff --git a/www/js/app.js b/www/js/app.js
index 3caba69..bfeef55 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -142,6 +142,11 @@ var tpl = {
}
FMS.initialized = 1;
tpl.loadTemplates( FMS.templates, function() {
+
+ if ( device.platform === 'Android' ) {
+ $.mobile.defaultPageTransition = 'none';
+ }
+
_.extend(FMS, {
router: new FMS.appRouter(),
locator: new FMS.Locate()
diff --git a/www/js/views/details.js b/www/js/views/details.js
index 1cd0efd..17f8d68 100644
--- a/www/js/views/details.js
+++ b/www/js/views/details.js
@@ -13,18 +13,18 @@
'click .ui-btn-left': 'onClickButtonPrev',
'click .ui-btn-right': 'onClickButtonNext',
'blur textarea': 'updateCurrentReport',
- 'change select': 'updateCurrentReport',
+ 'change select': 'updateSelect',
'blur input': 'updateCurrentReport'
},
afterRender: function() {
+ this.$('#form_category').attr('data-role', 'none');
+
if ( this.model.get('category') ) {
this.$('#form_category').val( this.model.get('category') );
+ this.setSelectClass();
}
- this.$('#form_category')
- .attr('data-role', 'none')
- .addClass('noselection');
},
afterDisplay: function() {
@@ -73,6 +73,20 @@
}
},
+ setSelectClass: function() {
+ var cat = $('#form_category');
+ if ( cat.val() !== "" && cat.val() !== '-- Pick a category --' ) {
+ cat.removeClass('noselection');
+ } else {
+ cat.addClass('noselection');
+ }
+ },
+
+ updateSelect: function() {
+ this.updateCurrentReport();
+ this.setSelectClass();
+ },
+
updateCurrentReport: function() {
if ( $('#form_category').val() && $('#form_title').val() && $('#form_detail').val() ) {
$('#next').addClass('page_complete_btn');
diff --git a/www/js/views/login.js b/www/js/views/login.js
index 312eda5..9f3d197 100644
--- a/www/js/views/login.js
+++ b/www/js/views/login.js
@@ -10,12 +10,15 @@
'pagebeforeshow': 'beforeDisplay',
'pageshow': 'afterDisplay',
'click #login': 'onClickLogin',
+ 'submit #signinForm': 'onClickLogin',
'click #logout': 'onClickLogout',
'click .ui-btn-left': 'onClickButtonPrev',
'click .ui-btn-right': 'onClickButtonNext'
},
- onClickLogin: function() {
+ onClickLogin: function(e) {
+ // prevent form submission from onscreen keyboard
+ e.preventDefault();
if ( this.validate() ) {
var that = this;
$.ajax( {
@@ -37,7 +40,9 @@
FMS.isLoggedIn = 1;
that.$('#password_row').hide();
that.$('#success_row').show();
+ $('#logout').focus();
} else {
+ $('#login').focus();
that.validationError('form_email', FMS.strings.login_error);
}
},
@@ -90,6 +95,11 @@
this.validationError('form_email', FMS.validationStrings.email.email);
}
+ if ( !isValid ) {
+ // this makes sure the onscreen keyboard is dismissed
+ $('#login').focus();
+ }
+
return isValid;
}
})
diff --git a/www/js/views/search.js b/www/js/views/search.js
index b506884..0cf1de2 100644
--- a/www/js/views/search.js
+++ b/www/js/views/search.js
@@ -10,7 +10,8 @@
'click #locate': 'goLocate',
'pagehide': 'destroy',
'pagebeforeshow': 'beforeDisplay',
- 'pageshow': 'afterDisplay'
+ 'pageshow': 'afterDisplay',
+ 'submit #postcodeForm': 'search'
},
afterDisplay: function() {
@@ -19,7 +20,9 @@
}
},
- search: function() {
+ search: function(e) {
+ // this is to stop form submission
+ e.preventDefault();
var pc = this.$('#pc').val();
this.listenTo(FMS.locator, 'search_located', this.searchSuccess );
this.listenTo(FMS.locator, 'search_failed', this.searchFail);
@@ -44,6 +47,8 @@
},
searchFail: function( details ) {
+ // this makes sure any onscreen keyboard is dismissed
+ $('#submit').focus();
this.stopListening(FMS.locator);
if ( details.msg ) {
this.displayError( details.msg );
@@ -65,7 +70,7 @@
this.navigate( 'around' );
},
- destroy: function() {
+ _destroy: function() {
delete FMS.searchMessage;
this.stopListening(FMS.locator);
}
diff --git a/www/js/views/submit.js b/www/js/views/submit.js
index 4380007..e385359 100644
--- a/www/js/views/submit.js
+++ b/www/js/views/submit.js
@@ -32,6 +32,8 @@
},
onClickSubmit: function(e) {
+ // in case we are getting here from a form submission
+ e.preventDefault();
this.beforeSubmit();
if ( this.validate() ) {
@@ -204,7 +206,8 @@
'pageshow': 'afterDisplay',
'click .ui-btn-left': 'onClickButtonPrev',
'click #report': 'onClickSubmit',
- 'click #confirm_name': 'onClickSubmit'
+ 'click #confirm_name': 'onClickSubmit',
+ 'submit #passwordForm': 'onClickSubmit'
},
initialize: function() {
@@ -247,10 +250,12 @@
$('#form_name').val(err.check_name);
$('#password_row').hide();
$('#check_name').show();
+ $('#confirm_name').focus();
} else {
if ( err.errors && err.errors.password ) {
this.validationError('form_password', err.errors.password );
}
+ $('#report').focus();
}
}