summaryrefslogtreecommitdiffstats
path: root/web/react/utils
diff options
context:
space:
mode:
authorReed Garmsen <rgarmsen2295@gmail.com>2015-08-25 12:47:18 -0700
committerReed Garmsen <rgarmsen2295@gmail.com>2015-08-25 13:16:44 -0700
commit656a88efdd2606ce8449097e740535f41aee9d64 (patch)
tree81ef9d460452ece278c6b7885919edcd4c21255d /web/react/utils
parent5766bbfc65e3f6663737da5d15359d68e3f991ff (diff)
downloadchat-656a88efdd2606ce8449097e740535f41aee9d64.tar.gz
chat-656a88efdd2606ce8449097e740535f41aee9d64.tar.bz2
chat-656a88efdd2606ce8449097e740535f41aee9d64.zip
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)
Diffstat (limited to 'web/react/utils')
-rw-r--r--web/react/utils/utils.jsx28
1 files changed, 28 insertions, 0 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index f718f7435..33c103c2e 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -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('__');