Removed warning message when at the max character limit

This commit is contained in:
Reed Garmsen
2015-08-28 14:43:48 -07:00
parent bdf53884f5
commit 023b286930
4 changed files with 6 additions and 51 deletions

View File

@@ -104,17 +104,14 @@ module.exports = React.createClass({
this.lastTime = t;
}
},
handleUserInput: function(message) {
var messageText = utils.truncateText(message);
var newPostError = utils.checkMessageLengthError(messageText, this.state.postError, 'Comment length cannot exceed ' + Constants.MAX_POST_LEN + ' characters');
handleUserInput: function(messageText) {
var draft = PostStore.getCommentDraft(this.props.rootId);
draft.message = messageText;
PostStore.storeCommentDraft(this.props.rootId, draft);
$('.post-right__scroll').scrollTop($('.post-right__scroll')[0].scrollHeight);
$('.post-right__scroll').perfectScrollbar('update');
this.setState({messageText: messageText, postError: newPostError});
this.setState({messageText: messageText});
},
handleUploadStart: function(clientIds, channelId) {
var draft = PostStore.getCommentDraft(this.props.rootId);

View File

@@ -130,12 +130,9 @@ module.exports = React.createClass({
this.lastTime = t;
}
},
handleUserInput: function(message) {
var messageText = utils.truncateText(message);
var newPostError = utils.checkMessageLengthError(messageText, this.state.postError, 'Message length cannot exceed ' + Constants.MAX_POST_LEN + ' characters');
handleUserInput: function(messageText) {
this.resizePostHolder();
this.setState({messageText: messageText, postError: newPostError});
this.setState({messageText: messageText});
var draft = PostStore.getCurrentDraft();
draft['message'] = messageText;

View File

@@ -38,10 +38,8 @@ module.exports = React.createClass({
$("#edit_post").modal('hide');
$(this.state.refocusId).focus();
},
handleEditInput: function(editText) {
var editMessage = utils.truncateText(editText);
var newError = utils.checkMessageLengthError(editMessage, this.state.error, 'New message length cannot exceed ' + Constants.MAX_POST_LEN + ' characters');
this.setState({editText: editMessage, error: newError});
handleEditInput: function(editMessage) {
this.setState({editText: editMessage});
},
handleEditKeyPress: function(e) {
if (e.which == 13 && !e.shiftKey && !e.altKey) {

View File

@@ -1001,43 +1001,6 @@ module.exports.isBrowserEdge = function() {
return window.naviagtor && navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('edge') > -1;
};
// Gets text length consistent with maxlength property of textarea html tag
module.exports.getLengthOfTextInTextarea = function(messageText) {
// Need to get length with carriage returns counting as two characters to match textbox maxlength behavior
// unless ie10/ie11/edge which already do
var len = messageText.length;
if (!module.exports.isBrowserIE() && !module.exports.isBrowserEdge()) {
len = messageText.replace(/\r(?!\n)|\n(?!\r)/g, '--').length;
}
return len;
};
module.exports.checkMessageLengthError = function(message, currentError, newError) {
var updatedError = currentError;
var len = module.exports.getLengthOfTextInTextarea(message);
if (!currentError && len >= Constants.MAX_POST_LEN) {
updatedError = newError;
} else if (currentError === newError && len < Constants.MAX_POST_LEN) {
updatedError = '';
}
return updatedError;
};
// Necessary due to issues with textarea max length and pasting newlines
module.exports.truncateText = function(message) {
var lengthDifference = module.exports.getLengthOfTextInTextarea(message) - message.length;
if (lengthDifference > 0) {
return message.substring(0, Constants.MAX_POST_LEN - lengthDifference);
}
return message.substring(0, Constants.MAX_POST_LEN);
};
// Used to get the id of the other user from a DM channel
module.exports.getUserIdFromChannelName = function(channel) {
var ids = channel.name.split('__');