assets.js.installableViewer.min.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of groupdocs-viewer Show documentation
Show all versions of groupdocs-viewer Show documentation
GroupDocs.Viewer for Java is a powerful document viewer component
that allows you to display over 50 document formats in your Java applications.
The viewer can both rasterize documents and convert them to SVG+HTML+CSS, delivering true-text high-fidelity rendering.
Supported file formats include: Microsoft Office, Microsoft Visio, Microsoft Project, Outlook documents, PDF, AutoCAD, Image files (JPG, BMP, GIF, TIFF, etc.) and many more formats.
(function(a){a.widget("ui.groupdocsViewer",{_viewModel:null,options:{enableViewerInit:true,supportTextSelection:true,resourcePrefix:""},_create:function(){a.extend(this.options,{element:this.element,applicationPath:a.ui.groupdocsViewer.prototype.applicationPath,widgetInstance:this});this._viewModel=this.getViewModel()},getViewModel:function(){if(this._viewModel==null)this._viewModel=this._createViewModel();return this._viewModel},_createViewModel:function(){return new window.groupdocs.groupdocsViewerViewModel(this.options)},on:function(a,b){this.element.on(a,b)},off:function(a,b){this.element.off(a,b)},setWidth:function(a){this._viewModel.setWidth(a)},setHeight:function(a){this._viewModel.setHeight(a)},openNextPage:function(){this._viewModel.openNextPage()},openPreviousPage:function(){this._viewModel.openPreviousPage()},setPage:function(a){this._viewModel.setPage(a)},openFirstPage:function(){this._viewModel.openFirstPage()},openLastPage:function(){this._viewModel.openLastPage()},showFileBrowser:function(){this._viewModel.showFileBrowser()},setViewerMode:function(a){this._viewModel.setViewerMode(a)},zoomIn:function(){this._viewModel.zoomIn()},zoomOut:function(){this._viewModel.zoomOut()},setZoom:function(a){this._viewModel.setZoom(a)},downloadDocument:function(){this._viewModel.downloadDocument()},printDocument:function(){this._viewModel.printDocument()},searchForward:function(d,c,b,a){this._viewModel.searchForward(d,c,b,a)},searchBackward:function(d,c,b,a){this._viewModel.searchBackward(d,c,b,a)},clearSearchValue:function(){this._viewModel.clearSearchValue()},getDocumentPageCount:function(){return this._viewModel.getDocumentPageCount()},destroy:function(){this._viewModel.destroy()}});if(!window.groupdocs)window.groupdocs={};window.groupdocs.groupdocsViewerViewModel=function(b){a.extend(this,b);this._create(b)};a.extend(window.groupdocs.groupdocsViewerViewModel.prototype,{groupdocsViewerWrapper:null,browserIsInternetExplorer:false,resizeTimeoutId:null,viewModes:{ScrollMode:1,BookMode:2},viewMode:null,licElement:null,_create:function(a){this._model=new b(a);this._init(a)},_init:function(z){var c,d=this.element,b=a.extend({hostUrl:this.applicationPath,docViewerId:"docViewer"+window.groupdocs.viewerId},z);window.groupdocs.viewerId++;if(z.enableViewerInit){var e,N=false;if(a.browser.msie){this.browserIsInternetExplorer=true;if(a.browser.version==8)N=true;e=".grpdx input[type='text']::-ms-clear {display: none;}";a("").appendTo("head")}var k="grpdx"+b.docViewerId,f=this,A="";if(f.browserIsInternetExplorer&&b.useHtmlBasedEngine)A=" ie";var P="";if(!b.showHeader)P='style="display: none"';d.each(function(){a('').appendTo(a(this))})}this.groupdocsViewerWrapper=c=d.find(".groupdocs_viewer_wrapper");var O=this.viewerHeader=c.find(".viewer_header"),i=this.viewerMainWrapper=c.find(".viewer_mainwrapper");if(!b.showHeader){O.height(0);i.css("top","0")}if(!z.enableViewerInit)return;if(b.filePath=="")b.openThumbnails=false;if(b.useHtmlBasedEngine)b.showViewerStyleControl=false;var E="#"+b.docViewerId,l=a(E),L=c.find("[name='search_wrapper']"),q,x;if(b.width)q=b.width;else q=d.width();c.width(q);if(b.height)x=b.height;else x=d.height();c.height(x);var G=0;if(b.preloadPagesCount&&b.preloadPagesCount>0)G=b.preloadPagesCount;var n=null;if(!b.useHtmlBasedEngine){n=c.find("[name='selection-content']");if(n.length==0)n=a("'").appendTo(c)}var R=c.find("[name='jGDerror']");R.find(".modal_dialog_overlay").click(function(){R.hide()});var F=c.find(".navigation-bar"),w=c.find(".zoom_wrappper"),B=c.find(".doc_viewer_wrapper_page_flip"),t=this.fileOpenDialogWrapper=c.find(".fileOpenDialogWrapper");if(!b.supportTextSelection){var U=E+" .ui-selectable-helper {display: none;visibility: hidden}";a("").appendTo("head")}var u;if(b.thumbnailsContainerWidth){var X=203,T=150,S=187,I=this.getScrollbarWidth(),s=Math.round(b.thumbnailsContainerWidth),Q=(X-I)/(s-I);u=Math.round(T/Q);var V=Math.round(S/Q);e="div.thumbnailsContainer{width:"+s+"px}";e+="div.thumbnailsContainer ul li img{width:"+u+"px}";e+="div.thumbnailsContainer ul li{min-width:"+V+"px}";e+=".thumbs_btn_slide{left:"+(s+2)+"px}";a("").appendTo("head")}e="";if(b.searchHighlightColor)e+="."+k+" .search_highlight_html, ."+k+" .search-highlight {background-color:"+b.searchHighlightColor+"}";if(b.currentSearchHighlightColor)e+=".grpdx."+k+" .current_search_highlight {background-color:"+b.currentSearchHighlightColor+"}";if(b.showOnePageInRow)e+=".grpdx."+k+" .doc-page {display:block; margin-left:auto; margin-right:auto;}";if(b.useEmScaling)e+=".grpdx."+k+" .html_page_contents {transform-origin:initial}";e&&a("").appendTo("head");function j(){f._localizeElements()}l.bind("onHtmlCreated",j);F.bind("onHtmlCreated",j);w.bind("onHtmlCreated",j);B.bind("onHtmlCreated",j);t.bind("onHtmlCreated",j);var ab={createHtml:true,viewerElement:l,useCaseSensitiveSearch:b.useCaseSensitiveSearch,searchForSeparateWords:b.searchForSeparateWords,treatPhrasesInDoubleQuotesAsExactPhrases:b.treatPhrasesInDoubleQuotesAsExactPhrases,useHtmlBasedEngine:b.useHtmlBasedEngine,searchIsVisible:b.showSearch},Y={createHtml:true,thumbnailWidth:u,quality:100,useHtmlBasedEngine:b.useHtmlBasedEngine,useInnerThumbnails:b.useInnerThumbnails,supportPageReordering:b.supportPageReordering},r;if(b.showThumbnails)if(b.useInnerThumbnails)r=i;else r=i;else r=null;var bb={watermarkText:b.watermarkText,watermarkColor:b.watermarkColor,preventTouchEventsBubbling:b.preventTouchEventsBubbling,searchForSeparateWords:b.searchForSeparateWords,treatPhrasesInDoubleQuotesAsExact:b.treatPhrasesInDoubleQuotesAsExact,usePngImagesForHtmlBasedEngine:b.usePngImagesForHtmlBasedEngine,alwaysOnePageInRow:b.showOnePageInRow,onlyShrinkLargePages:b.onlyShrinkLargePages,loadAllPagesOnSearch:b.loadAllPagesOnSearch,useEmScaling:b.useEmScaling,convertWordDocumentsCompletely:b.convertWordDocumentsCompletely,ignoreDocumentAbsence:b.ignoreDocumentAbsence},Z="onMenuClicked",y=c.find(".viewTypeMenu"),m={dropDownMenuIsVisible:ko.observable(false),dropDownMenuClicked:false,openScrollView:function(){f.openScrollView()},openDoublePageFlipView:function(){f.openDoublePageFlipView()},showDropDownMenu:function(a){this.dropDownMenuIsVisible(a)},toggleDropDownMenu:function(b,a){this.dropDownMenuIsVisible(!this.dropDownMenuIsVisible());this.dropDownMenuClicked=true;y.trigger(Z);a.stopPropagation()}},M=this.viewerAdapter=new DocViewerAdapter({fileId:b.filePath,fileVersion:"0",quality:b.quality,use_pdf:b.supportTextSelection?"true":"false",docSpace:l,_mode:"webComponent",createHtml:true,initialZoom:b.initialZoom,viewerWidth:q,viewerHeight:i.height(),docViewerId:b.docViewerId,zoomToFitWidth:b.zoomToFitWidth,zoomToFitHeight:b.zoomToFitHeight,navigation:F,navigationOptions:{createHtml:true},thumbnails:r,thumbnailsOptions:Y,zooming:w,zoomingOptions:{createHtml:true},search:L,searchOptions:ab,preloadPagesCount:G,docSpacePageFlip:b.useHtmlBasedEngine||b.viewerStyle==this.viewModes.ScrollMode&&!b.showViewerStyleControl?null:B,viewerStyle:b.viewerStyle,usePageNumberInUrlHash:false,selectionContent:n,imageHorizontalMargin:14,imageVerticalMargin:14,useJavaScriptDocumentDescription:true,searchPartialWords:true,variableHeightPageSupport:true,textSelectionSynchronousCalculation:false,minimumImageWidth:b.minimumImageWidth,fileDisplayName:b.fileDisplayName,pageContentType:b.useHtmlBasedEngine?"html":"image",searchExactText:b.searchExactText,viewerOptions:bb,viewTypeMenu:y,viewTypeViewModel:m});if(b.showFolderBrowser){var W={hostUrl:b.hostUrl,userId:b.userId,userKey:b.userKey,fileExplorer:c.find(".file_browser_content"),fileUploader:c.find(".file_browser_toolbar"),resourcePrefix:b.resourcePrefix,urlHashEnabled:false};t.fileOpenDialog(W);t.find(".popclose").click(function(){f._hideFileOpenDialog()})}j();var p=d.find(".thumbs_btn");b.useInnerThumbnails&&p.hide();function J(){b.showThumbnails&&b.thumbsImageBase64Encoded!=null&&p.css("background-image","url(data:image/png;base64,"+b.thumbsImageBase64Encoded+")").css("background-position","0 0")}J();p.click(function(){a(this).toggleClass("thumbs_btn_slide");d.find(".thumbnailsContainer").toggle();if(a.browser.msie){p.css("background-image","");J()}return false});c.find(".btnOpen").click(function(){f._showFileOpenDialog()});c.find(".file_browser_content").bind("fileSelected",function(b,a){f._hideFileOpenDialog();f.fileDisplayName=M.docViewerViewModel.fileDisplayName="";M.docViewerViewModel.loadDocument(a.guid)});if(b.showThumbnails&&b.openThumbnails){d.find(".thumbs_btn").addClass("thumbs_btn_slide");d.find(".thumbnailsContainer").css("display","block")}ko.applyBindings(m,y.get(0));a("html").click(function(){f.viewerAdapter.zoomViewModel&&f.viewerAdapter.zoomViewModel.showDropDownMenu(false);m.showDropDownMenu(false)});if(b.backgroundColor){d.find(".groupdocs_viewer_wrapper").css("background-color",b.backgroundColor);O.css("background-color",b.backgroundColor);d.find(".new_head_input").css("background-color",b.backgroundColor);d.find(".new_head_tools_wrapper").css("background-color",b.backgroundColor).css("box-shadow","none");d.find(".thumbs_btn").css("background-color",b.backgroundColor)}d.find(".btnOpen").css("display",b.showFolderBrowser?"":"none");d.find(".navigation-bar").css("display",b.showPaging?"":"none");w.css("display",b.showZoom?"":"none");d.find(".btn_download").css("display",b.showDownload?"":"none");d.find(".print_button").css("display",b.showPrint?"":"none");d.find(".viewTypeMenu").css("display",b.showViewerStyleControl?"":"none");b.showPrint===false&&b.showDownload===false&&d.find("[name='printAndDownloadToolbar']").css("display","none");b.showSearch===false&&L.css("display","none");function K(e,d,f){for(var c=["-moz-","-webkit-",""],a=e+"{",b=0;b"+g+"").appendTo("head");l.bind("onDocumentLoadComplete",function(b,a){f.documentLoadCompleteHandler(a,c,i)});l.bind("onDocumentLoaded",function(b,a){f.documentLoadedHandler(a,c,i)});if(b.viewerStyle==this.viewModes.BookMode)m.openDoublePageFlipView();else this.viewMode=this.viewModes.ScrollMode;var o=c.find("[name='jGDerror']"),C=o.find(".modal_dialog_content"),h=o.find(".modal_dialog_content_wrapper"),H=c.find(".viewer_mainwrapper"),cb=false;window.jGDError=function(c){a(d).trigger("error.groupdocs",c);if(b.enableStandardErrorHandling){c=c.replace(/^[\r\n\s]+|[\r\n\s]+$/g,"");if(!c)c="Sorry, we're unable to perform your request right now. Please try again later.";o.css("height","auto");var e,f;if(c.substring(0,1)=="<"){C.html(c);var i=H.width(),g=H.height();if(i<100)e=i;else e=i-100;if(g<100)f=g;else f=g-100}else C.text(c);if(e!=undefined){h.css("margin-left",-e/2);h.width(e)}f!=undefined&&h.height(f);o.show();h.css("margin-left",-h.width()/2);h.css("margin-top",-h.height()/2)}};this.resizeHandler()},documentLoadedHandler:function(d,b,c){this.printFrameLoaded=false;if(!d.lic&&b.find(".licBanner").length==0){c.addClass("viewer_mainwrapper_trial");this.licElement=a("");this.licElement.addClass("banner_trial");!this.showHeader&&this.licElement.css("top","0");this.licElement.html("This viewer has been created using an unlicensed version of GroupDocs.Viewer for Java v2.4.0");this.licElement.appendTo(b);!this.showHeader&&c.css("top",this.licElement.height()+"px")}},documentLoadCompleteHandler:function(a,b){var e=this;this.showImageWidth&&alert("Image width: "+a.page_size.Width);this.downloadUrl=a.url;this.pdfDownloadUrl=a.pdfDownloadUrl;this.pdfPrintUrl=a.pdfPrintUrl;this.documentPath=a.guid;var c=b.find(".btn_download"),d=b.find(".print_button");c.unbind();d.unbind();var f=this.groupdocsViewerWrapper.find("iframe[name=groupdocsPrintFrame]");f.remove();c.bind({click:function(){e._downloadDocument();return false}});d.bind({click:function(){e._printDocument();return false}})},_localizeElements:function(){var b=this;this.localizedStrings!=null&&b.element.find("[data-localize],[data-localize-ph],[data-localize-tooltip]").each(function(){var e=a(this),c=e.attr("data-localize"),d;if(c){d=b.localizedStrings[c];e.text(d)}else{c=e.attr("data-localize-ph");if(c){d=b.localizedStrings[c];e.attr("placeholder",d)}else{c=e.attr("data-localize-tooltip");if(c){d=b.localizedStrings[c];e.attr("data-tooltip",d)}}}})},getScrollbarWidth:function(){var c=null,d=a("").css("width","100px").css("height","100px").css("overflow","scroll").css("position","absolute").css("top","-9999px"),b=d[0];document.body.appendChild(b);c=b.offsetWidth-b.clientWidth;document.body.removeChild(b);return c},resizeHandler:function(){var c=false;if(this.showHeader){var a=this.viewerHeader.outerHeight(true);if(a!=this.viewerMainWrapper.position().top){var b=a.toString()+"px";this.viewerMainWrapper.css("top",b);this.licElement&&this.licElement.css("top",b);if(this.viewMode==this.viewModes.ScrollMode)this.viewerAdapter.docViewerViewModel.reInitSelectable();else this.viewerAdapter.docViewerPageFlipViewModel.reInitSelectable();c=true}}if(this.viewMode==this.viewModes.ScrollMode&&this.useInnerThumbnails)this.viewerAdapter.docViewerViewModel.resizeViewerElement();else this.viewerAdapter.docViewerViewModel.loadImagesForVisiblePages()},resizeHandlerWithDelay:function(){this.resizeTimeoutId&&clearTimeout(this.resizeTimeoutId);var a=this;this.resizeTimeoutId=window.setTimeout(function(){a.resizeHandler()},1e3)},setWidth:function(a){this.groupdocsViewerWrapper.width(a);this.resizeHandler();this.resizeHandlerWithDelay()},setHeight:function(a){this.groupdocsViewerWrapper.height(a);this.resizeHandler();this.resizeHandlerWithDelay()},_showFileOpenDialog:function(){var b=this;this.fileOpenDialogWrapper.addClass("in");this.fileOpenDialogWrapper.show();this.backdrop=a('').appendTo(this.groupdocsViewerWrapper),this.backdrop.click(function(){b._hideFileOpenDialog()});this.backdrop.addClass("in")},_hideFileOpenDialog:function(){this.backdrop.removeClass("in");this.backdrop.remove();this.fileOpenDialogWrapper.hide()},openScrollView:function(){var b=this.groupdocsViewerWrapper.find(".doc_viewer"),a=this.groupdocsViewerWrapper.find(".doc_viewer_wrapper_page_flip");a.css("position","absolute");a.css("height","100%");a.hide();b.show();this.viewerAdapter.docViewerViewModel.openCurrentPage();this.viewerAdapter.docViewerViewModel.reInitSelectable();if(this.viewerAdapter.zooming){this.viewerAdapter.zoomViewModel.setFitWidthZoom(this.viewerAdapter.docViewerViewModel.getFitWidthZoom());this.viewerAdapter.zoomViewModel.setFitHeightZoom(this.viewerAdapter.docViewerViewModel.getFitHeightZoom())}this.viewerAdapter.search&&this.viewerAdapter.searchViewModel.showControls();this.viewMode=this.viewModes.ScrollMode},openDoublePageFlipView:function(){if(!this.useHtmlBasedEngine){var b=this.groupdocsViewerWrapper.find(".doc_viewer"),a=this.groupdocsViewerWrapper.find(".doc_viewer_wrapper_page_flip");a.show();this.viewerAdapter.docViewerPageFlipViewModel.openCurrentPage();a.css("height","");a.css("top","");a.css("position","");b.hide();this.viewerAdapter.docViewerPageFlipViewModel.reInitSelectable();if(this.viewerAdapter.zooming){this.viewerAdapter.zoomViewModel.setFitWidthZoom(this.viewerAdapter.docViewerPageFlipViewModel.getFitWidthZoom());this.viewerAdapter.zoomViewModel.setFitHeightZoom(this.viewerAdapter.docViewerPageFlipViewModel.getFitHeightZoom())}this.viewerAdapter.search&&this.viewerAdapter.searchViewModel.hideControls();this.viewMode=this.viewModes.BookMode}},_downloadDocument:function(){this.element.trigger("onGDViewerDownloadButtonClick");this.element.trigger("downloadButtonClick.groupdocs");var b=this.downloadUrl;if(this.downloadPdfFile)b=this.pdfDownloadUrl;if(this.showDownloadErrorsInPopup)a.fileDownload(b,{failCallback:function(a){window.jGDError(a)},cookieName:self.jqueryFileDownloadCookieName,containerElement:this.groupdocsViewerWrapper});else window.location.href=b;return false},_printDocument:function(){if(this.usePdfPrinting)var k=window.open(this.pdfPrintUrl);else{var d="";if(this.fileDisplayName)d=this.fileDisplayName;var j=this;function e(){b[0].contentWindow.focus();b[0].contentWindow.print()}var c=this.useHtmlBasedEngine&&!this.useImageBasedPrinting,b=this.groupdocsViewerWrapper.find("iframe[name=groupdocsPrintFrame]"),g=null,f=null;if(this.printWithWatermark){g=this.watermarkText;f=this.watermarkColor}if(b.length==0){var i=500,h=500;b=a("");b.appendTo(this.groupdocsViewerWrapper);this._model.getPrintableHtml(this.documentPath,c,d,g,f,function(d){var a=b[0].contentWindow.document;b.load(function(){j.printFrameLoaded=true;if(c)window.setTimeout(function(){e()},10);else e()});a.open();a.write(d);a.close()},function(){})}else if(this.printFrameLoaded)e();else this._model.getPrintableHtml(this.documentPath,c,d,g,f,function(c){var a=b[0].contentWindow.document;a.open();a.write(c);a.close()},function(){})}return false},openNextPage:function(){this.viewerAdapter.navigationViewModel.down()},openPreviousPage:function(){this.viewerAdapter.navigationViewModel.up()},setPage:function(a){this.viewerAdapter.navigationViewModel.selectPage(a)},openFirstPage:function(){this.viewerAdapter.navigationViewModel.openFirstPage()},openLastPage:function(){this.viewerAdapter.navigationViewModel.openLastPage()},showFileBrowser:function(){this._showFileOpenDialog()},setViewerMode:function(a){if(a==0)this.openScrollView();else this.openDoublePageFlipView()},zoomIn:function(){this.viewerAdapter.zoomViewModel.zoomIn()},zoomOut:function(){this.viewerAdapter.zoomViewModel.zoomOut()},setZoom:function(b){var a=b;switch(b){case window.groupdocs.FitWidth:a=this.viewerAdapter.zoomViewModel.getFitWidthZoomValue();break;case window.groupdocs.FitHeight:a=this.viewerAdapter.zoomViewModel.getFitHeightZoomValue()}this.viewerAdapter.zoomViewModel.setZoom({value:a})},downloadDocument:function(){this._downloadDocument()},printDocument:function(){this._printDocument()},searchForward:function(a,d,c,b){if(this.viewerAdapter.searchViewModel.searchValue()!=a)this.viewerAdapter.searchViewModel.searched=false;this.viewerAdapter.searchViewModel.searchValue(a);this.viewerAdapter.searchViewModel.findNext(d,c,b)},searchBackward:function(a,d,c,b){if(this.viewerAdapter.searchViewModel.searchValue()!=a)this.viewerAdapter.searchViewModel.searched=false;this.viewerAdapter.searchViewModel.searchValue(a);this.viewerAdapter.searchViewModel.findPrevious(d,c,b)},clearSearchValue:function(){this.viewerAdapter.searchViewModel.clearValue()},getDocumentPageCount:function(){return this.viewerAdapter.docViewerViewModel.pageCount()},destroy:function(){var b=this.groupdocsViewerWrapper.find(".doc_viewer_wrapper_page_flip .pages_container_flip");b.length!=0&&b.turn("is")&&b.turn("destroy");this.groupdocsViewerWrapper.remove();a.Widget.prototype.destroy.call(this.widgetInstance)}});var b=function(b){a.extend(this,b);this._init()};a.extend(b.prototype,{_portalService:null,_init:function(){this._portalService=Container.Resolve("PortalService")},getPrintableHtml:function(f,a,b,e,c,g,d){this._portalService.getPrintableHtml(f,a,b,e,c,function(a){g.apply(this,[a.data])},function(a){d.apply(this,[a])})}});a.support.cors=true;if(!jQuery.browser){jQuery.browser={};(function(){jQuery.browser.msie=false;jQuery.browser.version=0;if(navigator.userAgent.match(/MSIE ([0-9]+)\./)){jQuery.browser.msie=true;jQuery.browser.version=RegExp.$1}})()}window.groupdocs.ScrollMode=0;window.groupdocs.BookMode=1;window.groupdocs.FitWidth=-1;window.groupdocs.FitHeight=-2;window.groupdocs.viewerId=1})(jQuery);