0ef0d8851673805a2b3aabe9f9266612f62919ae
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Resources / Public / JavaScript / HTMLArea / UserAgent / UserAgent.js
1 /*
2 * This file is part of the TYPO3 CMS project.
3 *
4 * It is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, either version 2
6 * of the License, or any later version.
7 *
8 * For the full copyright and license information, please read the
9 * LICENSE.txt file that was distributed with this source code.
10 *
11 * The TYPO3 project - inspiring people to share!
12 */
13
14 /**
15 * Module: TYPO3/CMS/Rtehtmlarea/HTMLArea/UserAgent/UserAgent
16 * Identify the current user agent
17 * @exports TYPO3/CMS/Rtehtmlarea/HTMLArea/UserAgent/UserAgent
18 */
19 define([], function () {
20
21 var userAgent = navigator.userAgent.toLowerCase();
22 var documentMode = document.documentMode,
23 isOpera = /opera/i.test(userAgent),
24 isChrome = /\bchrome\b/i.test(userAgent),
25 isWebKit = /webkit/i.test(userAgent),
26 isIE = (!isOpera && /msie/i.test(userAgent)) || /trident/i.test(userAgent),
27 isIE6 = isIE && /msie 6/i.test(userAgent),
28 isIE7 = isIE && (/msie 7/i.test(userAgent) || documentMode == 7),
29 isIE8 = isIE && ((/msie 8/i.test(userAgent) && documentMode != 7) || documentMode == 8),
30 isIEBeforeIE9 = isIE6 || isIE7 || isIE8 || (isIE && typeof documentMode !== 'undefined' && documentMode < 9),
31 isGecko = !isWebKit && !isIE && /gecko/i.test(userAgent),
32 isiPhone = /iphone/i.test(userAgent),
33 isiPad = /ipad/i.test(userAgent);
34 return {
35 isOpera: isOpera,
36 isChrome: isChrome,
37 isWebKit: isWebKit,
38 isSafari: !isChrome && /safari/i.test(userAgent),
39 isIE: isIE,
40 isIE6: isIE6,
41 isIE7: isIE7,
42 isIE8: isIE8,
43 isIEBeforeIE9: isIEBeforeIE9,
44 isGecko: isGecko,
45 isGecko2: isGecko && /rv:1\.8/i.test(userAgent),
46 isGecko3: isGecko && /rv:1\.9/i.test(userAgent),
47 isWindows: /windows|win32/i.test(userAgent),
48 isMac: /macintosh|mac os x/i.test(userAgent),
49 isAir: /adobeair/i.test(userAgent),
50 isLinux: /linux/i.test(userAgent),
51 isAndroid: /android/i.test(userAgent),
52 isiPhone: isiPhone,
53 isiPad: isiPad,
54 isiOS: isiPhone || isiPad,
55 /**
56 * Check if the client agent is supported
57 *
58 * @return boolean true if the client is supported
59 */
60 isSupported: function () {
61 return isGecko || isWebKit || isOpera || (isIE && !isIEBeforeIE9);
62 }
63 };
64 });