Fixed #4. We set the type flag now for each attachment that gets opened. If no mimetype was received, the type flag will be used.

This commit is contained in:
Christoph Haas 2015-06-17 14:09:02 +02:00
parent 7d1521ae6d
commit 94d4b9ed70

View File

@ -12,7 +12,7 @@ Zarafa.plugins.fileviewer.ViewerPanel = Ext.extend(Ext.Panel, {
* @cfg {String} viewerjsPath Path to the ViewerJS installation.
* This is a relative path starting from the plugin root.
*/
viewerjsPath: 'external/ViewerJS/index.html#',
viewerjsPath: 'external/ViewerJS/index.html',
/**
* @cfg {String} src The Iframe source. This will be applied if no record is set.
@ -50,8 +50,11 @@ Zarafa.plugins.fileviewer.ViewerPanel = Ext.extend(Ext.Panel, {
config = config || {};
if (Ext.isDefined(config.record)) {
this.src = this.getIframeURL(config.record.getInlineImageUrl());
this.title = config.record.get('name') || config.record.get('filename');
var extension = this.title.split('.').pop();
this.src = this.getIframeURL(config.record.getInlineImageUrl(), extension);
} else {
this.src = config.src;
this.title = config.title;
@ -160,12 +163,19 @@ Zarafa.plugins.fileviewer.ViewerPanel = Ext.extend(Ext.Panel, {
* Generate the complete Iframe URL including the ViewerJS path.
*
* @param {String} url The inline url of the attachment to view.
* @param {String} extension The fileextension of the attachment. Optional.
* @returns {string}
*/
getIframeURL: function (url) {
getIframeURL: function (url, extension) {
var pluginRoot = container.getBasePath() + 'plugins/fileviewer/';
return pluginRoot + this.viewerjsPath + url;
var options = '';
if(Ext.isDefined(extension)) {
options = '?type=' + extension;
}
return pluginRoot + this.viewerjsPath + options + '#' + url;
}
});