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,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(c,b,a){this._viewModel.searchForward(c,b,a)},searchBackward:function(c,b,a){this._viewModel.searchBackward(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(y){var c,d=this.element,b=a.extend({hostUrl:this.applicationPath,docViewerId:"docViewer"+window.groupdocs.viewerId},y);window.groupdocs.viewerId++;if(y.enableViewerInit){var h,N=false;if(a.browser.msie){this.browserIsInternetExplorer=true;if(a.browser.version==8)N=true;h=".grpdx input[type='text']::-ms-clear {display: none;}";a("").appendTo("head")}var e=this,z="";if(e.browserIsInternetExplorer&&b.useHtmlBasedEngine)z=" ie";d.each(function(){a('
').appendTo(a(this))})}this.groupdocsViewerWrapper=c=d.find(".groupdocs_viewer_wrapper");var v=this.viewerHeader=c.find(".viewer_header"),i=this.viewerMainWrapper=c.find(".viewer_mainwrapper");if(!b.showHeader){v.hide();v.height(0);i.css("top","0")}if(!y.enableViewerInit)return;if(b.filePath=="")b.openThumbnails=false;if(b.useHtmlBasedEngine)b.showViewerStyleControl=false;var E="#"+b.docViewerId,k=a(E),L=c.find("[name='search_wrapper']"),o,w;if(b.width)o=b.width;else o=d.width();c.width(o);if(b.height)w=b.height;else w=d.height();c.height(w);var G=0;if(b.preloadPagesCount&&b.preloadPagesCount>0)G=b.preloadPagesCount;var s=c.find("[name='selection-content']");if(s.length==0)s=a("'").appendTo(c);var P=c.find("[name='jGDerror']");P.find(".modal_dialog_overlay").click(function(){P.hide()});var F=c.find(".navigation-bar"),u=c.find(".zoom_wrappper"),B=c.find(".doc_viewer_wrapper_page_flip"),A=c.find(".fileOpenDialogWrapper");if(!b.supportTextSelection){var S=E+" .ui-selectable-helper {display: none;visibility: hidden}";a("").appendTo("head")}var r;if(b.thumbnailsContainerWidth){var V=203,R=150,Q=187,I=this.getScrollbarWidth(),q=Math.round(b.thumbnailsContainerWidth),O=(V-I)/(q-I);r=Math.round(R/O);var T=Math.round(Q/O);h="div.thumbnailsContainer{width:"+q+"px}";h+="div.thumbnailsContainer ul li img{width:"+r+"px}";h+="div.thumbnailsContainer ul li{min-width:"+T+"px}";h+=".thumbs_btn_slide{left:"+(q+2)+"px}";a("").appendTo("head")}function j(){e._localizeElements()}k.bind("onHtmlCreated",j);F.bind("onHtmlCreated",j);u.bind("onHtmlCreated",j);B.bind("onHtmlCreated",j);A.bind("onHtmlCreated",j);var Y={createHtml:true,viewerElement:k,useCaseSensitiveSearch:b.useCaseSensitiveSearch,searchForSeparateWords:b.searchForSeparateWords,useHtmlBasedEngine:b.useHtmlBasedEngine},W={createHtml:true,thumbnailWidth:r,quality:100,useHtmlBasedEngine:b.useHtmlBasedEngine,useInnerThumbnails:b.useInnerThumbnails,supportPageReordering:b.supportPageReordering},p;if(b.showThumbnails)if(b.useInnerThumbnails)p=i;else p=i;else p=null;var Z={watermarkText:b.watermarkText,watermarkFontSize:b.watermarkFontSize,watermarkColor:b.watermarkColor,watermarkLeft:b.watermarkLeft,watermarkTop:b.watermarkTop,preventTouchEventsBubbling:b.preventTouchEventsBubbling},X="onMenuClicked",x=c.find(".viewTypeMenu"),l={dropDownMenuIsVisible:ko.observable(false),dropDownMenuClicked:false,openScrollView:function(){e.openScrollView()},openDoublePageFlipView:function(){e.openDoublePageFlipView()},showDropDownMenu:function(a){this.dropDownMenuIsVisible(a)},toggleDropDownMenu:function(b,a){this.dropDownMenuIsVisible(!this.dropDownMenuIsVisible());this.dropDownMenuClicked=true;x.trigger(X);a.stopPropagation()}},M=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:o,viewerHeight:i.height(),docViewerId:b.docViewerId,zoomToFitWidth:b.zoomToFitWidth,zoomToFitHeight:b.zoomToFitHeight,navigation:F,navigationOptions:{createHtml:true},thumbnails:p,thumbnailsOptions:W,zooming:u,zoomingOptions:{createHtml:true},search:b.showSearch?L:null,searchOptions:Y,preloadPagesCount:G,docSpacePageFlip:b.useHtmlBasedEngine||b.viewerStyle==this.viewModes.ScrollMode&&!b.showViewerStyleControl?null:B,viewerStyle:b.viewerStyle,usePageNumberInUrlHash:false,selectionContent:s,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:Z,viewTypeMenu:x,viewTypeViewModel:l});if(b.showFolderBrowser){var U={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};A.fileOpenDialog(U)}j();var n=d.find(".thumbs_btn");b.useInnerThumbnails&&n.hide();function J(){b.thumbsImageBase64Encoded!=null&&n.css("background-image","url(data:image/png;base64,"+b.thumbsImageBase64Encoded+")").css("background-position","0 0")}J();n.click(function(){a(this).toggleClass("thumbs_btn_slide","slow");d.find(".thumbnailsContainer").toggle("slide","slow",function(){if(a.browser.msie){n.css("background-image","");J()}});return false});c.find(".btnOpen").click(function(){e._showFileOpenDialog()});c.find(".file_browser_content").bind("fileSelected",function(b,a){e.fileDisplayName=M.docViewerViewModel.fileDisplayName="";M.docViewerViewModel.loadDocument(a.guid)});!b.showThumbnails&&d.find(".thumbs_btn").hide();if(b.openThumbnails){d.find(".thumbs_btn").addClass("thumbs_btn_slide");d.find(".thumbnailsContainer").css("display","block")}ko.applyBindings(l,x.get(0));a("html").click(function(){e.viewerAdapter.zoomViewModel&&e.viewerAdapter.zoomViewModel.showDropDownMenu(false);l.showDropDownMenu(false)});if(b.backgroundColor){d.find(".groupdocs_viewer_wrapper").css("background-color",b.backgroundColor);v.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");u.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"+f+"").appendTo("head");k.bind("onDocumentLoadComplete",function(b,a){e.documentLoadCompleteHandler(a,c,i)});k.bind("onDocumentLoaded",function(b,a){e.documentLoadedHandler(a,c,i)});if(b.viewerStyle==this.viewModes.BookMode)l.openDoublePageFlipView();else this.viewMode=this.viewModes.ScrollMode;var m=c.find("[name='jGDerror']"),C=m.find(".modal_dialog_content"),g=m.find(".modal_dialog_content_wrapper"),H=c.find(".viewer_mainwrapper"),ab=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");var e,f;if(c.substring(0,1)=="<"){C.html(c);var i=H.width(),h=H.height();if(i<100)e=i;else e=i-100;if(h<100)f=h;else f=h-100}else C.text(c);if(e!=undefined){g.css("margin-left",-e/2);g.width(e)}f!=undefined&&g.height(f);m.show();g.css("margin-left",-g.width()/2);g.css("margin-top",-g.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 ");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.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}})},_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(){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");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 g=window.open(this.pdfPrintUrl);else{var d="";if(this.fileDisplayName)d=this.fileDisplayName;var f=this;function e(){b[0].contentWindow.focus();b[0].contentWindow.print()}var c=this.useHtmlBasedEngine&&!this.useImageBasedPrinting,b=this.groupdocsViewerWrapper.find("iframe[name=groupdocsPrintFrame]");if(b.length==0){b=a("");b.appendTo(this.groupdocsViewerWrapper);this._model.getPrintableHtml(this.documentPath,c,d,function(d){var a=b[0].contentWindow.document;b.load(function(){f.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,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,c,b){if(this.viewerAdapter.searchViewModel.searchValue()!=a)this.viewerAdapter.searchViewModel.searched=false;this.viewerAdapter.searchViewModel.searchValue(a);this.viewerAdapter.searchViewModel.findNext(c,b)},searchBackward:function(a,c,b){if(this.viewerAdapter.searchViewModel.searchValue()!=a)this.viewerAdapter.searchViewModel.searched=false;this.viewerAdapter.searchViewModel.searchValue(a);this.viewerAdapter.searchViewModel.findPrevious(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(d,a,b,e,c){this._portalService.getPrintableHtml(d,a,b,function(a){e.apply(this,[a.data])},function(a){c.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.viewerId=1})(jQuery);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy