4 * Copyright, Moxiecode Systems AB
5 * Released under LGPL License.
7 * License: http://www.tinymce.com/license
8 * Contributing: http://www.tinymce.com/contributing
12 * This class contains various environment constrants like browser versions etc.
13 * Normally you don't want to sniff specific browser versions but sometimes you have
14 * to when it's impossible to feature detect. So use this with care.
19 define("tinymce/Env", [], function() {
20 var nav = navigator, userAgent = nav.userAgent;
21 var opera, webkit, ie, ie11, gecko, mac, iDevice;
23 opera = window.opera && window.opera.buildNumber;
24 webkit = /WebKit/.test(userAgent);
25 ie = !webkit && !opera && (/MSIE/gi).test(userAgent) && (/Explorer/gi).test(nav.appName);
26 ie = ie && /MSIE (\w+)\./.exec(userAgent)[1];
27 ie11 = userAgent.indexOf('Trident') != -1 ? 11 : false;
29 gecko = !webkit && /Gecko/.test(userAgent);
30 mac = userAgent.indexOf('Mac') != -1;
31 iDevice = /(iPad|iPhone)/.test(userAgent);
33 // Is a iPad/iPhone and not on iOS5 sniff the WebKit version since older iOS WebKit versions
34 // says it has contentEditable support but there is no visible caret.
35 var contentEditable = !iDevice || userAgent.match(/AppleWebKit\/(\d*)/)[1] >= 534;
39 * Constant that is true if the browser is Opera.
48 * Constant that is true if the browser is WebKit (Safari/Chrome).
57 * Constant that is more than zero if the browser is IE.
66 * Constant that is true if the browser is Gecko.
75 * Constant that is true if the os is Mac OS.
84 * Constant that is true if the os is iOS.
93 * Constant that is true if the browser supports editing.
95 * @property contentEditable
99 contentEditable: contentEditable,
102 * Transparent image data url.
104 * @property transparentSrc
108 transparentSrc: "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
111 * Returns true/false if the browser can or can't place the caret after a inline block like an image.
113 * @property noCaretAfter
120 * Constant that is true if the browser supports native DOM Ranges. IE 9+.
125 range: window.getSelection && "Range" in window,
128 * Returns the IE document mode for non IE browsers this will fake IE 10.
130 * @property documentMode
133 documentMode: ie ? (document.documentMode || 7) : 10