-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdemo.html
196 lines (174 loc) · 7 KB
/
demo.html
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title>Knockout TinyMCE</title>
<link rel='stylesheet' type='text/css' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'>
<link rel="stylesheet" type='text/css' href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
<script src='http://code.jquery.com/jquery-2.1.1.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js'></script>
<script src='demo/tinymce/tinymce.js'></script>
<script src='knockout-tinymce.min.js'></script>
<link href='demo/style.css' type='text/css' rel='stylesheet'></link>
<script type='text/javascript'>
function rebindView3() {
var element = document.querySelector('#example-3-result');
ko.cleanNode(element);
ko.applyBindings(view3, element);
}
$(function() {
// Example 1
window.view1 = {
string_of_html: ko.observable()
};
ko.applyBindings(view1, document.querySelector('#example-1-result'));
// Example 2
window.view2 = {
string_of_html: ko.observable("<strong>click on me!</strong>")
};
ko.applyBindings(view2, document.querySelector('#example-2-result'));
// Example 3
window.view3 = {
string_of_html: null
};
ko.applyBindings(view3, document.querySelector('#example-3-result'));
});
</script>
</head>
<body>
<div class='container'>
<div class='header'>
<ul class='nav nav-pills pull-right'>
<li class='active'><a href="#">Demo</a></li>
<li><a href='https://github.com/immense/knockout-tinymce'>Code</a></li>
</ul>
<h3 class='text-muted'>Knockout TinyMCE</h3>
</div>
<div class='jumbotron'>
<h1>Knockout TinyMCE Demo</h1>
</div>
<div class='row'>
<!--
### Example 1 ###
-->
<div class='col-md-12'>
<h2><a href="#simple-example" name="simple-example">§</a> Simple example</h2>
<section id="simple-example-section">
<p>Use the <code>tinymce</code> binding on any <code>textarea</code> element.</p>
<label>View Model:</label>
<pre>window.view1 = {
string_of_html: ko.observable()
};
ko.applyBindings(view1, document.querySelector('#example-1-result'));</pre>
<label>Markup:</label>
<pre><section id='example-1-result'>
<textarea data-bind='tinymce: string_of_html'>
</section></pre>
<h3>Result:</h3>
<section id='example-1-result'>
<textarea id='string-of-html' class='form-control' data-bind="tinymce: string_of_html"></textarea>
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-3">Value</label>
<div class="col-sm-9">
<p class="form-control-static" data-bind="text: string_of_html"></p>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3">Value (as html)</label>
<div class="col-sm-9">
<p class="form-control-static" data-bind="html: string_of_html"></p>
</div>
</div>
</div>
</section>
</section>
</div>
<!--
### Example 2 ###
-->
<div class='col-md-12'>
<h2><a href="#options-example" name="options-example">§</a> Example with options</h2>
<section id="options-example-section">
<p>
You can also pass options via the <code>tinymceConfig</code> binding.
</p>
<label>View Model:</label>
<pre>window.view2 = {
string_of_html: ko.observable("<strong>click on me!</strong>")
};
ko.applyBindings(view2, document.querySelector('#example-2-result'));</pre>
<label>Markup:</label>
<pre><section id='example-2-result'>
<div data-bind='tinymce: string_of_html, tinymceConfig: { inline: true }'><div>
</section></pre>
<h3>Result:</h3>
<section id='example-2-result'>
<div data-bind="tinymce: string_of_html, tinymceConfig: { inline: true }"></div>
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-3">Value</label>
<div class="col-sm-9">
<p class="form-control-static" data-bind="text: string_of_html"></p>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3">Value (as html)</label>
<div class="col-sm-9">
<p class="form-control-static" data-bind="html: string_of_html"></p>
</div>
</div>
</div>
</section>
</section>
</div>
<!--
### Example 3 ###
-->
<div class='col-md-12'>
<h2><a href="#non-observable-binding" name="non-observable-binding">§</a> Example with non-observable</h2>
<section id="non-observable-binding-section">
<p>
The <code>tynemce</code> binding can also bind to non-observable properties.
</p>
<label>View Model:</label>
<pre>window.view3 = {
string_of_html: null
};
ko.applyBindings(view3, document.querySelector('#example-3-result'));</pre>
<label>Markup:</label>
<pre><section id='example-3-result'>
<div data-bind='tinymce: string_of_html'><div>
</section></pre>
<label>Note:</label>
<p>
Because <code>view3.string_of_html</code> is not observable, the displayed value won't update automatically, so you'll need to <button type="button" class="btn btn-xs btn-info" onclick="rebindView3()">rebind view3</button> to update the value (unless you use something like <a href="http://blog.stevensanderson.com/2013/05/20/knockout-es5-a-plugin-to-simplify-your-syntax/">Knockout-ES5</a>).
</p>
<h3>Result:</h3>
<section id='example-3-result'>
<div data-bind="tinymce: string_of_html"></div>
<div class="form-horizontal">
<div class="form-group">
<label class="control-label col-sm-3">Value</label>
<div class="col-sm-9">
<p class="form-control-static" data-bind="text: string_of_html"></p>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3">Value (as html)</label>
<div class="col-sm-9">
<p class="form-control-static" data-bind="html: string_of_html"></p>
</div>
</div>
</div>
</section>
</section>
</div>
</div>
<div class='footer'>
<p>© Immense Networks 2016</p>
</div>
</div>
</body>
</html>