diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-08-03 00:01:33 -0400 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-08-02 20:01:33 -0800 |
commit | 1de3bd3b4340cb51b2699a14a92d653db988a988 (patch) | |
tree | 604703f9acf4ea3b71f30bdfa532020e9fb233be /webapp/utils/utils.jsx | |
parent | 790dd91e7d93b5debaf86915c34f8a73a3ff95bd (diff) | |
download | chat-1de3bd3b4340cb51b2699a14a92d653db988a988.tar.gz chat-1de3bd3b4340cb51b2699a14a92d653db988a988.tar.bz2 chat-1de3bd3b4340cb51b2699a14a92d653db988a988.zip |
PLT-3640 Add mobile landing pages (#3674)
* PLT-3640 Moved all clientside user agent snooping into a single file
* PLT-3640 Added mobile landing pages on login to iOS and Android web apps
* PLT-3640 Moved landing page to appear before first login
* PLT-3640 Fixed detection of Chrome on Android
* PLT-3640 Disabled mobile landing pages when their respective URLs are set to blank
Diffstat (limited to 'webapp/utils/utils.jsx')
-rw-r--r-- | webapp/utils/utils.jsx | 51 |
1 files changed, 4 insertions, 47 deletions
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx index 4b3c8518c..187c7d7f4 100644 --- a/webapp/utils/utils.jsx +++ b/webapp/utils/utils.jsx @@ -12,6 +12,7 @@ import Constants from 'utils/constants.jsx'; var ActionTypes = Constants.ActionTypes; import * as AsyncClient from './async_client.jsx'; import Client from 'client/web_client.jsx'; +import * as UserAgent from 'utils/user_agent.jsx'; import {browserHistory} from 'react-router/es6'; import {FormattedMessage} from 'react-intl'; @@ -43,31 +44,6 @@ export function cmdOrCtrlPressed(e) { return (isMac() && e.metaKey) || (!isMac() && e.ctrlKey); } -export function isChrome() { - if (navigator.userAgent.indexOf('Chrome') > -1) { - return true; - } - return false; -} - -export function isSafari() { - if (navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1) { - return true; - } - return false; -} - -export function isIosChrome() { - // https://developer.chrome.com/multidevice/user-agent - return navigator.userAgent.indexOf('CriOS') !== -1; -} - -export function isMobileApp() { - const userAgent = navigator.userAgent; - - return userAgent.indexOf('iPhone') !== -1 && userAgent.indexOf('Safari') === -1 && userAgent.indexOf('CriOS') === -1; -} - export function isInRole(roles, inRole) { var parts = roles.split(' '); for (var i = 0; i < parts.length; i++) { @@ -146,7 +122,7 @@ export function notifyMe(title, body, channel, teamId) { var canDing = true; export function ding() { - if (!isBrowserFirefox() && canDing) { + if (!UserAgent.isFirefox() && canDing) { var audio = new Audio(bing); audio.play(); canDing = false; @@ -751,7 +727,7 @@ export function updateCodeTheme(userTheme) { xmlHTTP.open('GET', cssPath, true); xmlHTTP.onload = function onLoad() { $link.attr('href', cssPath); - if (isBrowserFirefox()) { + if (UserAgent.isFirefox()) { $link.one('load', () => { changeCss('code.hljs', 'visibility: visible'); }); @@ -1048,25 +1024,6 @@ export function generateId() { return id; } -export function isBrowserFirefox() { - return navigator && navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('firefox') > -1; -} - -// Checks if browser is IE10 or IE11 -export function isBrowserIE() { - 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; -} - -export function isBrowserEdge() { - return window.navigator && navigator.userAgent && navigator.userAgent.toLowerCase().indexOf('edge') > -1; -} - export function getDirectChannelName(id, otherId) { let handle; @@ -1244,7 +1201,7 @@ export function fillArray(value, length) { // Checks if a data transfer contains files not text, folders, etc.. // Slightly modified from http://stackoverflow.com/questions/6848043/how-do-i-detect-a-file-is-being-dragged-rather-than-a-draggable-element-on-my-pa export function isFileTransfer(files) { - if (isBrowserIE() || isBrowserEdge()) { + if (UserAgent.isInternetExplorer() || UserAgent.isEdge()) { return files.types != null && files.types.contains('Files'); } |