diff --git a/app/js/controllers.js b/app/js/controllers.js index b92c8420..cf567774 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -2517,7 +2517,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) }) - .controller('SettingsModalController', function ($rootScope, $scope, $timeout, $modal, AppUsersManager, AppChatsManager, AppPhotosManager, MtpApiManager, Storage, NotificationsManager, MtpApiFileManager, ApiUpdatesManager, ChangelogNotifyService, AppRuntimeManager, ErrorService, _) { + .controller('SettingsModalController', function ($rootScope, $scope, $timeout, $modal, AppUsersManager, AppChatsManager, AppPhotosManager, MtpApiManager, Storage, NotificationsManager, MtpApiFileManager, ApiUpdatesManager, ChangelogNotifyService, LayoutSwitchService, AppRuntimeManager, ErrorService, _) { $scope.profile = {}; $scope.photo = {}; @@ -2718,6 +2718,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) }); }) }; + + $scope.switchBackToDesktop = Config.Mobile && !Config.Navigator.mobile; + $scope.switchToDesktop = function () { + LayoutSwitchService.switchLayout(false); + }; }) .controller('ChangelogModalController', function ($scope, $modal) { diff --git a/app/js/init.js b/app/js/init.js index 8edf498b..0c3769e3 100644 --- a/app/js/init.js +++ b/app/js/init.js @@ -72,7 +72,7 @@ } $(document.body).addClass(classes.join(' ')); - ConfigStorage.get('current_layout', 'i18n_locale', function (params) { + ConfigStorage.get('layout_selected', 'i18n_locale', function (params) { var layout = params[0], locale = params[1], defaultLocale = 'en-us', @@ -91,7 +91,7 @@ } } if (ready) { - bootReady.boot = false; + bootReady.boot = false; angular.bootstrap(document, ['myApp']); } }; @@ -100,7 +100,8 @@ case 'mobile': Config.Mobile = true; break; case 'desktop': Config.Mobile = false; break; default: - Config.Mobile = Config.Navigator.mobile || $(window).width() < 480; + var width = $(window).width(); + Config.Mobile = Config.Navigator.mobile || width > 10 && width < 480; break; } $('head').append( diff --git a/app/js/locales/en-us.json b/app/js/locales/en-us.json index 1ac111fd..a9bc90da 100644 --- a/app/js/locales/en-us.json +++ b/app/js/locales/en-us.json @@ -48,6 +48,7 @@ "settings_modal_enter_send_description_md": "**Enter** - send message, **Shift + Enter** - new line", "settings_modal_ctrl_enter_send_description_md": "**Ctrl + Enter** - send message, **Enter** - new line", "settings_modal_send_on_enter": "Send on Enter", + "settings_switch_back_to_desktop": "Switch back to Desktop layout", "settings_modal_about": "About", "settings_modal_source_code_github": "Source code on GitHub", "settings_modal_follow_us_twitter": "Follow us on Twitter!", diff --git a/app/js/services.js b/app/js/services.js index 16f2d377..f27e9f75 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -4706,9 +4706,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) var confirmShown = false; function switchLayout(mobile) { + ConfigStorage.noPrefix(); Storage.set({ - current_layout: mobile ? 'mobile' : 'desktop', - layout_confirmed: {width: $(window).width(), mobile: mobile} + layout_selected: mobile ? 'mobile' : 'desktop', + layout_width: $(window).width() }).then(function () { AppRuntimeManager.reload(); }); @@ -4719,28 +4720,25 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return; } var width = $(window).width(); - if (!e && Config.Mobile && width <= 800) { + var newMobile = width < 600; + if (!width || + !e && (Config.Navigator.mobile ? width <= 800 : newMobile)) { return; } - var newMobile = width < 600; if (newMobile != Config.Mobile) { - Storage.get('layout_confirmed').then(function (result) { - if (result && - (result.mobile - ? width == result.width - : width == result.width - ) - ) { + ConfigStorage.noPrefix(); + Storage.get('layout_width').then(function (confirmedWidth) { + if (width == confirmedWidth) { return false; } confirmShown = true; ErrorService.confirm({ type: newMobile ? 'SWITCH_MOBILE_VERSION' : 'SWITCH_DESKTOP_VERSION' }).then(function () { - Storage.remove('layout_confirmed'); switchLayout(newMobile); }, function () { - Storage.set({layout_confirmed: {width: width, mobile: Config.Mobile}}); + ConfigStorage.noPrefix(); + Storage.set({layout_width: width}); confirmShown = false; }); }); diff --git a/app/partials/mobile/settings_modal.html b/app/partials/mobile/settings_modal.html index 9bf66b1a..3b94592d 100644 --- a/app/partials/mobile/settings_modal.html +++ b/app/partials/mobile/settings_modal.html @@ -134,6 +134,12 @@ +
+