From 94d4b9ed70a26d6c679bf03562dfa1f00dbc45c5 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Wed, 17 Jun 2015 14:09:02 +0200 Subject: [PATCH] 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. --- js/ViewerPanel.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/js/ViewerPanel.js b/js/ViewerPanel.js index d19424b..91ad13f 100644 --- a/js/ViewerPanel.js +++ b/js/ViewerPanel.js @@ -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; } });