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 is an online document viewer that lets you read documents in your browser, regardless of whether you have the software that they were created in. You can view many types to word processing documents (DOC, DOCX, TXT, RTF, ODT), presentations (PPT, PPTX), spreadsheets (XLS, XLSX), portable files (PDF), and image files (JPG, BMP, GIF, TIFF). For each file, you get a high-fidelity rendering, showing the document just as it would if you opened it in the software it was created in. Layout and formatting is retained and you see an exact copy of the original. GroupDocs.Viewer lets you really read the document. You can search text documents, copy text and even embed the document – GroupDocs.Viewer and all - in a web page. You can print or download the file from GroupDocs.Viewer if you need to work with it offline.

There is a newer version: 2.1.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});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(a){this._viewModel.searchForward(a)},searchBackward:function(a){this._viewModel.searchBackward(a)},clearSearchValue:function(){this._viewModel.clearSearchValue()}});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(v){var d,c=this.element,b=a.extend({hostUrl:this.applicationPath},v);if(v.enableViewerInit){var g,K=false;if(a.browser.msie){this.browserIsInternetExplorer=true;if(a.browser.version==8)K=true;g=".grpdx input[type='text']::-ms-clear {display: none;}";a("").appendTo("head")}var h=this;c.each(function(){a('
').appendTo(a(this))})}this.groupdocsViewerWrapper=d=c.find(".groupdocs_viewer_wrapper");var t=this.viewerHeader=d.find(".viewer_header"),j=this.viewerMainWrapper=d.find(".viewer_mainwrapper");if(!b.showHeader){t.hide();t.height(0);j.css("top","0")}if(!v.enableViewerInit)return;if(b.filePath=="")b.openThumbnails=false;if(b.useHtmlBasedEngine){b.showSearch=false;b.showViewerStyleControl=false}var A="#"+b.docViewerId,k=a(A),I=d.find("[name='search_wrapper']"),m,u;if(b.width)m=b.width;else m=c.width();d.width(m);if(b.height)u=b.height;else u=c.height();d.height(u);var C=0;if(b.preloadPagesCount&&b.preloadPagesCount>0)C=b.preloadPagesCount;var p=d.find("[name='selection-content']");if(p.length==0)p=a("'").appendTo(d);var M=d.find("[name='jGDerror']");M.find(".modal_dialog_overlay").click(function(){M.hide()});var B=d.find(".navigation-bar"),r=d.find(".zoom_wrappper"),x=d.find(".doc_viewer_wrapper_page_flip"),w=d.find(".fileOpenDialogWrapper");if(!b.supportTextSelection){var P=A+" .ui-selectable-helper {display: none;visibility: hidden}";a("").appendTo("head")}var o;if(b.thumbnailsContainerWidth){var S=203,O=150,N=187,F=this.getScrollbarWidth(),n=Math.round(b.thumbnailsContainerWidth),L=(S-F)/(n-F);o=Math.round(O/L);var Q=Math.round(N/L);g="div.thumbnailsContainer{width:"+n+"px}";g+="div.thumbnailsContainer ul li img{width:"+o+"px}";g+="div.thumbnailsContainer ul li{min-width:"+Q+"px}";g+=".thumbs_btn_slide{left:"+(n+2)+"px}";a("").appendTo("head")}function i(){h._localizeElements()}k.bind("onHtmlCreated",i);B.bind("onHtmlCreated",i);r.bind("onHtmlCreated",i);x.bind("onHtmlCreated",i);w.bind("onHtmlCreated",i);var J=this.viewerAdapter=new DocViewerAdapter({fileId:b.filePath,fileVersion:"0",quality:b.quality,use_pdf:b.supportTextSelection?"true":"false",docSpace:k,_mode:"webComponent",createHtml:true,initialZoom:b.initialZoom,viewerWidth:m,viewerHeight:j.height(),docViewerId:b.docViewerId,zoomToFitWidth:b.zoomToFitWidth,zoomToFitHeight:b.zoomToFitHeight,navigation:B,navigationOptions:{createHtml:true},thumbnails:b.showThumbnails?j:null,thumbnailsOptions:{createHtml:true,thumbnailWidth:o,quality:100,useHtmlBasedEngine:b.useHtmlBasedEngine},zooming:r,zoomingOptions:{createHtml:true},search:b.showSearch?I:null,searchOptions:{createHtml:true,viewerElement:k},preloadPagesCount:C,docSpacePageFlip:b.useHtmlRepresentation?null:x,viewerStyle:b.viewerStyle,usePageNumberInUrlHash:false,selectionContent:p,imageHorizontalMargin:14,imageVerticalMargin:14,useJavaScriptDocumentDescription:true,searchPartialWords:true,variableHeightPageSupport:true,textSelectionSynchronousCalculation:false,minimumImageWidth:b.minimumImageWidth,fileDisplayName:b.fileDisplayName,pageContentType:b.useHtmlBasedEngine?"html":"image"});if(b.showFolderBrowser){var R={hostUrl:b.hostUrl,userId:b.userId,userKey:b.userKey,fileExplorer:d.find(".file_browser_content"),fileUploader:d.find(".file_browser_toolbar"),resourcePrefix:b.resourcePrefix,urlHashEnabled:false};w.fileOpenDialog(R)}i();var s=c.find(".thumbs_btn");function G(){b.thumbsImageBase64Encoded!=null&&s.css("background-image","url(data:image/png;base64,"+b.thumbsImageBase64Encoded+")").css("background-position","0 0")}G();s.click(function(){a(this).toggleClass("thumbs_btn_slide","slow");c.find(".thumbnailsContainer").toggle("slide","slow",function(){if(a.browser.msie){s.css("background-image","");G()}});return false});d.find(".btnOpen").click(function(){h._showFileOpenDialog()});d.find(".file_browser_content").bind("fileSelected",function(b,a){h.fileDisplayName=J.docViewerViewModel.fileDisplayName="";J.docViewerViewModel.loadDocument(a.guid)});!b.showThumbnails&&c.find(".thumbs_btn").hide();if(b.openThumbnails){c.find(".thumbs_btn").addClass("thumbs_btn_slide");c.find(".thumbnailsContainer").css("display","block")}c.find(".head_tool_dropdown_btn").click(function(){a(this).toggleClass("active");a(this).next(".head_tool_dropdown").toggle("blind","fast");return false});a("html").click(function(){c.find(".new_head_tools_dropdown_wrapper").find(".active").next(".head_tool_dropdown").toggle("blind","fast");c.find(".new_head_tools_dropdown_wrapper").find(".active").removeClass("active")});if(b.backgroundColor){c.find(".groupdocs_viewer_wrapper").css("background-color",b.backgroundColor);t.css("background-color",b.backgroundColor);c.find(".new_head_input").css("background-color",b.backgroundColor);c.find(".new_head_tools_wrapper").css("background-color",b.backgroundColor).css("box-shadow","none");c.find(".thumbs_btn").css("background-color",b.backgroundColor)}c.find(".btnOpen").css("display",b.showFolderBrowser?"":"none");c.find(".navigation-bar").css("display",b.showPaging?"":"none");r.css("display",b.showZoom?"":"none");c.find(".btn_download").css("display",b.showDownload?"":"none");c.find(".print_button").css("display",b.showPrint?"":"none");c.find(".new_head_tools_dropdown_wrapper").css("display",b.showViewerStyleControl?"":"none");b.showPrint===false&&b.showDownload===false&&c.find("[name='printAndDownloadToolbar']").css("display","none");b.showSearch===false&&I.css("display","none");function H(e,d,f){for(var c=["-moz-","-webkit-",""],a=e+"{",b=0;b"+e+"").appendTo("head");k.bind("onDocumentLoadComplete",function(b,a){h.documentLoadCompleteHandler(a,d,j)});k.bind("onDocumentLoaded",function(b,a){h.documentLoadedHandler(a,d,j)});var E={openScrollView:function(){h.openScrollView()},openDoublePageFlipView:function(){h.openDoublePageFlipView()}};ko.applyBindings(E,d.find(".viewTypeMenu").get(0));if(b.viewerStyle==this.viewModes.BookMode)E.openDoublePageFlipView();else this.viewMode=this.viewModes.ScrollMode;var l=d.find("[name='jGDerror']"),y=l.find(".modal_dialog_content"),f=l.find(".modal_dialog_content_wrapper"),D=d.find(".viewer_mainwrapper"),T=false;window.jGDError=function(d){a(c).trigger("error.groupdocs",d);if(b.enableStandardErrorHandling){if(!d)d="Sorry, we're unable to perform your request right now. Please try again later.";l.css("height","auto");var e,g;if(d.substring(0,1)=="<"){y.html(d);var i=D.width(),h=D.height();if(i<100)e=i;else e=i-100;if(h<100)g=h;else g=h-100}else y.text(d);if(e!=undefined){f.css("margin-left",-e/2);f.width(e)}g!=undefined&&f.height(g);l.show();f.css("margin-left",-f.width()/2);f.css("margin-top",-f.height()/2)}};this.resizeHandler()},documentLoadedHandler:function(d,b,c){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 ");this.licElement.appendTo(b)}},documentLoadCompleteHandler:function(a,b){var e=this;this.showImageWidth&&alert("Image width: "+a.page_size.Width);this.downloadUrl=a.url;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}})},_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 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()}}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(){this.groupdocsViewerWrapper.find(".fileOpenDialogWrapper").modal("show")},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(){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");if(this.showDownloadErrorsInPopup)a.fileDownload(this.downloadUrl,{failCallback:function(a){window.jGDError(a)},cookieName:self.jqueryFileDownloadCookieName,containerElement:this.groupdocsViewerWrapper});else window.location.href=this.downloadUrl;return false},_printDocument:function(){if(this.usePdfPrinting)var d=window.open(this.pdfPrintUrl);else{var c="";if(this.fileDisplayName)c=this.fileDisplayName;var b=this.groupdocsViewerWrapper.find("iframe[name=groupdocsPrintFrame]");if(b.length==0){b=a("");b.appendTo(this.groupdocsViewerWrapper);this._model.getPrintableHtml(this.documentPath,c,function(c){b.load(function(){this.printFrameLoaded=true;b[0].contentWindow.focus();b[0].contentWindow.print()});var a=b[0].contentWindow.document;a.open();a.write(c);a.close()},function(){})}else if(this.printFrameLoaded){b[0].contentWindow.focus();b[0].contentWindow.print()}else this._model.getPrintableHtml(this.documentPath,c,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(a){this.viewerAdapter.zoomViewModel.setZoom({value:a})},downloadDocument:function(){this._downloadDocument()},printDocument:function(){this._printDocument()},searchForward:function(a){if(this.viewerAdapter.searchViewModel.searchValue()!=a)this.viewerAdapter.searchViewModel.searched=false;this.viewerAdapter.searchViewModel.searchValue(a);this.viewerAdapter.searchViewModel.findNext()},searchBackward:function(a){if(this.viewerAdapter.searchViewModel.searchValue()!=a)this.viewerAdapter.searchViewModel.searched=false;this.viewerAdapter.searchViewModel.searchValue(a);this.viewerAdapter.searchViewModel.findPrevious()},clearSearchValue:function(){this.viewerAdapter.searchViewModel.clearValue()},destroy:function(){var b=this.groupdocsViewerWrapper.find(".doc_viewer_wrapper_page_flip .pages_container_flip");b.turn("is")&&b.turn("destroy");this.groupdocsViewerWrapper.remove();a.Widget.prototype.destroy.call(this)}});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(c,a,d,b){this._portalService.getPrintableHtml(c,a,function(a){d.apply(this,[a.data])},function(a){b.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})(jQuery);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy