diff --git a/app/css/app.css b/app/css/app.css index 67f66afc..c987b565 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -339,13 +339,13 @@ input[type="number"]::-webkit-inner-spin-button { height: 100%; } .modal_close { - background: url(../img/icons/CloseHover_2x.png) 0 0 no-repeat; - background-size: 33px 33px; + background: url(../img/icons/PhotoControls.png) 0 -53px no-repeat; + background-size: 33px 86px; width: 33px; height: 33px; float: right; margin: 60px 30px 0 0; - opacity: 0.5; + opacity: 0.6; pointer-events: none; -webkit-transition : .2s; @@ -354,7 +354,40 @@ input[type="number"]::-webkit-inner-spin-button { transition : .2s; } .modal_close_wrap:hover .modal_close { - opacity: 1; + opacity: 0.85; +} + + +.modal_prev_wrap { + cursor: pointer; + position: fixed; + top: 0; + left: 0; + width: 50%; + height: 100%; +} +.modal_prev { + background: url(../img/icons/PhotoControls.png) 0 0 no-repeat; + background-size: 33px 86px; + width: 33px; + height: 33px; + float: left; + margin: 60px 0 0 30px; + opacity: 0.6; + pointer-events: none; + + -webkit-transition : .2s; + -moz-transition : .2s; + -o-transition : .2s; + transition : .2s; +} +.modal_prev_wrap:hover .modal_prev { + opacity: 0.85; +} + +.is_1x .modal_close, +.is_1x .modal_prev { + background-image: url(../img/icons/PhotoControls_1x.png); } .text-invisible { @@ -1849,6 +1882,12 @@ img.img_fullsize { color: #777; margin: 20px 0 0; } +.media_modal_actions { + margin-top: 20px; +} +.media_modal_action_link { + margin-left: 15px; +} .media_modal_author { font-weight: bold; } diff --git a/app/img/icons/CloseHover_1x.png b/app/img/icons/CloseHover_1x.png deleted file mode 100755 index 3f319431..00000000 Binary files a/app/img/icons/CloseHover_1x.png and /dev/null differ diff --git a/app/img/icons/CloseHover_2x.png b/app/img/icons/CloseHover_2x.png deleted file mode 100755 index ca9c4231..00000000 Binary files a/app/img/icons/CloseHover_2x.png and /dev/null differ diff --git a/app/img/icons/Close_1x.png b/app/img/icons/Close_1x.png deleted file mode 100755 index 3e6f6835..00000000 Binary files a/app/img/icons/Close_1x.png and /dev/null differ diff --git a/app/img/icons/Close_2x.png b/app/img/icons/Close_2x.png deleted file mode 100755 index 1a892be1..00000000 Binary files a/app/img/icons/Close_2x.png and /dev/null differ diff --git a/app/img/icons/PhotoControls.png b/app/img/icons/PhotoControls.png new file mode 100644 index 00000000..8abd1c58 Binary files /dev/null and b/app/img/icons/PhotoControls.png differ diff --git a/app/img/icons/PhotoControls_1x.png b/app/img/icons/PhotoControls_1x.png new file mode 100644 index 00000000..3fdea5f5 Binary files /dev/null and b/app/img/icons/PhotoControls_1x.png differ diff --git a/app/js/controllers.js b/app/js/controllers.js index a7063577..1ae73404 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -866,8 +866,128 @@ angular.module('myApp.controllers', []) } }) - .controller('PhotoModalController', function ($scope, AppPhotosManager) { + .controller('PhotoModalController', function ($q, $scope, $rootScope, $modalInstance, AppPhotosManager, AppMessagesManager, AppPeersManager, PeersSelectService, ErrorService) { + $scope.photo = AppPhotosManager.wrapForFull($scope.photoID); + $scope.nav = {}; + + var peerID = AppMessagesManager.getMessagePeer(AppMessagesManager.getMessage($scope.messageID)), + inputPeer = AppPeersManager.getInputPeerByID(peerID), + inputQuery = '', + inputFilter = {_: 'inputMessagesFilterPhotos'}, + list = [$scope.messageID], + maxID = $scope.messageID, + hasMore = true; + + updatePrevNext(); + + AppMessagesManager.getSearch(inputPeer, inputQuery, inputFilter, 0, 1000).then(function (searchCachedResult) { + // console.log(dT(), 'search cache', searchCachedResult); + if (searchCachedResult.history.indexOf($scope.messageID) >= 0) { + list = searchCachedResult.history; + maxID = list[list.length - 1]; + + updatePrevNext(); + } + // console.log(dT(), list, maxID); + }); + + + var jump = 0; + function movePosition (sign) { + var curIndex = list.indexOf($scope.messageID), + index = curIndex >= 0 ? curIndex + sign : 0, + curJump = ++jump; + + var promise = index >= list.length ? loadMore() : $q.when(); + promise.then(function () { + if (curJump != jump) { + return; + } + + $scope.messageID = list[index]; + $scope.photoID = AppMessagesManager.getMessage($scope.messageID).media.photo.id; + $scope.photo = AppPhotosManager.wrapForFull($scope.photoID); + + updatePrevNext(); + }); + }; + + var loadingPromise = false; + function loadMore () { + if (loadingPromise) return loadingPromise; + + return loadingPromise = AppMessagesManager.getSearch(inputPeer, inputQuery, inputFilter, maxID).then(function (searchResult) { + maxID = searchResult.history[searchResult.history.length - 1]; + list = list.concat(searchResult.history); + + hasMore = searchResult.history.length || list.length < searchResult.count; + updatePrevNext(); + loadingPromise = false; + }); + }; + + function updatePrevNext () { + var index = list.indexOf($scope.messageID); + $scope.nav.hasNext = hasMore || index < list.length - 1; + $scope.nav.hasPrev = index > 0; + }; + + $scope.nav.next = function () { + if (!$scope.nav.hasNext) { + return false; + } + + movePosition(+1); + }; + + $scope.nav.prev = function () { + if (!$scope.nav.hasPrev) { + return false; + } + movePosition(-1); + }; + + $scope.forward = function () { + var messageID = $scope.messageID; + PeersSelectService.selectPeer().then(function (peerString) { + var peerID = AppPeersManager.getPeerID(peerString); + AppMessagesManager.forwardMessages(peerID, [messageID]).then(function () { + $rootScope.$broadcast('history_focus', {peerString: peerString}); + }); + }); + }; + + $scope.delete = function () { + var messageID = $scope.messageID; + ErrorService.confirm({type: 'MESSAGE_DELETE'}).then(function () { + AppMessagesManager.deleteMessages([messageID]); + }); + }; + + + $scope.$on('history_delete', function (e, historyUpdate) { + console.log(dT(), 'delete', historyUpdate); + if (historyUpdate.peerID == peerID) { + if (historyUpdate.msgs[$scope.messageID]) { + if ($scope.nav.hasNext) { + $scope.nav.next(); + } else if ($scope.nav.hasPrev) { + $scope.nav.prev(); + } else { + return $modalInstance.dismiss(); + } + } + var newList = []; + for (var i = 0; i < list.length; i++) { + if (!historyUpdate.msgs[list[i]]) { + newList.push(list[i]); + } + }; + list = newList; + } + }); + }) .controller('VideoModalController', function ($scope, AppVideoManager) { diff --git a/app/js/directives.js b/app/js/directives.js index 601a4925..81d1a3a1 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -683,19 +683,18 @@ angular.module('myApp.directives', ['myApp.filters']) link: link, transclude: true, template: - '