| 776 |
lars |
1 |
<!DOCTYPE html>
|
|
|
2 |
<!--
|
|
|
3 |
Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved.
|
|
|
4 |
For licensing, see LICENSE.md or http://ckeditor.com/license
|
|
|
5 |
-->
|
|
|
6 |
<html>
|
|
|
7 |
|
|
|
8 |
<head>
|
|
|
9 |
<meta charset="utf-8">
|
|
|
10 |
<title>Using the CKEditor Read-Only API — CKEditor Sample</title>
|
|
|
11 |
<script src="../ckeditor.js"></script>
|
|
|
12 |
<link rel="stylesheet" href="sample.css">
|
|
|
13 |
<script>
|
|
|
14 |
var editor;
|
|
|
15 |
// The instanceReady event is fired, when an instance of CKEditor has finished
|
|
|
16 |
// its initialization.
|
|
|
17 |
CKEDITOR.on('instanceReady', function(ev)
|
|
|
18 |
{
|
|
|
19 |
editor = ev.editor;
|
|
|
20 |
// Show this "on" button.
|
|
|
21 |
document.getElementById('readOnlyOn').style.display = '';
|
|
|
22 |
// Event fired when the readOnly property changes.
|
|
|
23 |
editor.on('readOnly', function()
|
|
|
24 |
{
|
|
|
25 |
document.getElementById('readOnlyOn').style.display = this.readOnly ? 'none' : '';
|
|
|
26 |
document.getElementById('readOnlyOff').style.display = this.readOnly ? '' : 'none';
|
|
|
27 |
});
|
|
|
28 |
});
|
|
|
29 |
|
|
|
30 |
function toggleReadOnly(isReadOnly)
|
|
|
31 |
{
|
|
|
32 |
// Change the read-only state of the editor.
|
|
|
33 |
// http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-setReadOnly
|
|
|
34 |
editor.setReadOnly(isReadOnly);
|
|
|
35 |
}
|
|
|
36 |
</script>
|
|
|
37 |
</head>
|
|
|
38 |
|
|
|
39 |
<body>
|
|
|
40 |
<h1 class="samples">
|
|
|
41 |
<a href="index.html">CKEditor Samples</a> » Using the CKEditor Read-Only API </h1>
|
|
|
42 |
<div class="description">
|
|
|
43 |
<p> This sample shows how to use the <code><a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-setReadOnly">setReadOnly</a></code> API to put editor into the read-only state that makes it impossible for users to change
|
|
|
44 |
the editor contents. </p>
|
|
|
45 |
<p> For details on how to create this setup check the source code of this sample page. </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"><p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p></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"> </p>
|
|
|
54 |
</form>
|
|
|
55 |
<div id="footer">
|
|
|
56 |
<hr>
|
|
|
57 |
<p> CKEditor - The text editor for the Internet -
|
|
|
58 |
<a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
|
|
|
59 |
</p>
|
|
|
60 |
<p id="copy"> Copyright © 2003-2014,
|
|
|
61 |
<a class="samples" href="http://cksource.com/">CKSource</a> - Frederico Knabben. All rights reserved. </p>
|
|
|
62 |
</div>
|
|
|
63 |
</body>
|
|
|
64 |
|
|
|
65 |
</html>
|