summaryrefslogtreecommitdiff
path: root/www/js/MenuController.js
blob: f09d1c69abfea27992084a681ed34e063fc1cd79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* jshint -W041 */
/* jslint browser: true*/
/* global cordova,StatusBar,angular,console */

angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', '$ionicHistory', '$state', 'NVRDataModel', '$rootScope', '$ionicPopup', '$translate', '$timeout', '$location',function ($scope, $ionicSideMenuDelegate, zm, $stateParams, $ionicHistory, $state, NVRDataModel, $rootScope, $ionicPopup, $translate, $timeout, $location) {
  $scope.openMenu = function () {
    $ionicSideMenuDelegate.toggleLeft();
  };

  //----------------------------------------------------------------
  // This controller sits along with the main app to  bring up 
  // the language menu from the main menu
  //----------------------------------------------------------------


  $scope.go = function(p) {
   
    
    $ionicHistory.nextViewOptions({
      historyRoot: true,
      disableAnimate: true,
      expire: 300
    });
    $ionicSideMenuDelegate.toggleLeft();
    $location.path(p);
  };  

  $scope.navigateView = function (view, args) {

    if (view == $state.current.name) return;
    NVRDataModel.debug("Navigating view to: " + view);
    $ionicHistory.nextViewOptions({
      disableBack: true
    });
    $state.go(view, args);

    /*  $timeout (function() {
        window.stop();
        // after window stop executes, in next cycle
        // this _should_ ensure stop concludes before
        // exit/entry lifecycles kick in?
        $timeout (function() {$state.go(view,args);});
        
      });*/

  };


  $scope.switchLang = function () {
    $scope.lang = NVRDataModel.getLanguages();
    $scope.myopt = {
      lang: ""
    };

    $rootScope.zmPopup = $ionicPopup.show({
      scope: $scope,
      template: '<ion-radio-fix ng-repeat="item in lang" ng-value="item.value" ng-model="myopt.lang"> {{item.text}} </ion-radio-fix>',

      title: $translate.instant('kSelectLanguage'),

      buttons: [{
          text: $translate.instant('kButtonCancel'),
          onTap: function (e) {
            //return "CANCEL";
          }

        },
        {
          text: $translate.instant('kButtonOk'),
          onTap: function (e) {
            NVRDataModel.log("Language selected:" + $scope.myopt.lang);
            NVRDataModel.setDefaultLanguage($scope.myopt.lang, true);
            $rootScope.$broadcast('language-changed');

            //return "OK";

          }
        }
      ]
    });

  };

}]);