You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.6 KiB

  1. <!DOCTYPE html>
  2. <!--
  3. Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
  4. For licensing, see LICENSE.md or http://ckeditor.com/license
  5. -->
  6. <html>
  7. <head>
  8. <title>Using the CKEditor Read-Only API &mdash; CKEditor Sample</title>
  9. <meta charset="utf-8">
  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="description">
  38. <p>
  39. This sample shows how to use the
  40. <code><a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-setReadOnly">setReadOnly</a></code>
  41. API to put editor into the read-only state that makes it impossible for users to change the editor contents.
  42. </p>
  43. <p>
  44. For details on how to create this setup check the source code of this sample page.
  45. </p>
  46. </div>
  47. <form action="sample_posteddata.php" method="post">
  48. <p>
  49. <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>
  50. </p>
  51. <p>
  52. <input id="readOnlyOn" onclick="toggleReadOnly();" type="button" value="Make it read-only" style="display:none">
  53. <input id="readOnlyOff" onclick="toggleReadOnly( false );" type="button" value="Make it editable again" style="display:none">
  54. </p>
  55. </form>
  56. <div id="footer">
  57. <hr>
  58. <p>
  59. CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
  60. </p>
  61. <p id="copy">
  62. Copyright &copy; 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
  63. Knabben. All rights reserved.
  64. </p>
  65. </div>
  66. </body>
  67. </html>