From df647f6b74b419b83f7b48634ffc0bb77ccafd14 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Wed, 17 Jun 2015 15:49:42 +0200 Subject: [PATCH] Fixed #5. Default zoom level's can now be defined for PDF and ODF documents. --- config.php | 19 ++++++++++++++++++- js/ViewerPanel.js | 9 ++++++++- php/plugin.fileviewer.php | 7 ++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/config.php b/config.php index b8ea51e..670e77b 100644 --- a/config.php +++ b/config.php @@ -1,3 +1,20 @@ + +/** + * ######################### + * ADVANCED SECTION + * ######################### + */ + +/** + * Default zoom mode for PDF documents. (default: page-width) [Allowed: "auto", "page-actual", "page-width"] + */ +define('PLUGIN_FILEVIEWER_PDF_DEFAULT_ZOOM', "page-width"); +/** + * Default zoom mode for ODF documents. (default: page-width) [Allowed: "auto", "page-actual", "page-width"] + */ +define('PLUGIN_FILEVIEWER_ODF_DEFAULT_ZOOM', "auto"); \ No newline at end of file diff --git a/js/ViewerPanel.js b/js/ViewerPanel.js index 91ad13f..ac388d8 100644 --- a/js/ViewerPanel.js +++ b/js/ViewerPanel.js @@ -172,7 +172,14 @@ Zarafa.plugins.fileviewer.ViewerPanel = Ext.extend(Ext.Panel, { var options = ''; if(Ext.isDefined(extension)) { - options = '?type=' + extension; + if (extension === 'pdf'){ + options += '?zoom=' + container.getSettingsModel().get('zarafa/v1/plugins/fileviewer/config_pdf_default_zoom'); + } else if((/(od[tps])$/i).test(extension)) { + options += '?zoom=' + container.getSettingsModel().get('zarafa/v1/plugins/fileviewer/config_odf_default_zoom'); + } else { + options += '?zoom=auto'; + } + options += '&type=' + extension; } return pluginRoot + this.viewerjsPath + options + '#' + url; diff --git a/php/plugin.fileviewer.php b/php/plugin.fileviewer.php index 7b0ba90..bb6082a 100644 --- a/php/plugin.fileviewer.php +++ b/php/plugin.fileviewer.php @@ -48,12 +48,13 @@ class PluginFileviewer extends Plugin { 'v1' => Array( 'plugins' => Array( 'fileviewer' => Array( - 'enable' => PLUGIN_FILEVIEWER_USER_DEFAULT_ENABLE + 'enable' => PLUGIN_FILEVIEWER_USER_DEFAULT_ENABLE, + 'config_pdf_default_zoom' => PLUGIN_FILEVIEWER_PDF_DEFAULT_ZOOM, + 'config_odf_default_zoom' => PLUGIN_FILEVIEWER_ODF_DEFAULT_ZOOM, ) ) ) ) )); } -} -?> +} \ No newline at end of file