From db2335113e5c6f1265d8bb103687928d55e57df6 Mon Sep 17 00:00:00 2001 From: Arjun Roychowdhury Date: Wed, 4 Nov 2015 13:00:08 -0500 Subject: Proper android back button handling for modal views of events and monitors #61 --- www/js/EventCtrl.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'www/js/EventCtrl.js') diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index 00bec5d3..b731d101 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -36,6 +36,38 @@ angular.module('zmApp.controllers') var scrollbynumber = 0; $scope.eventsBeingLoaded = true; $scope.FrameArray = []; // will hold frame info from detailed Events API + + + // -------------------------------------------------------- + // 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); document.addEventListener("pause", onPause, false); console.log("I got STATE PARAM " + $stateParams.id); @@ -228,6 +260,9 @@ angular.module('zmApp.controllers') }); }); + + + // not explictly handling error --> I have a default "No events found" message // displayed in the template if events list is null -- cgit v1.2.3