diff options
| -rw-r--r-- | www/css/style.css | 5 | ||||
| -rw-r--r-- | www/index.html | 10 | ||||
| -rw-r--r-- | www/js/DataModel.js | 45 | ||||
| -rw-r--r-- | www/js/DevOptionsCtrl.js | 2 | ||||
| -rw-r--r-- | www/js/FirstUseCtrl.js | 39 | ||||
| -rw-r--r-- | www/js/MenuController.js | 51 | ||||
| -rw-r--r-- | www/js/app.js | 27 | ||||
| -rw-r--r-- | www/lang/locale-en.json | 6 | ||||
| -rw-r--r-- | www/templates/first-use.html | 6 | ||||
| -rw-r--r-- | www/templates/monitors.html | 4 |
10 files changed, 176 insertions, 19 deletions
diff --git a/www/css/style.css b/www/css/style.css index a7b88819..82992b87 100644 --- a/www/css/style.css +++ b/www/css/style.css @@ -1051,5 +1051,10 @@ body { font-family: sans-serif; } } +.white-button-text +{ + color:#fff !important; +} + diff --git a/www/index.html b/www/index.html index c376c1f1..43ed3c7d 100644 --- a/www/index.html +++ b/www/index.html @@ -100,6 +100,7 @@ <script src="js/NewsCtrl.js"></script> <script src="js/TimelineModalCtrl.js"></script> <script src="js/WizardCtrl.js"></script> + <script src="js/MenuController.js"></script> <script src="lib/ion-datetime-picker/release/ion-datetime-picker.min.js"></script> <script src="js/EventsModalGraphCtrl.js"></script> @@ -235,6 +236,15 @@ <i class="icon ion-settings"></i> </span> {{'kMenuDevSettings'|translate}} </ion-item> + + + <div ng-controller="MenuController"> + <ion-item ng-click="switchLang()" nav-clear menu-close href=""> + <span class=" item-icon-left"> + <i class="icon ion-earth"></i> + </span> {{'kLanguage'|translate}} + </ion-item> + </div> <ion-item nav-clear menu-close href="#/help"> <span class=" item-icon-left"> diff --git a/www/js/DataModel.js b/www/js/DataModel.js index be96cb5f..c3c5be36 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -2,7 +2,7 @@ /* jslint browser: true*/ -/* global cordova,StatusBar,angular,console, URI */ +/* global cordova,StatusBar,angular,console, URI, moment*/ // This is my central data respository and common functions // that many other controllers use @@ -11,11 +11,11 @@ angular.module('zmApp.controllers') .service('ZMDataModel', -['$http', '$q', '$ionicLoading', '$ionicBackdrop', '$fileLogger', 'zm','$rootScope','$ionicContentBanner', '$timeout','$cordovaPinDialog', '$ionicPopup', '$localstorage', '$state', '$ionicNativeTransitions', +['$http', '$q', '$ionicLoading', '$ionicBackdrop', '$fileLogger', 'zm','$rootScope','$ionicContentBanner', '$timeout','$cordovaPinDialog', '$ionicPopup', '$localstorage', '$state', '$ionicNativeTransitions', '$translate', function ($http, $q, $ionicLoading, $ionicBackdrop,$fileLogger, zm, $rootScope,$ionicContentBanner, $timeout, $cordovaPinDialog, - $ionicPopup, $localstorage, $state, $ionicNativeTransitions) { + $ionicPopup, $localstorage, $state, $ionicNativeTransitions, $translate) { var zmAppVersion="unknown"; var isBackground = false; @@ -26,6 +26,12 @@ angular.module('zmApp.controllers') var multiservers = []; var oldevents = []; + var languages = [ + {text:'English', value:'en'}, + {text:'Italian', value:'it'}, + {text: 'German', value: 'de'}, + ]; + var serverGroupList={}; var loginData = { @@ -79,6 +85,7 @@ angular.module('zmApp.controllers') 'packerySizes':'', 'timelineModalGraphType':'all', 'resumeDelay':300, + 'language':'en' @@ -423,6 +430,12 @@ angular.module('zmApp.controllers') loginData.useNphZms = true; } + if (typeof loginData.useNphZms == 'undefined') + { + zmDebug ("useNphZms does not exist. Setting to true"); + loginData.useNphZms = true; + } + // and now, force enable it loginData.useNphZms = true; @@ -574,6 +587,32 @@ angular.module('zmApp.controllers') } }, + + getLanguages: function() { + return languages; + }, + + setDefaultLanguage: function(l, permanent) { + + if (permanent) + window.localStorage.setItem("defaultLang", l); + + $translate.use(l).then(function(data) { + zmLog("Device Language is:" + data); + moment.locale(data); + $translate.fallbackLanguage('en'); + }, function(error) { + zmLog("Device Language error: " + error); + $translate.use('en'); + moment.locale('en'); + }); + }, + + getDefaultLanguage: function() { + return window.localStorage.getItem("defaultLang"); + + }, + getLogin: function () { diff --git a/www/js/DevOptionsCtrl.js b/www/js/DevOptionsCtrl.js index ecaf9b69..d114f4de 100644 --- a/www/js/DevOptionsCtrl.js +++ b/www/js/DevOptionsCtrl.js @@ -2,7 +2,7 @@ /* jslint browser: true*/ /* global cordova,StatusBar,angular,console */ -angular.module('zmApp.controllers').controller('zmApp.DevOptionsCtrl', ['$scope', '$rootScope', '$ionicModal', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicPopup', '$http', '$q', '$ionicLoading', '$ionicHistory','$state', 'SecuredPopups', 'translate', function ($scope, $rootScope, $ionicModal, zm, ZMDataModel, $ionicSideMenuDelegate, $ionicPopup, $http, $q, $ionicLoading, $ionicHistory, $state, SecuredPopups, $translate) { +angular.module('zmApp.controllers').controller('zmApp.DevOptionsCtrl', ['$scope', '$rootScope', '$ionicModal', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicPopup', '$http', '$q', '$ionicLoading', '$ionicHistory','$state', 'SecuredPopups', '$translate', function ($scope, $rootScope, $ionicModal, zm, ZMDataModel, $ionicSideMenuDelegate, $ionicPopup, $http, $q, $ionicLoading, $ionicHistory, $state, SecuredPopups, $translate) { $scope.openMenu = function () { diff --git a/www/js/FirstUseCtrl.js b/www/js/FirstUseCtrl.js index 2e0d5c85..b9031309 100644 --- a/www/js/FirstUseCtrl.js +++ b/www/js/FirstUseCtrl.js @@ -2,7 +2,7 @@ /* jslint browser: true*/ /* global cordova,StatusBar,angular,console */ -angular.module('zmApp.controllers').controller('zmApp.FirstUseCtrl', ['$scope','$ionicSideMenuDelegate', 'zm', '$stateParams', '$ionicHistory','$state', function ($scope,$ionicSideMenuDelegate,zm, $stateParams, $ionicHistory, $state) { +angular.module('zmApp.controllers').controller('zmApp.FirstUseCtrl', ['$scope','$ionicSideMenuDelegate', 'zm', '$stateParams', '$ionicHistory','$state', 'ZMDataModel', '$rootScope', '$ionicPopup', '$translate', function ($scope,$ionicSideMenuDelegate,zm, $stateParams, $ionicHistory, $state, ZMDataModel, $rootScope, $ionicPopup, $translate) { $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); }; @@ -19,6 +19,43 @@ $scope.openMenu = function () { }); + $scope.switchLang = function() + { + $scope.lang = ZMDataModel.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) { + ZMDataModel.zmLog("Language selected:"+$scope.myopt.lang); + ZMDataModel.setDefaultLanguage($scope.myopt.lang, true); + + + //return "OK"; + + } + } + ] + }); + + + }; + $scope.goToLogin = function() { $ionicHistory.nextViewOptions({ diff --git a/www/js/MenuController.js b/www/js/MenuController.js new file mode 100644 index 00000000..d0dd56fa --- /dev/null +++ b/www/js/MenuController.js @@ -0,0 +1,51 @@ +/* jshint -W041 */ +/* jslint browser: true*/ +/* global cordova,StatusBar,angular,console */ + +angular.module('zmApp.controllers').controller('MenuController', ['$scope','$ionicSideMenuDelegate', 'zm', '$stateParams', '$ionicHistory','$state', 'ZMDataModel', '$rootScope', '$ionicPopup', '$translate', function ($scope,$ionicSideMenuDelegate,zm, $stateParams, $ionicHistory, $state, ZMDataModel, $rootScope, $ionicPopup, $translate) { +$scope.openMenu = function () { + $ionicSideMenuDelegate.toggleLeft(); + }; + + + + + + $scope.switchLang = function() + { + $scope.lang = ZMDataModel.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) { + ZMDataModel.zmLog("Language selected:"+$scope.myopt.lang); + ZMDataModel.setDefaultLanguage($scope.myopt.lang, true); + + //return "OK"; + + } + } + ] + }); + + + }; + + +}]); diff --git a/www/js/app.js b/www/js/app.js index e13bc233..71015c7d 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -1186,17 +1186,22 @@ angular.module('zmApp', [ $ionicNativeTransitions.enable(true, false); - - - if(typeof navigator.globalization !== "undefined") { - navigator.globalization.getPreferredLanguage(function(language) { - $translate.use((language.value).split("-")[0]).then(function(data) { - ZMDataModel.zmLog("Device Language is:" + data); - moment.locale(data); - }, function(error) { - ZMDataModel.zmLog("Device Language error: " + error); - }); - }, null); + var lang = ZMDataModel.getDefaultLanguage(); + if (lang == undefined) + { + ZMDataModel.zmLog ("No language set, detecting..."); + if(typeof navigator.globalization !== "undefined") { + navigator.globalization.getPreferredLanguage(function(language) { + // dont make this permanent + ZMDataModel.setDefaultLanguage((language.value).split("-")[0], false); + + }, null); + } + } + else + { + ZMDataModel.zmLog ("Language stored as:"+lang); + ZMDataModel.setDefaultLanguage(lang, false); } ZMDataModel.zmLog(">>>>Language to be used:" + $translate.proposedLanguage()); diff --git a/www/lang/locale-en.json b/www/lang/locale-en.json index ba7a2d56..57bdb142 100644 --- a/www/lang/locale-en.json +++ b/www/lang/locale-en.json @@ -107,6 +107,7 @@ "kMaxItemsForTimeline" : "Max. items for Timeline", "kMaxMonitorsMontage" : "Max monitors in montage", "kMenuDevSettings" : "Developer Settings", + "kMenuOptions" : "Menu", "kMenuEventMontage" : "EventMontage", "kMenuEvents" : "Events", "kMenuExit" : "Exit", @@ -242,5 +243,8 @@ "kWizard" : "Wizard", "kWorkingOnGraph" : "working on graph data", "kZMSettingsFor" : "ZoneMinder settings for", - "kZMUpgradeNeeded" : "ZoneMinder upgrade needed" + "kZMUpgradeNeeded" : "ZoneMinder upgrade needed", + "kLanguage": "Language", + "kSelectLanguage": "Select Language" + }
\ No newline at end of file diff --git a/www/templates/first-use.html b/www/templates/first-use.html index c0553333..88c0cb76 100644 --- a/www/templates/first-use.html +++ b/www/templates/first-use.html @@ -31,6 +31,12 @@ {{'kExpert' | translate }} </button> + <br/> + <center> + <button class="button button-clear icon icon-left ion-android-globe white-button-text" ng-click="switchLang()"> + {{'kLanguage' | translate}} + </button> + </center> </div> </center> diff --git a/www/templates/monitors.html b/www/templates/monitors.html index 8cf41df1..2abfe751 100644 --- a/www/templates/monitors.html +++ b/www/templates/monitors.html @@ -14,7 +14,7 @@ <div class="item" ng-style="{'background-color': monitor.Monitor.Enabled=='1'?'white':'white'}"> <div ng-if="monitor.Monitor.Enabled == '1'"> <span class='item item-icon-left item-icon-right'> - <i class="icon ion-ios-monitor-outline"></i> + <i class="icon ion-ios-videocam-outline"></i> <b>{{monitor.Monitor.Name}}</b> <i class="icon {{monitor.Monitor.char}}" style="color:{{monitor.Monitor.color}};"></i> @@ -23,7 +23,7 @@ <div ng-if="monitor.Monitor.Enabled != '1'"> <span class='item item-icon-left item-icon-right'> - <i class="icon ion-ios-monitor-outline"></i> + <i class="icon ion-ios-videocam-outline"></i> <b>{{monitor.Monitor.Name}}</b> <i class="icon {{monitor.Monitor.char}}" style="color:grey;"></i> </span> |
