Browse Source

Preview image before paste

Closes #835
master
Igor Zhukov 8 years ago
parent
commit
65e35adc4c
  1. 21
      app/js/directives.js
  2. 8
      app/less/app.less
  3. 5
      app/partials/desktop/confirm_modal.html

21
app/js/directives.js

@ -1430,7 +1430,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1430,7 +1430,7 @@ angular.module('myApp.directives', ['myApp.filters'])
})
.directive('mySendForm', function (_, $timeout, $compile, $modalStack, $http, $interpolate, Storage, AppStickersManager, AppDocsManager, ErrorService, AppInlineBotsManager, shouldFocusOnInteraction) {
.directive('mySendForm', function (_, $q, $timeout, $compile, $modalStack, $http, $interpolate, Storage, AppStickersManager, AppDocsManager, ErrorService, AppInlineBotsManager, FileManager, shouldFocusOnInteraction) {
return {
link: link,
scope: {
@ -1685,10 +1685,18 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1685,10 +1685,18 @@ angular.module('myApp.directives', ['myApp.filters'])
}
function onFilePaste (blob) {
ErrorService.confirm({type: 'FILE_CLIPBOARD_PASTE'}).then(function () {
$scope.draftMessage.files = [blob];
$scope.draftMessage.isMedia = true;
});
var mimeType = blob.type || '';
var fileUrlPromise = $q.when(false);
if (['image/jpeg', 'image/gif', 'image/png', 'image/bmp'].indexOf(mimeType) >= 0) {
fileUrlPromise = FileManager.getFileCorrectUrl(blob, mimeType);
}
fileUrlPromise.then(function (fileUrl) {
fileUrl = fileUrl || false;
ErrorService.confirm({type: 'FILE_CLIPBOARD_PASTE', fileUrl: fileUrl}).then(function () {
$scope.draftMessage.files = [blob];
$scope.draftMessage.isMedia = true;
});
})
};
function onPasteEvent (e) {
@ -1705,6 +1713,9 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1705,6 +1713,9 @@ angular.module('myApp.directives', ['myApp.filters'])
}
if (files.length > 0) {
if (files.length == 1) {
return onFilePaste(files[0]);
}
ErrorService.confirm({type: 'FILES_CLIPBOARD_PASTE', files: files}).then(function () {
$scope.draftMessage.files = files;
$scope.draftMessage.isMedia = true;

8
app/less/app.less

@ -3301,6 +3301,14 @@ _:-ms-lang(x), .composer_rich_textarea:empty:focus:before { @@ -3301,6 +3301,14 @@ _:-ms-lang(x), .composer_rich_textarea:empty:focus:before {
.confirm_modal_extlink_jump {
word-break: break-all;
}
.confirm_modal_paste_image {
max-width: 274px;
height: 274px;
background-position: 50% 50%;
background-size: cover;
background-repeat: no-repeat;
margin: 10px auto -10px;
}
.photo_modal_window,
.video_modal_window,

5
app/partials/desktop/confirm_modal.html

@ -14,7 +14,10 @@ @@ -14,7 +14,10 @@
when="confirm_modal_clipboard_X_files_send">
</ng-pluralize>
</span>
<span ng-switch-when="FILE_CLIPBOARD_PASTE" my-i18n="confirm_modal_clipboard_file_send"></span>
<div ng-switch-when="FILE_CLIPBOARD_PASTE">
<span my-i18n="confirm_modal_clipboard_file_send"></span>
<div class="confirm_modal_paste_image" ng-if="fileUrl !== false" ng-style="{backgroundImage: 'url(' + fileUrl + ')'}"></div>
</div>
<span ng-switch-when="MESSAGE_DELETE" my-i18n="confirm_modal_message_delete"></span>
<span ng-switch-when="MESSAGES_DELETE">
<ng-pluralize count="count"

Loading…
Cancel
Save