Conflicts:
	web/react/components/mention_list.jsx
Этот коммит содержится в:
Asaad Mahmood
2015-08-05 15:50:54 +05:00
родитель 2d5a181c7d ea51edf0c4
Коммит 022317823e
12 изменённых файлов: 358 добавлений и 294 удалений

Просмотреть файл

@@ -34,7 +34,7 @@ module.exports = React.createClass({
var channelType = ChannelStore.getCurrent() && ChannelStore.getCurrent().type === 'P' ? "private group" : "channel" var channelType = ChannelStore.getCurrent() && ChannelStore.getCurrent().type === 'P' ? "private group" : "channel"
return ( return (
<div className="modal fade" ref="modal" id="delete_channel" role="dialog" aria-hidden="true"> <div className="modal fade" ref="modal" id="delete_channel" role="dialog" tabIndex="-1" aria-hidden="true">
<div className="modal-dialog"> <div className="modal-dialog">
<div className="modal-content"> <div className="modal-content">
<div className="modal-header"> <div className="modal-header">

Просмотреть файл

@@ -82,7 +82,7 @@ module.exports = React.createClass({
var error = this.state.error ? <div className='form-group has-error'><label className='control-label'>{ this.state.error }</label></div> : null; var error = this.state.error ? <div className='form-group has-error'><label className='control-label'>{ this.state.error }</label></div> : null;
return ( return (
<div className="modal fade" id="delete_post" ref="modal" role="dialog" aria-hidden="true"> <div className="modal fade" id="delete_post" ref="modal" role="dialog" tabIndex="-1" aria-hidden="true">
<div className="modal-dialog modal-push-down"> <div className="modal-dialog modal-push-down">
<div className="modal-content"> <div className="modal-content">
<div className="modal-header"> <div className="modal-header">

Просмотреть файл

@@ -51,7 +51,7 @@ module.exports = React.createClass({
var server_error = this.state.server_error ? <div className='form-group has-error'><br/><label className='control-label'>{ this.state.server_error }</label></div> : null; var server_error = this.state.server_error ? <div className='form-group has-error'><br/><label className='control-label'>{ this.state.server_error }</label></div> : null;
return ( return (
<div className="modal fade" ref="modal" id="edit_channel" role="dialog" aria-hidden="true"> <div className="modal fade" ref="modal" id="edit_channel" role="dialog" tabIndex="-1" aria-hidden="true">
<div className="modal-dialog"> <div className="modal-dialog">
<div className="modal-content"> <div className="modal-content">
<div className="modal-header"> <div className="modal-header">

Просмотреть файл

@@ -71,7 +71,7 @@ module.exports = React.createClass({
var error = this.state.error ? <div className='form-group has-error'><label className='control-label'>{ this.state.error }</label></div> : null; var error = this.state.error ? <div className='form-group has-error'><label className='control-label'>{ this.state.error }</label></div> : null;
return ( return (
<div className="modal fade edit-modal" ref="modal" id="edit_post" role="dialog" aria-hidden="true"> <div className="modal fade edit-modal" ref="modal" id="edit_post" role="dialog" tabIndex="-1" aria-hidden="true">
<div className="modal-dialog modal-push-down"> <div className="modal-dialog modal-push-down">
<div className="modal-content"> <div className="modal-content">
<div className="modal-header"> <div className="modal-header">

Просмотреть файл

@@ -18,38 +18,49 @@ module.exports = React.createClass({
var button = e.relatedTarget; var button = e.relatedTarget;
self.setState({title: $(button).attr('data-title'), value: $(button).attr('data-value')}); self.setState({title: $(button).attr('data-title'), value: $(button).attr('data-value')});
}); });
$(this.refs.modal.getDOMNode()).on('hide.bs.modal', function() {
self.setState({copiedLink: false});
});
} }
}, },
getInitialState: function() { getInitialState: function() {
return { }; return {copiedLink: false};
},
handleClick: function() {
this.setState({copiedLink: true});
}, },
render: function() { render: function() {
var currentUser = UserStore.getCurrentUser() var currentUser = UserStore.getCurrentUser();
var copyLinkConfirm = null;
if (this.state.copiedLink) {
copyLinkConfirm = <p className='copy-link-confirm'>Link copied to clipboard.</p>;
}
if (currentUser != null) { if (currentUser != null) {
return ( return (
<div className="modal fade" ref="modal" id="get_link" tabIndex="-1" role="dialog" aria-hidden="true"> <div className='modal fade' ref='modal' id='get_link' tabIndex='-1' role='dialog' aria-hidden='true'>
<div className="modal-dialog"> <div className='modal-dialog'>
<div className="modal-content"> <div className='modal-content'>
<div className="modal-header"> <div className='modal-header'>
<button type="button" className="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type='button' className='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
<h4 className="modal-title" id="myModalLabel">{this.state.title} Link</h4> <h4 className='modal-title' id='myModalLabel'>{this.state.title} Link</h4>
</div> </div>
<div className="modal-body"> <div className='modal-body'>
<p>{"The link below is used for open " + strings.TeamPlural + " or if you allowed your " + strings.Team + " members to sign up using their " + strings.Company + " email addresses."} <p>{'The link below is used for open ' + strings.TeamPlural + ' or if you allowed your ' + strings.Team + ' members to sign up using their ' + strings.Company + ' email addresses.'}
</p> </p>
<textarea className="form-control no-resize" readOnly="true" value={this.state.value}></textarea> <textarea className='form-control no-resize' readOnly='true' value={this.state.value}></textarea>
</div> </div>
<div className="modal-footer"> <div className='modal-footer'>
<button type="button" className="btn btn-default" data-dismiss="modal">Close</button> <button type='button' className='btn btn-default' data-dismiss='modal'>Close</button>
<button data-copy-btn type="button" className="btn btn-primary pull-left" data-clipboard-text={this.state.value}>Copy Link</button> <button data-copy-btn='true' type='button' className='btn btn-primary pull-left' onClick={this.handleClick} data-clipboard-text={this.state.value}>Copy Link</button>
{copyLinkConfirm}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
); );
} else { }
return <div/>; return <div/>;
} }
}
}); });

Просмотреть файл

@@ -15,20 +15,19 @@ module.exports = React.createClass({
return; return;
} }
var not_empty = false; var notEmpty = false;
for (var i = 0; i < self.state.invite_ids.length; i++) { for (var i = 0; i < self.state.inviteIds.length; i++) {
var index = self.state.invite_ids[i]; var index = self.state.inviteIds[i];
if (self.refs["email"+index].getDOMNode().value.trim() !== '') { if (self.refs['email' + index].getDOMNode().value.trim() !== '') {
not_empty = true; notEmpty = true;
break; break;
} }
} }
if (not_empty) { if (notEmpty) {
$('#confirm_invite_modal').modal('show'); $('#confirm_invite_modal').modal('show');
e.preventDefault(); e.preventDefault();
} }
}); });
$('#invite_member').on('hidden.bs.modal', function() { $('#invite_member').on('hidden.bs.modal', function() {
@@ -36,52 +35,54 @@ module.exports = React.createClass({
}); });
}, },
handleSubmit: function(e) { handleSubmit: function(e) {
var invite_ids = this.state.invite_ids; var inviteIds = this.state.inviteIds;
var count = invite_ids.length; var count = inviteIds.length;
var invites = []; var invites = [];
var email_errors = this.state.email_errors; var emailErrors = this.state.emailErrors;
var first_name_errors = this.state.first_name_errors; var firstNameErrors = this.state.firstNameErrors;
var last_name_errors = this.state.last_name_errors; var lastNameErrors = this.state.lastNameErrors;
var valid = true; var valid = true;
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
var index = invite_ids[i]; var index = inviteIds[i];
var invite = {}; var invite = {};
invite.email = this.refs["email"+index].getDOMNode().value.trim(); invite.email = this.refs['email' + index].getDOMNode().value.trim();
if (!invite.email || !utils.isEmail(invite.email)) { if (!invite.email || !utils.isEmail(invite.email)) {
email_errors[index] = "Please enter a valid email address"; emailErrors[index] = 'Please enter a valid email address';
valid = false; valid = false;
} else { } else {
email_errors[index] = ""; emailErrors[index] = '';
} }
if (config.AllowInviteNames) { if (config.AllowInviteNames) {
invite.first_name = this.refs["first_name"+index].getDOMNode().value.trim(); invite.firstName = this.refs['first_name' + index].getDOMNode().value.trim();
if (!invite.first_name && config.RequireInviteNames) { if (!invite.firstName && config.RequireInviteNames) {
first_name_errors[index] = "This is a required field"; firstNameErrors[index] = 'This is a required field';
valid = false; valid = false;
} else { } else {
first_name_errors[index] = ""; firstNameErrors[index] = '';
} }
invite.last_name = this.refs["last_name"+index].getDOMNode().value.trim(); invite.lastName = this.refs['last_name' + index].getDOMNode().value.trim();
if (!invite.last_name && config.RequireInviteNames) { if (!invite.lastName && config.RequireInviteNames) {
last_name_errors[index] = "This is a required field"; lastNameErrors[index] = 'This is a required field';
valid = false; valid = false;
} else { } else {
last_name_errors[index] = ""; lastNameErrors[index] = '';
} }
} }
invites.push(invite); invites.push(invite);
} }
this.setState({ email_errors: email_errors, first_name_errors: first_name_errors, last_name_errors: last_name_errors }); this.setState({emailErrors: emailErrors, firstNameErrors: firstNameErrors, lastNameErrors: lastNameErrors});
if (!valid || invites.length === 0) return; if (!valid || invites.length === 0) {
return;
}
var data = {} var data = {};
data["invites"] = invites; data.invites = invites;
Client.inviteMembers(data, Client.inviteMembers(data,
function() { function() {
@@ -89,146 +90,177 @@ module.exports = React.createClass({
$(this.refs.modal.getDOMNode()).modal('hide'); $(this.refs.modal.getDOMNode()).modal('hide');
}.bind(this), }.bind(this),
function(err) { function(err) {
if (err.message === "This person is already on your team") { if (err.message === 'This person is already on your team') {
email_errors[err.detailed_error] = err.message; emailErrors[err.detailed_error] = err.message;
this.setState({ email_errors: email_errors }); this.setState({emailErrors: emailErrors});
} else {
this.setState({serverError: err.message});
} }
else
this.setState({ server_error: err.message});
}.bind(this) }.bind(this)
); );
}, },
componentDidUpdate: function() { componentDidUpdate: function() {
$(this.refs.modalBody.getDOMNode()).css('max-height', $(window).height() - 200); $(this.refs.modalBody.getDOMNode()).css('max-height', $(window).height() - 200);
$(this.refs.modalBody.getDOMNode()).css('overflow-y', 'scroll'); $(this.refs.modalBody.getDOMNode()).css('overflow-y', 'scroll');
}, },
addInviteFields: function() { addInviteFields: function() {
var count = this.state.id_count + 1; var count = this.state.idCount + 1;
var invite_ids = this.state.invite_ids; var inviteIds = this.state.inviteIds;
invite_ids.push(count); inviteIds.push(count);
this.setState({ invite_ids: invite_ids, id_count: count }); this.setState({inviteIds: inviteIds, idCount: count});
}, },
clearFields: function() { clearFields: function() {
var invite_ids = this.state.invite_ids; var inviteIds = this.state.inviteIds;
for (var i = 0; i < invite_ids.length; i++) { for (var i = 0; i < inviteIds.length; i++) {
var index = invite_ids[i]; var index = inviteIds[i];
this.refs["email"+index].getDOMNode().value = ""; this.refs['email' + index].getDOMNode().value = '';
if (config.AllowInviteNames) { if (config.AllowInviteNames) {
this.refs["first_name"+index].getDOMNode().value = ""; this.refs['first_name' + index].getDOMNode().value = '';
this.refs["last_name"+index].getDOMNode().value = ""; this.refs['last_name' + index].getDOMNode().value = '';
} }
} }
this.setState({ this.setState({
invite_ids: [0], inviteIds: [0],
id_count: 0, idCount: 0,
email_errors: {}, emailErrors: {},
first_name_errors: {}, firstNameErrors: {},
last_name_errors: {} lastNameErrors: {}
}); });
}, },
removeInviteFields: function(index) { removeInviteFields: function(index) {
var count = this.state.id_count; var count = this.state.idCount;
var invite_ids = this.state.invite_ids; var inviteIds = this.state.inviteIds;
var i = invite_ids.indexOf(index); var i = inviteIds.indexOf(index);
if (i > -1) invite_ids.splice(i, 1); if (i > -1) {
if (!invite_ids.length) invite_ids.push(++count); inviteIds.splice(i, 1);
this.setState({ invite_ids: invite_ids, id_count: count }); }
if (!inviteIds.length) {
inviteIds.push(++count);
}
this.setState({inviteIds: inviteIds, idCount: count});
}, },
getInitialState: function() { getInitialState: function() {
return { return {
invite_ids: [0], inviteIds: [0],
id_count: 0, idCount: 0,
email_errors: {}, emailErrors: {},
first_name_errors: {}, firstNameErrors: {},
last_name_errors: {} lastNameErrors: {}
}; };
}, },
render: function() { render: function() {
var currentUser = UserStore.getCurrentUser() var currentUser = UserStore.getCurrentUser();
if (currentUser != null) { if (currentUser != null) {
var invite_sections = []; var inviteSections = [];
var invite_ids = this.state.invite_ids; var inviteIds = this.state.inviteIds;
var self = this; for (var i = 0; i < inviteIds.length; i++) {
for (var i = 0; i < invite_ids.length; i++) { var index = inviteIds[i];
var index = invite_ids[i]; var emailError = null;
var email_error = this.state.email_errors[index] ? <label className='control-label'>{ this.state.email_errors[index] }</label> : null; if (this.state.emailErrors[index]) {
var first_name_error = this.state.first_name_errors[index] ? <label className='control-label'>{ this.state.first_name_errors[index] }</label> : null; emailError = <label className='control-label'>{this.state.emailErrors[index]}</label>;
var last_name_error = this.state.last_name_errors[index] ? <label className='control-label'>{ this.state.last_name_errors[index] }</label> : null; }
var firstNameError = null;
if (this.state.firstNameErrors[index]) {
firstNameError = <label className='control-label'>{this.state.firstNameErrors[index]}</label>;
}
var lastNameError = null;
if (this.state.lastNameErrors[index]) {
lastNameError = <label className='control-label'>{this.state.lastNameErrors[index]}</label>;
}
invite_sections[index] = ( var removeButton = null;
<div key={"key" + index}> if (index) {
<div> removeButton = (<div>
<button type="button" className="btn btn-link remove__member" onClick={this.removeInviteFields.bind(this, index)}><span className="fa fa-trash"></span></button> <button type='button' className='btn btn-link remove__member' onClick={this.removeInviteFields.bind(this, index)}><span className='fa fa-trash'></span></button>
</div> </div>);
<div className={ email_error ? "form-group invite has-error" : "form-group invite" }> }
<input onKeyUp={this.displayNameKeyUp} type="text" ref={"email"+index} className="form-control" placeholder="email@domain.com" maxLength="64" /> var emailClass = 'form-group invite';
{ email_error } if (emailError) {
</div> emailClass += ' has-error';
<div className="row--invite"> }
{ config.AllowInviteNames ?
<div className="col-sm-6"> var nameFields = null;
<div className={ first_name_error ? "form-group has-error" : "form-group" }> if (config.AllowInviteNames) {
<input type="text" className="form-control" ref={"first_name"+index} placeholder="First name" maxLength="64" /> var firstNameClass = 'form-group';
{ first_name_error } if (firstNameError) {
firstNameClass += ' has-error';
}
var lastNameClass = 'form-group';
if (lastNameError) {
lastNameClass += ' has-error';
}
nameFields = (<div className='row--invite'>
<div className='col-sm-6'>
<div className={firstNameClass}>
<input type='text' className='form-control' ref={'first_name' + index} placeholder='First name' maxLength='64' />
{firstNameError}
</div> </div>
</div> </div>
: "" } <div className='col-sm-6'>
{ config.AllowInviteNames ? <div className={lastNameClass}>
<div className="col-sm-6"> <input type='text' className='form-control' ref={'last_name' + index} placeholder='Last name' maxLength='64' />
<div className={ last_name_error ? "form-group has-error" : "form-group" }> {lastNameError}
<input type="text" className="form-control" ref={"last_name"+index} placeholder="Last name" maxLength="64" />
{ last_name_error }
</div> </div>
</div> </div>
: "" } </div>);
}
inviteSections[index] = (
<div key={'key' + index}>
{removeButton}
<div className={emailClass}>
<input onKeyUp={this.displayNameKeyUp} type='text' ref={'email' + index} className='form-control' placeholder='email@domain.com' maxLength='64' />
{emailError}
</div> </div>
{nameFields}
</div> </div>
); );
} }
var server_error = this.state.server_error ? <div className='form-group has-error'><label className='control-label'>{ this.state.server_error }</label></div> : null; var serverError = null;
if (this.state.serverError) {
serverError = <div className='form-group has-error'><label className='control-label'>{this.state.serverError}</label></div>;
}
return ( return (
<div> <div>
<div className="modal fade" ref="modal" id="invite_member" tabIndex="-1" role="dialog" aria-hidden="true"> <div className='modal fade' ref='modal' id='invite_member' tabIndex='-1' role='dialog' aria-hidden='true'>
<div className="modal-dialog"> <div className='modal-dialog'>
<div className="modal-content"> <div className='modal-content'>
<div className="modal-header"> <div className='modal-header'>
<button type="button" className="close" data-dismiss="modal" aria-label="Close" data-reactid=".5.0.0.0.0"><span aria-hidden="true" data-reactid=".5.0.0.0.0.0">×</span></button> <button type='button' className='close' data-dismiss='modal' aria-label='Close' data-reactid='.5.0.0.0.0'><span aria-hidden='true' data-reactid='.5.0.0.0.0.0'>×</span></button>
<h4 className="modal-title" id="myModalLabel">Invite New Member</h4> <h4 className='modal-title' id='myModalLabel'>Invite New Member</h4>
</div> </div>
<div ref="modalBody" className="modal-body"> <div ref='modalBody' className='modal-body'>
<form role="form"> <form role='form'>
{ invite_sections } {inviteSections}
</form> </form>
{ server_error } {serverError}
<button type="button" className="btn btn-default" onClick={this.addInviteFields}>Add another</button> <button type='button' className='btn btn-default' onClick={this.addInviteFields}>Add another</button>
<br/> <br/>
<br/> <br/>
<span>People invited automatically join Town Square channel.</span> <span>People invited automatically join Town Square channel.</span>
</div> </div>
<div className="modal-footer"> <div className='modal-footer'>
<button type="button" className="btn btn-default" data-dismiss="modal">Cancel</button> <button type='button' className='btn btn-default' data-dismiss='modal'>Cancel</button>
<button onClick={this.handleSubmit} type="button" className="btn btn-primary">Send Invitations</button> <button onClick={this.handleSubmit} type='button' className='btn btn-primary'>Send Invitations</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<ConfirmModal <ConfirmModal
id="confirm_invite_modal" id='confirm_invite_modal'
parent_id="invite_member" parent_id='invite_member'
title="Discard Invitations?" title='Discard Invitations?'
message="You have unsent invitations, are you sure you want to discard them?" message='You have unsent invitations, are you sure you want to discard them?'
confirm_button="Yes, Discard" confirm_button='Yes, Discard/'
/> />
</div> </div>
); );
} else { }
return <div/>; return <div/>;
} }
}
}); });

