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 * Environment information. 24 * @namespace 25 * @example 26 */ 27 CKEDITOR.env = (function() 28 { 29 var agent = navigator.userAgent.toLowerCase(); 30 var opera = window.opera; 31 32 var env = 33 /** @lends CKEDITOR.env */ 34 { 35 /** 36 * Indicates that CKEditor is running on Internet Explorer. 37 * @type Boolean 38 * @example 39 * if ( CKEDITOR.env.ie ) 40 * alert( "I'm on IE!" ); 41 */ 42 ie : /*@cc_on!@*/false, 43 /** 44 * Indicates that CKEditor is running on Opera. 45 * @type Boolean 46 * @example 47 * if ( CKEDITOR.env.opera ) 48 * alert( "I'm on Opera!" ); 49 */ 50 opera : ( !!opera && opera.version ), 51 /** 52 * Indicates that CKEditor is running on a WebKit based browser, like 53 * Safari. 54 * @type Boolean 55 * @example 56 * if ( CKEDITOR.env.webkit ) 57 * alert( "I'm on WebKit!" ); 58 */ 59 webkit : ( agent.indexOf( ' applewebkit/' ) > -1 ), 60 /** 61 * Indicates that CKEditor is running on Adobe AIR. 62 * @type Boolean 63 * @example 64 * if ( CKEDITOR.env.air ) 65 * alert( "I'm on AIR!" ); 66 */ 67 air : ( agent.indexOf( ' adobeair/' ) > -1 ), 68 /** 69 * Indicates that CKEditor is running on Macintosh. 70 * @type Boolean 71 * @example 72 * if ( CKEDITOR.env.mac ) 73 * alert( "I love apples!" ); 74 */ 75 mac : ( agent.indexOf( 'macintosh' ) > -1 ) 76 }; 77 78 /** 79 * Indicates that CKEditor is running on a Gecko based browser, like 80 * Firefox. 81 * @name CKEDITOR.env.gecko 82 * @type Boolean 83 * @example 84 * if ( CKEDITOR.env.gecko ) 85 * alert( "I'm riding a gecko!" ); 86 */ 87 env.gecko = ( navigator.product == 'Gecko' && !env.webkit && !env.opera ); 88 89 /** 90 * Indicates that CKEditor is running on a compatible browser. 91 * @name CKEDITOR.env.isCompatible 92 * @type Boolean 93 * @example 94 * if ( CKEDITOR.env.isCompatible ) 95 * alert( "Your browser is pretty cool!" ); 96 */ 97 env.isCompatible = (function() 98 { 99 // Internet Explorer 6.0+ 100 if ( env.ie ) 101 return ( agent.match(/msie (\d+)/)[1] >= 6 ); 102 103 // Gecko. 104 if ( env.gecko ) 105 return navigator.productSub >= 20030210; 106 107 // Opera 9.50+ 108 if ( env.opera ) 109 return parseFloat( opera.version() ) >= 9.5; 110 111 // Adobe AIR 1.0+ 112 // Checked before Safari because AIR have the WebKit rich text editor 113 // features from Safari 3.0.4, but the version reported is 420. 114 if ( env.air ) 115 return ( agent.match( / adobeair\/(\d+)/ )[1] >= 1 ); 116 117 // WebKit 522+ (Safari 3+) 118 if ( env.webkit ) 119 return ( agent.match( / applewebkit\/(\d+)/ )[1] >= 522 ); 120 121 return false; 122 })(); 123 124 return env; 125 })(); 126