blob: 0b52d6a70a7a9381fa7248348e443452b8700c53 (
plain)
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
|
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
var ViewImageModal = require('./view_image.jsx');
var FileAttachment = require('./file_attachment.jsx');
var Constants = require('../utils/constants.jsx');
module.exports = React.createClass({
displayName: "FileAttachmentList",
propTypes: {
filenames: React.PropTypes.arrayOf(React.PropTypes.string).isRequired,
postId: React.PropTypes.string.isRequired,
channelId: React.PropTypes.string,
userId: React.PropTypes.string
},
getInitialState: function() {
return {startImgId: 0};
},
render: function() {
var filenames = this.props.filenames;
var postImageModalId = "view_image_modal_" + this.props.postId;
var postFiles = [];
for (var i = 0; i < filenames.length && i < Constants.MAX_DISPLAY_FILES; i++) {
postFiles.push(<FileAttachment key={i} filenames={filenames} index={i} imageModalId={postImageModalId} handleImageClick={this.handleImageClick} />);
}
return (
<div>
<div className="post-image__columns">
{postFiles}
</div>
<ViewImageModal
channelId={this.props.channelId}
userId={this.props.userId}
modalId={postImageModalId}
startId={this.state.startImgId}
imgCount={0}
filenames={filenames} />
</div>
);
},
handleImageClick: function(e) {
this.setState({startImgId: parseInt($(e.target.parentNode).attr('data-img-id'))});
}
});
|