1 /* 2 * CKEditor - The text editor for Internet - http://ckeditor.com 3 * Copyright (C) 2003-2008 Frederico Caldeira Knabben 4 * 5 * == BEGIN LICENSE == 6 * 7 * Licensed under the terms of any of the following licenses at your 8 * choice: 9 * 10 * - GNU General Public License Version 2 or later (the "GPL") 11 * http://www.gnu.org/licenses/gpl.html 12 * 13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 14 * http://www.gnu.org/licenses/lgpl.html 15 * 16 * - Mozilla Public License Version 1.1 or later (the "MPL") 17 * http://www.mozilla.org/MPL/MPL-1.1.html 18 * 19 * == END LICENSE == 20 */ 21 22 /** 23 * @fileOverview Defines the {@link CKEDITOR.env} object, which constains 24 * environment and browser information. 25 */ 26 27 if ( !CKEDITOR.env ) 28 { 29 /** 30 * Environment and browser information. 31 * @namespace 32 * @example 33 */ 34 CKEDITOR.env = (function() 35 { 36 var agent = navigator.userAgent.toLowerCase(); 37 var opera = window.opera; 38 39 var env = 40 /** @lends CKEDITOR.env */ 41 { 42 /** 43 * Indicates that CKEditor is running on Internet Explorer. 44 * @type Boolean 45 * @example 46 * if ( CKEDITOR.env.ie ) 47 * alert( "I'm on IE!" ); 48 */ 49 ie : /*@cc_on!@*/false, 50 /** 51 * Indicates that CKEditor is running on Opera. 52 * @type Boolean 53 * @example 54 * if ( CKEDITOR.env.opera ) 55 * alert( "I'm on Opera!" ); 56 */ 57 opera : ( !!opera && opera.version ), 58 /** 59 * Indicates that CKEditor is running on a WebKit based browser, like 60 * Safari. 61 * @type Boolean 62 * @example 63 * if ( CKEDITOR.env.webkit ) 64 * alert( "I'm on WebKit!" ); 65 */ 66 webkit : ( agent.indexOf( ' applewebkit/' ) > -1 ), 67 /** 68 * Indicates that CKEditor is running on Adobe AIR. 69 * @type Boolean 70 * @example 71 * if ( CKEDITOR.env.air ) 72 * alert( "I'm on AIR!" ); 73 */ 74 air : ( agent.indexOf( ' adobeair/' ) > -1 ), 75 /** 76 * Indicates that CKEditor is running on Macintosh. 77 * @type Boolean 78 * @example 79 * if ( CKEDITOR.env.mac ) 80 * alert( "I love apples!" ); 81 */ 82 mac : ( agent.indexOf( 'macintosh' ) > -1 ) 83 }; 84 85 /** 86 * Indicates that CKEditor is running on a Gecko based browser, like 87 * Firefox. 88 * @name CKEDITOR.env.gecko 89 * @type Boolean 90 * @example 91 * if ( CKEDITOR.env.gecko ) 92 * alert( "I'm riding a gecko!" ); 93 */ 94 env.gecko = ( navigator.product == 'Gecko' && !env.webkit && !env.opera ); 95 96 /** 97 * Indicates that CKEditor is running on a compatible browser. 98 * @name CKEDITOR.env.isCompatible 99 * @type Boolean 100 * @example 101 * if ( CKEDITOR.env.isCompatible ) 102 * alert( "Your browser is pretty cool!" ); 103 */ 104 env.isCompatible = (function() 105 { 106 // Internet Explorer 6.0+ 107 if ( env.ie ) 108 return ( agent.match(/msie (\d+)/)[1] >= 6 ); 109 110 // Gecko. 111 if ( env.gecko ) 112 return navigator.productSub >= 20030210; 113 114 // Opera 9.50+ 115 if ( env.opera ) 116 return parseFloat( opera.version() ) >= 9.5; 117 118 // Adobe AIR 1.0+ 119 // Checked before Safari because AIR have the WebKit rich text editor 120 // features from Safari 3.0.4, but the version reported is 420. 121 if ( env.air ) 122 return ( agent.match( / adobeair\/(\d+)/ )[1] >= 1 ); 123 124 // WebKit 522+ (Safari 3+) 125 if ( env.webkit ) 126 return ( agent.match( / applewebkit\/(\d+)/ )[1] >= 522 ); 127 128 return false; 129 })(); 130 131 return env; 132 })(); 133 } 134