mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-27 01:38:21 +01:00
preview package
This commit is contained in:
parent
fb29ce4e43
commit
8589c2be9a
2
Makefile
2
Makefile
@ -22,7 +22,7 @@ coffees= src/core/core.coffee\
|
||||
|
||||
|
||||
|
||||
packages = CoreServices NotePad wTerm ActivityMonitor DummyApp Files MarkOn MarketPlace Blogger
|
||||
packages = CoreServices NotePad wTerm ActivityMonitor DummyApp Files MarkOn MarketPlace Blogger Preview
|
||||
|
||||
main: build_coffees build_tags build_themes schemes libs build_packages
|
||||
- cp src/index.html $(BUILDDIR)/
|
||||
|
11
src/packages/Preview/Makefile
Normal file
11
src/packages/Preview/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
coffee_files = main.coffee
|
||||
|
||||
jsfiles = pdf.js
|
||||
|
||||
cssfiles = main.css
|
||||
|
||||
copyfiles = pdf.worker.js scheme.html package.json
|
||||
|
||||
|
||||
PKG_NAME=Preview
|
||||
include ../pkg.mk
|
35
src/packages/Preview/main.coffee
Normal file
35
src/packages/Preview/main.coffee
Normal file
@ -0,0 +1,35 @@
|
||||
class Preview extends this.OS.GUI.BaseApplication
|
||||
constructor: (args) ->
|
||||
super "Preview", args
|
||||
|
||||
main: () ->
|
||||
me = @
|
||||
url = "https://os.localhost:9195/test.pdf"
|
||||
@view = @find "view"
|
||||
PDFJS.workerSrc = @_api.handler.get + "/#{@path()}/pdf.worker.js"
|
||||
#PDFJS.workerSrc = "packages/Preview/pdf.worker.js"
|
||||
#PDFJS.disableWorker = true
|
||||
console.log PDFJS.workerSrc
|
||||
PDFJS.getDocument(url)
|
||||
.then (pdf) ->
|
||||
fn = (p) ->
|
||||
return if p > pdf.numPages
|
||||
pdf.getPage(p).then (page) ->
|
||||
scale = 1.5
|
||||
viewport = page.getViewport scale
|
||||
div = ($ "<div/>").attr("id", "page-" + (page.pageIndex + 1))
|
||||
($ me.view).append div
|
||||
canvas = ($ "<canvas/>")[0]
|
||||
div.append canvas
|
||||
context = canvas.getContext '2d'
|
||||
canvas.height = viewport.height
|
||||
canvas.width = viewport.width
|
||||
renderContext =
|
||||
canvasContext: context
|
||||
viewport: viewport
|
||||
page.render renderContext
|
||||
fn(p+1)
|
||||
fn(1)
|
||||
|
||||
|
||||
this.OS.register "Preview", Preview
|
10
src/packages/Preview/main.css
Normal file
10
src/packages/Preview/main.css
Normal file
@ -0,0 +1,10 @@
|
||||
afx-app-window[data-id = "preview-win"] afx-hbox[data-id="container"] {
|
||||
display: block;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
afx-app-window[data-id = "preview-win"] afx-hbox[data-id="container"] canvas{
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
display: block;
|
||||
}
|
13
src/packages/Preview/package.json
Normal file
13
src/packages/Preview/package.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"app":"Preview",
|
||||
"name":"Preview",
|
||||
"description":"Media files viewer",
|
||||
"info":{
|
||||
"author": "Xuan Sang LE",
|
||||
"email": "xsang.le@gmail.com"
|
||||
},
|
||||
"version":"0.1a",
|
||||
"category":"Utils",
|
||||
"iconclass":"fa fa-eye",
|
||||
"mimes":["[^\/]*/.*pdf"]
|
||||
}
|
13922
src/packages/Preview/pdf.js
Normal file
13922
src/packages/Preview/pdf.js
Normal file
File diff suppressed because it is too large
Load Diff
41660
src/packages/Preview/pdf.worker.js
vendored
Normal file
41660
src/packages/Preview/pdf.worker.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5
src/packages/Preview/scheme.html
Normal file
5
src/packages/Preview/scheme.html
Normal file
@ -0,0 +1,5 @@
|
||||
<afx-app-window data-id = "preview-win" apptitle="Preview" width="600" height="400">
|
||||
<afx-hbox data-id = "container">
|
||||
<div data-id="view" ></div>
|
||||
</afx-hbox>
|
||||
</afx-app-window>
|
Loading…
Reference in New Issue
Block a user