This repository was archived by the owner on Sep 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 798
/
Copy pathpost.js
executable file
·118 lines (111 loc) · 5.58 KB
/
post.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
define(
[
'react',
'create-react-class',
'react-dom',
'./comment',
'./attachment',
'../../services/common-functions'
],
function (React, createReactClass, ReactDOM, Comment, Attachment, commonFunctions) {
var Post = createReactClass({
getDefaultProps: function() {
return {
displayName: 'John Doe',
description: 'My profile description',
displayPicture: '../dist/img/user7-128x128.jpg'
}
},
toggleCollapse: function(event) {
var box = ReactDOM.findDOMNode(this).children[0],
boxBody = ReactDOM.findDOMNode(this).children[0].children[1],
icon = event.currentTarget.children[0];
commonFunctions.toggleBoxCollapse(box, boxBody, icon);
},
removeBox: function(event){
var box = ReactDOM.findDOMNode(this).children[0];
commonFunctions.removeBox(box);
},
render: function() {
var postPicture = '', attachments = [], comments = [];
if(this.props.postPicture){
postPicture = <img className="img-responsive pad" src={this.props.postPicture} alt="Photo" />;
}
if(this.props.attachments){
attachments = this.props.attachments.map(function(attachmentDetails, iterator){
return (
<Attachment key={iterator}
title={attachmentDetails.title}
picture={attachmentDetails.picture}
link={attachmentDetails.link}
content={attachmentDetails.content} />
)
});
}
if(this.props.comments){
comments = this.props.comments.map(function(commentDetails, iterator){
return (
<Comment key={iterator}
displayName={commentDetails.displayName}
displayPicture={commentDetails.displayPicture}
date={commentDetails.date}
content={commentDetails.content} />
)
});
}
return (
<div className={"col-md-"+this.props.width}>
<div className="box box-widget">
<div className="box-header with-border">
<div className="user-block">
<img className="img-circle" src={this.props.displayPicture} alt="user image" />
<span className="username">
<a href="#">{this.props.displayName}</a>
</span>
<span className="description">{this.props.date}</span>
</div>
{/* /.user-block */}
<div className="box-tools">
<button className="btn btn-box-tool" data-toggle="tooltip" title="Mark as read">
<i className="fa fa-circle-o"></i>
</button>
<button className="btn btn-box-tool" data-widget="collapse" onClick={this.toggleCollapse}>
<i className="fa fa-minus"></i>
</button>
<button className="btn btn-box-tool" data-widget="remove" onClick={this.removeBox}>
<i className="fa fa-times"></i>
</button>
</div>
{/* /.box-tools */}
</div>
{/* /.box-header */}
<div className="box-body">
{postPicture}
<p>{this.props.content}</p>
{attachments}
{this.props.children}
</div>
{/* /.box-body */}
<div className="box-footer box-comments">
{comments}
{/* /.box-comment */}
</div>
{/* /.box-footer */}
<div className="box-footer">
<form action="#" method="post">
<img className="img-responsive img-circle img-sm" src="../dist/img/user4-128x128.jpg" alt="alt text" />
{/* .img-push is used to add margin to elements next to floating images */}
<div className="img-push">
<input type="text" className="form-control input-sm" placeholder="Press enter to post comment" />
</div>
</form>
</div>
{/* /.box-footer */}
</div>
</div>
)
}
});
return Post;
}
)