diff --git a/Preview/Makefile b/Preview/Makefile deleted file mode 100644 index b029392..0000000 --- a/Preview/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -coffee_files = main.coffee - -jsfiles = pdf.js - -cssfiles = main.css - -copyfiles = pdf.worker.js scheme.html package.json bg.jpg - - -PKG_NAME=Preview -include ../pkg.mk \ No newline at end of file diff --git a/Preview/README.md b/Preview/README.md index 6fe6f86..9a106ca 100644 --- a/Preview/README.md +++ b/Preview/README.md @@ -1,3 +1,6 @@ # Preview -Image and PDF file viewer for AntOS \ No newline at end of file +Image and PDF file viewer for AntOS + +## Change logs +* v0.1.0-a: add depends on libpdfjs, user the default PDFJS viewer \ No newline at end of file diff --git a/Preview/build/debug/README.md b/Preview/build/debug/README.md deleted file mode 100644 index e8f6cc2..0000000 --- a/Preview/build/debug/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Preview - -Image and PDF file viewer for antOS \ No newline at end of file diff --git a/Preview/build/debug/bg.jpg b/Preview/build/debug/bg.jpg deleted file mode 100644 index fd9abc3..0000000 Binary files a/Preview/build/debug/bg.jpg and /dev/null differ diff --git a/Preview/build/debug/main.css b/Preview/build/debug/main.css deleted file mode 100644 index 555c20c..0000000 --- a/Preview/build/debug/main.css +++ /dev/null @@ -1,36 +0,0 @@ - - -afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] div[data-id = "view"] -{ - display: block; - overflow:auto; - background-image: url("bg.jpg"); - background-repeat: repeat; -} - -afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] afx-hbox[data-id = "statcontainer"] -{ - background-color: transparent; - border-bottom: 1px solid #cbcbcb; -} -afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] afx-hbox[data-id = "statcontainer"] button, -afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] afx-hbox[data-id = "statcontainer"] input -{ - height: 24px; -} -afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] canvas{ - margin-left: auto; - margin-right: auto; - display: block; -} - -afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] div.pdf-page { - margin-bottom: 5px; -} - -afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] div[data-id = "view"].image -{ - display: flex; - align-items: center; - justify-content: center; -} diff --git a/Preview/build/debug/main.js b/Preview/build/debug/main.js deleted file mode 100644 index 7c3a68f..0000000 --- a/Preview/build/debug/main.js +++ /dev/null @@ -1 +0,0 @@ -var e;(function(){var e;e=class extends this.OS.application.BaseApplication{constructor(e){super("Preview",e)}main(){return this.currfile=void 0,this.args&&this.args.length>0&&(this.currfile=this.args[0].path.asFileHandle()),this.view=this.find("view"),this.status=this.find("status"),this.zoom=this.find("zoom"),this.btnext=this.find("btnext"),this.btprev=this.find("btprev"),this.btreset=this.find("btreset"),this.txtpage=this.find("txtpage"),this.zoom.onvaluechange=e=>this.setViewScale(e.data),this.btreset.onbtclick=e=>(this.zoom.value=100,this.setViewScale(100)),this.btnext.onbtclick=e=>{var t;if(t=parseInt($(this.txtpage).val()),!isNaN(t))return $(this.txtpage).val(t+1),this.gotoPage()},this.btprev.onbtclick=e=>{var t;if(t=parseInt($(this.txtpage).val()),!isNaN(t))return $(this.txtpage).val(t-1),this.gotoPage()},$(this.txtpage).keyup(e=>{if(13===e.which&&this.pdf)return this.gotoPage()}),PDFJS.workerSrc=(this.path()+"/pdf.worker.js").asFileHandle().getlink(),this.pdf=void 0,this.img=void 0,this.bindKey("ALT-O",()=>this.actionFile(this.name+"-Open")),this.bindKey("CTRL-X",()=>this.actionFile(this.name+"-Close")),this.zoom.max=200,this.zoom.value=100,this.open(this.currfile)}open(e){if(e)return this.currfile!==e&&(this.currfile=e),e.onready().then(()=>(e.info.size=(e.info.size/1024).toFixed(2),this.renderFile())).catch(t=>this.error(__("File not found {0}",e.path),t))}gotoPage(){var e;if(this.pdf&&(e=parseInt($(this.txtpage).val()),!isNaN(e)&&!(e<=0||e>this.pdf.numPages)))return $(this.view).empty(),this.renderPDFPages(e,this.zoom.value/100,!1).catch(t=>this.error(__("Unable to render page {0}",e),t))}renderFile(){var e;if(e=this.currfile.info.mime)return this.pdf=void 0,this.img=void 0,$(this.view).empty(),this.zoom.value=100,e.match(/^[^\/]+\/.*pdf.*/g)?this.renderPDF():e.match(/image\/.*svg.*/g)?this.renderSVG():e.match(/image\/.*/g)?this.renderImage():this.notify(__("Mime type {0} is not supported",file.info.mime))}setStatus(e){return $(this.status).html(e)}setViewScale(e){var t,r,n,i,a,s;if(this.currfile){if(a=e/100,(i=this.currfile.info.mime).match(/^[^\/]+\/.*pdf.*/g)){if(!this.pdf)return;return $(this.view).empty(),this.load(this.renderPDFPages(1,a)).catch(e=>this.error(__("Unable to set view scale"),e))}if(i.match(/image\/.*svg.*/g))return $($(this.view).children()[0]).css("width",Math.round(e)+"%").css("height",Math.round(e)+"%");if(i.match(/image\/.*/g)){if(!this.img)return;return r=(t=$(this.view).children()[0]).getContext("2d"),s=this.img.width*a,n=this.img.height*a,t.height=n,t.width=s,r.clearRect(0,0,t.width,t.height),r.scale(a,a),r.drawImage(this.img,0,0)}}}renderPDFPages(e,t,r){return new Promise((n,i)=>{var a;return a=`${this.currfile.info.name} (${this.currfile.info.size} Kb)`,e>this.pdf.numPages?n():this.pdf.getPage(e).then(s=>{var o,l,c,u,h;return h=s.getViewport(t),c=$("
").attr("id","page-"+(s.pageIndex+1)).attr("scale",t).addClass("pdf-page"),$(this.view).append(c),o=$("