readonly.html 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <!--
  3. Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
  4. For licensing, see LICENSE.html or http://ckeditor.com/license
  5. -->
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <title>Read-only State &mdash; CKEditor Sample</title>
  9. <meta content="text/html; charset=utf-8" http-equiv="content-type" />
  10. <script type="text/javascript" src="../ckeditor.js"></script>
  11. <script src="sample.js" type="text/javascript"></script>
  12. <link href="sample.css" rel="stylesheet" type="text/css" />
  13. <script type="text/javascript">
  14. //<![CDATA[
  15. var editor;
  16. // The instanceReady event is fired, when an instance of CKEditor has finished
  17. // its initialization.
  18. CKEDITOR.on( 'instanceReady', function( ev )
  19. {
  20. editor = ev.editor;
  21. // Show this "on" button.
  22. document.getElementById( 'readOnlyOn' ).style.display = '';
  23. // Event fired when the readOnly property changes.
  24. editor.on( 'readOnly', function()
  25. {
  26. document.getElementById( 'readOnlyOn' ).style.display = this.readOnly ? 'none' : '';
  27. document.getElementById( 'readOnlyOff' ).style.display = this.readOnly ? '' : 'none';
  28. });
  29. });
  30. function toggleReadOnly( isReadOnly )
  31. {
  32. // Change the read-only state of the editor.
  33. // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setReadOnly
  34. editor.setReadOnly( isReadOnly );
  35. }
  36. //]]>
  37. </script>
  38. </head>
  39. <body>
  40. <h1 class="samples">
  41. CKEditor Sample &mdash; Using the CKEditor Read-Only API
  42. </h1>
  43. <div class="description">
  44. <p>
  45. This sample shows how to use the
  46. <code><a class="samples" href="http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setReadOnly">setReadOnly</a></code>
  47. API to put editor into the read-only state that makes it impossible for users to change the editor contents.
  48. </p>
  49. <p>
  50. For details on how to create this setup check the source code of this sample page.
  51. </p>
  52. </div>
  53. <!-- This <div> holds alert messages to be display in the sample page. -->
  54. <div id="alerts">
  55. <noscript>
  56. <p>
  57. <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
  58. support, like yours, you should still see the contents (HTML data) and you should
  59. be able to edit it normally, without a rich editor interface.
  60. </p>
  61. </noscript>
  62. </div>
  63. <form action="sample_posteddata.php" method="post">
  64. <p>
  65. <textarea class="ckeditor" id="editor1" name="editor1" cols="100" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
  66. </p>
  67. <p>
  68. <input id="readOnlyOn" onclick="toggleReadOnly();" type="button" value="Make it read-only" style="display:none" />
  69. <input id="readOnlyOff" onclick="toggleReadOnly( false );" type="button" value="Make it editable again" style="display:none" />
  70. </p>
  71. </form>
  72. <div id="footer">
  73. <hr />
  74. <p>
  75. CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
  76. </p>
  77. <p id="copy">
  78. Copyright &copy; 2003-2011, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
  79. Knabben. All rights reserved.
  80. </p>
  81. </div>
  82. </body>
  83. </html>