diff --git a/app/css/app.css b/app/css/app.css index ef31e543..4eece49b 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -283,6 +283,12 @@ input[type="number"]::-webkit-inner-spin-button { overflow: hidden; } +.dropdown-menu { + border-radius: 2px; + padding: 0; + -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.175); + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.175); +} .dropdown-menu > li > a { padding: 5px 14px; font-size: 13px; @@ -347,7 +353,7 @@ input[type="number"]::-webkit-inner-spin-button { } .modal-close-link, -.modal-save-link { +.modal-head-link { font-size: 12px; line-height: 1.4; float: right; @@ -355,10 +361,10 @@ input[type="number"]::-webkit-inner-spin-button { margin: 6px 2px 0 0; } .modal-close-link:hover, -.modal-save-link:hover { +.modal-head-link:hover { text-decoration: none; } -.modal-save-link { +.modal-head-link { margin-right: 15px; } @@ -519,7 +525,7 @@ input[type="number"]::-webkit-inner-spin-button { padding: 14px 12px; position: relative; } -.im_dialogs_search { +.im_page_split .im_dialogs_search { margin-right: 48px; position: relative; } @@ -567,13 +573,9 @@ input[type="number"]::-webkit-inner-spin-button { } .im_dialogs_panel_dropdown .dropdown-menu { - border-radius: 2px; right: auto; left: 0; margin-top: 8px; - padding: 0; - -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.175); - box-shadow: 0 1px 3px rgba(0, 0, 0, 0.175); } @@ -1687,17 +1689,29 @@ img.img_fullsize { .user_modal_status { color: #999; } + +.user_modal_actions_wrap { + margin-top: 8px; +} .user_modal_send_btn { border: 0; background: #4E9CD8; font-size: 12px; - margin-top: 8px; padding-left: 16px; padding-right: 16px; + float: left; } .user_modal_send_btn:hover { background: #539BD1; } +.user_modal_other_btn { + margin-left: 10px; + float: left; +} +.user_modal_other_btn .dropdown-toggle { + border: 0; + font-size: 12px; +} .user_modal_settings_wrap { margin-top: 25px; @@ -2638,3 +2652,16 @@ ce671b orange .im_dialogs_panel_dropdown.open .dropdown-toggle .icon-bar { background: #fff; } + +/* Import contact modal */ +.import_contact_modal_window .modal-dialog { + max-width: 380px; +} +.import_modal_field_wrap { + margin-bottom: 10px; +} + +.modal-content-animated { + -webkit-transition: margin-top linear 0.2s; + transition: margin-top linear 0.2s; +} \ No newline at end of file diff --git a/app/js/controllers.js b/app/js/controllers.js index a8f27f2d..aaed4663 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -579,8 +579,8 @@ angular.module('myApp.controllers', []) }); PeersSelectService.selectPeer().then(function (peerString) { - var inputPeer = AppPeersManager.getInputPeer(peerString); - AppMessagesManager.forwardMessages(selectedMessageIDs, inputPeer).then(function () { + var peerID = AppPeersManager.getPeerID(peerString); + AppMessagesManager.forwardMessages(peerID, selectedMessageIDs).then(function () { selectedCancel(); $rootScope.$broadcast('history_focus', {peerString: peerString}); }); @@ -824,8 +824,12 @@ angular.module('myApp.controllers', []) $scope.video = AppVideoManager.wrapForFull($scope.videoID); }) - .controller('UserModalController', function ($scope, $location, $rootScope, $modalStack, AppUsersManager, NotificationsManager, AppMessagesManager, AppPeersManager) { - $scope.user = AppUsersManager.wrapForFull($scope.userID); + .controller('UserModalController', function ($scope, $location, $rootScope, $modal, AppUsersManager, NotificationsManager, AppMessagesManager, AppPeersManager, PeersSelectService) { + + var peerString = AppUsersManager.getUserString($scope.userID); + + $scope.user = AppUsersManager.getUser($scope.userID); + $scope.userPhoto = AppUsersManager.getUserPhoto($scope.userID, 'User'); $scope.settings = {notifications: true}; @@ -849,7 +853,7 @@ angular.module('myApp.controllers', []) $scope.goToHistory = function () { - $rootScope.$broadcast('history_focus', {peerString: $scope.user.peerString}); + $rootScope.$broadcast('history_focus', {peerString: peerString}); }; $scope.flushHistory = function () { @@ -860,6 +864,49 @@ angular.module('myApp.controllers', []) $scope.goToHistory(); }); }; + + $scope.importContact = function (edit) { + var scope = $rootScope.$new(); + scope.importContact = { + phone: $scope.user.phone, + first_name: $scope.user.first_name, + last_name: $scope.user.last_name, + }; + + $modal.open({ + templateUrl: edit ? 'partials/edit_contact_modal.html' : 'partials/import_contact_modal.html', + controller: 'ImportContactModalController', + windowClass: 'import_contact_modal_window', + scope: scope + }).result.then(function (foundUserID) { + if ($scope.userID == foundUserID) { + $scope.user = AppUsersManager.getUser($scope.userID); + console.log($scope.user); + } + }); + }; + + $scope.deleteContact = function () { + AppUsersManager.deleteContacts([$scope.userID]).then(function () { + $scope.user = AppUsersManager.getUser($scope.userID); + console.log($scope.user); + }); + }; + + $scope.shareContact = function () { + PeersSelectService.selectPeer().then(function (peerString) { + var peerID = AppPeersManager.getPeerID(peerString); + + AppMessagesManager.sendOther(peerID, { + _: 'inputMediaContact', + phone_number: $scope.user.phone, + first_name: $scope.user.first_name, + last_name: $scope.user.last_name + }); + $rootScope.$broadcast('history_focus', {peerString: peerString}); + }) + } + }) .controller('ChatModalController', function ($scope, $timeout, $rootScope, $modal, AppUsersManager, AppChatsManager, MtpApiManager, MtpApiFileManager, NotificationsManager, AppMessagesManager, AppPeersManager, ApiUpdatesManager, ContactsSelectService, ErrorService) { @@ -873,6 +920,7 @@ angular.module('myApp.controllers', []) AppUsersManager.saveApiUsers(result.users); $scope.chatFull = AppChatsManager.wrapForFull($scope.chatID, result.full_chat); + $scope.$broadcast('ui_height'); }); $scope.settings = {notifications: true}; @@ -1190,7 +1238,7 @@ angular.module('myApp.controllers', []) } }) - .controller('ContactsModalController', function ($scope, $modalInstance, AppUsersManager) { + .controller('ContactsModalController', function ($scope, $modal, $modalInstance, AppUsersManager) { $scope.contacts = []; $scope.search = {}; @@ -1213,8 +1261,8 @@ angular.module('myApp.controllers', []) } } - $scope.$watch('search.query', function (newValue) { - AppUsersManager.getContacts(newValue).then(function (contactsList) { + function updateContacts (query) { + AppUsersManager.getContacts(query).then(function (contactsList) { $scope.contacts = []; angular.forEach(contactsList, function(userID) { var contact = { @@ -1226,7 +1274,9 @@ angular.module('myApp.controllers', []) }); $scope.$broadcast('contacts_change'); }); - }); + }; + + $scope.$watch('search.query', updateContacts); $scope.contactSelect = function (userID) { if ($scope.disabledContacts[userID]) { @@ -1254,6 +1304,18 @@ angular.module('myApp.controllers', []) } } + $scope.importContact = function () { + $modal.open({ + templateUrl: 'partials/import_contact_modal.html', + controller: 'ImportContactModalController', + windowClass: 'import_contact_modal_window' + }).result.then(function (foundUserID) { + if (foundUserID) { + updateContacts($scope.search && $scope.search.query || ''); + } + }); + }; + }) .controller('PeerSelectController', function ($scope, $modalInstance) { @@ -1334,3 +1396,25 @@ angular.module('myApp.controllers', []) }); }; }) + + .controller('ImportContactModalController', function ($scope, $modalInstance, $rootScope, AppUsersManager) { + if ($scope.importContact === undefined) { + $scope.importContact = {}; + } + + $scope.doImport = function () { + if ($scope.importContact && $scope.importContact.phone) { + $scope.progress = {enabled: true}; + AppUsersManager.importContact( + $scope.importContact.phone, + $scope.importContact.first_name, + $scope.importContact.last_name + ).then(function (foundUserID) { + $modalInstance.close(foundUserID); + })['finally'](function () { + delete $scope.progress.enabled; + }); + } + }; + + }) diff --git a/app/js/directives.js b/app/js/directives.js index 0a701144..9d9fa903 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -36,7 +36,7 @@ angular.module('myApp.directives', ['myApp.filters']) }; - function link (scope, element, attrs) { + function link ($scope, element, attrs) { var dialogsWrap = $('.im_dialogs_wrap', element)[0], scrollableWrap = $('.im_dialogs_scrollable_wrap', element)[0], headWrap = $('.tg_page_head')[0], @@ -53,10 +53,10 @@ angular.module('myApp.directives', ['myApp.filters']) }); } - scope.$on('ui_dialogs_prepend', updateScroller); + $scope.$on('ui_dialogs_prepend', updateScroller); - scope.$on('ui_dialogs_append', function () { + $scope.$on('ui_dialogs_append', function () { onContentLoaded(function () { updateScroller(); moreNotified = false; @@ -67,7 +67,7 @@ angular.module('myApp.directives', ['myApp.filters']) }); }); - scope.$on('ui_dialogs_change', function () { + $scope.$on('ui_dialogs_change', function () { onContentLoaded(function () { updateScroller(); moreNotified = false; @@ -82,7 +82,7 @@ angular.module('myApp.directives', ['myApp.filters']) // console.log('scroll', moreNotified); if (!moreNotified && scrollableWrap.scrollTop >= scrollableWrap.scrollHeight - scrollableWrap.clientHeight - 300) { // console.log('emit need more'); - scope.$emit('dialogs_need_more'); + $scope.$emit('dialogs_need_more'); moreNotified = true; } }); @@ -124,7 +124,7 @@ angular.module('myApp.directives', ['myApp.filters']) link: link }; - function link (scope, element, attrs) { + function link ($scope, element, attrs) { var searchWrap = $('.contacts_modal_search')[0], panelWrap = $('.contacts_modal_panel')[0], contactsWrap = $('.contacts_wrap', element)[0]; @@ -142,7 +142,7 @@ angular.module('myApp.directives', ['myApp.filters']) } $($window).on('resize', updateSizes); - scope.$on('contacts_change', function () { + $scope.$on('contacts_change', function () { onContentLoaded(updateSizes) }); }; @@ -155,7 +155,7 @@ angular.module('myApp.directives', ['myApp.filters']) link: link }; - function link (scope, element, attrs) { + function link ($scope, element, attrs) { var historyWrap = $('.im_history_wrap', element)[0], historyMessagesEl = $('.im_history_messages', element)[0], historyEl = $('.im_history', element)[0], @@ -195,7 +195,7 @@ angular.module('myApp.directives', ['myApp.filters']) var animated = transform ? true : false, curAnimation = false; - scope.$on('ui_history_append', function (e, options) { + $scope.$on('ui_history_append', function (e, options) { if (!atBottom && !options.my) { return; } @@ -232,7 +232,7 @@ angular.module('myApp.directives', ['myApp.filters']) }); }); - scope.$on('ui_history_change', function () { + $scope.$on('ui_history_change', function () { $(scrollableWrap).addClass('im_history_to_bottom'); $(scrollable).css({bottom: 0}); onContentLoaded(function () { @@ -257,7 +257,7 @@ angular.module('myApp.directives', ['myApp.filters']) }); }); - scope.$on('ui_history_focus', function () { + $scope.$on('ui_history_focus', function () { if (!atBottom) { scrollableWrap.scrollTop = scrollableWrap.scrollHeight; updateScroller(); @@ -265,7 +265,7 @@ angular.module('myApp.directives', ['myApp.filters']) } }); - scope.$on('ui_history_prepend', function () { + $scope.$on('ui_history_prepend', function () { var sh = scrollableWrap.scrollHeight, st = scrollableWrap.scrollTop, ch = scrollableWrap.clientHeight; @@ -287,10 +287,10 @@ angular.module('myApp.directives', ['myApp.filters']) }); }); - scope.$on('ui_panel_update', function () { + $scope.$on('ui_panel_update', function () { onContentLoaded(function () { updateSizes(); - scope.$broadcast('ui_message_send'); + $scope.$broadcast('ui_message_send'); $timeout(function () { $(scrollableWrap).trigger('scroll'); @@ -298,7 +298,7 @@ angular.module('myApp.directives', ['myApp.filters']) }); }); - scope.$on('ui_editor_resize', updateSizes); + $scope.$on('ui_editor_resize', updateSizes); var atBottom = true; $(scrollableWrap).on('scroll', function (e) { @@ -312,7 +312,7 @@ angular.module('myApp.directives', ['myApp.filters']) if (!moreNotified && scrollableWrap.scrollTop <= 300) { moreNotified = true; - scope.$emit('history_need_more'); + $scope.$emit('history_need_more'); } }); @@ -375,7 +375,7 @@ angular.module('myApp.directives', ['myApp.filters']) } }; - function link (scope, element, attrs) { + function link ($scope, element, attrs) { var messageField = $('textarea', element)[0], fileSelects = $('input', element), dropbox = $('.im_send_dropbox_wrap', element)[0], @@ -395,7 +395,7 @@ angular.module('myApp.directives', ['myApp.filters']) $(richTextarea).on('keyup', function (e) { updateHeight(); - scope.draftMessage.text = richTextarea.innerText; + $scope.draftMessage.text = richTextarea.innerText; $timeout.cancel(updatePromise); updatePromise = $timeout(updateValue, 1000); @@ -404,9 +404,9 @@ angular.module('myApp.directives', ['myApp.filters']) fileSelects.on('change', function () { var self = this; - scope.$apply(function () { - scope.draftMessage.files = Array.prototype.slice.call(self.files); - scope.draftMessage.isMedia = $(self).hasClass('im_media_attach_input'); + $scope.$apply(function () { + $scope.draftMessage.files = Array.prototype.slice.call(self.files); + $scope.draftMessage.isMedia = $(self).hasClass('im_media_attach_input'); setTimeout(function () { try { self.value = ''; @@ -422,7 +422,7 @@ angular.module('myApp.directives', ['myApp.filters']) }); }; - scope.$on('settings_changed', updateSendSettings); + $scope.$on('settings_changed', updateSendSettings); updateSendSettings(); $(editorElement).on('keydown', function (e) { @@ -453,13 +453,13 @@ angular.module('myApp.directives', ['myApp.filters']) return; } lastTyping = now; - scope.$emit('ui_typing'); + $scope.$emit('ui_typing'); }); function updateField () { if (richTextarea) { $timeout.cancel(updatePromise); - var html = $('
{{user | userStatus}}
{{user.phone | phoneNumber}}
- + +