File: draghandlerreadonly.html

package info (click to toggle)
ckeditor 4.16.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 258,804 kB
  • sloc: javascript: 239,590; sh: 184; makefile: 64; python: 37; php: 15; xml: 5
file content (40 lines) | stat: -rw-r--r-- 883 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<div id="editor">
	<img src="../../../_assets/logo.png">
	<p>Some text</p>
</div>

<label><input id="readonly" type="checkbox">Editor readonly</label>

<script>
	// Drag & drop of widgets isn't supported on mobiles.
	if ( bender.tools.env.mobile ) {
		bender.ignore();
	}

	CKEDITOR.replace( 'editor', {
		on: {
			instanceReady: function() {
				var readonlyCheckBox = CKEDITOR.document.findOne( '#readonly' ),
					editor = this;

				setReadOnly();

				if ( CKEDITOR.env.ie && !CKEDITOR.env.edge ) {
					setInterval( function() {
						setReadOnly();
					}, 150 );
				} else {
					readonlyCheckBox.on( 'change', function() {
						setReadOnly( readonlyCheckBox.$.checked );
					} );
				}

				function setReadOnly() {
					if ( editor.readOnly !== readonlyCheckBox.$.checked ) {
						editor.setReadOnly( readonlyCheckBox.$.checked );
					}
				}
			}
		}
	} );
</script>