JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.1
[ckeditor.git] / _samples / sample.js
1 /*\r
2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license\r
4 */\r
5 \r
6 // This file is not required by CKEditor and may be safely ignored.\r
7 // It is just a helper file that displays a red message about browser compatibility\r
8 // at the top of the samples (if incompatible browser is detected).\r
9 \r
10 if ( window.CKEDITOR )\r
11 {\r
12         (function()\r
13         {\r
14                 var showCompatibilityMsg = function()\r
15                 {\r
16                         var env = CKEDITOR.env;\r
17 \r
18                         var html = '<p><strong>Your browser is not compatible with CKEditor.</strong>';\r
19 \r
20                         var browsers =\r
21                         {\r
22                                 gecko : 'Firefox 2.0',\r
23                                 ie : 'Internet Explorer 6.0',\r
24                                 opera : 'Opera 9.5',\r
25                                 webkit : 'Safari 3.0'\r
26                         };\r
27 \r
28                         var alsoBrowsers = '';\r
29 \r
30                         for ( var key in env )\r
31                         {\r
32                                 if ( browsers[ key ] )\r
33                                 {\r
34                                         if ( env[key] )\r
35                                                 html += ' CKEditor is compatible with ' + browsers[ key ] + ' or higher.';\r
36                                         else\r
37                                                 alsoBrowsers += browsers[ key ] + '+, ';\r
38                                 }\r
39                         }\r
40 \r
41                         alsoBrowsers = alsoBrowsers.replace( /\+,([^,]+), $/, '+ and $1' );\r
42 \r
43                         html += ' It is also compatible with ' + alsoBrowsers + '.';\r
44 \r
45                         html += '</p><p>With non compatible browsers, you should still be able to see and edit the contents (HTML) in a plain text field.</p>';\r
46 \r
47                         var alertsEl = document.getElementById( 'alerts' );\r
48                         alertsEl && ( alertsEl.innerHTML = html );\r
49                 };\r
50 \r
51                 var onload = function()\r
52                 {\r
53                         // Show a friendly compatibility message as soon as the page is loaded,\r
54                         // for those browsers that are not compatible with CKEditor.\r
55                         if ( !CKEDITOR.env.isCompatible )\r
56                                 showCompatibilityMsg();\r
57                 };\r
58 \r
59                 // Register the onload listener.\r
60                 if ( window.addEventListener )\r
61                         window.addEventListener( 'load', onload, false );\r
62                 else if ( window.attachEvent )\r
63                         window.attachEvent( 'onload', onload );\r
64         })();\r
65 }\r