diff options
| -rw-r--r-- | www/js/EventCtrl.js | 35 | ||||
| -rw-r--r-- | www/js/MonitorCtrl.js | 39 | ||||
| -rw-r--r-- | www/js/MontageCtrl.js | 31 |
3 files changed, 101 insertions, 4 deletions
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 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(); diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index c3fe4cfd..4850d0f9 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -51,6 +51,37 @@ angular.module('zmApp.controllers').controller('zmApp.MontageCtrl', ['$scope', ' $scope.MontageMonitors = ZMDataModel.applyMontageMonitorPrefs (message, 1)[0]; + // -------------------------------------------------------- + // Handling of back button in case modal is open should + // close the modal + // -------------------------------------------------------- + + $ionicPlatform.registerBackButtonAction(function (e) { + e.preventDefault(); + if ($scope.modal && $scope.modal.isShown()) + { + // switch off awake, as liveview is finished + ZMDataModel.zmDebug("Modal is open, closing it"); + ZMDataModel.setAwake(false); + $scope.modal.remove(); + $scope.isModalActive = false; + } + 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); |
