// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
var PostStore = require('../stores/post_store.jsx');
var ChannelStore = require('../stores/channel_store.jsx');
var UserProfile = require( './user_profile.jsx' );
var UserStore = require('../stores/user_store.jsx');
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
var utils = require('../utils/utils.jsx');
var SearchBox =require('./search_bar.jsx');
var CreateComment = require( './create_comment.jsx' );
var Constants = require('../utils/constants.jsx');
var ViewImageModal = require('./view_image.jsx');
var ActionTypes = Constants.ActionTypes;
RhsHeaderPost = React.createClass({
handleClose: function(e) {
e.preventDefault();
AppDispatcher.handleServerAction({
type: ActionTypes.RECIEVED_SEARCH,
results: null
});
AppDispatcher.handleServerAction({
type: ActionTypes.RECIEVED_POST_SELECTED,
results: null
});
},
handleBack: function(e) {
e.preventDefault();
AppDispatcher.handleServerAction({
type: ActionTypes.RECIEVED_SEARCH_TERM,
term: this.props.fromSearch,
do_search: true,
is_mention_search: this.props.isMentionSearch
});
AppDispatcher.handleServerAction({
type: ActionTypes.RECIEVED_POST_SELECTED,
results: null
});
},
render: function() {
var back = this.props.fromSearch ? {"< "} : "";
return (
{back}Message Details
);
}
});
RootPost = React.createClass({
handleImageClick: function(e) {
this.setState({startImgId: parseInt($(e.target.parentNode).attr('data-img-id'))});
},
getInitialState: function() {
return { startImgId: 0 };
},
render: function() {
var postImageModalId = "rhs_view_image_modal_" + this.props.post.id;
var message = utils.textToJsx(this.props.post.message);
var filenames = this.props.post.filenames;
var isOwner = UserStore.getCurrentId() == this.props.post.user_id;
var type = "Post"
if (this.props.post.root_id.length > 0) {
type = "Comment"
}
if (filenames) {
var postFiles = [];
var images = [];
var re1 = new RegExp(' ', 'g');
var re2 = new RegExp('\\(', 'g');
var re3 = new RegExp('\\)', 'g');
for (var i = 0; i < filenames.length && i < Constants.MAX_DISPLAY_FILES; i++) {
var fileSplit = filenames[i].split('.');
if (fileSplit.length < 2) continue;
var ext = fileSplit[fileSplit.length-1];
fileSplit.splice(fileSplit.length-1,1)
var filePath = fileSplit.join('.');
var filename = filePath.split('/')[filePath.split('/').length-1];
var ftype = utils.getFileType(ext);
if (ftype === "image") {
var url = filePath.replace(re1, '%20').replace(re2, '%28').replace(re3, '%29');
postFiles.push(
);
}
});
CommentPost = React.createClass({
handleImageClick: function(e) {
this.setState({startImgId: parseInt($(e.target.parentNode).attr('data-img-id'))});
},
getInitialState: function() {
return { startImgId: 0 };
},
render: function() {
var commentClass = "post";
var postImageModalId = "rhs_comment_view_image_modal_" + this.props.post.id;
var filenames = this.props.post.filenames;
var isOwner = UserStore.getCurrentId() == this.props.post.user_id;
var type = "Post"
if (this.props.post.root_id.length > 0) {
type = "Comment"
}
if (filenames) {
var postFiles = [];
var images = [];
var re1 = new RegExp(' ', 'g');
var re2 = new RegExp('\\(', 'g');
var re3 = new RegExp('\\)', 'g');
for (var i = 0; i < filenames.length && i < Constants.MAX_DISPLAY_FILES; i++) {
var fileSplit = filenames[i].split('.');
if (fileSplit.length < 2) continue;
var ext = fileSplit[fileSplit.length-1];
fileSplit.splice(fileSplit.length-1,1)
var filePath = fileSplit.join('.');
var filename = filePath.split('/')[filePath.split('/').length-1];
var type = utils.getFileType(ext);
if (type === "image") {
var url = filePath.replace(re1, '%20').replace(re2, '%28').replace(re3, '%29');
postFiles.push(