Toggle the dots at the end of bib preview, based on size of payload.

This commit is contained in:
Shane Kilkelly 2016-05-20 09:17:25 +01:00
parent 0ea16f0bcc
commit 9a6876d237
2 changed files with 6 additions and 1 deletions

View file

@ -28,7 +28,7 @@ div.binary-file.full-size(
div.scroll-container
p
| {{ bibtexPreview.data }}
p
p(ng-show="bibtexPreview.shouldShowDots")
| ...
p.no-preview(

View file

@ -7,6 +7,7 @@ define [
$scope.bibtexPreview =
loading: false
shouldShowDots: false
error: false
data: null
@ -31,11 +32,15 @@ define [
$scope.loadBibtexFilePreview = () ->
url = "/project/#{project_id}/file/#{$scope.openFile.id}?range=0-#{TWO_MEGABYTES}"
$scope.bibtexPreview.loading = true
$scope.bibtexPreview.shouldShowDots = false
$scope.$apply()
$http.get(url)
.success (data) ->
$scope.bibtexPreview.loading = false
$scope.bibtexPreview.error = false
# show dots when payload is closs to cutoff
if data.length >= (TWO_MEGABYTES - 200)
$scope.bibtexPreview.shouldShowDots = true
try
# remove last partial line
data = data.replace(/\n.*$/, '')