Add TEST and PDF attachment preview (close #40)

This commit is contained in:
RainLoop Team 2013-12-29 18:26:40 +04:00
parent 50f16ea7b7
commit a8a21f42f7
7 changed files with 99 additions and 10 deletions

View file

@ -55,8 +55,29 @@ Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android');
*/
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
/**
* @type {boolean}
*/
Globals.bDisableNanoScroll = Globals.bMobileDevice;
/**
* @type {boolean}
*/
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
/**
* @type {boolean}
*/
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
/**
* @type {string}
*/
Globals.sAnimationType = '';
if (Globals.bAllowPdfPreview && navigator && navigator.mimeTypes)
{
Globals.bAllowPdfPreview = !!_.find(navigator.mimeTypes, function (oType) {
return oType && 'application/pdf' === oType.type;
});
}

View file

@ -53,7 +53,7 @@ AttachmentModel.prototype.initByJson = function (oJsonAttachment)
var bResult = false;
if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object'])
{
this.mimeType = oJsonAttachment.MimeType;
this.mimeType = (oJsonAttachment.MimeType || '').toLowerCase();
this.fileName = oJsonAttachment.FileName;
this.estimatedSize = Utils.pInt(oJsonAttachment.EstimatedSize);
this.isInline = !!oJsonAttachment.IsInline;
@ -90,7 +90,16 @@ AttachmentModel.prototype.isImage = 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;
};
/**

View file

@ -195,6 +195,14 @@
data-bind="visible: isImage(), attr: {href: linkPreview(), title: fileName}" target="_blank">
<i class="icon-eye"></i>
</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>
</div>
</li>

View file

@ -133,12 +133,33 @@ Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android');
*/
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
/**
* @type {boolean}
*/
Globals.bDisableNanoScroll = Globals.bMobileDevice;
/**
* @type {boolean}
*/
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
/**
* @type {boolean}
*/
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
/**
* @type {string}
*/
Globals.sAnimationType = '';
if (Globals.bAllowPdfPreview && navigator && navigator.mimeTypes)
{
Globals.bAllowPdfPreview = !!_.find(navigator.mimeTypes, function (oType) {
return oType && 'application/pdf' === oType.type;
});
}
Consts.Defaults = {};
Consts.Values = {};
Consts.DataImages = {};

File diff suppressed because one or more lines are too long

View file

@ -133,12 +133,33 @@ Globals.bIsAndroidDevice = -1 < Globals.sUserAgent.indexOf('android');
*/
Globals.bMobileDevice = Globals.bIsiOSDevice || Globals.bIsAndroidDevice;
/**
* @type {boolean}
*/
Globals.bDisableNanoScroll = Globals.bMobileDevice;
/**
* @type {boolean}
*/
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
/**
* @type {boolean}
*/
Globals.bAnimationSupported = !Globals.bMobileDevice && $html.hasClass('csstransitions');
/**
* @type {string}
*/
Globals.sAnimationType = '';
if (Globals.bAllowPdfPreview && navigator && navigator.mimeTypes)
{
Globals.bAllowPdfPreview = !!_.find(navigator.mimeTypes, function (oType) {
return oType && 'application/pdf' === oType.type;
});
}
Consts.Defaults = {};
Consts.Values = {};
Consts.DataImages = {};
@ -5985,7 +6006,7 @@ AttachmentModel.prototype.initByJson = function (oJsonAttachment)
var bResult = false;
if (oJsonAttachment && 'Object/Attachment' === oJsonAttachment['@Object'])
{
this.mimeType = oJsonAttachment.MimeType;
this.mimeType = (oJsonAttachment.MimeType || '').toLowerCase();
this.fileName = oJsonAttachment.FileName;
this.estimatedSize = Utils.pInt(oJsonAttachment.EstimatedSize);
this.isInline = !!oJsonAttachment.IsInline;
@ -6022,7 +6043,16 @@ AttachmentModel.prototype.isImage = 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;
};
/**

File diff suppressed because one or more lines are too long