Ticket #9290: readonly2.html

File readonly2.html, 3.7 KB (added by Jakub Ś, 12 years ago)
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<!--
3Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
4For 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
16var editor;
17
18// The instanceReady event is fired, when an instance of CKEditor has finished
19// its initialization.
20CKEDITOR.on( 'instanceReady', function( ev )
21        {
22                editor = ev.editor;
23
24                // Show this "on" button.
25                document.getElementById( 'readOnlyOff' ).style.display = '';
26
27                // Event fired when the readOnly property changes.
28                editor.on( 'readOnly', function()
29                        {
30                                document.getElementById( 'readOnlyOn' ).style.display = this.readOnly ? 'none' : '';
31                                document.getElementById( 'readOnlyOff' ).style.display = this.readOnly ? '' : 'none';
32                        });
33        });
34
35function toggleReadOnly( isReadOnly )
36{
37        // Change the read-only state of the editor.
38        // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setReadOnly
39        editor.setReadOnly( isReadOnly );
40}
41
42        //]]>
43        </script>
44
45</head>
46<body>
47        <h1 class="samples">
48                CKEditor Sample &mdash; Using the CKEditor Read-Only API
49        </h1>
50        <div class="description">
51        <p>
52                This sample shows how to use the
53                <code><a class="samples" href="http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setReadOnly">setReadOnly</a></code>
54                API to put editor into the read-only state that makes it impossible for users to change the editor contents.
55        </p>
56        <p>
57                For details on how to create this setup check the source code of this sample page.
58        </p>
59        </div>
60
61        <!-- This <div> holds alert messages to be display in the sample page. -->
62        <div id="alerts">
63                <noscript>
64                        <p>
65                                <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
66                                support, like yours, you should still see the contents (HTML data) and you should
67                                be able to edit it normally, without a rich editor interface.
68                        </p>
69                </noscript>
70        </div>
71        <form action="sample_posteddata.php" method="post">
72                <p>
73                        <textarea id="editor2" name="editor2" 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>
74                        <script type="text/javascript">
75                        //<![CDATA[
76
77                                // This call can be placed at any point after the
78                                // <textarea>, or inside a <head><script> in a
79                                // window.onload event handler.
80
81                                // Replace the <textarea id="editor"> with an CKEditor
82                                // instance, using default configurations.
83                                CKEDITOR.replace( 'editor2', {readOnly : true} );
84                        //]]>
85                        </script>
86                </p>
87                <p>
88                        <input id="readOnlyOn" onclick="toggleReadOnly();" type="button" value="Make it read-only" style="display:none" />
89                        <input id="readOnlyOff" onclick="toggleReadOnly( false );" type="button" value="Make it editable again" style="display:none" /> <!---->
90                </p>
91        </form>
92        <div id="footer">
93                <hr />
94                <p>
95                        CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
96                </p>
97                <p id="copy">
98                        Copyright &copy; 2003-2012, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
99                        Knabben. All rights reserved.
100                </p>
101        </div>
102</body>
103</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy