summaryrefslogtreecommitdiff
path: root/www/js/MonitorCtrl.js
diff options
context:
space:
mode:
authorArjun Roychowdhury <pliablepixels@gmail.com>2015-11-04 13:00:08 -0500
committerArjun Roychowdhury <pliablepixels@gmail.com>2015-11-04 13:00:08 -0500
commitdb2335113e5c6f1265d8bb103687928d55e57df6 (patch)
treef9c7bd9d71ca2fc5514bc14b5c53e97df5829b50 /www/js/MonitorCtrl.js
parentb721eaa84b5d2ba607daf3a1496515405d208297 (diff)
Proper android back button handling for modal views of events and monitors #61
Diffstat (limited to 'www/js/MonitorCtrl.js')
-rw-r--r--www/js/MonitorCtrl.js39
1 files changed, 35 insertions, 4 deletions
diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js
index da73d52b..c996b8e8 100644
--- a/www/js/MonitorCtrl.js
+++ b/www/js/MonitorCtrl.js
@@ -6,8 +6,8 @@
// refer to comments in EventCtrl for the modal stuff. They are almost the same
angular.module('zmApp.controllers')
- .controller('zmApp.MonitorCtrl', ['$ionicPopup', 'zm', '$scope', 'ZMDataModel', 'message', '$ionicSideMenuDelegate', '$ionicLoading', '$ionicModal', '$state', '$http', '$rootScope', '$timeout','$ionicHistory',
- function ($ionicPopup, zm, $scope, ZMDataModel, message, $ionicSideMenuDelegate, $ionicLoading, $ionicModal, $state, $http, $rootScope, $timeout, $ionicHistory) {
+ .controller('zmApp.MonitorCtrl', ['$ionicPopup', 'zm', '$scope', 'ZMDataModel', 'message', '$ionicSideMenuDelegate', '$ionicLoading', '$ionicModal', '$state', '$http', '$rootScope', '$timeout','$ionicHistory', '$ionicPlatform',
+ function ($ionicPopup, zm, $scope, ZMDataModel, message, $ionicSideMenuDelegate, $ionicLoading, $ionicModal, $state, $http, $rootScope, $timeout, $ionicHistory, $ionicPlatform) {
//-----------------------------------------------------------------------
@@ -24,8 +24,39 @@ angular.module('zmApp.controllers')
console.log("Setting Awake to " + ZMDataModel.getKeepAwake());
ZMDataModel.setAwake(ZMDataModel.getKeepAwake());
-
-
+ // --------------------------------------------------------
+ // Handling of back button in case modal is open should
+ // close the modal
+ // --------------------------------------------------------
+
+ $ionicPlatform.registerBackButtonAction(function (e) {
+ e.preventDefault();
+ if ($scope.modal.isShown())
+ {
+ // switch off awake, as liveview is finished
+ ZMDataModel.zmDebug("Modal is open, closing it");
+ ZMDataModel.setAwake(false);
+ $scope.modal.remove();
+ }
+ else
+ {
+ ZMDataModel.zmDebug("Modal is closed, so toggling or exiting");
+ if (!$ionicSideMenuDelegate.isOpenLeft())
+ {
+ $ionicSideMenuDelegate.toggleLeft();
+
+ }
+ else
+ {
+ navigator.app.exitApp();
+ }
+
+ }
+
+ }, 1000);
+
+
+
$scope.openMenu = function () {
$ionicSideMenuDelegate.toggleLeft();