Browse Source

Improved document thumbs, added popup

master
Igor Zhukov 11 years ago
parent
commit
6e070d477a
  1. 39
      app/css/app.css
  2. 23
      app/js/services.js
  3. 17
      app/partials/message.html

39
app/css/app.css

@ -1043,16 +1043,37 @@ div.im_message_video_thumb {
background-position: -2px -542px; background-position: -2px -542px;
} }
.im_message_document_link_disabled {
cursor: default;
pointer-events: none;
}
.im_message_document_info { .im_message_document_info {
float: left; float: left;
} }
.im_message_document_thumb_wrap {
.im_message_document_thumb {
border-radius: 2px; border-radius: 2px;
overflow: hidden; overflow: hidden;
background: #f2f2f2;
width: 100px;
min-height: 38px;
max-height: 100px;
margin-right: 10px;
text-align: center;
float: left;
line-height: 0;
}
img.im_message_document_thumb {
max-width: 100px; max-width: 100px;
max-height: 100px; max-height: 100px;
vertical-align: middle;
/*-webkit-filter: blur(1px);
-moz-filter: blur(1px);
-o-filter: blur(1px);
-ms-filter: blur(1px);
filter: blur(1px);
filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius='1');*/
} }
.im_message_document_name_wrap { .im_message_document_name_wrap {
overflow: hidden; overflow: hidden;
@ -1062,6 +1083,7 @@ div.im_message_video_thumb {
padding: 0 0 1px; padding: 0 0 1px;
} }
.im_message_document_name { .im_message_document_name {
color: #222; color: #222;
display: inline-block; display: inline-block;
@ -1076,6 +1098,9 @@ div.im_message_video_thumb {
color: #999; color: #999;
padding-left: 2px; padding-left: 2px;
} }
.im_message_document_actions a {
margin-right: 10px;
}
.icon-audio { .icon-audio {
display: block; display: block;
@ -1130,6 +1155,16 @@ div.im_message_video_thumb {
width: 290px; width: 290px;
} }
.im_message_document_thumbed .im_message_document_name_wrap,
.im_message_document_thumbed .im_message_audio_name_wrap,
.im_message_document_thumbed .im_message_upload_progress_wrap,
.im_message_document_thumbed .im_message_download_progress_wrap {
width: 230px;
}
.im_message_document_thumbed .im_message_document_name {
max-width: 150px;
}
.tg_up_progress, .tg_up_progress,
.tg_down_progress { .tg_down_progress {
height: 5px; height: 5px;

23
app/js/services.js

@ -1119,8 +1119,8 @@ angular.module('myApp.services', [])
attachType, fileName, fileName; attachType, fileName, fileName;
if (!options.isMedia) { if (!options.isMedia) {
attachType = 'doc'; attachType = 'document';
fileName = 'doc.' + file.type.split('/')[1]; fileName = 'document.' + file.type.split('/')[1];
} else if (['image/jpeg', 'image/gif', 'image/png', 'image/bmp'].indexOf(file.type) >= 0) { } else if (['image/jpeg', 'image/gif', 'image/png', 'image/bmp'].indexOf(file.type) >= 0) {
attachType = 'photo'; attachType = 'photo';
fileName = 'photo.' + file.type.split('/')[1]; fileName = 'photo.' + file.type.split('/')[1];
@ -1131,8 +1131,8 @@ angular.module('myApp.services', [])
attachType = 'audio'; attachType = 'audio';
fileName = 'audio.mp3'; fileName = 'audio.mp3';
} else { } else {
attachType = 'doc'; attachType = 'document';
fileName = 'doc.' + file.type.split('/')[1]; fileName = 'document.' + file.type.split('/')[1];
} }
if (!file.name) { if (!file.name) {
@ -1197,7 +1197,7 @@ angular.module('myApp.services', [])
inputMedia = {_: 'inputMediaUploadedAudio', file: inputFile, duration: 0}; inputMedia = {_: 'inputMediaUploadedAudio', file: inputFile, duration: 0};
break; break;
case 'doc': case 'document':
default: default:
inputMedia = {_: 'inputMediaUploadedDocument', file: inputFile, file_name: file.name, mime_type: file.type}; inputMedia = {_: 'inputMediaUploadedDocument', file: inputFile, file_name: file.name, mime_type: file.type};
} }
@ -1935,7 +1935,7 @@ angular.module('myApp.services', [])
height = 100, height = 100,
thumbPhotoSize = doc.thumb, thumbPhotoSize = doc.thumb,
thumb = { thumb = {
placeholder: 'img/placeholders/DocThumbConversation.jpg', // placeholder: 'img/placeholders/DocThumbConversation.jpg',
width: width, width: width,
height: height height: height
}; };
@ -1952,13 +1952,15 @@ angular.module('myApp.services', [])
} else { } else {
thumb = false; thumb = false;
} }
doc.thumb = thumb; doc.thumb = thumb;
doc.canDownload = !(window.chrome && chrome.fileSystem && chrome.fileSystem.chooseEntry);
doc.withPreview = doc.canDownload && doc.mime_type.match(/^(image\/|application\/pdf)/);
return docsForHistory[docID] = doc; return docsForHistory[docID] = doc;
} }
function openDoc (docID, accessHash) { function openDoc (docID, accessHash, popup) {
var doc = docs[docID], var doc = docs[docID],
historyDoc = docsForHistory[docID] || doc || {}, historyDoc = docsForHistory[docID] || doc || {},
inputFileLocation = { inputFileLocation = {
@ -2000,6 +2002,11 @@ angular.module('myApp.services', [])
MtpApiFileManager.downloadFile(doc.dc_id, inputFileLocation, doc.size, null, {mime: doc.mime_type}).then(function (url) { MtpApiFileManager.downloadFile(doc.dc_id, inputFileLocation, doc.size, null, {mime: doc.mime_type}).then(function (url) {
delete historyDoc.progress; delete historyDoc.progress;
if (popup) {
window.open(url, '_blank');
return
}
var a = $('<a>Download</a>').css({position: 'absolute', top: 1, left: 1}).attr('href', url).attr('target', '_blank').attr('download', doc.file_name).appendTo('body'); var a = $('<a>Download</a>').css({position: 'absolute', top: 1, left: 1}).attr('href', url).attr('target', '_blank').attr('download', doc.file_name).appendTo('body');
a[0].dataset.downloadurl = ['png', doc.file_name, url].join(':'); a[0].dataset.downloadurl = ['png', doc.file_name, url].join(':');
a[0].click(); a[0].click();

17
app/partials/message.html

@ -120,11 +120,19 @@
</div> </div>
</a> </a>
<div ng-switch-when="messageMediaDocument" class="im_message_document"> <div ng-switch-when="messageMediaDocument" class="im_message_document" ng-class="{im_message_document_thumbed: !!historyMessage.media.document.thumb}">
<a href="" ng-click="openDoc(historyMessage.media.document.id)" ng-if="!historyMessage.media.document.progress.enabled"> <a href="" ng-click="openDoc(historyMessage.media.document.id, false, historyMessage.media.document.withPreview)" ng-class="{im_message_document_link_disabled: historyMessage.media.document.progress.enabled}">
<i class="icon icon-document"></i> <i class="icon icon-document" ng-if="!historyMessage.media.document.thumb"></i>
<div class="im_message_document_thumb_wrap" ng-if="historyMessage.media.document.thumb">
<img
class="im_message_document_thumb"
my-load-thumb
thumb="historyMessage.media.document.thumb"
width="{{historyMessage.media.document.thumb.width}}"
height="{{historyMessage.media.document.thumb.height}}"
/>
</div>
</a> </a>
<i class="icon icon-document" ng-if="historyMessage.media.document.progress.enabled"></i>
<div class="im_message_document_info"> <div class="im_message_document_info">
<div class="im_message_document_name_wrap"> <div class="im_message_document_name_wrap">
@ -140,6 +148,7 @@
</div> </div>
<div class="im_message_document_actions" ng-if="!historyMessage.media.document.progress.enabled"> <div class="im_message_document_actions" ng-if="!historyMessage.media.document.progress.enabled">
<a href="" ng-click="openDoc(historyMessage.media.document.id)">Download</a> <a href="" ng-click="openDoc(historyMessage.media.document.id)">Download</a>
<a href="" ng-click="openDoc(historyMessage.media.document.id, false, true)" ng-if="historyMessage.media.document.withPreview">Open</a>
</div> </div>
<div class="im_message_download_progress_wrap" ng-if="historyMessage.media.document.progress.enabled"> <div class="im_message_download_progress_wrap" ng-if="historyMessage.media.document.progress.enabled">
<div class="progress tg_down_progress"> <div class="progress tg_down_progress">

Loading…
Cancel
Save