summaryrefslogtreecommitdiffstats
path: root/web/react/utils/utils.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/utils/utils.jsx')
-rw-r--r--web/react/utils/utils.jsx53
1 files changed, 31 insertions, 22 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 7a512c901..14a5b2f40 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -290,7 +290,6 @@ function getYoutubeEmbed(link) {
$('.video-uploader.' + youtubeId).html(metadata.channelTitle);
$('.video-title.' + youtubeId).find('a').html(metadata.title);
$('.post-list-holder-by-time').scrollTop($('.post-list-holder-by-time')[0].scrollHeight);
- $('.post-list-holder-by-time').perfectScrollbar('update');
}
if (config.GoogleDeveloperKey) {
@@ -460,9 +459,21 @@ module.exports.textToJsx = function(text, options) {
var mentionRegex = /^(?:@)([a-z0-9_]+)$/gi; // looks loop invariant but a weird JS bug needs it to be redefined here
var explicitMention = mentionRegex.exec(trimWord);
- if ((trimWord.toLowerCase().indexOf(searchTerm) > -1 || word.toLowerCase().indexOf(searchTerm) > -1) && searchTerm != '') {
-
- highlightSearchClass = ' search-highlight';
+ if (searchTerm !== '') {
+ let searchWords = searchTerm.split(' ');
+ for (let idx in searchWords) {
+ let searchWord = searchWords[idx];
+ if (searchWord === word.toLowerCase() || searchWord === trimWord.toLowerCase()) {
+ highlightSearchClass = ' search-highlight';
+ break;
+ } else if (searchWord.charAt(searchWord.length - 1) === '*') {
+ let searchWordPrefix = searchWord.slice(0,-1);
+ if (trimWord.toLowerCase().indexOf(searchWordPrefix) > -1 || word.toLowerCase().indexOf(searchWordPrefix) > -1) {
+ highlightSearchClass = ' search-highlight';
+ break;
+ }
+ }
+ }
}
if (explicitMention &&
@@ -607,23 +618,6 @@ module.exports.splitFileLocation = function(fileLocation) {
return {ext: ext, name: filename, path: filePath};
};
-// Asynchronously gets the size of a file by requesting its headers. If successful, it calls the
-// provided callback with the file size in bytes as the argument.
-module.exports.getFileSize = function(url, callback) {
- var request = new XMLHttpRequest();
-
- request.open('HEAD', url, true);
- request.onreadystatechange = function onReadyStateChange() {
- if (request.readyState === 4 && request.status === 200) {
- if (callback) {
- callback(parseInt(request.getResponseHeader('content-length'), 10));
- }
- }
- };
-
- request.send();
-};
-
module.exports.toTitleCase = function(str) {
function doTitleCase(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
@@ -785,7 +779,7 @@ function switchChannel(channel, teammateName) {
AsyncClient.getChannels(true, true, true);
AsyncClient.getChannelExtraInfo(true);
- AsyncClient.getPosts(true, channel.id, Constants.POST_CHUNK_SIZE);
+ AsyncClient.getPosts(channel.id);
$('.inner__wrap').removeClass('move--right');
$('.sidebar--left').removeClass('move--right');
@@ -1007,6 +1001,21 @@ 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;
+};
+
// Used to get the id of the other user from a DM channel
module.exports.getUserIdFromChannelName = function(channel) {
var ids = channel.name.split('__');