• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Brightspace / react-valence-ui-fileviewer / 7111280825

06 Dec 2023 07:04AM UTC coverage: 56.35% (-32.8%) from 89.198%
7111280825

push

github

web-flow
Merge pull request #114 from Brightspace/venkata/node-sass-update-2

adding npm i in release.yml

604 of 1444 branches covered (0.0%)

1624 of 2882 relevant lines covered (56.35%)

11.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.22
/src/plugins/pdf/alternate/alternateViewer.js
1
'use strict';
2

3
var React = require('react'),
38!
4
        ReactDOM = require( 'react-dom' ),
5
        pdfjs = require('./pdfjs-lib'),
2✔
6
        pdfjsWorkerSrcInit = require('./pdfjsWorkerSrcInit');
2✔
7

2✔
8
var AlternativeViewer = React.createClass({
2✔
9
        propTypes: {
10
                src: React.PropTypes.string.isRequired,
2✔
11
                resizeCallback: React.PropTypes.func,
12
                progressCallback: React.PropTypes.func,
13
                fileInfo: React.PropTypes.object
14
        },
15
        onPagesInit: function() {
16
                this.state.pdfViewer.currentScaleValue = 'page-width';
17
        },
18
        loadDocument: function() {
×
19
                var self = this;
20
                var withCredentials = true;
21
                if ( this.props.fileInfo && this.props.fileInfo.withCredentials === false ) {
18✔
22
                        withCredentials = false;
18✔
23
                }
18✔
24
                pdfjs.getDocument({
2✔
25
                        url: self.props.src,
26
                        withCredentials: withCredentials
18✔
27
                }).then(function(pdfDocument) {
28
                        self.state.pdfViewer.setDocument(pdfDocument);
29
                        self.state.pdfLinkService.setDocument(pdfDocument, null);
30
                        self.updateProgress(100);
18✔
31
                });
18✔
32
        },
18✔
33
        getInitialState: function() {
34
                return {
35
                        container: null,
36
                        pdfLinkService: null,
18✔
37
                        pdfViewer: null
38
                };
39
        },
40
        shouldComponentUpdate: function() {
41
                return false;
42
        },
43
        componentDidMount: function() {
18✔
44
                if (this.props.resizeCallback) {
45
                        this.props.resizeCallback('100%', false);
46
                }
18✔
47
                var container = ReactDOM.findDOMNode(this),
2✔
48
                        pdfLinkService = new pdfjs.PDFLinkService();
49

18✔
50
                this.updateProgress(10);
18✔
51

52
                var pdfViewer = new pdfjs.PDFViewer({
18✔
53
                        container: container,
54
                        linkService: pdfLinkService
18✔
55
                });
56
                pdfLinkService.setViewer(this.pdfViewer);
57

58
                container.addEventListener('pagesinit', this.onPagesInit);
18✔
59

60
                this.setState({
18✔
61
                        container: container,
62
                        pdfLinkService: pdfLinkService,
18✔
63
                        pdfViewer: pdfViewer
64
                });
65

66
                pdfjsWorkerSrcInit().then(this.loadDocument);
67
        },
68
        componentWillUnmount: function() {
18✔
69
                this.state.container.removeEventListener('pagesinit', this.onPagesInit);
70
        },
71
        updateProgress: function(progress) {
2✔
72
                if (this.props.progressCallback) {
73
                        this.props.progressCallback(progress, 'guess');
74
                }
38✔
75
        },
10✔
76
        render: function() {
77
                return (
78
                        <div className="vui-fileviewer-pdf-alternate">
79
                                <div className="pdfViewer"></div>
18✔
80
                        </div>
81
                );
82
        }
83
});
84

85
module.exports = AlternativeViewer;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc