JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.0
[ckeditor.git] / _samples / sample.js
diff --git a/_samples/sample.js b/_samples/sample.js
new file mode 100644 (file)
index 0000000..7c13452
--- /dev/null
@@ -0,0 +1,71 @@
+/*\r
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+// This file is not required by CKEditor and may be safely ignored.\r
+// It is just a helper file that displays a red message about browser compatibility\r
+// at the top of the samples (if incompatible browser is detected).\r
+\r
+// Firebug has been presented some bugs with console. It must be "initialized"\r
+// before the page load to work.\r
+// FIXME: Remove the following in the future, if Firebug gets fixed.\r
+if ( typeof console != 'undefined' )\r
+       console.log();\r
+\r
+\r
+if ( window.CKEDITOR )\r
+{\r
+       (function()\r
+       {\r
+               var showCompatibilityMsg = function()\r
+               {\r
+                       var env = CKEDITOR.env;\r
+\r
+                       var html = '<p><strong>Your browser is not compatible with CKEditor.</strong>';\r
+\r
+                       var browsers =\r
+                       {\r
+                               gecko : 'Firefox 2.0',\r
+                               ie : 'Internet Explorer 6.0',\r
+                               opera : 'Opera 9.5',\r
+                               webkit : 'Safari 3.0'\r
+                       };\r
+\r
+                       var alsoBrowsers = '';\r
+\r
+                       for ( var key in env )\r
+                       {\r
+                               if ( browsers[ key ] )\r
+                               {\r
+                                       if ( env[key] )\r
+                                               html += ' CKEditor is compatible with ' + browsers[ key ] + ' or higher.';\r
+                                       else\r
+                                               alsoBrowsers += browsers[ key ] + '+, ';\r
+                               }\r
+                       }\r
+\r
+                       alsoBrowsers = alsoBrowsers.replace( /\+,([^,]+), $/, '+ and $1' );\r
+\r
+                       html += ' It is also compatible with ' + alsoBrowsers + '.';\r
+\r
+                       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
+\r
+                       document.getElementById( 'alerts' ).innerHTML = html;\r
+               };\r
+\r
+               var onload = function()\r
+               {\r
+                       // Show a friendly compatibility message as soon as the page is loaded,\r
+                       // for those browsers that are not compatible with CKEditor.\r
+                       if ( !CKEDITOR.env.isCompatible )\r
+                               showCompatibilityMsg();\r
+               };\r
+\r
+               // Register the onload listener.\r
+               if ( window.addEventListener )\r
+                       window.addEventListener( 'load', onload, false );\r
+               else if ( window.attachEvent )\r
+                       window.attachEvent( 'onload', onload );\r
+       })();\r
+}\r