sample.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
  3. For licensing, see LICENSE.html or http://ckeditor.com/license
  4. */
  5. // This file is not required by CKEditor and may be safely ignored.
  6. // It is just a helper file that displays a red message about browser compatibility
  7. // at the top of the samples (if incompatible browser is detected).
  8. if ( window.CKEDITOR )
  9. {
  10. (function()
  11. {
  12. var showCompatibilityMsg = function()
  13. {
  14. var env = CKEDITOR.env;
  15. var html = '<p><strong>Your browser is not compatible with CKEditor.</strong>';
  16. var browsers =
  17. {
  18. gecko : 'Firefox 2.0',
  19. ie : 'Internet Explorer 6.0',
  20. opera : 'Opera 9.5',
  21. webkit : 'Safari 3.0'
  22. };
  23. var alsoBrowsers = '';
  24. for ( var key in env )
  25. {
  26. if ( browsers[ key ] )
  27. {
  28. if ( env[key] )
  29. html += ' CKEditor is compatible with ' + browsers[ key ] + ' or higher.';
  30. else
  31. alsoBrowsers += browsers[ key ] + '+, ';
  32. }
  33. }
  34. alsoBrowsers = alsoBrowsers.replace( /\+,([^,]+), $/, '+ and $1' );
  35. html += ' It is also compatible with ' + alsoBrowsers + '.';
  36. 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>';
  37. var alertsEl = document.getElementById( 'alerts' );
  38. alertsEl && ( alertsEl.innerHTML = html );
  39. };
  40. var onload = function()
  41. {
  42. // Show a friendly compatibility message as soon as the page is loaded,
  43. // for those browsers that are not compatible with CKEditor.
  44. if ( !CKEDITOR.env.isCompatible )
  45. showCompatibilityMsg();
  46. };
  47. // Register the onload listener.
  48. if ( window.addEventListener )
  49. window.addEventListener( 'load', onload, false );
  50. else if ( window.attachEvent )
  51. window.attachEvent( 'onload', onload );
  52. })();
  53. }