%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 18.224.44.186
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/js/ui/viewer/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/js/ui/viewer//ui.viewer.item.min.js
(function(){"use strict";BX.namespace("BX.UI.Viewer");BX.UI.Viewer.Item=function(t){t=t||{};this.controller=null;this.title=t.title;this.src=t.src;this.nakedActions=t.nakedActions;this.actions=t.actions;this.contentType=t.contentType;this.isLoaded=false;this.isLoading=false;this.sourceNode=null;this.transformationPromise=null;this.transformationTimeoutId=null;this.viewerGroupBy=null;this.isSeparate=false;this.transformationTimeout=t.transformationTimeout||22e3;this.layout={container:null};this.options=t;this.init()};BX.UI.Viewer.Item.prototype={setController:function(t){if(!(t instanceof BX.UI.Viewer.Controller)){throw new Error("BX.UI.Viewer.Item: 'controller' has to be instance of BX.UI.Viewer.Controller.")}this.controller=t},setPropertiesByNode:function(t){this.title=t.dataset.title||t.title||t.alt;this.src=t.dataset.src;this.viewerGroupBy=t.dataset.viewerGroupBy;this.isSeparate=t.dataset.viewerSeparateItem||false;this.nakedActions=t.dataset.actions?JSON.parse(t.dataset.actions):undefined},bindSourceNode:function(t){this.sourceNode=t},applyReloadOptions:function(t){},isSeparateItem:function(){return this.isSeparate},isPullConnected:function(){if(top.BX.PULL){if(BX.type.isFunction(top.BX.PULL.isConnected)){return top.BX.PULL.isConnected()}else{var t=top.BX.PULL.getDebugInfoArray();return t.connected}}return false},registerTransformationHandler:function(t){if(this.isLoaded){return}if(this.controller.getCurrentItem()===this){this.controller.setTextOnLoading(BX.message("JS_UI_VIEWER_ITEM_TRANSFORMATION_IN_PROGRESS"))}if(this.isPullConnected()){BX.addCustomEvent("onPullEvent-main",function(t,e){if(t==="transformationComplete"&&this.transformationPromise){this.loadData().then(function(){this.transformationPromise.fulfill(this)}.bind(this))}}.bind(this));console.log("BX.PULL.extendWatch");BX.PULL.extendWatch(t)}else{setTimeout(function(){BX.ajax.promise({url:BX.util.add_url_param(this.src,{ts:"bxviewer"}),method:"GET",dataType:"json",headers:[{name:"BX-Viewer-check-transformation",value:null}]}).then(function(t){if(!t.data||!t.data.transformation){this.registerTransformationHandler()}else{this.loadData().then(function(){this.transformationPromise.fulfill(this)}.bind(this))}}.bind(this))}.bind(this),5e3)}this.transformationTimeoutId=setTimeout(function(){if(!this.isLoaded){console.log("Throw transformationTimeout");if(this._loadPromise){this._loadPromise.reject({status:"timeout",message:BX.message("JS_UI_VIEWER_ITEM_TRANSFORMATION_ERROR_1").replace("#DOWNLOAD_LINK#",this.getSrc()),item:this});this.isLoading=false}}else{console.log("We don't have transformationTimeout :) ")}this.resetTransformationTimeout()}.bind(this),this.transformationTimeout)},resetTransformationTimeout:function(){if(this.transformationTimeoutId){clearTimeout(this.transformationTimeoutId)}this.transformationTimeoutId=null},init:function(){},load:function(){var t=new BX.Promise;if(this.isLoaded){t.fulfill(this);console.log("isLoaded");return t}if(this.isLoading){console.log("isLoading");return this._loadPromise}this.isLoading=true;this._loadPromise=this.loadData().then(function(t){this.isLoaded=true;this.isLoading=false;return t}.bind(this)).catch(function(t){console.log("catch");this.isLoaded=false;this.isLoading=false;if(!t.item){t.item=this}var e=new BX.Promise;e.reject(t);return e}.bind(this));console.log("will load");return this._loadPromise},listContainerModifiers:function(){return[]},getSrc:function(){return this.src},hashCode:function(t){var e=0,i=t.length,r=0;if(i>0){while(r<i)e=(e<<5)-e+t.charCodeAt(r++)|0}return e},generateUniqueId:function(){return this.hashCode(this.getSrc()||"")+Math.floor(Math.random()*Math.floor(1e4))},getTitle:function(){return this.title},getGroupBy:function(){return this.viewerGroupBy},getNakedActions:function(){if(typeof this.nakedActions==="undefined"){return[{type:"download"}]}return this.nakedActions},setActions:function(t){this.actions=t},getActions:function(){return this.actions},loadData:function(){var t=new BX.Promise;t.setAutoResolve(true);t.fulfill(this);return t},render:function(){},getContentWidth:function(){},handleKeyPress:function(t){},asFirstToShow:function(){},afterRender:function(){},beforeHide:function(){}};BX.UI.Viewer.Image=function(t){t=t||{};BX.UI.Viewer.Item.apply(this,arguments);this.resizedSrc=t.resizedSrc;this.width=t.width;this.height=t.height;this.imageNode=null;this.layout={container:null}};BX.UI.Viewer.Image.prototype={__proto__:BX.UI.Viewer.Item.prototype,constructor:BX.UI.Viewer.Item,setPropertiesByNode:function(t){BX.UI.Viewer.Item.prototype.setPropertiesByNode.apply(this,arguments);this.src=t.dataset.src||t.src;this.width=t.dataset.width;this.height=t.dataset.height},applyReloadOptions:function(t){this.controller.unsetCachedData(this.src)},tryToExportResizedSrcFromSourceNode:function(){var t=210;if(!(this.sourceNode instanceof Image)){return}if(!this.sourceNode.naturalWidth){return}var e=this.controller.getItemContainer().offsetHeight;var i=this.controller.getItemContainer().offsetWidth;var r=e/i;var n=e-t;var o=n/r;if(this.sourceNode.naturalWidth>=o||this.sourceNode.naturalHeight>=n){this.resizedSrc=this.sourceNode.src}},loadData:function(){var t=new BX.Promise;if(!this.shouldRunLocalResize()){this.resizedSrc=this.src}this.tryToExportResizedSrcFromSourceNode();if(this.controller.getCachedData(this.src)){this.resizedSrc=this.controller.getCachedData(this.src).resizedSrc}if(!this.resizedSrc){var e=new XMLHttpRequest;e.onreadystatechange=function(){if(e.readyState!==XMLHttpRequest.DONE){return}if((e.status===200||e.status===0)&&e.response){console.log("resize image");this.resizedSrc=URL.createObjectURL(e.response);this.imageNode=new Image;this.imageNode.src=this.resizedSrc;this.imageNode.onload=function(){t.fulfill(this)}.bind(this);this.controller.setCachedData(this.src,{resizedSrc:this.resizedSrc})}else{t.reject({item:this,type:"error"})}}.bind(this);e.open("GET",BX.util.add_url_param(this.src,{ts:"bxviewer"}),true);e.responseType="blob";e.setRequestHeader("BX-Viewer-image","x");e.send()}else{this.imageNode=new Image;this.imageNode.onload=function(){t.fulfill(this)}.bind(this);this.imageNode.onerror=this.imageNode.onabort=function(e){console.log("reject");t.reject({item:this,type:"error"})}.bind(this);this.imageNode.src=this.resizedSrc}return t},shouldRunLocalResize:function(){return!this.controller.isExternalLink(this.src)},render:function(){var t=document.createDocumentFragment();t.appendChild(this.imageNode);if(this.title){t.appendChild(BX.create("div",{props:{className:"viewer-inner-fullsize"},children:[BX.create("a",{props:{href:BX.util.add_url_param(this.src,{ts:"bxviewer",ibxShowImage:1}),target:"_blank"},text:BX.message("JS_UI_VIEWER_IMAGE_VIEW_FULL_SIZE"),events:{click:function(t){t.stopPropagation()}}})]}))}this.imageNode.alt=this.title;return t},getContentWidth:function(){var t=new BX.Promise;t.fulfill(this.imageNode.offsetWidth);return t},afterRender:function(){if(!window.chrome){setTimeout(function(){this.imageNode.removeAttribute("width");this.imageNode.removeAttribute("height")}.bind(this),200)}}};BX.UI.Viewer.PlainText=function(t){t=t||{};BX.UI.Viewer.Item.apply(this,arguments);this.content=t.content};BX.UI.Viewer.PlainText.prototype={__proto__:BX.UI.Viewer.Item.prototype,constructor:BX.UI.Viewer.Item,setPropertiesByNode:function(t){BX.UI.Viewer.Item.prototype.setPropertiesByNode.apply(this,arguments);this.content=t.dataset.content},render:function(){var t=BX.create("span",{text:this.content});t.style.fontSize="14px";t.style.color="white";return t}};BX.UI.Viewer.Audio=function(t){t=t||{};BX.UI.Viewer.Item.apply(this,arguments);this.playerId="audio-playerId_"+this.generateUniqueId();this.svgMask=null};BX.UI.Viewer.Audio.prototype={__proto__:BX.UI.Viewer.Item.prototype,constructor:BX.UI.Viewer.Item,setPropertiesByNode:function(t){BX.UI.Viewer.Item.prototype.setPropertiesByNode.apply(this,arguments);this.playerId="audio-playerId_"+this.generateUniqueId()},loadData:function(){var t=new BX.Promise;if(BX.getClass("BX.Fileman.Player")){t.fulfill(this);return t}var e=[{name:"BX-Viewer-src",value:this.src},{name:"BX-Viewer",value:"audio"}];var i=BX.ajax.promise({url:BX.util.add_url_param(this.src,{ts:"bxviewer"}),method:"GET",dataType:"json",headers:e});i.then(function(e){if(!e||!e.data){var i=e?e.errors:[];t.reject({item:this,type:"error",errors:i||[]});return}if(e.data.html&&!BX.getClass("BX.Fileman.Player")){var r=BX.processHTML(e.data.html);BX.load(r.STYLE,function(){BX.ajax.processScripts(r.SCRIPT,undefined,function(){t.fulfill(this)}.bind(this))}.bind(this))}else{t.fulfill(this)}}.bind(this));return t},render:function(){this.player=new BX.Fileman.Player(this.playerId,{width:320,height:52,isAudio:true,skin:"vjs-viewer-audio-player-skin",sources:[{src:this.src,type:"audio/mp3"}],onInit:function(t){t.vjsPlayer.controlBar.removeChild("timeDivider");t.vjsPlayer.controlBar.removeChild("durationDisplay");t.vjsPlayer.controlBar.removeChild("fullscreenToggle");t.vjsPlayer.hasStarted(true)}});return this.player.createElement()},afterRender:function(){this.player.init()}};BX.UI.Viewer.HightlightCode=function(t){t=t||{};BX.UI.Viewer.Item.apply(this,arguments);this.content=t.content};BX.UI.Viewer.HightlightCode.prototype={__proto__:BX.UI.Viewer.Item.prototype,constructor:BX.UI.Viewer.Item,setPropertiesByNode:function(t){BX.UI.Viewer.Item.prototype.setPropertiesByNode.apply(this,arguments);this.content=t.dataset.content},listContainerModifiers:function(){return["ui-viewer-document","ui-viewer-document-hlcode"]},loadData:function(){var t=new BX.Promise;BX.loadExt("ui.highlightjs").then(function(){if(!this.content){var e=new XMLHttpRequest;e.onreadystatechange=function(){if(e.readyState!==XMLHttpRequest.DONE){return}if((e.status===200||e.status===0)&&e.response){this.content=e.response;console.log("text content is loaded");this.controller.setCachedData(this.src,{content:this.content});t.fulfill(this)}else{t.reject({item:this,type:"error"})}}.bind(this);e.open("GET",BX.util.add_url_param(this.src,{ts:"bxviewerText"}),true);e.responseType="text";e.send()}else{t.fulfill(this)}}.bind(this));return t},render:function(){var t=this.getTitle().substring(this.getTitle().lastIndexOf(".")+1);return BX.create("div",{props:{tabIndex:2208},style:{width:"100%",height:"100%",paddingTop:"67px",background:"rgba(0, 0, 0, 0.1)",overflow:"auto"},children:[BX.create("pre",{children:[this.codeNode=BX.create("code",{props:{className:hljs.getLanguage(t)?t:"plaintext"},style:{fontSize:"14px",textAlign:"left"},text:this.content})]})]})},getContentWidth:function(){var t=new BX.Promise;t.fulfill(this.codeNode.offsetWidth);return t},afterRender:function(){hljs.highlightBlock(this.codeNode)}};BX.UI.Viewer.Unknown=function(t){BX.UI.Viewer.Item.apply(this,arguments)};BX.UI.Viewer.Unknown.prototype={__proto__:BX.UI.Viewer.Item.prototype,constructor:BX.UI.Viewer.Item,render:function(){return BX.create("div",{props:{className:"ui-viewer-unsupported"},children:[BX.create("div",{props:{className:"ui-viewer-unsupported-title"},text:BX.message("JS_UI_VIEWER_ITEM_UNKNOWN_TITLE")}),BX.create("div",{props:{className:"ui-viewer-unsupported-text"},text:BX.message("JS_UI_VIEWER_ITEM_UNKNOWN_NOTICE")}),BX.create("a",{props:{className:"ui-btn ui-btn-light-border ui-btn-themes",href:this.getSrc(),target:"_blank"},text:BX.message("JS_UI_VIEWER_ITEM_UNKNOWN_DOWNLOAD_ACTION")})]})}};BX.UI.Viewer.Video=function(t){t=t||{};BX.UI.Viewer.Item.apply(this,arguments);this.player=null;this.sources=[];this.transformationPromise=null;this.contentNode=null;this.forceTransformation=false;this.videoWidth=null;this.playerId="playerId_"+this.generateUniqueId()};BX.UI.Viewer.Video.prototype={__proto__:BX.UI.Viewer.Item.prototype,constructor:BX.UI.Viewer.Item,setPropertiesByNode:function(t){BX.UI.Viewer.Item.prototype.setPropertiesByNode.apply(this,arguments);this.playerId="playerId_"+this.generateUniqueId()},applyReloadOptions:function(t){if(t.forceTransformation){this.forceTransformation=true}},init:function(){BX.addCustomEvent("PlayerManager.Player:onAfterInit",this.handleAfterInit.bind(this));BX.addCustomEvent("PlayerManager.Player:onError",this.handleAfterInit.bind(this))},loadData:function(){var t=new BX.Promise;var e=[{name:"BX-Viewer-src",value:this.src}];e.push({name:this.forceTransformation?"BX-Viewer-force-transformation":"BX-Viewer",value:"video"});var i=BX.ajax.promise({url:BX.util.add_url_param(this.src,{ts:"bxviewer"}),method:"GET",dataType:"json",headers:e});i.then(function(e){if(!e||!e.data){var i=e?e.errors:[];t.reject({item:this,type:"error",errors:i||[]});return}if(e.data.hasOwnProperty("pullTag")){this.transformationPromise=t;this.registerTransformationHandler(e.data.pullTag)}else{if(e.data.data){this.width=e.data.data.width;this.height=e.data.data.height;this.sources=e.data.data.sources}if(e.data.html){var r=BX.processHTML(e.data.html);BX.load(r.STYLE,function(){BX.ajax.processScripts(r.SCRIPT,undefined,function(){t.fulfill(this)}.bind(this))}.bind(this))}}}.bind(this));return t},handleAfterInit:function(t){if(t.id!==this.playerId){return}if(this.handleVideoError(t)){return}if(t.vjsPlayer.videoWidth()>0&&t.vjsPlayer.videoHeight()>0){this.adjustVideo()}else{t.vjsPlayer.one("loadedmetadata",this.adjustVideo.bind(this))}},handleVideoError:function(t){if(t.id!==this.playerId){return false}if(t.vjsPlayer.error()&&!this.forceTransformation){console.log("forceTransformation");this.controller.reload(this,{forceTransformation:true});return true}return false},adjustVideo:function(){var t=this.contentNode;if(!t){return}if(!this.player.vjsPlayer){return}if(this.adjustVideoWidth(t,this.player.width,this.player.height,this.player.vjsPlayer.videoWidth(),this.player.vjsPlayer.videoHeight())){this.player.vjsPlayer.fluid(true)}BX.addClass(t,"player-loaded");BX.style(t,"opacity",1)},adjustVideoWidth:function(t,e,i,r,n){if(!BX.type.isDomNode(t)){return false}if(!e||!i||!r||!n){return false}if(n<i&&r<e){BX.width(t,r);this.videoWidth=r;if(!this.contentWidthPromise.state){this.contentWidthPromise.fulfill(this.videoWidth)}return true}else{i=window.innerHeight-250;var o=e/i;var s=r/n;var a=1;if(o>s){a=i/n}else{a=e/r}BX.width(t,Math.floor(r*a));this.videoWidth=Math.floor(r*a);if(!this.contentWidthPromise.state){this.contentWidthPromise.fulfill(this.videoWidth)}}return true},getContentWidth:function(){this.contentWidthPromise=new BX.Promise;if(this.videoWidth){this.contentWidthPromise.fulfill(this.videoWidth)}return this.contentWidthPromise},render:function(){this.player=new BX.Fileman.Player(this.playerId,{width:this.width,height:this.height,sources:this.sources});this.controller.showLoading();return this.contentNode=BX.create("div",{style:{opacity:0},children:[this.player.createElement()]})},asFirstToShow:function(){if(this.player){this.player.mute(true);this.player.play()}},afterRender:function(){this.player.init()}};BX.UI.Viewer.Document=function(t){BX.UI.Viewer.Item.apply(this,arguments);t=t||{};this.scale=t.scale||1.4;this.pdfDocument=null;this.pdfPages={};this.pdfRenderedPages={};this.lastRenderedPdfPage=null;this.contentNode=null;this.previewHtml=null;this.previewScriptToProcess=null;this.transformationPromise=null;this.disableAnnotationLayer=false};BX.UI.Viewer.Document.prototype={__proto__:BX.UI.Viewer.Item.prototype,constructor:BX.UI.Viewer.Item,setPropertiesByNode:function(t){BX.UI.Viewer.Item.prototype.setPropertiesByNode.apply(this,arguments);this.disableAnnotationLayer=t.dataset.hasOwnProperty("disableAnnotationLayer")},applyReloadOptions:function(t){this.controller.unsetCachedData(this.src)},listContainerModifiers:function(){return["ui-viewer-document"]},loadData:function(){var t=new BX.Promise;console.log("loadData pdf");var e=BX.ajax.promise({url:BX.util.add_url_param(this.src,{ts:"bxviewer"}),method:"GET",dataType:"json",headers:[{name:"BX-Viewer-src",value:this.src},{name:"BX-Viewer",value:"document"}]});e.then(function(e){if(!e||!e.data){t.reject({item:this,message:BX.message("JS_UI_VIEWER_ITEM_TRANSFORMATION_ERROR_1").replace("#DOWNLOAD_LINK#",this.getSrc()),type:"error"});return}if(e.data.hasOwnProperty("pullTag")){this.transformationPromise=t;this.registerTransformationHandler(e.data.pullTag)}if(e.data.data&&e.data.data.src){this._pdfSrc=e.data.data.src;BX.loadExt("ui."+this.getPdfJsExtensionName()).then(function(){if(!pdfjsLib.GlobalWorkerOptions.workerSrc){pdfjsLib.GlobalWorkerOptions.workerSrc="/bitrix/js/ui/"+this.getPdfJsExtensionName()+"/pdf.worker.js"}t.fulfill(this)}.bind(this),function(){})}}.bind(this));return t},getPdfJsExtensionName:function(){return BX.browser.IsIE11()?"pdfjs-ie11":"pdfjs"},render:function(){this.controller.showLoading();this.contentNode=BX.create("div",{props:{className:"ui-viewer-item-document-content",tabIndex:2208},style:{width:"100%",height:"100%",paddingTop:"67px",background:"rgba(0, 0, 0, 0.1)",overflow:"auto"}});BX.bind(this.contentNode,"scroll",BX.throttle(this.handleScrollDocument.bind(this),100));return this.contentNode},getNakedActions:function(){var t=BX.UI.Viewer.Item.prototype.getNakedActions.apply(this,arguments)||[];return this.insertPrintBeforeInfo(t)},insertPrintBeforeInfo:function(t){t=t||[];var e=null;for(var i=0;i<t.length;i++){if(t[i].type==="info"){e=i}}var r={type:"print",action:this.print.bind(this)};if(e===null){t.push(r)}else{t=BX.util.insertIntoArray(t,e,r)}return t},getFirstDocumentPageHeight:function(){var t=new BX.Promise;if(this._height){t.fulfill(this._height)}else{this.getDocumentPage(this.pdfDocument,1).then(function(e){var i=e.getViewport(this.scale);this._height=i.height;t.fulfill(this._height)}.bind(this))}return t},handleScrollDocument:function(t){var e=3;this.getFirstDocumentPageHeight().then(function(t){var i=this.contentNode.scrollHeight-this.contentNode.scrollTop-this.contentNode.clientHeight;if(i<t*e&&this.pdfDocument.numPages>this.lastRenderedPdfPage){for(var r=this.lastRenderedPdfPage+1;r<=Math.min(this.pdfDocument.numPages,this.lastRenderedPdfPage+e);r++){this.renderDocumentPage(this.pdfDocument,r)}}}.bind(this))},loadDocument:function(){var t=new BX.Promise;if(this.pdfDocument){t.fulfill(this.pdfDocument)}else{pdfjsLib.getDocument(this._pdfSrc).promise.then(function(e){this.pdfDocument=e;t.fulfill(this.pdfDocument)}.bind(this))}return t},getDocumentPage:function(t,e){var i=new BX.Promise;if(this.pdfPages[e]){i.fulfill(this.pdfPages[e])}else{t.getPage(e).then(function(t){this.pdfPages[e]=t;i.fulfill(this.pdfPages[e])}.bind(this))}return i},renderDocumentPage:function(t,e){if(this.pdfRenderedPages[e]){return}this.pdfRenderedPages[e]=true;this.getDocumentPage(t,e).then(function(t){var i=this.createCanvasPage();var r=t.getViewport(this.scale);i.height=r.height;i.width=r.width;var n=t.render({canvasContext:i.getContext("2d"),viewport:r});if(!this.disableAnnotationLayer){n.then(function(){return t.getAnnotations()}).then(function(e){var n=BX.pos(i);var o=BX.create("div",{props:{className:"ui-viewer-pdf-annotation-layer"}});BX.insertAfter(o,i);BX.adjust(o,{style:{margin:"-"+i.offsetHeight+"px auto 0 auto",height:i.height+"px",width:i.width+"px"}});pdfjsLib.AnnotationLayer.render({viewport:r.clone({dontFlip:true}),linkService:pdfjsLib.SimpleLinkService,div:o,annotations:e,page:t})})}n.then(function(){return t.getTextContent()}).then(function(t){var e=BX.pos(i);var n=BX.create("div",{props:{className:"ui-viewer-pdf-text-layer"}});BX.insertAfter(n,i);BX.adjust(n,{style:{margin:"-"+i.offsetHeight+"px auto 0 auto",height:i.height+"px",width:i.width+"px"}});pdfjsLib.renderTextLayer({textContent:t,container:n,viewport:r,textDivs:[]})});this.lastRenderedPdfPage=Math.max(e,this.lastRenderedPdfPage);if(e===1){this.firstWidthDocumentPage=i.width;this.contentWidthPromise.fulfill(this.firstWidthDocumentPage)}this.controller.hideLoading()}.bind(this))},createCanvasPage:function(){var t=document.createElement("canvas");t.className="ui-viewer-document-page-canvas";this.contentNode.appendChild(t);return t},getContentWidth:function(){this.contentWidthPromise=new BX.Promise;if(this.firstWidthDocumentPage){this.contentWidthPromise.fulfill(this.firstWidthDocumentPage)}return this.contentWidthPromise},afterRender:function(){this.loadDocument().then(function(t){for(var e=1;e<=Math.min(t.numPages,3);e++){if(e===1){this._handleControls=this.controller.handleVisibleControls.bind(this.controller);this.controller.enableReadingMode(true);var i=this.controller.actionPanel.getItemById("print");if(i){i.layout.container.classList.remove("ui-btn-disabled")}BX.throttle(BX.bind(window,"mousemove",this._handleControls),20)}this.renderDocumentPage(t,e)}}.bind(this))},beforeHide:function(){this.pdfRenderedPages=[];BX.unbind(window,"mousemove",this._handleControls);if(this.printer){this.hidePrintProgress();this.printer.destroy()}},updatePrintProgressMessage:function(t,e){var i=Math.round(t/e*100);this.controller.setTextOnLoading(BX.message("JS_UI_VIEWER_ITEM_PREPARING_TO_PRINT").replace("#PROGRESS#",i))},showPrintProgress:function(t,e){this.contentNode.style.opacity=.7;this.contentNode.style.filter="blur(2px)";this.controller.showLoading({zIndex:1});this.updatePrintProgressMessage(t,e)},hidePrintProgress:function(){this.contentNode.style.opacity=null;this.contentNode.style.filter=null;this.controller.hideLoading()},print:function(){if(!this.pdfDocument){console.warn("Where is pdf document to print?");return}this.showPrintProgress(0,this.pdfDocument.numPages);this.printer=new BX.UI.Viewer.Document.PrintService({pdf:this.pdfDocument});this.printer.init().then(function(){this.printer.prepare({onProgress:this.updatePrintProgressMessage.bind(this)}).then(function(){this.hidePrintProgress();this.printer.performPrint()}.bind(this))}.bind(this))},handleKeyPress:function(t){switch(t.code){case"PageDown":case"PageUp":case"ArrowDown":case"ArrowUp":BX.focus(this.contentNode);break}}};BX.UI.Viewer.Document.PrintService=function(t){t=t||{};this.pdf=t.pdf;this.iframe=null;this.documentOverview={}};BX.UI.Viewer.Document.PrintService.prototype={init:function(){var t=new BX.Promise;this.pdf.getPage(1).then(function(e){var i=e.getViewport(1);this.documentOverview={width:i.width,height:i.height,rotation:i.rotation};t.fulfill(this.documentOverview)}.bind(this));return t},prepare:function(t){t=t||{};var e=this.pdf.numPages;var i=-1;var r=new BX.Promise;var n=null;if(BX.type.isFunction(t.onProgress)){n=t.onProgress}this.frame=this.createIframe();var o=function(){if(++i>=e){console.log("finish",this.frame.contentWindow.document);setTimeout(function(){r.fulfill()}.bind(this),1e3);return}this.renderPage(i+1).then(function(){if(n){n(i+1,e)}o()})}.bind(this);o();return r},renderPage:function(t){return this.pdf.getPage(t).then(function(t){var e=document.createElement("canvas");var i=t.getViewport(1);var r=150;var n=r/72;e.width=Math.floor(i.width*n);e.height=Math.floor(i.height*n);var o=96/72;var s=Math.floor(i.width*o)+"px";var a=Math.floor(i.height*o)+"px";var h=e.getContext("2d");h.save();h.fillStyle="rgb(255, 255, 255)";h.fillRect(0,0,e.width,e.height);h.restore();var d={canvasContext:h,transform:[n,0,0,n,0,0],viewport:t.getViewport(1,i.rotation),intent:"print"};return t.render(d).promise.then(function(){return{scratchCanvas:e,width:s,height:a}})}).then(function(t){var e=document.createElement("img");e.style.width=t.width;e.style.height=t.height;var i=t.scratchCanvas;if("toBlob"in i&&!this.disableCreateObjectURL){i.toBlob(function(t){e.src=URL.createObjectURL(t)})}else{e.src=i.toDataURL()}var r=document.createElement("div");r.appendChild(e);this.frame.contentWindow.document.body.appendChild(r)}.bind(this))},destroy:function(){if(this.frame){BX.remove(this.frame)}},createIframe:function(){var t=document.createElement("iframe");t.src="about:blank";t.name="document-print-frame";t.style.display="none";document.body.appendChild(t);var e=t.contentWindow;var i=e.document;i.open();i.write("<html><head>");var r=this.getDocumentOverview();var n="<style>";n+="html, body { background: #fff !important; height: 100%; }";n+="@supports ((size:A4) and (size:1pt 1pt)) {"+"@page { size: "+r.width+"pt "+r.height+"pt;}"+"}";n+="</style>";i.write(n);i.write("</head><body>");i.write("</body></html>");i.close();return t},performPrint:function(){this.frame.contentWindow.focus();this.frame.contentWindow.print()},getDocumentOverview:function(){return this.documentOverview}}})();
//# sourceMappingURL=ui.viewer.item.map.js

Youez - 2016 - github.com/yon3zu
LinuXploit