Skip to content

Commit 63a3f12

Browse files
TINY-11911: Added version checking for disabled option in the disabled demo.
1 parent 01ef601 commit 63a3f12

File tree

1 file changed

+44
-29
lines changed

1 file changed

+44
-29
lines changed

src/demo/html/disabled.html

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,56 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<meta charset="utf-8"/>
5-
<title>TinyMCE WebComponent Demo: Disabled and Readonly </title>
6-
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
7-
</head>
83

9-
<body>
10-
<script>
11-
function toggleDisabled() {
12-
var editor = document.getElementById('mody');
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>TinyMCE WebComponent Demo: Disabled and Readonly </title>
7+
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
8+
</head>
139

14-
if (!editor.hasAttribute('disabled')) {
15-
editor.setAttribute('disabled', '');
10+
<body>
11+
<script>
12+
13+
14+
function toggleDisabled() {
15+
var editor = document.getElementById('mody');
16+
const editorInstance = editor.get
17+
var version = tinymce.majorVersion + '.' + tinymce.minorVersion
18+
var isoldVersion = parseFloat(version) < 7.6
19+
if (isoldVersion) {
20+
if (!editor.hasAttribute('readonly')) {
21+
editor.setAttribute('readonly', '');
22+
} else {
23+
editor.removeAttribute('readonly');
24+
}
1625
} else {
17-
editor.removeAttribute('disabled');
26+
if (!editor.hasAttribute('disabled')) {
27+
editor.setAttribute('disabled', '')
28+
}
29+
else {
30+
editor.removeAttribute('disabled');
31+
}
1832
}
1933
}
2034

21-
function toggleReadonly() {
22-
var editor = document.getElementById('mody');
35+
function toggleReadonly() {
36+
var editor = document.getElementById('mody');
2337

24-
editor.removeAttribute('disabled');
25-
if (!editor.hasAttribute('readonly')) {
26-
editor.setAttribute('readonly', '');
27-
} else {
28-
editor.removeAttribute('readonly');
29-
}
38+
editor.removeAttribute('disabled');
39+
if (!editor.hasAttribute('readonly')) {
40+
editor.setAttribute('readonly', '');
41+
} else {
42+
editor.removeAttribute('readonly');
3043
}
31-
</script>
32-
<h2>TinyMCE WebComponent Demo: Disabled and Readonly</h2>
33-
<div id="ephox-ui">
34-
<button onclick="toggleDisabled()">Toggle disabled</button>
35-
<button onclick="toggleReadonly()">Toggle readonly</button>
36-
<tinymce-editor id="mody"></tinymce-editor>
37-
</div>
44+
}
45+
</script>
46+
<h2>TinyMCE WebComponent Demo: Disabled and Readonly</h2>
47+
<div id="ephox-ui">
48+
<button onclick="toggleDisabled()">Toggle disabled</button>
49+
<button onclick="toggleReadonly()">Toggle readonly</button>
50+
<tinymce-editor id="mody"></tinymce-editor>
51+
</div>
3852
<script src="../../../node_modules/tinymce/tinymce.js"></script>
3953
<script src="../../../dist/tinymce-webcomponent.js"></script>
40-
</body>
41-
</html>
54+
</body>
55+
56+
</html>

0 commit comments

Comments
 (0)