mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Add TEST and PDF attachment preview (close #40)
This commit is contained in:
parent
50f16ea7b7
commit
a8a21f42f7
7 changed files with 99 additions and 10 deletions
|
|
@ -55,8 +55,29 @@ Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android');
|
||||||
*/
|
*/
|
||||||
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
|
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
|
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
Globals.sAnimationType = '';
|
Globals.sAnimationType = '';
|
||||||
|
|
||||||
|
if (Globals.bAllowPdfPreview && navigator && navigator.mimeTypes)
|
||||||
|
{
|
||||||
|
Globals.bAllowPdfPreview = !!_.find(navigator.mimeTypes, function (oType) {
|
||||||
|
return oType && 'application/pdf' === oType.type;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ AttachmentModel.prototype.initByJson = function (oJsonAttachment)
|
||||||
var bResult = false;
|
var bResult = false;
|
||||||
if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object'])
|
if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object'])
|
||||||
{
|
{
|
||||||
this.mimeType = oJsonAttachment.MimeType;
|
this.mimeType = (oJsonAttachment.MimeType || '').toLowerCase();
|
||||||
this.fileName = oJsonAttachment.FileName;
|
this.fileName = oJsonAttachment.FileName;
|
||||||
this.estimatedSize = Utils.pInt(oJsonAttachment.EstimatedSize);
|
this.estimatedSize = Utils.pInt(oJsonAttachment.EstimatedSize);
|
||||||
this.isInline = !!oJsonAttachment.IsInline;
|
this.isInline = !!oJsonAttachment.IsInline;
|
||||||
|
|
@ -90,7 +90,16 @@ AttachmentModel.prototype.isImage = function ()
|
||||||
*/
|
*/
|
||||||
AttachmentModel.prototype.isText = function ()
|
AttachmentModel.prototype.isText = function ()
|
||||||
{
|
{
|
||||||
return 'text/' === this.mimeType.substr(0, 5);
|
return 'text/' === this.mimeType.substr(0, 5) &&
|
||||||
|
-1 === Utils.inArray(this.mimeType, ['text/html']);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
AttachmentModel.prototype.isPdf = function ()
|
||||||
|
{
|
||||||
|
return Globals.bAllowPdfPreview && 'application/pdf' === this.mimeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,14 @@
|
||||||
data-bind="visible: isImage(), attr: {href: linkPreview(), title: fileName}" target="_blank">
|
data-bind="visible: isImage(), attr: {href: linkPreview(), title: fileName}" target="_blank">
|
||||||
<i class="icon-eye"></i>
|
<i class="icon-eye"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<a class="attachmentPreview pull-left"
|
||||||
|
data-bind="visible: isText(), attr: {href: linkPreviewAsPlain(), title: fileName}" target="_blank">
|
||||||
|
<i class="icon-eye"></i>
|
||||||
|
</a>
|
||||||
|
<a class="attachmentPreview pull-left"
|
||||||
|
data-bind="visible: isPdf(), attr: {href: linkPreview(), title: fileName}" target="_blank">
|
||||||
|
<i class="icon-eye"></i>
|
||||||
|
</a>
|
||||||
<span class="attachmentSize pull-right" data-bind="text: friendlySize"></span>
|
<span class="attachmentSize pull-right" data-bind="text: friendlySize"></span>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -133,12 +133,33 @@ Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android');
|
||||||
*/
|
*/
|
||||||
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
|
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
|
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
Globals.sAnimationType = '';
|
Globals.sAnimationType = '';
|
||||||
|
|
||||||
|
if (Globals.bAllowPdfPreview && navigator && navigator.mimeTypes)
|
||||||
|
{
|
||||||
|
Globals.bAllowPdfPreview = !!_.find(navigator.mimeTypes, function (oType) {
|
||||||
|
return oType && 'application/pdf' === oType.type;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Consts.Defaults = {};
|
Consts.Defaults = {};
|
||||||
Consts.Values = {};
|
Consts.Values = {};
|
||||||
Consts.DataImages = {};
|
Consts.DataImages = {};
|
||||||
|
|
|
||||||
4
rainloop/v/0.0.0/static/js/admin.min.js
vendored
4
rainloop/v/0.0.0/static/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -133,12 +133,33 @@ Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android');
|
||||||
*/
|
*/
|
||||||
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
|
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
|
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
Globals.sAnimationType = '';
|
Globals.sAnimationType = '';
|
||||||
|
|
||||||
|
if (Globals.bAllowPdfPreview && navigator && navigator.mimeTypes)
|
||||||
|
{
|
||||||
|
Globals.bAllowPdfPreview = !!_.find(navigator.mimeTypes, function (oType) {
|
||||||
|
return oType && 'application/pdf' === oType.type;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Consts.Defaults = {};
|
Consts.Defaults = {};
|
||||||
Consts.Values = {};
|
Consts.Values = {};
|
||||||
Consts.DataImages = {};
|
Consts.DataImages = {};
|
||||||
|
|
@ -5985,7 +6006,7 @@ AttachmentModel.prototype.initByJson = function (oJsonAttachment)
|
||||||
var bResult = false;
|
var bResult = false;
|
||||||
if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object'])
|
if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object'])
|
||||||
{
|
{
|
||||||
this.mimeType = oJsonAttachment.MimeType;
|
this.mimeType = (oJsonAttachment.MimeType || '').toLowerCase();
|
||||||
this.fileName = oJsonAttachment.FileName;
|
this.fileName = oJsonAttachment.FileName;
|
||||||
this.estimatedSize = Utils.pInt(oJsonAttachment.EstimatedSize);
|
this.estimatedSize = Utils.pInt(oJsonAttachment.EstimatedSize);
|
||||||
this.isInline = !!oJsonAttachment.IsInline;
|
this.isInline = !!oJsonAttachment.IsInline;
|
||||||
|
|
@ -6022,7 +6043,16 @@ AttachmentModel.prototype.isImage = function ()
|
||||||
*/
|
*/
|
||||||
AttachmentModel.prototype.isText = function ()
|
AttachmentModel.prototype.isText = function ()
|
||||||
{
|
{
|
||||||
return 'text/' === this.mimeType.substr(0, 5);
|
return 'text/' === this.mimeType.substr(0, 5) &&
|
||||||
|
-1 === Utils.inArray(this.mimeType, ['text/html']);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
AttachmentModel.prototype.isPdf = function ()
|
||||||
|
{
|
||||||
|
return Globals.bAllowPdfPreview && 'application/pdf' === this.mimeType;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
8
rainloop/v/0.0.0/static/js/app.min.js
vendored
8
rainloop/v/0.0.0/static/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue