2 Copyright (c) 2003-2009, 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 isCustomDomain : function()
\r
76 return this.ie && document.domain != window.location.hostname;
\r
81 * Indicates that CKEditor is running on a Gecko based browser, like
\r
83 * @name CKEDITOR.env.gecko
\r
86 * if ( CKEDITOR.env.gecko )
\r
87 * alert( "I'm riding a gecko!" );
\r
89 env.gecko = ( navigator.product == 'Gecko' && !env.webkit && !env.opera );
\r
93 // Internet Explorer 6.0+
\r
96 version = parseFloat( agent.match( /msie (\d+)/ )[1] );
\r
99 * Indicate IE8 browser.
\r
101 env.ie8 = !!document.documentMode;
\r
104 * Indicte IE8 document mode.
\r
106 env.ie8Compat = document.documentMode == 8;
\r
109 * Indicates that CKEditor is running on an IE7-like environment, which
\r
110 * includes IE7 itself and IE8's IE7 document mode.
\r
113 env.ie7Compat = ( ( version == 7 && !document.documentMode )
\r
114 || document.documentMode == 7 );
\r
117 * Indicates that CKEditor is running on an IE6-like environment, which
\r
118 * includes IE6 itself and IE7 and IE8 quirks mode.
\r
121 * if ( CKEDITOR.env.ie6Compat )
\r
122 * alert( "I'm on IE6 or quirks mode!" );
\r
124 env.ie6Compat = ( version < 7 || env.quirks );
\r
131 var geckoRelease = agent.match( /rv:([\d\.]+)/ );
\r
132 if ( geckoRelease )
\r
134 geckoRelease = geckoRelease[1].split( '.' );
\r
135 version = geckoRelease[0] * 10000 + ( geckoRelease[1] || 0 ) * 100 + ( geckoRelease[2] || 0 ) * 1;
\r
141 version = parseFloat( opera.version() );
\r
144 // Checked before Safari because AIR have the WebKit rich text editor
\r
145 // features from Safari 3.0.4, but the version reported is 420.
\r
147 version = parseFloat( agent.match( / adobeair\/(\d+)/ )[1] );
\r
149 // WebKit 522+ (Safari 3+)
\r
151 version = parseFloat( agent.match( / applewebkit\/(\d+)/ )[1] );
\r
154 * Contains the browser version.
\r
156 * For gecko based browsers (like Firefox) it contains the revision
\r
157 * number with first three parts concatenated with a padding zero
\r
158 * (e.g. for revision 1.9.0.2 we have 10900).
\r
160 * For webkit based browser (like Safari and Chrome) it contains the
\r
161 * WebKit build version (e.g. 522).
\r
162 * @name CKEDITOR.env.version
\r
165 * if ( CKEDITOR.env.ie && <b>CKEDITOR.env.version</b> <= 6 )
\r
166 * alert( "Ouch!" );
\r
168 env.version = version;
\r
171 * Indicates that CKEditor is running on a compatible browser.
\r
172 * @name CKEDITOR.env.isCompatible
\r
175 * if ( CKEDITOR.env.isCompatible )
\r
176 * alert( "Your browser is pretty cool!" );
\r
179 ( env.ie && version >= 6 ) ||
\r
180 ( env.gecko && version >= 10801 ) ||
\r
181 ( env.opera && version >= 9.5 ) ||
\r
182 ( env.air && version >= 1 ) ||
\r
183 ( env.webkit && version >= 522 ) ||
\r
186 // The CSS class to be appended on the main UI containers, making it
\r
187 // easy to apply browser specific styles to it.
\r
191 env.gecko ? 'gecko' :
\r
192 env.opera ? 'opera' :
\r
194 env.webkit ? 'webkit' :
\r
198 env.cssClass += ' cke_browser_quirks';
\r
202 env.cssClass += ' cke_browser_ie' + (
\r
203 env.version < 7 ? '6' :
\r
204 env.version >= 8 ? '8' :
\r
208 env.cssClass += ' cke_browser_iequirks';
\r
211 if ( env.gecko && version < 10900 )
\r
212 env.cssClass += ' cke_browser_gecko18';
\r
218 // PACKAGER_RENAME( CKEDITOR.env )
\r
219 // PACKAGER_RENAME( CKEDITOR.env.ie )
\r