1
0

pdf-reader.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. angular.module('pdfReader', ['pdf', 'angularUtils.directives.dirPagination'])
  2. .controller('PdfListController', function($scope, $http) {
  3. $scope.search = '';
  4. $scope.pdfName = undefined;
  5. $scope.pdfUrl = undefined;
  6. $scope.scroll = 0;
  7. $scope.loading = 'is-invisible';
  8. $scope.progress = 0;
  9. $scope.errorStatus = 'is-invisible none';
  10. $scope.error = undefined;
  11. $scope.getNavStyle = function(scroll) {
  12. if(scroll > 100) return 'pdf-controls fixed';
  13. else return 'pdf-controls';
  14. }
  15. $scope.onError = function(error) {
  16. console.log(error);
  17. $scope.$apply(function(){$scope.errorStatus = ''});
  18. $scope.$apply(function(){$scope.error=error.message;})
  19. }
  20. $scope.onLoad = function() {
  21. $scope.errorStatus = 'is-invisible none'
  22. $scope.loading = '';
  23. }
  24. $scope.onProgress = function (progressData) {
  25. var value = progressData.loaded / progressData.total * 100;
  26. if( (value - $scope.progress) >= 10 || value >= 100 ) {
  27. $scope.$apply(function(){$scope.progress = value;});
  28. }
  29. if( value >= 100 ) {
  30. $scope.loading = 'is-invisible';
  31. }
  32. };
  33. $scope.view = function(pdf) {
  34. $scope.pdfUrl = '/documents/' + pdf.link;
  35. $scope.pdfName = pdf.title;
  36. $scope.progress = 0;
  37. };
  38. $scope.pdfs = [];
  39. $http.get("/data/documents.json").then(function(response){
  40. $scope.pdfs = response.data;
  41. });
  42. });