X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_samples%2Fsample.js;fp=_samples%2Fsample.js;h=7c134527b6dc87a85a6bb9cb5888cbd2e5c86444;hb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;hp=0000000000000000000000000000000000000000;hpb=b93873b6532ee7515fb0d6f8b73176c44fad28f7;p=ckeditor.git diff --git a/_samples/sample.js b/_samples/sample.js new file mode 100644 index 0000000..7c13452 --- /dev/null +++ b/_samples/sample.js @@ -0,0 +1,71 @@ +/* +Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.html or http://ckeditor.com/license +*/ + +// This file is not required by CKEditor and may be safely ignored. +// It is just a helper file that displays a red message about browser compatibility +// at the top of the samples (if incompatible browser is detected). + +// Firebug has been presented some bugs with console. It must be "initialized" +// before the page load to work. +// FIXME: Remove the following in the future, if Firebug gets fixed. +if ( typeof console != 'undefined' ) + console.log(); + + +if ( window.CKEDITOR ) +{ + (function() + { + var showCompatibilityMsg = function() + { + var env = CKEDITOR.env; + + var html = '

Your browser is not compatible with CKEditor.'; + + var browsers = + { + gecko : 'Firefox 2.0', + ie : 'Internet Explorer 6.0', + opera : 'Opera 9.5', + webkit : 'Safari 3.0' + }; + + var alsoBrowsers = ''; + + for ( var key in env ) + { + if ( browsers[ key ] ) + { + if ( env[key] ) + html += ' CKEditor is compatible with ' + browsers[ key ] + ' or higher.'; + else + alsoBrowsers += browsers[ key ] + '+, '; + } + } + + alsoBrowsers = alsoBrowsers.replace( /\+,([^,]+), $/, '+ and $1' ); + + html += ' It is also compatible with ' + alsoBrowsers + '.'; + + html += '

With non compatible browsers, you should still be able to see and edit the contents (HTML) in a plain text field.

'; + + document.getElementById( 'alerts' ).innerHTML = html; + }; + + var onload = function() + { + // Show a friendly compatibility message as soon as the page is loaded, + // for those browsers that are not compatible with CKEditor. + if ( !CKEDITOR.env.isCompatible ) + showCompatibilityMsg(); + }; + + // Register the onload listener. + if ( window.addEventListener ) + window.addEventListener( 'load', onload, false ); + else if ( window.attachEvent ) + window.attachEvent( 'onload', onload ); + })(); +}