readonly.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <!DOCTYPE html>
  2. <!--
  3. Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  4. For licensing, see LICENSE.md or http://ckeditor.com/license
  5. -->
  6. <html>
  7. <head>
  8. <meta charset="utf-8">
  9. <title>Using the CKEditor Read-Only API &mdash; CKEditor Sample</title>
  10. <script src="../../ckeditor.js"></script>
  11. <link rel="stylesheet" href="sample.css">
  12. <script>
  13. var editor;
  14. // The instanceReady event is fired, when an instance of CKEditor has finished
  15. // its initialization.
  16. CKEDITOR.on( 'instanceReady', function( ev ) {
  17. editor = ev.editor;
  18. // Show this "on" button.
  19. document.getElementById( 'readOnlyOn' ).style.display = '';
  20. // Event fired when the readOnly property changes.
  21. editor.on( 'readOnly', function() {
  22. document.getElementById( 'readOnlyOn' ).style.display = this.readOnly ? 'none' : '';
  23. document.getElementById( 'readOnlyOff' ).style.display = this.readOnly ? '' : 'none';
  24. });
  25. });
  26. function toggleReadOnly( isReadOnly ) {
  27. // Change the read-only state of the editor.
  28. // http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-setReadOnly
  29. editor.setReadOnly( isReadOnly );
  30. }
  31. </script>
  32. </head>
  33. <body>
  34. <h1 class="samples">
  35. <a href="index.html">CKEditor Samples</a> &raquo; Using the CKEditor Read-Only API
  36. </h1>
  37. <div class="warning deprecated">
  38. This sample is not maintained anymore. Check out its <a href="http://sdk.ckeditor.com/samples/readonly.html">brand new version in CKEditor SDK</a>.
  39. </div>
  40. <div class="description">
  41. <p>
  42. This sample shows how to use the
  43. <code><a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-setReadOnly">setReadOnly</a></code>
  44. API to put editor into the read-only state that makes it impossible for users to change the editor contents.
  45. </p>
  46. <p>
  47. For details on how to create this setup check the source code of this sample page.
  48. </p>
  49. </div>
  50. <form action="sample_posteddata.php" method="post">
  51. <p>
  52. <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>
  53. </p>
  54. <p>
  55. <input id="readOnlyOn" onclick="toggleReadOnly();" type="button" value="Make it read-only" style="display:none">
  56. <input id="readOnlyOff" onclick="toggleReadOnly( false );" type="button" value="Make it editable again" style="display:none">
  57. </p>
  58. </form>
  59. <div id="footer">
  60. <hr>
  61. <p>
  62. CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
  63. </p>
  64. <p id="copy">
  65. Copyright &copy; 2003-2015, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
  66. Knabben. All rights reserved.
  67. </p>
  68. </div>
  69. </body>
  70. </html>