Просмотреть файл

@@ -15,63 +15,49 @@ var MAX_ITEMS_IN_LIST = 25;
var ITEM_HEIGHT = 36; var ITEM_HEIGHT = 36;
module.exports = React.createClass({ module.exports = React.createClass({
displayName: "MentionList", displayName: 'MentionList',
componentDidMount: function() { componentDidMount: function() {
PostStore.addMentionDataChangeListener(this._onChange); PostStore.addMentionDataChangeListener(this.onListenerChange);
var self = this; var self = this;
$('.post-right__scroll').scroll(function(){
if($('.mentions--top').length){
$('#reply_mention_tab .mentions--top').css({ bottom: $(window).height() - $('.post-right__scroll #reply_textbox').offset().top });
}
});
$('body').on('keydown.mentionlist', '#' + this.props.id, $('body').on('keydown.mentionlist', '#' + this.props.id,
function(e) { function(e) {
if (!self.isEmpty() && self.state.mentionText != '-1' && (e.which === 13 || e.which === 9)) { if (!self.isEmpty() && self.state.mentionText !== '-1' && (e.which === 13 || e.which === 9)) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
self.addCurrentMention(); self.addCurrentMention();
} } else if (!self.isEmpty() && self.state.mentionText !== '-1' && (e.which === 38 || e.which === 40)) {
else if (!self.isEmpty() && self.state.mentionText != '-1' && (e.which === 38 || e.which === 40)) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
var tempSelectedMention = -1;
if (e.which === 38) { if (e.which === 38) {
if (self.getSelection(self.state.selectedMention - 1)) if (self.getSelection(self.state.selectedMention - 1)) {
self.setState({selectedMention: self.state.selectedMention - 1, selectedUsername: self.refs['mention' + (self.state.selectedMention - 1)].props.username}); self.setState({selectedMention: self.state.selectedMention - 1, selectedUsername: self.refs['mention' + (self.state.selectedMention - 1)].props.username});
else {
while (self.getSelection(++tempSelectedMention))
; //Need to find the top of the list
self.setState({ selectedMention: tempSelectedMention - 1, selectedUsername: self.refs['mention' + (tempSelectedMention - 1)].props.username });
} }
} } else if (e.which === 40) {
else if (e.which === 40) { if (self.getSelection(self.state.selectedMention + 1)) {
if (self.getSelection(self.state.selectedMention + 1))
self.setState({selectedMention: self.state.selectedMention + 1, selectedUsername: self.refs['mention' + (self.state.selectedMention + 1)].props.username}); self.setState({selectedMention: self.state.selectedMention + 1, selectedUsername: self.refs['mention' + (self.state.selectedMention + 1)].props.username});
else }
self.setState({ selectedMention: 0, selectedUsername: self.refs.mention0.props.username });
} }
self.scrollToMention(e.which, tempSelectedMention); self.scrollToMention(e.which);
} }
} }
); );
$(document).click(function(e) { $(document).click(function(e) {
if (!($('#' + self.props.id).is(e.target) || $('#' + self.props.id).has(e.target).length || if (!($('#' + self.props.id).is(e.target) || $('#' + self.props.id).has(e.target).length ||
('mentionlist' in self.refs && $(self.refs['mentionlist'].getDOMNode()).has(e.target).length))) { ('mentionlist' in self.refs && $(self.refs.mentionlist.getDOMNode()).has(e.target).length))) {
self.setState({mentionText: "-1"}) self.setState({mentionText: '-1'});
} }
}); });
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
PostStore.removeMentionDataChangeListener(this._onChange); PostStore.removeMentionDataChangeListener(this.onListenerChange);
$('body').off('keydown.mentionlist', '#' + this.props.id); $('body').off('keydown.mentionlist', '#' + this.props.id);
}, },
componentDidUpdate: function() { componentDidUpdate: function() {
if (this.state.mentionText != "-1") { if (this.state.mentionText !== '-1') {
if (this.state.selectedUsername !== "" && (!this.getSelection(this.state.selectedMention) || this.state.selectedUsername !== this.refs['mention' + this.state.selectedMention].props.username)) { if (this.state.selectedUsername !== '' && (!this.getSelection(this.state.selectedMention) || this.state.selectedUsername !== this.refs['mention' + this.state.selectedMention].props.username)) {
var tempSelectedMention = -1; var tempSelectedMention = -1;
var foundMatch = false; var foundMatch = false;
while (tempSelectedMention < this.state.selectedMention && this.getSelection(++tempSelectedMention)) { while (tempSelectedMention < this.state.selectedMention && this.getSelection(++tempSelectedMention)) {
@@ -85,17 +71,22 @@ module.exports = React.createClass({
this.setState({selectedMention: 0, selectedUsername: this.refs.mention0.props.username}); this.setState({selectedMention: 0, selectedUsername: this.refs.mention0.props.username});
} }
} }
} } else if (this.state.selectedMention !== 0) {
else if (this.state.selectedMention !== 0) { this.setState({selectedMention: 0, selectedUsername: ''});
this.setState({ selectedMention: 0, selectedUsername: "" });
} }
}, },
_onChange: function(id, mentionText, excludeList) { onListenerChange: function(id, mentionText, excludeList) {
if (id !== this.props.id) return; if (id !== this.props.id) {
return;
}
var newState = this.state; var newState = this.state;
if (mentionText != null) newState.mentionText = mentionText; if (mentionText != null) {
if (excludeList != null) newState.excludeUsers = excludeList; newState.mentionText = mentionText;
}
if (excludeList != null) {
newState.excludeUsers = excludeList;
}
this.setState(newState); this.setState(newState);
}, },
@@ -112,38 +103,43 @@ module.exports = React.createClass({
this.setState({selectedMention: listId, selectedUsername: this.refs['mention' + listId].props.username}); this.setState({selectedMention: listId, selectedUsername: this.refs['mention' + listId].props.username});
}, },
getSelection: function(listId) { getSelection: function(listId) {
if (!this.refs['mention' + listId]) if (!this.refs['mention' + listId]) {
return false; return false;
else }
return true; return true;
}, },
addCurrentMention: function() { addCurrentMention: function() {
if (!this.getSelection(this.state.selectedMention)) if (!this.getSelection(this.state.selectedMention)) {
this.addFirstMention(); this.addFirstMention();
else } else {
this.refs['mention' + this.state.selectedMention].handleClick(); this.refs['mention' + this.state.selectedMention].handleClick();
}
}, },
addFirstMention: function() { addFirstMention: function() {
if (!this.refs.mention0) return; if (!this.refs.mention0) {
return;
}
this.refs.mention0.handleClick(); this.refs.mention0.handleClick();
}, },
isEmpty: function() { isEmpty: function() {
return (!this.refs.mention0); return (!this.refs.mention0);
}, },
scrollToMention: function(keyPressed, ifLoopUp) { scrollToMention: function(keyPressed) {
var direction = keyPressed === 38 ? "up" : "down"; var direction;
if (keyPressed === 38) {
direction = 'up';
} else {
direction = 'down';
}
var scrollAmount = 0; var scrollAmount = 0;
if (direction === "up" && ifLoopUp !== -1) if (direction === 'up') {
scrollAmount = $("#mentionsbox").height() * 100; //Makes sure that it scrolls all the way to the bottom scrollAmount = '-=' + ($('#' + this.refs['mention' + this.state.selectedMention].props.id + '_mentions').innerHeight() - 5);
else if (direction === "down" && this.state.selectedMention === 0) } else if (direction === 'down') {
scrollAmount = 0; scrollAmount = '+=' + ($('#' + this.refs['mention' + this.state.selectedMention].props.id + '_mentions').innerHeight() - 5);
else if (direction === "up") }
scrollAmount = "-=" + ($('#'+this.refs['mention' + this.state.selectedMention].props.id +"_mentions").innerHeight() - 5);
else if (direction === "down")
scrollAmount = "+=" + ($('#'+this.refs['mention' + this.state.selectedMention].props.id +"_mentions").innerHeight() - 5);
$("#mentionsbox").animate({ $('#mentionsbox').animate({
scrollTop: scrollAmount scrollTop: scrollAmount
}, 75); }, 75);
}, },
@@ -157,12 +153,14 @@ module.exports = React.createClass({
return false; return false;
}, },
getInitialState: function() { getInitialState: function() {
return { excludeUsers: [], mentionText: "-1", selectedMention: 0, selectedUsername: "" }; return {excludeUsers: [], mentionText: '-1', selectedMention: 0, selectedUsername: ''};
}, },
render: function() { render: function() {
var self = this; var self = this;
var mentionText = this.state.mentionText; var mentionText = this.state.mentionText;
if (mentionText === '-1') return null; if (mentionText === '-1') {
return null;
}
var profiles = UserStore.getActiveOnlyProfiles(); var profiles = UserStore.getActiveOnlyProfiles();
var users = []; var users = [];
@@ -171,32 +169,38 @@ module.exports = React.createClass({
} }
var all = {}; var all = {};
all.username = "all"; all.username = 'all';
all.nickname = ""; all.nickname = '';
all.secondary_text = "Notifies everyone in the team"; all.secondary_text = 'Notifies everyone in the team';
all.id = "allmention"; all.id = 'allmention';
users.push(all); users.push(all);
var channel = {}; var channel = {};
channel.username = "channel"; channel.username = 'channel';
channel.nickname = ""; channel.nickname = '';
channel.secondary_text = "Notifies everyone in the channel"; channel.secondary_text = 'Notifies everyone in the channel';
channel.id = "channelmention"; channel.id = 'channelmention';
users.push(channel); users.push(channel);
users.sort(function(a, b) { users.sort(function(a, b) {
if (a.username < b.username) return -1; if (a.username < b.username) {
if (a.username > b.username) return 1; return -1;
}
if (a.username > b.username) {
return 1;
}
return 0; return 0;
}); });
var mentions = {}; var mentions = {};
var index = 0; var index = 0;
for (var i = 0; i < users.length && index < MAX_ITEMS_IN_LIST; i++) { for (var i = 0; i < users.length && index < MAX_ITEMS_IN_LIST; i++) {
if (this.alreadyMentioned(users[i].username)) continue; if (this.alreadyMentioned(users[i].username)) {
continue;
if ((users[i].first_name && users[i].first_name.lastIndexOf(mentionText,0) === 0) }
|| (users[i].last_name && users[i].last_name.lastIndexOf(mentionText,0) === 0) || users[i].username.lastIndexOf(mentionText,0) === 0) { if ((users[i].first_name && users[i].first_name.lastIndexOf(mentionText, 0) === 0) ||
(users[i].last_name && users[i].last_name.lastIndexOf(mentionText, 0) === 0) ||
users[i].username.lastIndexOf(mentionText, 0) === 0) {
mentions[index] = ( mentions[index] = (
<Mention <Mention
ref={'mention' + index} ref={'mention' + index}
@@ -204,7 +208,7 @@ module.exports = React.createClass({
secondary_text={Utils.getFullName(users[i])} secondary_text={Utils.getFullName(users[i])}
id={users[i].id} id={users[i].id}
listId={index} listId={index}
isFocused={this.state.selectedMention === index ? "mentions-focus" : ""} isFocused={this.state.selectedMention === index ? 'mentions-focus' : ''}
handleMouseEnter={function(value) { return function() { self.handleMouseEnter(value); } }(index)} handleMouseEnter={function(value) { return function() { self.handleMouseEnter(value); } }(index)}
handleClick={this.handleClick} /> handleClick={this.handleClick} />
); );
@@ -214,20 +218,22 @@ module.exports = React.createClass({
var numMentions = Object.keys(mentions).length; var numMentions = Object.keys(mentions).length;
if (numMentions < 1) return null; if (numMentions < 1) {
return null;
}
var $mention_tab = $('#'+this.props.id); var $mentionTab = $('#' + this.props.id);
var maxHeight = Math.min(MAX_HEIGHT_LIST, $mention_tab.offset().top - 10); var maxHeight = Math.min(MAX_HEIGHT_LIST, $mentionTab.offset().top - 10);
var style = { var style = {
height: Math.min(maxHeight, (numMentions * ITEM_HEIGHT) + 4), height: Math.min(maxHeight, (numMentions * ITEM_HEIGHT) + 4),
width: $mention_tab.parent().width(), width: $mentionTab.parent().width(),
bottom: $(window).height() - $mention_tab.offset().top, bottom: $(window).height() - $mentionTab.offset().top,
left: $mention_tab.offset().left left: $mentionTab.offset().left
}; };
return ( return (
<div className="mentions--top" style={style}> <div className='mentions--top' style={style}>
<div ref="mentionlist" className="mentions-box" id="mentionsbox"> <div ref='mentionlist' className='mentions-box' id='mentionsbox'>
{mentions} {mentions}
</div> </div>
</div> </div>

Просмотреть файл

@@ -1,58 +1,53 @@
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. // Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information. // See License.txt for license information.
var utils = require('../utils/utils.jsx'); var utils = require('../utils/utils.jsx');
var client = require('../utils/client.jsx'); var client = require('../utils/client.jsx');
var asyncClient = require('../utils/async_client.jsx'); var asyncClient = require('../utils/async_client.jsx');
var UserStore = require('../stores/user_store.jsx'); var UserStore = require('../stores/user_store.jsx');
var TeamStore = require('../stores/team_store.jsx'); var TeamStore = require('../stores/team_store.jsx');
var Constants = require('../utils/constants.jsx');
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'NewChannelModal',
handleSubmit: function(e) { handleSubmit: function(e) {
e.preventDefault(); e.preventDefault();
var channel = {}; var channel = {};
var state = { server_error: "" }; var state = {serverError: ''};
channel.display_name = this.refs.display_name.getDOMNode().value.trim(); channel.display_name = this.refs.display_name.getDOMNode().value.trim();
if (!channel.display_name) { if (!channel.display_name) {
state.display_name_error = "This field is required"; state.displayNameError = 'This field is required';
state.inValid = true; state.inValid = true;
} } else if (channel.display_name.length > 22) {
else if (channel.display_name.length > 22) { state.displayNameError = 'This field must be less than 22 characters';
state.display_name_error = "This field must be less than 22 characters";
state.inValid = true; state.inValid = true;
} } else {
else { state.displayNameError = '';
state.display_name_error = "";
} }
channel.name = this.refs.channel_name.getDOMNode().value.trim(); channel.name = this.refs.channel_name.getDOMNode().value.trim();
if (!channel.name) { if (!channel.name) {
state.name_error = "This field is required"; state.nameError = 'This field is required';
state.inValid = true; state.inValid = true;
} } else if (channel.name.length > 22) {
else if(channel.name.length > 22){ state.nameError = 'This field must be less than 22 characters';
state.name_error = "This field must be less than 22 characters";
state.inValid = true; state.inValid = true;
} } else {
else { var cleanedName = utils.cleanUpUrlable(channel.name);
var cleaned_name = utils.cleanUpUrlable(channel.name); if (cleanedName !== channel.name) {
if (cleaned_name != channel.name) { state.nameError = "Must be lowercase alphanumeric characters, allowing '-' but not starting or ending with '-'";
state.name_error = "Must be lowercase alphanumeric characters, allowing '-' but not starting or ending with '-'";
state.inValid = true; state.inValid = true;
} } else {
else { state.nameError = '';
state.name_error = "";
} }
} }
this.setState(state); this.setState(state);
if (state.inValid) if (state.inValid) {
return; return;
}
var cu = UserStore.getCurrentUser(); var cu = UserStore.getCurrentUser();
channel.team_id = cu.team_id; channel.team_id = cu.team_id;
@@ -63,77 +58,90 @@ module.exports = React.createClass({
var self = this; var self = this;
client.createChannel(channel, client.createChannel(channel,
function() { function() {
this.refs.display_name.getDOMNode().value = ""; this.refs.display_name.getDOMNode().value = '';
this.refs.channel_name.getDOMNode().value = ""; this.refs.channel_name.getDOMNode().value = '';
this.refs.channel_desc.getDOMNode().value = ""; this.refs.channel_desc.getDOMNode().value = '';
$(self.refs.modal.getDOMNode()).modal('hide'); $(self.refs.modal.getDOMNode()).modal('hide');
window.location = TeamStore.getCurrentTeamUrl() + "/channels/" + channel.name; window.location = TeamStore.getCurrentTeamUrl() + '/channels/' + channel.name;
asyncClient.getChannels(true); asyncClient.getChannels(true);
}.bind(this), }.bind(this),
function(err) { function(err) {
state.server_error = err.message; state.serverError = err.message;
state.inValid = true; state.inValid = true;
this.setState(state); this.setState(state);
}.bind(this) }.bind(this)
); );
}, },
displayNameKeyUp: function(e) { displayNameKeyUp: function() {
var display_name = this.refs.display_name.getDOMNode().value.trim(); var displayName = this.refs.display_name.getDOMNode().value.trim();
var channel_name = utils.cleanUpUrlable(display_name); var channelName = utils.cleanUpUrlable(displayName);
this.refs.channel_name.getDOMNode().value = channel_name; this.refs.channel_name.getDOMNode().value = channelName;
}, },
componentDidMount: function() { componentDidMount: function() {
var self = this; var self = this;
$(this.refs.modal.getDOMNode()).on('show.bs.modal', function(e) { $(this.refs.modal.getDOMNode()).on('show.bs.modal', function(e) {
var button = e.relatedTarget; var button = e.relatedTarget;
self.setState({ channel_type: $(button).attr('data-channeltype') }); self.setState({channelType: $(button).attr('data-channeltype')});
}); });
}, },
getInitialState: function() { getInitialState: function() {
return { channel_type: "" }; return {channelType: ''};
}, },
render: function() { render: function() {
var displayNameError = null;
var nameError = null;
var serverError = null;
var displayNameClass = 'form-group';
var nameClass = 'form-group';
var display_name_error = this.state.display_name_error ? <label className='control-label'>{ this.state.display_name_error }</label> : null; if (this.state.displayNameError) {
var name_error = this.state.name_error ? <label className='control-label'>{ this.state.name_error }</label> : null; displayNameError = <label className='control-label'>{this.state.displayNameError}</label>;
var server_error = this.state.server_error ? <div className='form-group has-error'><label className='control-label'>{ this.state.server_error }</label></div> : null; displayNameClass += ' has-error';
}
if (this.state.nameError) {
nameError = <label className='control-label'>{this.state.nameError}</label>;
nameClass += ' has-error';
}
if (this.state.serverError) {
serverError = <div className='form-group has-error'><label className='control-label'>{this.state.serverError}</label></div>;
}
return ( return (
<div className="modal fade" id="new_channel" ref="modal" tabIndex="-1" role="dialog" aria-hidden="true"> <div className='modal fade' id='new_channel' ref='modal' tabIndex='-1' role='dialog' aria-hidden='true'>
<div className="modal-dialog"> <div className='modal-dialog'>
<div className="modal-content"> <div className='modal-content'>
<div className="modal-header"> <div className='modal-header'>
<button type="button" className="close" data-dismiss="modal"> <button type='button' className='close' data-dismiss='modal'>
<span aria-hidden="true">&times;</span> <span aria-hidden='true'>&times;</span>
<span className="sr-only">Close</span> <span className='sr-only'>Cancel</span>
</button> </button>
<h4 className="modal-title">New Channel</h4> <h4 className='modal-title'>New Channel</h4>
</div> </div>
<div className="modal-body"> <form role='form'>
<form role="form"> <div className='modal-body'>
<div className={ this.state.display_name_error ? "form-group has-error" : "form-group" }> <div className={displayNameClass}>
<label className='control-label'>Display Name</label> <label className='control-label'>Display Name</label>
<input onKeyUp={this.displayNameKeyUp} type="text" ref="display_name" className="form-control" placeholder="Enter display name" maxLength="64" /> <input onKeyUp={this.displayNameKeyUp} type='text' ref='display_name' className='form-control' placeholder='Enter display name' maxLength='64' />
{ display_name_error } {displayNameError}
</div> </div>
<div className={ this.state.name_error ? "form-group has-error" : "form-group" }> <div className={nameClass}>
<label className='control-label'>Handle</label> <label className='control-label'>Handle</label>
<input type="text" className="form-control" ref="channel_name" placeholder="lowercase alphanumeric's only" maxLength="64" /> <input type='text' className='form-control' ref='channel_name' placeholder="lowercase alphanumeric's only" maxLength='64' />
{ name_error } {nameError}
</div> </div>
<div className="form-group"> <div className='form-group'>
<label className='control-label'>Description</label> <label className='control-label'>Description</label>
<textarea className="form-control no-resize" ref="channel_desc" rows="3" placeholder="Description" maxLength="1024"></textarea> <textarea className='form-control no-resize' ref='channel_desc' rows='3' placeholder='Description' maxLength='1024'></textarea>
</div>
{serverError}
</div>
<div className='modal-footer'>
<button type='button' className='btn btn-default' data-dismiss='modal'>Cancel</button>
<button onClick={this.handleSubmit} type='submit' className='btn btn-primary'>Create New Channel</button>
</div> </div>
{ server_error }
</form> </form>
</div> </div>
<div className="modal-footer">
<button type="button" className="btn btn-default" data-dismiss="modal">Close</button>
<button onClick={this.handleSubmit} type="button" className="btn btn-primary">Create New Channel</button>
</div>
</div>
</div> </div>
</div> </div>
); );

Просмотреть файл

@@ -29,7 +29,7 @@ module.exports = React.createClass({
tabs.push({name: "feature", ui_name: "Features", icon: "glyphicon glyphicon-wrench"}); tabs.push({name: "feature", ui_name: "Features", icon: "glyphicon glyphicon-wrench"});
return ( return (
<div className="modal fade" ref="modal" id="team_settings" role="dialog" aria-hidden="true"> <div className="modal fade" ref="modal" id="team_settings" role="dialog" tabIndex="-1" aria-hidden="true">
<div className="modal-dialog settings-modal"> <div className="modal-dialog settings-modal">
<div className="modal-content"> <div className="modal-content">
<div className="modal-header"> <div className="modal-header">

Просмотреть файл

@@ -32,7 +32,7 @@ module.exports = React.createClass({
tabs.push({name: "appearance", ui_name: "Appearance", icon: "glyphicon glyphicon-wrench"}); tabs.push({name: "appearance", ui_name: "Appearance", icon: "glyphicon glyphicon-wrench"});
return ( return (
<div className="modal fade" ref="modal" id="user_settings1" role="dialog" aria-hidden="true"> <div className="modal fade" ref="modal" id="user_settings1" role="dialog" tabIndex="-1" aria-hidden="true">
<div className="modal-dialog settings-modal"> <div className="modal-dialog settings-modal">
<div className="modal-content"> <div className="modal-content">
<div className="modal-header"> <div className="modal-header">

Просмотреть файл

@@ -0,0 +1,6 @@
.copy-link-confirm {
position: fixed;
color: rgb(153, 230, 153);
top: 84%;
left: 130px;
}

Просмотреть файл

@@ -33,6 +33,7 @@
@import "partials/error"; @import "partials/error";
@import "partials/error-bar"; @import "partials/error-bar";
@import "partials/loading"; @import "partials/loading";
@import "partials/get-link";
// Responsive Css // Responsive Css
@import "partials/responsive"; @import "partials/responsive";