Fixed issue with carriage returns being counted improperly in non-ie browsers and updated error messages to be appropriate to what is being typed (message vs. post vs. edit)

Этот коммит содержится в:
Reed Garmsen
2015-08-25 12:47:18 -07:00
родитель 5766bbfc65
Коммит 656a88efdd
4 изменённых файлов: 43 добавлений и 8 удалений

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

@@ -1004,6 +1004,34 @@ module.exports.isBrowserFirefox = function() {
return navigator && navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
};
// Checks if browser is IE10 or IE11
module.exports.isBrowserIE = function() {
if (window.navigator && window.navigator.userAgent) {
var ua = window.navigator.userAgent;
return ua.indexOf('Trident/7.0') > 0 || ua.indexOf('Trident/6.0') > 0;
}
return false;
};
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;
};
// Used to get the id of the other user from a DM channel
module.exports.getUserIdFromChannelName = function(channel) {
var ids = channel.name.split('__');