Nation Notes module contributed by Z&H Healthcare.
[openemr.git] / library / custom_template / ckeditor / _source / core / env.js
blob6053e792d96cb957caf019df4fca3257a8e15a2a
1 /*
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
6 /**
7  * @fileOverview Defines the {@link CKEDITOR.env} object, which constains
8  *              environment and browser information.
9  */
11 if ( !CKEDITOR.env )
13         /**
14          * @namespace Environment and browser information.
15          */
16         CKEDITOR.env = (function()
17         {
18                 var agent = navigator.userAgent.toLowerCase();
19                 var opera = window.opera;
21                 var env =
22                 /** @lends CKEDITOR.env */
23                 {
24                         /**
25                          * Indicates that CKEditor is running on Internet Explorer.
26                          * @type Boolean
27                          * @example
28                          * if ( CKEDITOR.env.ie )
29                          *     alert( "I'm on IE!" );
30                          */
31                         ie              : /*@cc_on!@*/false,
33                         /**
34                          * Indicates that CKEditor is running on Opera.
35                          * @type Boolean
36                          * @example
37                          * if ( CKEDITOR.env.opera )
38                          *     alert( "I'm on Opera!" );
39                          */
40                         opera   : ( !!opera && opera.version ),
42                         /**
43                          * Indicates that CKEditor is running on a WebKit based browser, like
44                          * Safari.
45                          * @type Boolean
46                          * @example
47                          * if ( CKEDITOR.env.webkit )
48                          *     alert( "I'm on WebKit!" );
49                          */
50                         webkit  : ( agent.indexOf( ' applewebkit/' ) > -1 ),
52                         /**
53                          * Indicates that CKEditor is running on Adobe AIR.
54                          * @type Boolean
55                          * @example
56                          * if ( CKEDITOR.env.air )
57                          *     alert( "I'm on AIR!" );
58                          */
59                         air             : ( agent.indexOf( ' adobeair/' ) > -1 ),
61                         /**
62                          * Indicates that CKEditor is running on Macintosh.
63                          * @type Boolean
64                          * @example
65                          * if ( CKEDITOR.env.mac )
66                          *     alert( "I love apples!" );
67                          */
68                         mac     : ( agent.indexOf( 'macintosh' ) > -1 ),
70                         /**
71                          * Indicates that CKEditor is running on a quirks mode environemnt.
72                          * @type Boolean
73                          * @example
74                          * if ( CKEDITOR.env.quirks )
75                          *     alert( "Nooooo!" );
76                          */
77                         quirks : ( document.compatMode == 'BackCompat' ),
79                         /**
80                          * Indicates that CKEditor is running on a mobile like environemnt.
81                          * @type Boolean
82                          * @example
83                          * if ( CKEDITOR.env.mobile )
84                          *     alert( "I'm running with CKEditor today!" );
85                          */
86                         mobile : ( agent.indexOf( 'mobile' ) > -1 ),
88                         /**
89                          * Indicates that the browser has a custom domain enabled. This has
90                          * been set with "document.domain".
91                          * @returns {Boolean} "true" if a custom domain is enabled.
92                          * @example
93                          * if ( CKEDITOR.env.isCustomDomain() )
94                          *     alert( "I'm in a custom domain!" );
95                          */
96                         isCustomDomain : function()
97                         {
98                                 if ( !this.ie )
99                                         return false;
101                                 var domain = document.domain,
102                                         hostname = window.location.hostname;
104                                 return domain != hostname &&
105                                         domain != ( '[' + hostname + ']' );     // IPv6 IP support (#5434)
106                         }
107                 };
109                 /**
110                  * Indicates that CKEditor is running on a Gecko based browser, like
111                  * Firefox.
112                  * @name CKEDITOR.env.gecko
113                  * @type Boolean
114                  * @example
115                  * if ( CKEDITOR.env.gecko )
116                  *     alert( "I'm riding a gecko!" );
117                  */
118                 env.gecko = ( navigator.product == 'Gecko' && !env.webkit && !env.opera );
120                 var version = 0;
122                 // Internet Explorer 6.0+
123                 if ( env.ie )
124                 {
125                         version = parseFloat( agent.match( /msie (\d+)/ )[1] );
127                         /**
128                          * Indicates that CKEditor is running on Internet Explorer 8.
129                          * @name CKEDITOR.env.ie8
130                          * @type Boolean
131                          * @example
132                          * if ( CKEDITOR.env.ie8 )
133                          *     alert( "I'm on IE8!" );
134                          */
135                         env.ie8 = !!document.documentMode;
137                         /**
138                          * Indicates that CKEditor is running on Internet Explorer 8 on
139                          * standards mode.
140                          * @name CKEDITOR.env.ie8Compat
141                          * @type Boolean
142                          * @example
143                          * if ( CKEDITOR.env.ie8Compat )
144                          *     alert( "Now I'm on IE8, for real!" );
145                          */
146                         env.ie8Compat = document.documentMode == 8;
148                         /**
149                          * Indicates that CKEditor is running on an IE7-like environment, which
150                          * includes IE7 itself and IE8's IE7 document mode.
151                          * @name CKEDITOR.env.ie7Compat
152                          * @type Boolean
153                          * @example
154                          * if ( CKEDITOR.env.ie8Compat )
155                          *     alert( "I'm on IE7 or on an IE7 like IE8!" );
156                          */
157                         env.ie7Compat = ( ( version == 7 && !document.documentMode )
158                                         || document.documentMode == 7 );
160                         /**
161                          * Indicates that CKEditor is running on an IE6-like environment, which
162                          * includes IE6 itself and IE7 and IE8 quirks mode.
163                          * @name CKEDITOR.env.ie6Compat
164                          * @type Boolean
165                          * @example
166                          * if ( CKEDITOR.env.ie6Compat )
167                          *     alert( "I'm on IE6 or quirks mode!" );
168                          */
169                         env.ie6Compat = ( version < 7 || env.quirks );
170                 }
172                 // Gecko.
173                 if ( env.gecko )
174                 {
175                         var geckoRelease = agent.match( /rv:([\d\.]+)/ );
176                         if ( geckoRelease )
177                         {
178                                 geckoRelease = geckoRelease[1].split( '.' );
179                                 version = geckoRelease[0] * 10000 + ( geckoRelease[1] || 0 ) * 100 + ( geckoRelease[2] || 0 ) * 1;
180                         }
181                 }
183                 // Opera 9.50+
184                 if ( env.opera )
185                         version = parseFloat( opera.version() );
187                 // Adobe AIR 1.0+
188                 // Checked before Safari because AIR have the WebKit rich text editor
189                 // features from Safari 3.0.4, but the version reported is 420.
190                 if ( env.air )
191                         version = parseFloat( agent.match( / adobeair\/(\d+)/ )[1] );
193                 // WebKit 522+ (Safari 3+)
194                 if ( env.webkit )
195                         version = parseFloat( agent.match( / applewebkit\/(\d+)/ )[1] );
197                 /**
198                  * Contains the browser version.<br />
199                  * <br />
200                  * For gecko based browsers (like Firefox) it contains the revision
201                  * number with first three parts concatenated with a padding zero
202                  * (e.g. for revision 1.9.0.2 we have 10900).<br />
203                  * <br />
204                  * For webkit based browser (like Safari and Chrome) it contains the
205                  * WebKit build version (e.g. 522).
206                  * @name CKEDITOR.env.version
207                  * @type Boolean
208                  * @example
209                  * if ( CKEDITOR.env.ie && <b>CKEDITOR.env.version</b> <= 6 )
210                  *     alert( "Ouch!" );
211                  */
212                 env.version = version;
214                 /**
215                  * Indicates that CKEditor is running on a compatible browser.
216                  * @name CKEDITOR.env.isCompatible
217                  * @type Boolean
218                  * @example
219                  * if ( CKEDITOR.env.isCompatible )
220                  *     alert( "Your browser is pretty cool!" );
221                  */
222                 env.isCompatible =
223                         !env.mobile && (
224                         ( env.ie && version >= 6 ) ||
225                         ( env.gecko && version >= 10801 ) ||
226                         ( env.opera && version >= 9.5 ) ||
227                         ( env.air && version >= 1 ) ||
228                         ( env.webkit && version >= 522 ) ||
229                         false );
231                 /**
232                  * The CSS class to be appended on the main UI containers, making it
233                  * easy to apply browser specific styles to it.
234                  * @name CKEDITOR.env.cssClass
235                  * @type String
236                  * @example
237                  * myDiv.className = CKEDITOR.env.cssClass;
238                  */
239                 env.cssClass =
240                         'cke_browser_' + (
241                                 env.ie ? 'ie' :
242                                 env.gecko ? 'gecko' :
243                                 env.opera ? 'opera' :
244                                 env.webkit ? 'webkit' :
245                                 'unknown' );
247                 if ( env.quirks )
248                         env.cssClass += ' cke_browser_quirks';
250                 if ( env.ie )
251                 {
252                         env.cssClass += ' cke_browser_ie' + (
253                                 env.version < 7 ? '6' :
254                                 env.version >= 8 ? document.documentMode:
255                                 '7' );
257                         if ( env.quirks )
258                                 env.cssClass += ' cke_browser_iequirks';
259                 }
261                 if ( env.gecko && version < 10900 )
262                         env.cssClass += ' cke_browser_gecko18';
264                 if ( env.air )
265                         env.cssClass += ' cke_browser_air';
267                 return env;
268         })();
271 // PACKAGER_RENAME( CKEDITOR.env )
272 // PACKAGER_RENAME( CKEDITOR.env.ie )