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.Annotation is an HTML5-based document & image annotator designed to be easily integrated into web, mobile and desktop apps. It allows developers to provide end users with the ability to annotate documents and images of more than 50 file formats, including PDF and Microsoft Office documents, Visio diagrams, CAD and raster images.

There is a newer version: 18.4
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)},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(C){var c,d=this.element,b=a.extend({hostUrl:this.applicationPath,docViewerId:"docViewer"+window.groupdocs.viewerId},C);window.groupdocs.viewerId++;if(C.enableViewerInit){var f,z=false;if(a.browser.msie){this.browserIsInternetExplorer=true;if(a.browser.version==8)z=true;f=".grpdx input[type='text']::-ms-clear {display: none;}";a("").appendTo("head")}var k="grpdx"+b.docViewerId,e=this,s="";if(e.browserIsInternetExplorer&&b.useHtmlBasedEngine){s=" ie";if(z)s+=" ie8"}var O="";if(!b.showHeader)O='style="display: none"';d.each(function(){a('
\t\t\t\t\t\t\t\t
'+(b.supportPageRotation?'
':"")+'
'+(b.showThumbnails?' ':"")+'
').appendTo(a(this))})}this.groupdocsViewerWrapper=c=d.find(".groupdocs_viewer_wrapper");var N=this.viewerHeader=c.find(".viewer_header"),i=this.viewerMainWrapper=c.find(".viewer_mainwrapper");if(!b.showHeader){N.height(0);i.css("top","0")}if(!C.enableViewerInit)return;if(b.filePath=="")b.openThumbnails=false;if(b.useHtmlBasedEngine)b.showViewerStyleControl=false;var G="#"+b.docViewerId,l=a(G),L=c.find("[name='search_wrapper']"),q,A;if(b.width)q=b.width;else q=d.width();c.width(q);if(b.height)A=b.height;else A=d.height();c.height(A);var o=null;if(!b.useHtmlBasedEngine){o=c.find("[name='selection-content']");if(o.length==0)o=a("'").appendTo(c)}var Q=c.find("[name='jGDerror']");Q.find(".modal_dialog_overlay").click(function(){Q.hide()});var w=c.find(".navigation-bar"),y=c.find(".zoom_wrappper"),D=c.find(".doc_viewer_wrapper_page_flip"),u=this.fileOpenDialogWrapper=c.find(".fileOpenDialogWrapper");if(!b.supportTextSelection){var T=G+" .ui-selectable-helper {display: none;visibility: hidden}";a("").appendTo("head")}var v;if(b.thumbnailsContainerWidth){var W=203,S=150,R=187,I=this.getScrollbarWidth(),t=Math.round(b.thumbnailsContainerWidth),P=(W-I)/(t-I);v=Math.round(S/P);var U=Math.round(R/P);f="div.thumbnailsContainer{width:"+t+"px}";f+="div.thumbnailsContainer ul li img{width:"+v+"px}";f+="div.thumbnailsContainer ul li{min-width:"+U+"px}";f+=".thumbs_btn_slide{left:"+(t+2)+"px}";a("").appendTo("head")}f="";if(b.searchHighlightColor)f+="."+k+" .search_highlight_html, ."+k+" .search-highlight {background-color:"+b.searchHighlightColor+"}";if(b.currentSearchHighlightColor)f+=".grpdx."+k+" .current_search_highlight {background-color:"+b.currentSearchHighlightColor+"}";if(b.showOnePageInRow)f+=".grpdx."+k+" .doc-page {display:block; margin-left:auto; margin-right:auto;}";if(b.useEmScaling)f+=".grpdx."+k+" .html_page_contents {transform-origin:initial}";f&&a("").appendTo("head");function j(){e._localizeElements()}l.bind("onHtmlCreated",j);w.bind("onHtmlCreated",j);y.bind("onHtmlCreated",j);D.bind("onHtmlCreated",j);u.bind("onHtmlCreated",j);var Z={createHtml:true,viewerElement:l,useCaseSensitiveSearch:b.useCaseSensitiveSearch,searchForSeparateWords:b.searchForSeparateWords,treatPhrasesInDoubleQuotesAsExactPhrases:b.treatPhrasesInDoubleQuotesAsExactPhrases,useHtmlBasedEngine:b.useHtmlBasedEngine,searchIsVisible:b.showSearch},X={createHtml:true,thumbnailWidth:v,quality:100,useHtmlBasedEngine:b.useHtmlBasedEngine&&b.useHtmlThumbnails,useInnerThumbnails:b.useInnerThumbnails,supportPageReordering:b.supportPageReordering,use_pdf:b.supportTextSelection?"true":"false",supportPageRotation:b.supportPageRotation},r;if(b.showThumbnails)if(b.useInnerThumbnails)r=i;else r=i;else r=null;var ab={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,onlyShrinkLargePages:b.onlyShrinkLargePages,loadAllPagesOnSearch:b.loadAllPagesOnSearch,useEmScaling:b.useEmScaling,convertWordDocumentsCompletely:b.convertWordDocumentsCompletely,ignoreDocumentAbsence:b.ignoreDocumentAbsence,usePdf:b.supportTextSelection,preloadPagesOnBrowserSide:b.preloadPagesOnBrowserSide,supportPageRotation:b.supportPageRotation},Y="onMenuClicked",B=c.find(".viewTypeMenu"),n={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;B.trigger(Y);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:w,navigationOptions:{createHtml:true},thumbnails:r,thumbnailsOptions:X,zooming:y,zoomingOptions:{createHtml:true},search:L,searchOptions:Z,preloadPagesCount:b.preloadPagesCount,docSpacePageFlip:b.useHtmlBasedEngine||b.viewerStyle==this.viewModes.ScrollMode&&!b.showViewerStyleControl?null:D,viewerStyle:b.viewerStyle,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:ab,viewTypeMenu:B,viewTypeViewModel:n});if(b.showFolderBrowser){var V={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};u.fileOpenDialog(V);u.find(".popclose").click(function(){e._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(){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=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(n,B.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);N.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");y.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){e.documentLoadCompleteHandler(a,c,i)});l.bind("onDocumentLoaded",function(b,a){e.documentLoadedHandler(a,c,i)});l.bind("isDocumentSinglePaged.groupdocs",function(b,a){e.documentSinglePagedHandler(a,w)});if(b.viewerStyle==this.viewModes.BookMode)n.openDoublePageFlipView();else this.viewMode=this.viewModes.ScrollMode;var m=c.find("[name='jGDerror']"),E=m.find(".modal_dialog_content"),h=m.find(".modal_dialog_content_wrapper");m.removeClass("jerrorwrapper");var H=c.find(".viewer_mainwrapper"),bb=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)=="<"){E.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 E.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)}};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 .NET ");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}})},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(){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('




© 2015 - 2024 Weber Informatics LLC | Privacy Policy