From 6baf77da5ab8103040ea83ad49d54d85a3f95401 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Thu, 2 Oct 2014 14:43:56 +0400 Subject: [PATCH] Added language for mobile settings --- app/css/mobile.css | 3 +++ app/js/controllers.js | 11 ++++++++--- app/js/init.js | 10 ++++------ app/js/lib/config.js | 11 +++++++++-- app/partials/desktop/lang_footer.html | 2 +- app/partials/mobile/settings_modal.html | 10 ++++++++++ 6 files changed, 35 insertions(+), 12 deletions(-) diff --git a/app/css/mobile.css b/app/css/mobile.css index 8ba8b3a6..12cb61b8 100644 --- a/app/css/mobile.css +++ b/app/css/mobile.css @@ -851,6 +851,9 @@ a.im_message_fwd_author { .mobile_modal_action_wrap { border-bottom: 1px solid #e0e0e0; } +.mobile_modal_select_wrap { + margin: 7px 12px 0; +} a.mobile_modal_action, span.mobile_modal_action { color: #000; diff --git a/app/js/controllers.js b/app/js/controllers.js index ddc81a12..55e9621f 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -1453,16 +1453,21 @@ angular.module('myApp.controllers', ['myApp.i18n']) } }) - .controller('AppLangFooterController', function ($scope, _, Storage, ErrorService, AppRuntimeManager) { + .controller('AppLangSelectController', function ($scope, _, Storage, ErrorService, AppRuntimeManager) { $scope.supportedLocales = Config.I18n.supported; $scope.langNames = Config.I18n.languages; $scope.curLocale = Config.I18n.locale; + $scope.form = {locale: Config.I18n.locale}; $scope.localeSelect = function localeSelect (newLocale) { - Storage.set({i18n_locale: newLocale}); + newLocale = newLocale || $scope.form.locale; if ($scope.curLocale !== newLocale) { ErrorService.confirm({type: 'APPLY_LANG_WITH_RELOAD'}).then(function () { - AppRuntimeManager.reload(); + Storage.set({i18n_locale: newLocale}).then(function () { + AppRuntimeManager.reload(); + }); + }, function () { + $scope.form.locale = $scope.curLocale; }); } }; diff --git a/app/js/init.js b/app/js/init.js index 9f0ccc36..8edf498b 100644 --- a/app/js/init.js +++ b/app/js/init.js @@ -111,12 +111,10 @@ locale = (navigator.language || '').toLowerCase(); locale = Config.I18n.aliases[locale] || locale; } - if (!Config.Mobile) { - for (var i = 0; i < Config.I18n.supported.length; i++) { - if (Config.I18n.supported[i] == locale) { - Config.I18n.locale = locale; - break; - } + for (var i = 0; i < Config.I18n.supported.length; i++) { + if (Config.I18n.supported[i] == locale) { + Config.I18n.locale = locale; + break; } } bootReady.i18n_ng = Config.I18n.locale == defaultLocale; // Already included diff --git a/app/js/lib/config.js b/app/js/lib/config.js index 4f803603..9ecf900f 100644 --- a/app/js/lib/config.js +++ b/app/js/lib/config.js @@ -201,7 +201,11 @@ Config.LangCountries = {"es": "ES", "ru": "RU", "en": "US", "de": "DE", "it": "I function storageRemoveValue () { var keys = Array.prototype.slice.call(arguments), prefix = storageGetPrefix(), - i, key; + i, key, callback; + + if (typeof keys[keys.length - 1] === 'function') { + callback = keys.pop(); + } for (i = 0; i < keys.length; i++) { key = keys[i] = prefix + keys[i]; @@ -211,7 +215,10 @@ Config.LangCountries = {"es": "ES", "ru": "RU", "en": "US", "de": "DE", "it": "I } } if (useCs) { - chrome.storage.local.remove(keys); + chrome.storage.local.remove(keys, callback); + } + else if (callback) { + callback(); } }; diff --git a/app/partials/desktop/lang_footer.html b/app/partials/desktop/lang_footer.html index 91c3c103..b8e149d0 100644 --- a/app/partials/desktop/lang_footer.html +++ b/app/partials/desktop/lang_footer.html @@ -1,4 +1,4 @@ -