mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
enable on-demand viewing of pdfs for per-user compiles
This commit is contained in:
parent
e6dcce21fd
commit
3c31988e9a
2 changed files with 11 additions and 2 deletions
|
@ -12,7 +12,8 @@ define [
|
||||||
|
|
||||||
constructor: (@url, @options) ->
|
constructor: (@url, @options) ->
|
||||||
# PDFJS.disableFontFace = true # avoids repaints, uses worker more
|
# PDFJS.disableFontFace = true # avoids repaints, uses worker more
|
||||||
# PDFJS.disableAutoFetch = true # enable this to prevent loading whole file
|
if @options.disableAutoFetch
|
||||||
|
PDFJS.disableAutoFetch = true # prevent loading whole file
|
||||||
# PDFJS.disableStream
|
# PDFJS.disableStream
|
||||||
# PDFJS.disableRange
|
# PDFJS.disableRange
|
||||||
@scale = @options.scale || 1
|
@scale = @options.scale || 1
|
||||||
|
|
|
@ -27,13 +27,21 @@ define [
|
||||||
$scope.document.destroy() if $scope.document?
|
$scope.document.destroy() if $scope.document?
|
||||||
$scope.loadCount = if $scope.loadCount? then $scope.loadCount + 1 else 1
|
$scope.loadCount = if $scope.loadCount? then $scope.loadCount + 1 else 1
|
||||||
# TODO need a proper url manipulation library to add to query string
|
# TODO need a proper url manipulation library to add to query string
|
||||||
$scope.document = new PDFRenderer($scope.pdfSrc + '&pdfng=true' , {
|
url = $scope.pdfSrc
|
||||||
|
# add 'pdfng=true' to show that we are using the angular pdfjs viewer
|
||||||
|
queryStringExists = url.match(/\?/)
|
||||||
|
url = url + (if not queryStringExists then '?' else '&') + 'pdfng=true'
|
||||||
|
# for isolated compiles, load the pdf on-demand because nobody will overwrite it
|
||||||
|
onDemandLoading = window.location?.search?.match(/isolated=true/)?
|
||||||
|
$scope.document = new PDFRenderer(url, {
|
||||||
scale: 1,
|
scale: 1,
|
||||||
|
disableAutoFetch: if onDemandLoading then true else undefined
|
||||||
navigateFn: (ref) ->
|
navigateFn: (ref) ->
|
||||||
# this function captures clicks on the annotation links
|
# this function captures clicks on the annotation links
|
||||||
$scope.navigateTo = ref
|
$scope.navigateTo = ref
|
||||||
$scope.$apply()
|
$scope.$apply()
|
||||||
progressCallback: (progress) ->
|
progressCallback: (progress) ->
|
||||||
|
return if onDemandLoading is true # don't show progress for on-demand page loading
|
||||||
$scope.$emit 'progress', progress
|
$scope.$emit 'progress', progress
|
||||||
loadedCallback: () ->
|
loadedCallback: () ->
|
||||||
$scope.$emit 'loaded'
|
$scope.$emit 'loaded'
|
||||||
|
|
Loading…
Reference in a new issue