-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPDFModal.js
61 lines (55 loc) · 1.72 KB
/
PDFModal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React from 'react';
import {Button, Modal} from 'react-bootstrap';
/**
* Renders a Button that opens a pdf preview modal;
* @type {PDFModal}
*/
class PDFModal extends React.Component
{
constructor()
{
super();
this.state = {
showModal: false
}
}
close()
{
this.setState({showModal: false});
}
open()
{
this.setState({showModal: true});
}
render()
{
let viewer = process.env.PUBLIC_URL + "/pdfjs-hypothesis/web/viewer.html";
viewer = viewer + "?file=" + process.env.PUBLIC_URL + '/mockpdf.pdf';
return (
/* HTML starts here */
<div style={{display: "block"}}>
<Button
bsStyle="danger"
bsSize="xsmall"
onClick={this.open.bind(this)}
className="link2 pdf-link"
componentClass="a"
>
PDF <span id="whatsthis"></span>
</Button>
<Modal show={this.state.showModal} onHide={this.close.bind(this)} bsSize="large" aria-labelledby="contained-modal-title-lg" id="iframe_modal">
<Modal.Header style={{ paddingBottom: '0px', borderBottom: '0px' }}>
<button className="btn btn-default pull-right" onClick={this.close.bind(this)}>×</button>
</Modal.Header>
<Modal.Body style={{width: "100%"}}>
{/*<span id="spinner-iframe" className="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span>*/}
<iframe id="pdf_iframe" className="block" src={viewer} frameBorder="0" style={{width: "100%", height: window.innerHeight - 200}} title="PDF"></iframe>
{/*<div id="status"></div>*/}
</Modal.Body>
</Modal>
</div>
/* HTML ends here */
);
}
};
export default PDFModal;