All Downloads are FREE. Search and download functionalities are using the official Maven repository.

assets.js.installableViewer.min.js Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 17.5.0
Show newest version
(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()},loadDocument:function(a){this._viewModel.loadDocument(a)},rotateCurrentPage:function(a){this._viewModel._rotatePage(a)},setLoadingState:function(a){this._viewModel.setLoadingState(a)},getContentControlDescriptions:function(){return this._viewModel.getContentControlDescriptions()},navigateToContentControl:function(a){this._viewModel.navigateToContentControl(a)},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,printImageElements:null,_create:function(a){this._model=new b(a);this._init(a)},_init:function(E){var c,d=this.element;this.viewerId=window.groupdocs.viewerId;var b=a.extend({hostUrl:this.applicationPath,docViewerId:"docViewer"+this.viewerId},E);this.printImageElements=[];window.groupdocs.viewerId++;if(E.enableViewerInit){var f,A=false;if(a.browser.msie){this.browserIsInternetExplorer=true;if(a.browser.version==8)A=true;f=".grpdx input[type='text']::-ms-clear {display: none;}";a("").appendTo("head")}var l="grpdx"+b.docViewerId,e=this,t="";if(e.browserIsInternetExplorer&&b.useHtmlBasedEngine){t=" ie";if(A)t+=" ie8"}var P="";if(!b.showHeader)P='style="display: none"';d.each(function(){a('
'+(b.supportPageRotation?'
':"")+'
'+(b.showThumbnails?' ':"")+'
').appendTo(a(this))})}this.groupdocsViewerWrapper=c=d.find(".groupdocs_viewer_wrapper");var B=this.viewerHeader=c.find(".viewer_header"),j=this.viewerMainWrapper=c.find(".viewer_mainwrapper");if(!b.showHeader){B.height(0);j.css("top","0")}if(!E.enableViewerInit)return;if(b.filePath=="")b.openThumbnails=false;var I="#"+b.docViewerId,i=a(I),N=c.find("[name='search_wrapper']");if(b.useHtmlBasedEngine){B.find("li[name='openDoublePageFlipViewMenuItem']").hide();if(!b.supportTextSelection){f="."+l+" .html_pages_container{-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}";a("").appendTo("head");if(this.browserIsInternetExplorer)i.on("selectstart",function(a){a.preventDefault();return true})}}var r,C;if(b.width)r=b.width;else r=d.width();c.width(r);if(b.height)C=b.height;else C=d.height();c.height(C);var o=null;if(!b.useHtmlBasedEngine){o=c.find("[name='selection-content']");if(o.length==0)o=a("'").appendTo(c)}var R=c.find("[name='jGDerror']");R.find(".modal_dialog_overlay").click(function(){R.hide()});var x=c.find(".navigation-bar"),z=c.find(".zoom_wrappper"),F=c.find(".doc_viewer_wrapper_page_flip"),v=this.fileOpenDialogWrapper=c.find(".fileOpenDialogWrapper");if(!b.supportTextSelection){var U=I+" .ui-selectable-helper {display: none;visibility: hidden}";a("").appendTo("head")}var w;if(b.thumbnailsContainerWidth){var X=203,T=150,S=187,K=this.getScrollbarWidth(),u=Math.round(b.thumbnailsContainerWidth),Q=(X-K)/(u-K);w=Math.round(T/Q);var V=Math.round(S/Q);f="div.thumbnailsContainer{width:"+u+"px}";f+="div.thumbnailsContainer ul li img{width:"+w+"px}";f+="div.thumbnailsContainer ul li{min-width:"+V+"px}";f+=".thumbs_btn_slide{left:"+(u+2)+"px}";a("").appendTo("head")}f="";if(b.searchHighlightColor)f+="."+l+" .search_highlight_html, ."+l+" .search-highlight {background-color:"+b.searchHighlightColor+"}";if(b.currentSearchHighlightColor)f+=".grpdx."+l+" .current_search_highlight {background-color:"+b.currentSearchHighlightColor+"}";if(b.useEmScaling)f+=".grpdx."+l+" .html_page_contents {transform-origin:initial}";f&&a("").appendTo("head");function k(){e._localizeElements()}i.bind("onHtmlCreated",k);x.bind("onHtmlCreated",k);z.bind("onHtmlCreated",k);F.bind("onHtmlCreated",k);v.bind("onHtmlCreated",k);var db={createHtml:true,viewerElement:i,useCaseSensitiveSearch:b.useCaseSensitiveSearch,searchForSeparateWords:b.searchForSeparateWords,treatPhrasesInDoubleQuotesAsExactPhrases:b.treatPhrasesInDoubleQuotesAsExactPhrases,useHtmlBasedEngine:b.useHtmlBasedEngine,searchIsVisible:b.showSearch,useRtl:b.useRtl,useAccentInsensitiveSearch:b.useAccentInsensitiveSearch,useVirtualScrolling:b.useVirtualScrolling},Z={createHtml:true,thumbnailWidth:w,quality:100,useHtmlBasedEngine:b.useHtmlBasedEngine,useHtmlThumbnails:b.useHtmlThumbnails,useInnerThumbnails:b.useInnerThumbnails,supportPageReordering:b.supportPageReordering,use_pdf:b.supportTextSelection?"true":"false",ignoreDocumentAbsence:b.ignoreDocumentAbsence,supportPageRotation:b.supportPageRotation,showThumbnails:b.openThumbnails},s;if(b.showThumbnails)if(b.useInnerThumbnails)s=j;else s=j;else s=null;var eb={watermarkText:b.watermarkText,watermarkColor:b.watermarkColor,watermarkPosition:b.watermarkPosition,watermarkWidth:b.watermarkFontSize,preventTouchEventsBubbling:b.preventTouchEventsBubbling,searchForSeparateWords:b.searchForSeparateWords,treatPhrasesInDoubleQuotesAsExact:b.treatPhrasesInDoubleQuotesAsExact,usePngImagesForHtmlBasedEngine:b.usePngImagesForHtmlBasedEngine,alwaysOnePageInRow:b.showOnePageInRow||b.viewerStyle==window.groupdocs.OnePageInRow,onlyShrinkLargePages:b.onlyShrinkLargePages,loadAllPagesOnSearch:b.loadAllPagesOnSearch,useEmScaling:b.useEmScaling,convertWordDocumentsCompletely:b.convertWordDocumentsCompletely,ignoreDocumentAbsence:b.ignoreDocumentAbsence,usePdf:b.supportTextSelection,preloadPagesOnBrowserSide:b.preloadPagesOnBrowserSide,supportPageRotation:b.supportPageRotation,useAccentInsensitiveSearch:b.useAccentInsensitiveSearch,useRtl:b.useRtl,viewerLayout:b.viewerStyle,useVirtualScrolling:b.useVirtualScrolling,supportListOfContentControls:b.supportListOfContentControls,supportListOfBookmarks:b.supportListOfBookmarks,embedImagesIntoHtmlForWordFiles:b.embedImagesIntoHtmlForWordFiles},ab="onMenuClicked",D=c.find(".viewTypeMenu"),n={dropDownMenuIsVisible:ko.observable(false),dropDownMenuClicked:false,openScrollView:function(){e.setMultiplePagesInRowLayout()},openDoublePageFlipView:function(){e.openDoublePageFlipView()},openOnePageInRowView:function(){e.openOnePageInRowView()},openTwoPagesInRowView:function(){e.openTwoPagesInRowView()},openCoverThenTwoPagesInRowView:function(){e.openCoverThenTwoPagesInRowView()},showDropDownMenu:function(a){this.dropDownMenuIsVisible(a)},toggleDropDownMenu:function(b,a){this.dropDownMenuIsVisible(!this.dropDownMenuIsVisible());this.dropDownMenuClicked=true;D.trigger(ab);a.stopPropagation()}},O=this.viewerAdapter=new DocViewerAdapter({fileId:b.filePath,fileVersion:"0",quality:b.quality,use_pdf:b.supportTextSelection?"true":"false",docSpace:i,_mode:"webComponent",createHtml:true,initialZoom:b.initialZoom,viewerWidth:r,viewerHeight:j.height(),docViewerId:b.docViewerId,zoomToFitWidth:b.zoomToFitWidth,zoomToFitHeight:b.zoomToFitHeight,navigation:x,navigationOptions:{createHtml:true},thumbnails:s,thumbnailsOptions:Z,zooming:z,zoomingOptions:{createHtml:true},search:N,searchOptions:db,preloadPagesCount:b.preloadPagesCount,docSpacePageFlip:b.useHtmlBasedEngine||b.viewerStyle==this.viewModes.ScrollMode&&!b.showViewerStyleControl?null:F,usePageNumberInUrlHash:false,selectionContent:o,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:eb,viewTypeMenu:D,viewTypeViewModel:n});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};v.fileOpenDialog(W);v.find(".popclose").click(function(){e._hideFileOpenDialog()})}k();var q=d.find(".thumbs_btn");b.useInnerThumbnails&&q.hide();function L(){b.showThumbnails&&b.thumbsImageBase64Encoded!=null&&q.css("background-image","url(data:image/png;base64,"+b.thumbsImageBase64Encoded+")").css("background-position","0 0")}L();q.click(function(){a(this).toggleClass("thumbs_btn_slide");d.find(".thumbnailsContainer").toggle();if(a.browser.msie){q.css("background-image","");L()}return false});c.find(".btnOpen").click(function(){e._showFileOpenDialog()});c.find("[name=rotateClockwise]").click(function(){e._rotatePage(90)});c.find("[name=rotateCounterClockwise]").click(function(){e._rotatePage(-90)});c.find(".file_browser_content").bind("fileSelected",function(b,a){e._hideFileOpenDialog();e.fileDisplayName=O.docViewerViewModel.fileDisplayName="";O.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(n,D.get(0));a("html").click(function(){e.viewerAdapter.zoomViewModel&&e.viewerAdapter.zoomViewModel.showDropDownMenu(false);n.showDropDownMenu(false)});if(b.backgroundColor){d.find(".groupdocs_viewer_wrapper").css("background-color",b.backgroundColor);B.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");z.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&&N.css("display","none");function M(e,d,f){for(var c=["-moz-","-webkit-",""],a=e+"{",b=0;b"+g+"").appendTo("head");i.bind("onDocumentLoadComplete",function(b,a){e.documentLoadCompleteHandler(a,c,j)});i.bind("onDocumentLoaded",function(b,a){e.documentLoadedHandler(a,c,j)});i.bind("isDocumentSinglePaged.groupdocs",function(b,a){e.documentSinglePagedHandler(a,x)});if(b.viewerStyle==this.viewModes.BookMode)n.openDoublePageFlipView();else this.viewMode=this.viewModes.ScrollMode;var m=c.find("[name='jGDerror']"),G=m.find(".modal_dialog_content"),h=m.find(".modal_dialog_content_wrapper"),Y=m.find(".modal_dialog_header");m.removeClass("jerrorwrapper");var J=c.find(".viewer_mainwrapper"),fb=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.";m.css("height","auto");Y.text("Error");var e,f;if(c.substring(0,1)=="<"){G.html(c);var i=J.width(),g=J.height();if(i<100)e=i;else e=i-100;if(g<100)f=g;else f=g-100}else G.text(c);if(e!=undefined){h.css("margin-left",-e/2);h.width(e)}f!=undefined&&h.height(f);m.show();h.css("margin-left",-h.width()/2);h.css("margin-top",-h.height()/2)}};var p=this.groupdocsViewerWrapper.find("[name='messageDialog']"),cb=p.find("[name='minimizeButton']"),bb=p.find("[name='maximizeButton']");cb.click(function(){p.addClass("min")});bb.click(function(){p.removeClass("min")});this.resizeHandler()},documentLoadedHandler:function(i,d,e){this.printFrameLoaded=false;var f=a("body"),c="printFrame"+this.viewerId,b=f.children("div.groupdocsPrintFrame[name='"+c+"'],div.groupdocsPrintFrameDeactivated[name='"+c+"']");if(b.length==0){b=a("
");b.attr("name",c);b.appendTo(f)}else b.empty();this.printImageElements.length=0;for(var j=i.page_count,g,h=0;h").appendTo(b);this.printImageElements.push(g)}if(!i.lic&&d.find(".licBanner").length==0){e.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.10.0 ");this.licElement.appendTo(d);!this.showHeader&&e.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();c.bind({click:function(){e._downloadDocument();return false}});d.bind({click:function(){e._printDocument();return false}})},documentSinglePagedHandler:function(b,a){if(this.showPaging)if(b)a.hide();else a.show()},_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(){if(this.showHeader){var c=this.viewerHeader.outerHeight(true),a=0;if(this.licElement)a=this.licElement.height();if(c!=this.viewerMainWrapper.position().top-a){var b=c;if(this.licElement){this.licElement.css("top",b.toString()+"px");b+=a}this.viewerMainWrapper.css("top",b.toString()+"px");if(this.viewMode==this.viewModes.BookMode)this.viewerAdapter.docViewerPageFlipViewModel.reInitSelectable();else this.viewerAdapter.docViewerViewModel.reInitSelectable()}}if(this.viewMode!=this.viewModes.BookMode&&this.useInnerThumbnails){var d=0,e=this.viewerAdapter.thumbnailsViewModel;if(e)d=e.getThumbnailsPanelWidth();this.viewerAdapter.docViewerViewModel.resizeViewerElement(d)}else this.viewerAdapter.docViewerViewModel.loadImagesForVisiblePages();this._setFitWidthAndHeightValues()},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('




© 2015 - 2024 Weber Informatics LLC | Privacy Policy