Ext.namespace("Zarafa.plugins.filepreviewer");Zarafa.plugins.filepreviewer.ABOUT='<p>Copyright (C) 2015  Christoph Haas &lt;christoph.h@sprinternet.at&gt;</p><p>Copyright (C) 2016  2016 Kopano and its licensors</p><p>This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p><p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.</p><p>You should have received a copy of the GNU Affero General Public License along with this program.  If not, see <a href="http://www.gnu.org/licenses/" target="_blank">http://www.gnu.org/licenses/</a>.</p><hr /><p>The filepreviewer plugin contains the following third-party components:</p><h1>ViewerJS</h1><p>Copyright (C) 2015 viewerjs.org</p>';
Ext.namespace("Zarafa.plugins.filepreviewer");
Zarafa.plugins.filepreviewer.FileviewerPlugin=Ext.extend(Zarafa.core.Plugin,{initPlugin:function(){Zarafa.plugins.filepreviewer.FileviewerPlugin.superclass.initPlugin.apply(this,arguments);Zarafa.core.data.SharedComponentType.addProperty("filepreviewer.viewpanel")},doOpen:function(a){Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType["filepreviewer.viewpanel"],a,{modal:!0,autoResize:!0})},isSupportedDocument:function(a){return a.match(/^.*\.(pdf|od[tps]|jpg|jpeg|png|bmp|gif|mp4|mp3|ogg|webm|wav)$/i)?!0:
!1},bidSharedComponent:function(a,b){var c=-1;switch(a){case Zarafa.core.data.SharedComponentType["filepreviewer.viewpanel"]:c=1;break;case Zarafa.core.data.SharedComponentType["common.view"]:if(b instanceof Zarafa.core.data.IPMAttachmentRecord){var d=b.get("name");this.isSupportedDocument(d)&&(c=2)}}return c},getSharedComponent:function(a,b){var c;switch(a){case Zarafa.core.data.SharedComponentType["common.view"]:c=this;break;case Zarafa.core.data.SharedComponentType["filepreviewer.viewpanel"]:c=
Zarafa.plugins.filepreviewer.ViewerPanel}return c}});Zarafa.onReady(function(){container.registerPlugin(new Zarafa.core.PluginMetaData({name:"filepreviewer",displayName:_("File previewer plugin"),about:Zarafa.plugins.filepreviewer.ABOUT,pluginConstructor:Zarafa.plugins.filepreviewer.FileviewerPlugin}))});Ext.namespace("Zarafa.plugins.filepreviewer");
Zarafa.plugins.filepreviewer.ViewerPanel=Ext.extend(Ext.Panel,{viewerjsPath:"external/ViewerJS/index.html",src:"",title:"",autoResize:!1,defaultScale:.8,constructor:function(a){a=a||{};if(Ext.isDefined(a.record)){this.title=a.record.get("name")||a.record.get("filename");var b=this.title.split(".").pop();this.src=this.getIframeURL(a.record.getInlineImageUrl(),b)}else this.src=a.src,this.title=a.title;Ext.isDefined(a.autoResize)?this.autoResize=a.autoResize:this.autoResize=!1;Ext.isDefined(a.defaultScale)?
this.defaultScale=a.defaultScale:this.defaultScale=.8;Ext.applyIf(a,{xtype:"filepreviewer.viewerpanel",layout:"anchor",anchor:"100%",items:[{xtype:"component",ref:"iframe",autoEl:{tag:"iframe",src:this.src,style:{width:"100%",height:"100%"},frameborder:0,allowfullscreen:!0},listeners:{afterrender:this.onAfterRender}}],title:this.title,header:!1,height:Ext.getBody().getViewSize().height*this.defaultScale,width:Ext.getBody().getViewSize().width*this.defaultScale});Zarafa.plugins.filepreviewer.ViewerPanel.superclass.constructor.call(this,
a)},initEvents:function(){if(!0===this.autoResize)Ext.EventManager.onWindowResize(this.resizePanel,this);else!1!==this.autoResize&&(this.autoResize.on("resize",this.resizePanel,this),Ext.isDefined(this.autoResize.autoScroll)&&(this.autoResize.initialAutoScrollValue=this.autoResize.autoScroll,this.autoResize.setAutoScroll(!1)))},onDestroy:function(){!0===this.autoResize?Ext.EventManager.removeResizeListener(this.resizePanel,this):!1!==this.autoResize&&(this.autoResize.un("resize",this.resizePanel,
this),Ext.isDefined(this.autoResize.autoScroll)&&this.autoResize.setAutoScroll(this.autoResize.initialAutoScrollValue));Zarafa.plugins.filepreviewer.ViewerPanel.superclass.onDestroy.call(this,arguments)},resizePanel:function(a,b){if(2<arguments.length){var c=arguments[0];a=c.getInnerWidth();b=c.getInnerHeight()}this.setWidth(a*this.defaultScale);this.setHeight(b*this.defaultScale);this.ownerCt instanceof Ext.Window&&this.ownerCt.center()},getIframeURL:function(a,b){var c=container.getBasePath()+"plugins/filepreviewer/",
d="";Ext.isDefined(b)&&(d="pdf"===b?d+("?zoom="+container.getSettingsModel().get("zarafa/v1/plugins/filepreviewer/config_pdf_default_zoom")):/(od[tps])$/i.test(b)?d+("?zoom="+container.getSettingsModel().get("zarafa/v1/plugins/filepreviewer/config_odf_default_zoom")):d+"?zoom=auto",d+="&type="+b);return c+this.viewerjsPath+d+"#"+a},onAfterRender:function(){var a=this.refOwner;this.getEl().on("load",a.onLoadFrame,this.getEl(),{single:!0})},onLoadFrame:function(){var a=this.dom.contentDocument.getElementById("download"),
a=Ext.get(a);a.on("click",function(){Zarafa.core.Util.skipRequester=!0})}});Ext.reg("filepreviewer.viewerpanel",Zarafa.plugins.filepreviewer.ViewerPanel);//# sourceMappingURL=filepreview.js.map
