diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index df0a751d9b30df72da446e8cfce38868de148a9c..b7308055b93fc5a52e6fcf752fd3d061ccfc6268 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -503,10 +503,11 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ } -function HomeController($scope, $state, $timeout, $ionicHistory, csPlatform, csCurrency) { +function HomeController($scope, $state, $timeout, $ionicHistory, $translate, UIUtils, csPlatform, csCurrency, csSettings) { 'ngInject'; $scope.loading = true; + $scope.locales = angular.copy(csSettings.locales); $scope.enter = function(e, state) { if (state && state.stateParams && state.stateParams.error) { // Error query parameter @@ -558,6 +559,32 @@ function HomeController($scope, $state, $timeout, $ionicHistory, csPlatform, csC } }; + $scope.changeLanguage = function(langKey) { + $translate.use(langKey); + $scope.hideLocalesPopover(); + csSettings.data.locale = _.findWhere($scope.locales, {id: langKey}); + }; + + /* -- show/hide locales popup -- */ + + $scope.showLocalesPopover = function(event) { + UIUtils.popover.show(event, { + templateUrl: 'templates/api/locales_popover.html', + scope: $scope, + autoremove: true, + afterShow: function(popover) { + $scope.localesPopover = popover; + } + }); + }; + + $scope.hideLocalesPopover = function() { + if ($scope.localesPopover) { + $scope.localesPopover.hide(); + $scope.localesPopover = null; + } + }; + // For DEV ONLY /*$timeout(function() { $scope.loginAndGo(); diff --git a/www/templates/api/home.html b/www/templates/api/home.html index db9604dc5c64ba84ac51e8ad2cc172060846dab2..d669e13eca05942a4b2b3c4f821cfe23cd5f4b34 100644 --- a/www/templates/api/home.html +++ b/www/templates/api/home.html @@ -5,15 +5,11 @@ <ion-nav-buttons side="right"> <!-- locales --> - <img ng-if="$root.settings.locale.country" - ng-src="https://www.countryflags.io/{{$root.settings.locale.country}}/shiny/32.png" - style="padding: 5px 0" - ng-click="showLocalesPopover($event)"> - <button class="button button-clear hidden-xs hidden-sm gray" - style="max-width: 450px !important" - ng-click="showLocalesPopover($event)"> - {{$root.settings.locale.label}} + ng-click="showLocalesPopover($event)" style="align-content: center"> + <img ng-if="$root.settings.locale.country" + ng-src="https://www.countryflags.io/{{$root.settings.locale.country}}/shiny/32.png"> + <span ng-if="!$root.settings.locale.country">{{$root.settings.locale.label}} </span> <small class="ion-arrow-down-b"></small> </button> </ion-nav-buttons> diff --git a/www/templates/api/locales_popover.html b/www/templates/api/locales_popover.html index e71190c63941d09753a7fd3c2410cbd81478c1ce..db706efc4ed4f62bda8a95440b0cd1585cd1c6f6 100644 --- a/www/templates/api/locales_popover.html +++ b/www/templates/api/locales_popover.html @@ -6,7 +6,7 @@ class="item item-icon-left ink" ng-click="changeLanguage(l.id)"> <i class="item-image avatar" - style="background-image: url(https://www.countryflags.io/{{l.country}}/flat/32.png)"></i> + style="border-radius: 0; background-image: url(https://www.countryflags.io/{{l.country}}/shiny/64.png)"></i> {{l.label | translate}} </a> diff --git a/www/templates/api/transfer.html b/www/templates/api/transfer.html index cd774b6cd39b38ac93d675a9c8ea84cdbf92874f..efb9ced6dff3641e81dc6a63622b5d96902a1de9 100644 --- a/www/templates/api/transfer.html +++ b/www/templates/api/transfer.html @@ -12,15 +12,11 @@ <ion-nav-buttons side="right"> <!-- locales --> - <img ng-if="$root.settings.locale.country" - ng-src="https://www.countryflags.io/{{$root.settings.locale.country}}/shiny/32.png" - style="padding: 5px 0" - ng-click="showLocalesPopover($event)"> - <button class="button button-clear hidden-xs hidden-sm gray" - style="max-width: 450px !important" - ng-click="showLocalesPopover($event)"> - {{$root.settings.locale.label}} + ng-click="showLocalesPopover($event)" style="align-content: center"> + <img ng-hide="!$root.settings.locale.country" + ng-src="https://www.countryflags.io/{{$root.settings.locale.country}}/shiny/32.png"> + <span ng-hide="$root.settings.locale.country">{{$root.settings.locale.label}} </span> <small class="ion-arrow-down-b"></small> </button> diff --git a/www/templates/home/home.html b/www/templates/home/home.html index 305ac7c1b25cc487f09edf378ad33514d3e346a7..f1708265da1cc520d6bdb6d04302665284a8ace8 100644 --- a/www/templates/home/home.html +++ b/www/templates/home/home.html @@ -2,6 +2,17 @@ <!-- no title --> <ion-nav-title></ion-nav-title> + <ion-nav-buttons side="secondary" > + <!-- locales --> + <button class="button button-clear hidden-xs hidden-sm gray" + ng-click="showLocalesPopover($event)" style="align-content: center"> + <img ng-if=":locale:$root.settings.locale.country" + ng-src="https://www.countryflags.io/{{:locale:$root.settings.locale.country}}/shiny/32.png"> + <span ng-if=":locale:!$root.settings.locale.country">{{:locale:$root.settings.locale.label}} </span> + <small class="ion-arrow-down-b"></small> + </button> + </ion-nav-buttons> + <ion-content class="has-header text-center no-padding-xs positive-900-bg circle-bg-dark">