diff --git a/app/js/controllers.js b/app/js/controllers.js index e52c78b5..e98967b0 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -2335,6 +2335,37 @@ angular.module('myApp.controllers', ['myApp.i18n']) }); }) + .controller('EmbedModalController', function ($q, $sce, $scope, $rootScope, $modalInstance, AppPhotosManager, AppMessagesManager, AppPeersManager, AppWebPagesManager, PeersSelectService, ErrorService) { + + $scope.webpage = AppWebPagesManager.wrapForHistory($scope.webpageID); + + $scope.iframeSrc = $sce.trustAsResourceUrl($scope.webpage.embed_url); + + $scope.nav = {}; + + $scope.forward = function () { + var messageID = $scope.messageID; + PeersSelectService.selectPeers({confirm_type: 'FORWARD_PEER'}).then(function (peerStrings) { + angular.forEach(peerStrings, function (peerString) { + var peerID = AppPeersManager.getPeerID(peerString); + AppMessagesManager.forwardMessages(peerID, [messageID]).then(function () { + if (peerStrings.length == 1) { + $rootScope.$broadcast('history_focus', {peerString: peerString}); + } + }); + }); + }); + }; + + $scope['delete'] = function () { + var messageID = $scope.messageID; + ErrorService.confirm({type: 'MESSAGE_DELETE'}).then(function () { + AppMessagesManager.deleteMessages([messageID]); + }); + }; + + }) + .controller('UserModalController', function ($scope, $location, $rootScope, $modal, AppUsersManager, MtpApiManager, NotificationsManager, AppPhotosManager, AppMessagesManager, AppPeersManager, PeersSelectService, ErrorService) { var peerString = AppUsersManager.getUserString($scope.userID); diff --git a/app/js/directives.js b/app/js/directives.js index d0c7054a..18ed4257 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -457,7 +457,7 @@ angular.module('myApp.directives', ['myApp.filters']) templateUrl: templateUrl('message_attach_contact') }; }) - .directive('myMessageWebpage', function(AppPhotosManager) { + .directive('myMessageWebpage', function(AppWebPagesManager, AppPhotosManager) { return { scope: { 'webpage': '=myMessageWebpage', @@ -466,6 +466,12 @@ angular.module('myApp.directives', ['myApp.filters']) templateUrl: templateUrl('message_attach_webpage'), link: function ($scope) { $scope.openPhoto = AppPhotosManager.openPhoto; + $scope.openEmbed = function ($event) { + if ($scope.webpage && $scope.webpage.embed_url) { + AppWebPagesManager.openEmbed($scope.webpage.id, $scope.messageId); + return cancelEvent($event); + } + }; $scope.$on('webpage_updated', function (e, eventData) { if ($scope.webpage && $scope.webpage.id == eventData.id) { diff --git a/app/js/services.js b/app/js/services.js index 8da21099..60cd67a1 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -2827,13 +2827,20 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) } }; - $rootScope.$on('apiUpdate', function (e, update) { - switch (update._) { - case 'updateWebPage': - saveWebPage(update.webpage); - break; - } - }); + function openEmbed (webpageID, messageID) { + var scope = $rootScope.$new(true); + + scope.webpageID = webpageID; + scope.messageID = messageID; + + $modal.open({ + templateUrl: templateUrl('embed_modal'), + windowTemplateUrl: templateUrl('media_modal_layout'), + controller: 'EmbedModalController', + scope: scope, + windowClass: 'photo_modal_window' + }); + } function wrapForHistory (webPageID) { var webPage = angular.copy(webpages[webPageID]) || {_: 'webPageEmpty'}; @@ -2845,8 +2852,17 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return webPage; } + $rootScope.$on('apiUpdate', function (e, update) { + switch (update._) { + case 'updateWebPage': + saveWebPage(update.webpage); + break; + } + }); + return { saveWebPage: saveWebPage, + openEmbed: openEmbed, wrapForHistory: wrapForHistory } }) diff --git a/app/less/desktop.less b/app/less/desktop.less index e1c31771..781b5807 100644 --- a/app/less/desktop.less +++ b/app/less/desktop.less @@ -2153,6 +2153,11 @@ a.im_panel_peer_photo .peer_initials { } } +.embed_modal_wrap .modal-body { + line-height: 0; + padding: 0; +} + .photo_modal_window, .video_modal_window, .document_modal_window { diff --git a/app/partials/desktop/embed_modal.html b/app/partials/desktop/embed_modal.html new file mode 100644 index 00000000..12c1c7bb --- /dev/null +++ b/app/partials/desktop/embed_modal.html @@ -0,0 +1,38 @@ +