2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
7 * @fileOverview Defines the {@link CKEDITOR.env} object, which constains
\r
8 * environment and browser information.
\r
11 if ( !CKEDITOR.env )
\r
14 * Environment and browser information.
\r
18 CKEDITOR.env = (function()
\r
20 var agent = navigator.userAgent.toLowerCase();
\r
21 var opera = window.opera;
\r
24 /** @lends CKEDITOR.env */
\r
27 * Indicates that CKEditor is running on Internet Explorer.
\r
30 * if ( CKEDITOR.env.ie )
\r
31 * alert( "I'm on IE!" );
\r
33 ie : /*@cc_on!@*/false,
\r
36 * Indicates that CKEditor is running on Opera.
\r
39 * if ( CKEDITOR.env.opera )
\r
40 * alert( "I'm on Opera!" );
\r
42 opera : ( !!opera && opera.version ),
\r
45 * Indicates that CKEditor is running on a WebKit based browser, like
\r
49 * if ( CKEDITOR.env.webkit )
\r
50 * alert( "I'm on WebKit!" );
\r
52 webkit : ( agent.indexOf( ' applewebkit/' ) > -1 ),
\r
55 * Indicates that CKEditor is running on Adobe AIR.
\r
58 * if ( CKEDITOR.env.air )
\r
59 * alert( "I'm on AIR!" );
\r
61 air : ( agent.indexOf( ' adobeair/' ) > -1 ),
\r
64 * Indicates that CKEditor is running on Macintosh.
\r
67 * if ( CKEDITOR.env.mac )
\r
68 * alert( "I love apples!" );
\r
70 mac : ( agent.indexOf( 'macintosh' ) > -1 ),
\r
72 quirks : ( document.compatMode == 'BackCompat' ),
\r
74 mobile : ( agent.indexOf( 'mobile' ) > -1 ),
\r
76 isCustomDomain : function()
\r
78 return this.ie && document.domain != window.location.hostname;
\r
83 * Indicates that CKEditor is running on a Gecko based browser, like
\r
85 * @name CKEDITOR.env.gecko
\r
88 * if ( CKEDITOR.env.gecko )
\r
89 * alert( "I'm riding a gecko!" );
\r
91 env.gecko = ( navigator.product == 'Gecko' && !env.webkit && !env.opera );
\r
95 // Internet Explorer 6.0+
\r
98 version = parseFloat( agent.match( /msie (\d+)/ )[1] );
\r
101 * Indicate IE8 browser.
\r
103 env.ie8 = !!document.documentMode;
\r
106 * Indicte IE8 document mode.
\r
108 env.ie8Compat = document.documentMode == 8;
\r
111 * Indicates that CKEditor is running on an IE7-like environment, which
\r
112 * includes IE7 itself and IE8's IE7 document mode.
\r
115 env.ie7Compat = ( ( version == 7 && !document.documentMode )
\r
116 || document.documentMode == 7 );
\r
119 * Indicates that CKEditor is running on an IE6-like environment, which
\r
120 * includes IE6 itself and IE7 and IE8 quirks mode.
\r
123 * if ( CKEDITOR.env.ie6Compat )
\r
124 * alert( "I'm on IE6 or quirks mode!" );
\r
126 env.ie6Compat = ( version < 7 || env.quirks );
\r
133 var geckoRelease = agent.match( /rv:([\d\.]+)/ );
\r
134 if ( geckoRelease )
\r
136 geckoRelease = geckoRelease[1].split( '.' );
\r
137 version = geckoRelease[0] * 10000 + ( geckoRelease[1] || 0 ) * 100 + ( geckoRelease[2] || 0 ) * 1;
\r
143 version = parseFloat( opera.version() );
\r
146 // Checked before Safari because AIR have the WebKit rich text editor
\r
147 // features from Safari 3.0.4, but the version reported is 420.
\r
149 version = parseFloat( agent.match( / adobeair\/(\d+)/ )[1] );
\r
151 // WebKit 522+ (Safari 3+)
\r
153 version = parseFloat( agent.match( / applewebkit\/(\d+)/ )[1] );
\r
156 * Contains the browser version.
\r
158 * For gecko based browsers (like Firefox) it contains the revision
\r
159 * number with first three parts concatenated with a padding zero
\r
160 * (e.g. for revision 1.9.0.2 we have 10900).
\r
162 * For webkit based browser (like Safari and Chrome) it contains the
\r
163 * WebKit build version (e.g. 522).
\r
164 * @name CKEDITOR.env.version
\r
167 * if ( CKEDITOR.env.ie && <b>CKEDITOR.env.version</b> <= 6 )
\r
168 * alert( "Ouch!" );
\r
170 env.version = version;
\r
173 * Indicates that CKEditor is running on a compatible browser.
\r
174 * @name CKEDITOR.env.isCompatible
\r
177 * if ( CKEDITOR.env.isCompatible )
\r
178 * alert( "Your browser is pretty cool!" );
\r
182 ( env.ie && version >= 6 ) ||
\r
183 ( env.gecko && version >= 10801 ) ||
\r
184 ( env.opera && version >= 9.5 ) ||
\r
185 ( env.air && version >= 1 ) ||
\r
186 ( env.webkit && version >= 522 ) ||
\r
189 // The CSS class to be appended on the main UI containers, making it
\r
190 // easy to apply browser specific styles to it.
\r
194 env.gecko ? 'gecko' :
\r
195 env.opera ? 'opera' :
\r
197 env.webkit ? 'webkit' :
\r
201 env.cssClass += ' cke_browser_quirks';
\r
205 env.cssClass += ' cke_browser_ie' + (
\r
206 env.version < 7 ? '6' :
\r
207 env.version >= 8 ? '8' :
\r
211 env.cssClass += ' cke_browser_iequirks';
\r
214 if ( env.gecko && version < 10900 )
\r
215 env.cssClass += ' cke_browser_gecko18';
\r
221 // PACKAGER_RENAME( CKEDITOR.env )
\r
222 // PACKAGER_RENAME( CKEDITOR.env.ie )
\r