2014-12-01 05:42:47 -05:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
"ide/pdfng/directives/pdfTextLayer"
|
|
|
|
"ide/pdfng/directives/pdfAnnotations"
|
|
|
|
"ide/pdfng/directives/pdfHighlights"
|
|
|
|
"ide/pdfng/directives/pdfRenderer"
|
|
|
|
"ide/pdfng/directives/pdfPage"
|
2014-12-01 09:35:12 -05:00
|
|
|
"libs/pdf" # needs pdfjs-1.0.712, override the path in require.js to get it
|
2014-12-01 05:42:47 -05:00
|
|
|
], (
|
|
|
|
App
|
|
|
|
pdfTextLayer
|
|
|
|
pdfAnnotations
|
|
|
|
pdfHighlights
|
|
|
|
pdfRenderer
|
|
|
|
pdfPage
|
|
|
|
pdf
|
|
|
|
) ->
|
|
|
|
|
|
|
|
# App = angular.module 'pdfViewerApp', ['pdfPage', 'PDFRenderer', 'pdfHighlights']
|
|
|
|
|
2014-12-05 07:12:01 -05:00
|
|
|
App.controller 'pdfViewerController', ['$scope', '$q', '$timeout', 'PDFRenderer', '$element', 'pdfHighlights', ($scope, $q, $timeout, PDFRenderer, $element, pdfHighlights) ->
|
2014-12-01 05:42:47 -05:00
|
|
|
@load = () ->
|
|
|
|
$scope.document = new PDFRenderer($scope.pdfSrc, {
|
|
|
|
scale: 1,
|
|
|
|
navigateFn: (ref) ->
|
|
|
|
# this function captures clicks on the annotation links
|
|
|
|
$scope.navigateTo = ref
|
|
|
|
$scope.$apply()
|
|
|
|
})
|
|
|
|
|
|
|
|
# we will have all the main information needed to start display
|
|
|
|
# after the following promise is resolved
|
|
|
|
$scope.loaded = $q.all({
|
|
|
|
numPages: $scope.document.getNumPages()
|
|
|
|
destinations: $scope.document.getDestinations()
|
|
|
|
# get size of first page as default @ scale 1
|
|
|
|
pdfViewport: $scope.document.getPdfViewport 1, 1
|
|
|
|
}).then (result) ->
|
|
|
|
$scope.pdfViewport = result.pdfViewport
|
|
|
|
$scope.pdfPageSize = [
|
|
|
|
result.pdfViewport.height,
|
|
|
|
result.pdfViewport.width
|
|
|
|
]
|
|
|
|
$scope.destinations = result.destinations
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'resolved q.all, page size is', result
|
2014-12-01 05:42:47 -05:00
|
|
|
$scope.numPages = result.numPages
|
|
|
|
|
|
|
|
@setScale = (scale, containerHeight, containerWidth) ->
|
|
|
|
$scope.loaded.then () ->
|
|
|
|
scale = {} if not scale?
|
|
|
|
if scale.scaleMode == 'scale_mode_fit_width'
|
|
|
|
# TODO make this dynamic
|
|
|
|
numScale = (containerWidth - 40) / ($scope.pdfPageSize[1])
|
|
|
|
else if scale.scaleMode == 'scale_mode_fit_height'
|
|
|
|
# TODO magic numbers for jquery ui layout
|
|
|
|
numScale = (containerHeight - 20) / ($scope.pdfPageSize[0])
|
|
|
|
else if scale.scaleMode == 'scale_mode_value'
|
|
|
|
numScale = scale.scale
|
|
|
|
else if scale.scaleMode == 'scale_mode_auto'
|
|
|
|
# TODO
|
|
|
|
else
|
|
|
|
scale.scaleMode = 'scale_mode_fit_width'
|
|
|
|
numScale = (containerWidth - 40) / ($scope.pdfPageSize[1])
|
|
|
|
# TODO
|
|
|
|
$scope.scale.scale = numScale
|
|
|
|
$scope.document.setScale(numScale)
|
|
|
|
$scope.defaultPageSize = [
|
|
|
|
numScale * $scope.pdfPageSize[0],
|
|
|
|
numScale * $scope.pdfPageSize[1]
|
2014-11-25 11:00:21 -05:00
|
|
|
]
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'in setScale result', $scope.scale.scale, $scope.defaultPageSize
|
2014-12-01 05:42:47 -05:00
|
|
|
|
|
|
|
@redraw = (position) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'in redraw'
|
|
|
|
# console.log 'reseting pages array for', $scope.numPages
|
2014-12-01 05:42:47 -05:00
|
|
|
$scope.pages = ({
|
|
|
|
pageNum: i + 1
|
|
|
|
} for i in [0 .. $scope.numPages-1])
|
|
|
|
if position? && position.page?
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'position is', position.page, position.offset
|
|
|
|
# console.log 'setting current page', position.page
|
2014-12-01 05:42:47 -05:00
|
|
|
pagenum = position.page
|
|
|
|
$scope.pages[pagenum].current = true
|
|
|
|
$scope.pages[pagenum].position = position
|
|
|
|
|
|
|
|
@zoomIn = () ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'zoom in'
|
2014-12-01 05:42:47 -05:00
|
|
|
newScale = $scope.scale.scale * 1.2
|
|
|
|
$scope.forceScale = { scaleMode: 'scale_mode_value', scale: newScale }
|
|
|
|
|
|
|
|
@zoomOut = () ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'zoom out'
|
2014-12-01 05:42:47 -05:00
|
|
|
newScale = $scope.scale.scale / 1.2
|
|
|
|
$scope.forceScale = { scaleMode: 'scale_mode_value', scale: newScale }
|
|
|
|
|
|
|
|
@fitWidth = () ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'fit width'
|
2014-12-01 05:42:47 -05:00
|
|
|
$scope.forceScale = { scaleMode: 'scale_mode_fit_width' }
|
|
|
|
|
|
|
|
@fitHeight = () ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'fit height'
|
2014-12-01 05:42:47 -05:00
|
|
|
$scope.forceScale = { scaleMode: 'scale_mode_fit_height' }
|
|
|
|
|
|
|
|
@checkPosition = () ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'check position'
|
2014-12-01 05:42:47 -05:00
|
|
|
$scope.forceCheck = ($scope.forceCheck || 0) + 1
|
|
|
|
|
|
|
|
@showRandomHighlights = () ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'show highlights'
|
2014-12-01 05:42:47 -05:00
|
|
|
$scope.highlights = [
|
|
|
|
{
|
|
|
|
page: 3
|
|
|
|
h: 100
|
|
|
|
v: 100
|
|
|
|
height: 30
|
|
|
|
width: 200
|
|
|
|
}
|
2014-11-25 11:00:21 -05:00
|
|
|
]
|
|
|
|
|
2014-12-01 05:42:47 -05:00
|
|
|
# we work with (pagenumber, % of height down page from top)
|
|
|
|
# pdfListView works with (pagenumber, vertical position up page from
|
|
|
|
# bottom measured in pts)
|
|
|
|
|
|
|
|
@getPdfPosition = () ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'in getPdfPosition'
|
2014-12-01 05:42:47 -05:00
|
|
|
topPageIdx = 0
|
|
|
|
topPage = $scope.pages[0]
|
|
|
|
# find first visible page
|
|
|
|
visible = $scope.pages.some (page, i) ->
|
|
|
|
[topPageIdx, topPage] = [i, page] if page.visible
|
|
|
|
if visible
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'found it', topPageIdx
|
2014-12-01 05:42:47 -05:00
|
|
|
else
|
|
|
|
console.log 'CANNOT FIND TOP PAGE'
|
|
|
|
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'top page is', topPage.pageNum, topPage.elemTop, topPage.elemBottom, topPage
|
2014-12-01 05:42:47 -05:00
|
|
|
top = topPage.elemTop
|
|
|
|
bottom = topPage.elemBottom
|
|
|
|
viewportTop = 0
|
|
|
|
viewportHeight = $element.height()
|
|
|
|
topVisible = (top >= viewportTop && top < viewportTop + viewportHeight)
|
|
|
|
someContentVisible = (top < viewportTop && bottom > viewportTop)
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'in PdfListView', top, topVisible, someContentVisible, viewportTop
|
2014-12-01 05:42:47 -05:00
|
|
|
if topVisible
|
|
|
|
canvasOffset = 0
|
|
|
|
else if someContentVisible
|
|
|
|
canvasOffset = viewportTop - top
|
|
|
|
else
|
|
|
|
canvasOffset = null
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'pdfListview position = ', canvasOffset
|
2014-12-01 05:42:47 -05:00
|
|
|
# instead of using promise, check if size is known and revert to
|
|
|
|
# default otherwise
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'looking up viewport', topPage.viewport, $scope.pdfViewport
|
2014-12-01 05:42:47 -05:00
|
|
|
if topPage.viewport
|
|
|
|
viewport = topPage.viewport
|
|
|
|
pdfOffset = viewport.convertToPdfPoint(0, canvasOffset);
|
|
|
|
else
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'WARNING: had to default to global page size'
|
2014-12-01 05:42:47 -05:00
|
|
|
viewport = $scope.pdfViewport
|
|
|
|
scaledOffset = canvasOffset / $scope.scale.scale
|
|
|
|
pdfOffset = viewport.convertToPdfPoint(0, scaledOffset);
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'converted to offset = ', pdfOffset
|
2014-12-01 05:42:47 -05:00
|
|
|
newPosition = {
|
|
|
|
"page": topPageIdx,
|
|
|
|
"offset" : { "top" : pdfOffset[1], "left": 0 }
|
|
|
|
}
|
|
|
|
return newPosition
|
|
|
|
|
|
|
|
@computeOffset = (page, position) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'computing offset for', page, position
|
2014-12-01 05:42:47 -05:00
|
|
|
element = page.element
|
2014-12-04 11:44:41 -05:00
|
|
|
#console.log 'element =', $(element), 'parent =', $(element).parent()
|
|
|
|
t1 = $(element).offset()?.top
|
|
|
|
t2 = $(element).parent().offset()?.top
|
|
|
|
if not (t1? and t2?)
|
|
|
|
return $q((resolve, reject) -> reject('elements destroyed'))
|
2014-12-01 05:42:47 -05:00
|
|
|
pageTop = $(element).offset().top - $(element).parent().offset().top
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log('top of page scroll is', pageTop, 'vs', page.elemTop)
|
|
|
|
# console.log('inner height is', $(element).innerHeight())
|
2014-12-01 05:42:47 -05:00
|
|
|
currentScroll = $(element).parent().scrollTop()
|
|
|
|
offset = position.offset
|
|
|
|
# convert offset to pixels
|
|
|
|
return $scope.document.getPdfViewport(page.pageNum).then (viewport) ->
|
|
|
|
page.viewport = viewport
|
|
|
|
pageOffset = viewport.convertToViewportPoint(offset.left, offset.top)
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'addition offset =', pageOffset
|
|
|
|
# console.log 'total', pageTop + pageOffset[1]
|
2014-12-01 05:42:47 -05:00
|
|
|
Math.round(pageTop + pageOffset[1] + currentScroll) ## 10 is margin
|
|
|
|
|
|
|
|
@setPdfPosition = (page, position) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'required pdf Position is', position
|
2014-12-01 05:42:47 -05:00
|
|
|
@computeOffset(page, position).then (offset) ->
|
|
|
|
$scope.pleaseScrollTo = offset
|
|
|
|
$scope.position = position
|
|
|
|
|
|
|
|
return this
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
App.directive 'pdfViewer', ['$q', '$timeout', ($q, $timeout) ->
|
|
|
|
{
|
|
|
|
controller: 'pdfViewerController'
|
|
|
|
controllerAs: 'ctrl'
|
|
|
|
scope: {
|
|
|
|
"pdfSrc": "="
|
|
|
|
"highlights": "="
|
|
|
|
"position": "="
|
|
|
|
"scale": "="
|
|
|
|
"pleaseJumpTo": "="
|
|
|
|
}
|
|
|
|
template: """
|
|
|
|
<div data-pdf-page class='pdf-page-container page-container' ng-repeat='page in pages'></div>
|
|
|
|
"""
|
|
|
|
link: (scope, element, attrs, ctrl) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'in pdfViewer element is', element
|
|
|
|
# console.log 'attrs', attrs
|
2014-12-01 05:42:47 -05:00
|
|
|
layoutReady = $q.defer()
|
|
|
|
layoutReady.notify 'waiting for layout'
|
2014-11-25 11:00:21 -05:00
|
|
|
layoutReady.promise.then () ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'layoutReady was resolved'
|
2014-12-01 05:42:47 -05:00
|
|
|
|
|
|
|
# TODO can we combine this with scope.parentSize, need to finalize boxes
|
|
|
|
updateContainer = () ->
|
|
|
|
scope.containerSize = [
|
|
|
|
element.innerWidth()
|
|
|
|
element.innerHeight()
|
|
|
|
element.offset().top
|
|
|
|
]
|
|
|
|
|
|
|
|
doRescale = (scale) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'doRescale', scale
|
2014-12-01 05:42:47 -05:00
|
|
|
origposition = angular.copy scope.position
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'origposition', origposition
|
2014-12-01 05:42:47 -05:00
|
|
|
layoutReady.promise.then () ->
|
|
|
|
[h, w] = [element.innerHeight(), element.width()]
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'in promise', h, w
|
2014-12-01 05:42:47 -05:00
|
|
|
ctrl.setScale(scale, h, w).then () ->
|
|
|
|
ctrl.redraw(origposition)
|
|
|
|
|
|
|
|
scope.$on 'layout-ready', () ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'GOT LAYOUT READY EVENT'
|
|
|
|
# console.log 'calling refresh'
|
2014-12-01 05:42:47 -05:00
|
|
|
updateContainer()
|
|
|
|
layoutReady.resolve 'layout is ready'
|
|
|
|
scope.parentSize = [
|
|
|
|
element.innerHeight(),
|
|
|
|
element.innerWidth()
|
|
|
|
]
|
|
|
|
#scope.$apply()
|
|
|
|
|
|
|
|
scope.$on 'layout:pdf:resize', () ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'GOT LAYOUT-RESIZE EVENT'
|
2014-12-01 05:42:47 -05:00
|
|
|
scope.parentSize = [
|
|
|
|
element.innerHeight(),
|
|
|
|
element.innerWidth()
|
|
|
|
]
|
|
|
|
#scope.$apply()
|
|
|
|
|
|
|
|
element.on 'scroll', () ->
|
2014-12-05 07:12:01 -05:00
|
|
|
#console.log 'scroll event', element.scrollTop(), 'adjusting?', scope.adjustingScroll
|
2014-12-01 05:42:47 -05:00
|
|
|
if scope.adjustingScroll
|
2014-12-04 11:49:24 -05:00
|
|
|
updateContainer()
|
|
|
|
scope.$apply()
|
2014-12-01 05:42:47 -05:00
|
|
|
scope.adjustingScroll = false
|
|
|
|
return
|
2014-12-04 11:49:24 -05:00
|
|
|
scope.scrolled = true
|
2014-12-05 07:12:01 -05:00
|
|
|
if scope.scrollHandlerTimeout
|
|
|
|
$timeout.cancel(scope.scrollHandlerTimeout)
|
|
|
|
scope.scrollHandlerTimeout = $timeout scrollHandler, 100
|
2014-12-04 11:49:24 -05:00
|
|
|
|
2014-12-05 07:12:01 -05:00
|
|
|
scrollHandler = () ->
|
|
|
|
scope.scrollHandlerTimeout = null
|
2014-12-04 11:49:24 -05:00
|
|
|
updateContainer()
|
|
|
|
scope.$apply()
|
2014-12-01 05:42:47 -05:00
|
|
|
scope.position = ctrl.getPdfPosition()
|
|
|
|
scope.$apply()
|
|
|
|
|
|
|
|
scope.$watch 'pdfSrc', (newVal, oldVal) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'loading pdf', newVal, oldVal
|
2014-12-01 05:42:47 -05:00
|
|
|
return unless newVal?
|
|
|
|
ctrl.load()
|
|
|
|
# trigger a redraw
|
|
|
|
scope.scale = angular.copy (scope.scale)
|
|
|
|
|
|
|
|
scope.$watch 'scale', (newVal, oldVal) ->
|
|
|
|
# no need to set scale when initialising, done in pdfSrc
|
|
|
|
return if newVal == oldVal
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'XXX calling Setscale in scale watch'
|
2014-12-01 05:42:47 -05:00
|
|
|
doRescale newVal
|
|
|
|
|
|
|
|
scope.$watch 'forceScale', (newVal, oldVal) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'got change in numscale watcher', newVal, oldVal
|
2014-12-01 05:42:47 -05:00
|
|
|
return unless newVal?
|
|
|
|
doRescale newVal
|
|
|
|
|
2014-12-02 06:42:57 -05:00
|
|
|
# scope.$watch 'position', (newVal, oldVal) ->
|
|
|
|
# console.log 'got change in position watcher', newVal, oldVal
|
2014-12-01 05:42:47 -05:00
|
|
|
|
|
|
|
scope.$watch 'forceCheck', (newVal, oldVal) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'forceCheck', newVal, oldVal
|
2014-12-01 05:42:47 -05:00
|
|
|
return unless newVal?
|
|
|
|
scope.adjustingScroll = true # temporarily disable scroll
|
|
|
|
doRescale scope.scale
|
|
|
|
|
|
|
|
scope.$watch('parentSize', (newVal, oldVal) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'XXX in parentSize watch', newVal, oldVal
|
2014-12-01 05:42:47 -05:00
|
|
|
if newVal == oldVal
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'returning because old and new are the same'
|
2014-12-01 05:42:47 -05:00
|
|
|
return
|
|
|
|
return unless oldVal?
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'XXX calling setScale in parentSize watcher'
|
2014-12-01 05:42:47 -05:00
|
|
|
doRescale scope.scale
|
|
|
|
, true)
|
|
|
|
|
2014-12-02 06:42:57 -05:00
|
|
|
# scope.$watch 'elementWidth', (newVal, oldVal) ->
|
|
|
|
# console.log '*** watch INTERVAL element width is', newVal, oldVal
|
2014-12-01 05:42:47 -05:00
|
|
|
|
|
|
|
scope.$watch 'pleaseScrollTo', (newVal, oldVal) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'got request to ScrollTo', newVal, 'oldVal', oldVal
|
2014-12-01 05:42:47 -05:00
|
|
|
return unless newVal?
|
|
|
|
scope.adjustingScroll = true # temporarily disable scroll
|
|
|
|
# handler while we reposition
|
|
|
|
$(element).scrollTop(newVal)
|
|
|
|
scope.pleaseScrollTo = undefined
|
|
|
|
|
|
|
|
scope.$watch 'pleaseJumpTo', (newPosition, oldPosition) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'in pleaseJumpTo', newPosition, oldPosition
|
2014-12-01 05:42:47 -05:00
|
|
|
return unless newPosition?
|
|
|
|
ctrl.setPdfPosition scope.pages[newPosition.page-1], newPosition
|
|
|
|
|
|
|
|
scope.$watch 'navigateTo', (newVal, oldVal) ->
|
|
|
|
return unless newVal?
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'got request to navigate to', newVal, 'oldVal', oldVal
|
2014-12-01 05:42:47 -05:00
|
|
|
scope.navigateTo = undefined
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'navigate to', newVal
|
|
|
|
# console.log 'look up page num'
|
2014-12-01 05:42:47 -05:00
|
|
|
scope.loaded.then () ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'destinations are', scope.destinations
|
2014-12-01 05:42:47 -05:00
|
|
|
r = scope.destinations[newVal.dest]
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'need to go to', r
|
|
|
|
# console.log 'page ref is', r[0]
|
2014-12-01 05:42:47 -05:00
|
|
|
scope.document.getPageIndex(r[0]).then (pidx) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'page num is', pidx
|
2014-12-01 05:42:47 -05:00
|
|
|
page = scope.pages[pidx]
|
|
|
|
scope.document.getPdfViewport(page.pageNum).then (viewport) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
#console.log 'got viewport', viewport
|
2014-12-01 05:42:47 -05:00
|
|
|
coords = viewport.convertToViewportPoint r[2], r[3]
|
2014-12-02 06:42:57 -05:00
|
|
|
#console.log 'viewport position', coords
|
|
|
|
#console.log 'r is', r, 'r[1]', r[1], 'r[1].name', r[1].name
|
2014-12-01 05:42:47 -05:00
|
|
|
if r[1].name == 'XYZ'
|
2014-12-02 06:42:57 -05:00
|
|
|
#console.log 'XYZ:', r[2], r[3]
|
2014-12-01 05:42:47 -05:00
|
|
|
newPosition = {page: pidx, offset: {top: r[3], left: r[2]}}
|
|
|
|
ctrl.setPdfPosition scope.pages[pidx], newPosition # XXX?
|
|
|
|
|
|
|
|
scope.$watch "highlights", (areas) ->
|
2014-12-02 06:42:57 -05:00
|
|
|
# console.log 'got HIGHLIGHTS in pdfViewer', areas
|
2014-12-01 05:42:47 -05:00
|
|
|
return if !areas?
|
2014-12-02 06:42:57 -05:00
|
|
|
#console.log 'areas are', areas
|
2014-12-01 05:42:47 -05:00
|
|
|
highlights = for area in areas or []
|
|
|
|
{
|
|
|
|
page: area.page - 1
|
|
|
|
highlight:
|
|
|
|
left: area.h
|
|
|
|
top: area.v
|
|
|
|
height: area.height
|
|
|
|
width: area.width
|
|
|
|
}
|
2014-12-02 06:42:57 -05:00
|
|
|
#console.log 'highlights', highlights
|
2014-12-01 05:42:47 -05:00
|
|
|
|
|
|
|
return if !highlights.length
|
|
|
|
|
|
|
|
first = highlights[0]
|
|
|
|
|
|
|
|
pageNum = scope.pages[first.page].pageNum
|
|
|
|
|
|
|
|
scope.document.getPdfViewport(pageNum).then (viewport) ->
|
|
|
|
position = {
|
|
|
|
page: first.page
|
|
|
|
offset:
|
|
|
|
left: first.highlight.left
|
|
|
|
top: viewport.viewBox[3] - first.highlight.top + first.highlight.height + 72
|
|
|
|
}
|
|
|
|
ctrl.setPdfPosition(scope.pages[first.page], position)
|
2014-11-25 11:00:21 -05:00
|
|
|
|
2014-12-01 05:42:47 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
]
|