diff options
author | Struan Donald <struan@exo.org.uk> | 2013-08-23 12:28:22 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-08-23 12:28:22 +0100 |
commit | 05a58fa513a0a20834eface604217bf80513582b (patch) | |
tree | 74a90498e71dc2b6256da5bca320c63b5af726a5 | |
parent | 3f0eaa675e1dd90cf32fae78806da5b87203b0f5 (diff) |
Correctly handle back button on start screens
On the inital screens the android back button should quit the app, or if
on the map screen and you've started a report it should cancel it. Add
in a default back method to FMSView and an override method for the map,
exising report and offline screens
Fixes #117
-rw-r--r-- | src/js/router.js | 4 | ||||
-rw-r--r-- | src/js/views/around.js | 8 | ||||
-rw-r--r-- | src/js/views/existing.js | 4 | ||||
-rw-r--r-- | src/js/views/fms.js | 8 | ||||
-rw-r--r-- | src/js/views/offline.js | 4 |
5 files changed, 26 insertions, 2 deletions
diff --git a/src/js/router.js b/src/js/router.js index 6745835..c42a742 100644 --- a/src/js/router.js +++ b/src/js/router.js @@ -37,8 +37,8 @@ }, back: function(e) { - if (this.currentView && this.currentView.prev) { - this.currentView.onClickButtonPrev(e); + if (this.currentView && this.currentView.back) { + this.currentView.back(e); } }, diff --git a/src/js/views/around.js b/src/js/views/around.js index 964bef4..d912198 100644 --- a/src/js/views/around.js +++ b/src/js/views/around.js @@ -77,6 +77,14 @@ } }, + _back: function(e) { + if ( $('#confirm-map').css('display') == 'block' ) { + this.onClickCancel(e); + } else { + navigator.app.exitApp(); + } + }, + setMapPosition: function( info ) { var coords = info.coordinates; fixmystreet.latitude = coords.latitude; diff --git a/src/js/views/existing.js b/src/js/views/existing.js index 0d16760..a34fd0b 100644 --- a/src/js/views/existing.js +++ b/src/js/views/existing.js @@ -13,6 +13,10 @@ 'vclick #discard': 'discardReport' }, + _back: function() { + navigator.app.exitApp(); + }, + setHeight: function(content, height) { content.css( 'min-height', content + 'px'); }, diff --git a/src/js/views/fms.js b/src/js/views/fms.js index f60bf77..214dc2c 100644 --- a/src/js/views/fms.js +++ b/src/js/views/fms.js @@ -13,6 +13,14 @@ 'vclick .ui-btn-right': 'onClickButtonNext' }, + back: function(e) { + if ( this._back ) { + this._back(e); + } else if ( this.prev ) { + this.onClickButtonPrev(e); + } + }, + render: function(){ if ( !this.template ) { console.log('no template to render'); diff --git a/src/js/views/offline.js b/src/js/views/offline.js index ff28e4b..c90cd90 100644 --- a/src/js/views/offline.js +++ b/src/js/views/offline.js @@ -22,6 +22,10 @@ 'blur textarea': 'toggleNextButton' }, + _back: function() { + navigator.app.exitApp(); + }, + draftHasContent: function() { var hasContent = false; |