From 9a24b87d95befd6c6ff6a18f27d1f73ca005de32 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 4 Feb 2014 23:55:20 +0400 Subject: [PATCH] Added send settings --- app/css/app.css | 7 +++++++ app/index.html | 6 +++--- app/js/controllers.js | 18 +++++++++++++++--- app/js/directives.js | 13 +++++++++++-- app/partials/settings_modal.html | 15 +++++++++++++++ 5 files changed, 51 insertions(+), 8 deletions(-) diff --git a/app/css/app.css b/app/css/app.css index ee6ae73d..27db35a4 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -1463,6 +1463,13 @@ img.img_fullsize { background-color: #FFF; } +.settings_send_choose_form input { + margin-top: 2px; +} +.settings_send_choose_form { + margin-bottom: 20px; +} + .settings_user_phone, .settings_version { color: #999; diff --git a/app/index.html b/app/index.html index bbe74ad7..100c9908 100644 --- a/app/index.html +++ b/app/index.html @@ -7,7 +7,7 @@ - + @@ -53,9 +53,9 @@ - + - + diff --git a/app/js/controllers.js b/app/js/controllers.js index b5285d2c..f15ea5b2 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -162,7 +162,7 @@ angular.module('myApp.controllers', []) $scope.isLoggedIn = true; $scope.openSettings = function () { $modal.open({ - templateUrl: 'partials/settings_modal.html?1', + templateUrl: 'partials/settings_modal.html?2', controller: 'SettingsModalController', scope: $rootScope.$new(), windowClass: 'settings_modal_window' @@ -587,7 +587,7 @@ angular.module('myApp.controllers', []) }); }) - .controller('SettingsModalController', function ($scope, $timeout, AppUsersManager, AppChatsManager, MtpApiManager, AppConfigManager, NotificationsManager) { + .controller('SettingsModalController', function ($rootScope, $scope, $timeout, AppUsersManager, AppChatsManager, MtpApiManager, AppConfigManager, NotificationsManager) { $scope.profile = {}; @@ -600,10 +600,13 @@ angular.module('myApp.controllers', []) }); $scope.notify = {}; + $scope.send = {}; - AppConfigManager.get(['notify_nodesktop', 'notify_nosound']).then(function (settings) { + AppConfigManager.get(['notify_nodesktop', 'notify_nosound', 'send_ctrlenter']).then(function (settings) { $scope.notify.sound = !settings.notify_nosound; $scope.notify.desktop = !settings.notify_nodesktop; + $scope.send.enter = settings.send_ctrlenter ? '' : '1'; + console.log($scope.send.enter); }); $scope.$watch('notify.sound', function(newValue) { @@ -623,6 +626,15 @@ angular.module('myApp.controllers', []) } }); + $scope.$watch('send.enter', function(newValue) { + if (newValue) { + AppConfigManager.remove('send_ctrlenter'); + } else { + AppConfigManager.set({send_ctrlenter: true}); + } + $rootScope.$broadcast('settings_changed'); + }); + $scope.error = {}; $scope.save = function () { MtpApiManager.invokeApi('account.updateProfile', { diff --git a/app/js/directives.js b/app/js/directives.js index 3d836d90..3aa96255 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -255,7 +255,7 @@ angular.module('myApp.directives', ['myApp.filters']) }) - .directive('mySendForm', function ($timeout) { + .directive('mySendForm', function ($timeout, AppConfigManager) { return { link: link, @@ -305,7 +305,16 @@ angular.module('myApp.directives', ['myApp.filters']) }); }); - var sendOnEnter = true; + var sendOnEnter = true, + updateSendSettings = function () { + AppConfigManager.get('send_ctrlenter').then(function (sendOnCtrl) { + sendOnEnter = !sendOnCtrl; + }); + }; + + scope.$on('settings_changed', updateSendSettings); + updateSendSettings(); + $(editorElement).on('keydown', function (e) { if (e.keyCode == 13) { var submit = false; diff --git a/app/partials/settings_modal.html b/app/partials/settings_modal.html index bc8e4d92..d2bc6170 100644 --- a/app/partials/settings_modal.html +++ b/app/partials/settings_modal.html @@ -26,6 +26,21 @@ +
+
+ +
+
+ +
+
+

Sound: {{notify.sound ? 'ON' : 'OFF'}}