forked from Alex-D/Trumbowyg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
287 lines (258 loc) · 12.1 KB
/
index.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Trumbowyg by Alex-D</title>
<link rel="stylesheet" href="examples/css/main.css">
<link rel="stylesheet" href="dist/ui/trumbowyg.css">
<link rel="stylesheet" href="dist/plugins/colors/ui/trumbowyg.colors.css">
</head>
<body>
<div id="main" role="main">
<header>
<h1>Examples of use Trumbowyg</h1>
<p>
Close an editor on clic on "Close" in top right corner. <br>
To reopen an editor, double-click on his text.
</p>
</header>
<form action="#">
<div id="default-editor">
<h2>This editor is the default build of Trumbowyg.</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus, aliquam, minima fugiat placeat provident optio nam reiciendis eius beatae quibusdam!
</p>
<p>
The text is derived from Cicero's De Finibus Bonorum et Malorum (On the Ends of Goods and Evils, or alternatively [About] The Purposes of Good and Evil ). The original passage began: Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit (Translation: "Neither is there anyone who loves grief itself since it is grief and thus wants to obtain it").
</p>
<code><pre>
$('#default-editor').trumbowyg();
</pre></code>
</div>
<div id="simple-editor">
<h2>This is a minimalist demo of Trumbowyg.</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus, aliquam, minima fugiat placeat provident optio nam reiciendis eius beatae quibusdam!
</p>
<code><pre>
$('#simple-editor').trumbowyg({
btns: [jQuery.trumbowyg.btnsGrps.semantic]
});
</pre></code>
</div>
<div id="customized-buttonpane">
<h2>This is a demo of Trumbowyg with a customized button pane</h2>
<p>
The text is derived from Cicero's De Finibus Bonorum et Malorum (On the Ends of Goods and Evils, or alternatively [About] The Purposes of Good and Evil ). The original passage began: Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit (Translation: "Neither is there anyone who loves grief itself since it is grief and thus wants to obtain it").
</p>
<p style="text-align: center;">
<img src="http://alex-d.github.io/Trumbowyg/img/logo-tbw.png" alt="Trumbowyg logo">
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dignissimos, minima, asperiores libero architecto sequi fugit dolore sunt in officiis facere ut quaerat ullam laudantium delectus aliquam tenetur alias! Ea, nisi, est earum temporibus dolores quas qui repellendus aliquid voluptatibus tempore facilis eligendi omnis reiciendis nihil ullam quo dolorem nam deleniti. Fugit dignissimos dolorum dolore voluptate repudiandae recusandae debitis. Neque, adipisci, maiores magni aliquam molestiae ex natus minus quod tempora nemo debitis eum laboriosam voluptatum ut architecto animi nobis vero quis dolore eaque! Corporis, dolore, illum, autem in eum ea doloribus ut consequuntur modi et ullam adipisci blanditiis corrupti ab voluptate.
</p>
<p>
It is not known exactly when the text acquired its current standard form; it may have been as late as the 1960s. The passage was discovered by Richard McClintock, a Latin scholar who is the publications director at Hampden-Sydney College in Virginia, by searching for citings of the rarely used word 'consectetur' in classical literature.
</p>
<code><pre>
/*
* Add your own groups of button
*/
$.trumbowyg.btnsGrps.test = ['bold', 'link'];
/* Add new words for customs btnsDef just below */
$.extend(true, $.trumbowyg.langs, {
fr: {
align: 'Alignement',
image: 'Image'
}
});
$('#customized-buttonpane').trumbowyg({
lang: 'fr',
closable: true,
fixedBtnPane: true,
btnsDef: {
// Customizables dropdowns
align: {
dropdown: ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
ico: 'justifyLeft'
},
image: {
dropdown: ['insertImage', 'upload', 'base64'],
ico: 'insertImage'
}
},
btns: ['viewHTML',
'|', 'formatting',
'|', 'btnGrp-test',
'|', 'align',
'|', 'btnGrp-lists',
'|', 'image']
});
</pre></code>
</div>
<textarea id="form-content" cols="30" rows="10" required>
<h1>This editor is create from a textarea</h1>
<p>
Even though using "lorem ipsum" often arouses curiosity due to its resemblance to classical Latin, it is not intended to have meaning. Where text is visible in a document, people tend to focus on the textual content rather than upon overall presentation, so publishers use lorem ipsum when displaying a typeface or design in order to direct the focus to presentation. "Lorem ipsum" also approximates a typical distribution of spaces in English. <br>
The most common lorem ipsum text reads as follows: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<code><pre>
$('#form-content').trumbowyg({
lang: 'fr',
closable: true,
mobile: true,
fixedBtnPane: true,
fixedFullWidth: true,
semantic: true,
resetCss: true,
autoAjustHeight: true,
autogrow: true
});
</pre></code>
</textarea>
<div id="dynamic-iframe-example"></div>
<textarea id="placeholder-editor" cols="30" rows="10" placeholder="This is a placeholder..." required></textarea>
<button type="submit">Submit</button>
</form>
</div>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="dist/trumbowyg.js"></script>
<script src="dist/langs/fr.min.js"></script>
<script src="dist/plugins/upload/trumbowyg.upload.js"></script>
<script src="dist/plugins/base64/trumbowyg.base64.js"></script>
<script src="dist/plugins/colors/trumbowyg.colors.js"></script>
<script>
/** Default editor configuration **/
$('#default-editor')
.trumbowyg()
.on('dblclick', function(){
$(this).trumbowyg();
})
.on('tbwfocus tbwblur tbwchange tbwresize tbwpaste tbwclose', function(e){
console.log(e.type);
});
/** Default editor configuration **/
$('#simple-editor')
.trumbowyg({
btns: ['btnGrp-semantic']
})
.on('dblclick', function(){
$(this).trumbowyg();
});
/********************************************************
* Customized button pane + buttons groups + dropdowns
* Use upload and base64 plugins
*******************************************************/
/*
* Add your own groups of button
*/
$.trumbowyg.btnsGrps.test = ['bold', 'link'];
/* Add new words for customs btnsDef just below */
$.extend(true, $.trumbowyg.langs, {
fr: {
align: 'Alignement',
image: 'Image'
}
});
var customizedButtonPaneTbwOptions = {
lang: 'fr',
closable: true,
fixedBtnPane: true,
btnsDef: {
// Customizables dropdowns
align: {
dropdown: ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
ico: 'justifyLeft'
},
image: {
dropdown: ['insertImage', 'upload', 'base64'],
ico: 'insertImage'
}
},
btns: ['viewHTML',
'|', 'formatting',
'|', 'btnGrp-test',
'|', 'align',
'|', 'btnGrp-lists',
'|', 'image',
'|', 'foreColor', 'backColor']
};
$('#customized-buttonpane')
.trumbowyg(customizedButtonPaneTbwOptions)
.on('dblclick', function(){
$(this).trumbowyg(customizedButtonPaneTbwOptions);
});
/** Simple customization with current options **/
var formTbwOptions = {
lang: 'fr',
closable: true,
mobile: true,
fixedBtnPane: true,
fixedFullWidth: true,
semantic: true,
resetCss: true,
removeformatPasted: true,
autogrow: true,
btnsDef: {
strong: {
func: 'bold',
key: 'G'
}
}
};
$('#form-content')
.trumbowyg(formTbwOptions)
.on('dblclick', function(){
$(this).trumbowyg(formTbwOptions);
});
/** Dynamic Iframe **/
// Create the iframe element.
var $iframe = $('<iframe/>').css({
width: '100%',
height: 400,
border: 0
});
$('#dynamic-iframe-example').append($iframe);
// Get the document of the iframe.
var $editor = $('<div>', {
id: 'editor'
}).html(
'<h2>This is within an iframe</h2> <p>Soc'
+ 'tempor pulvinar ac ultricies, placerat in, elementum,'
+ 'adipiscing pid, mid augue pulvinar eros nisi! In magn'
+ 'magnis. Porttitor platea turpis nisi. Pulvinar massa,'
+ ' habitasse <strong>a nunc rhoncus adipiscing</strong></p>'),
optionTbwIframe = {
closable: true,
fullscreenable: false
};
setTimeout(function(){
var contextIframe = $iframe.contents()[0];
// Set the style on the head of the iframe.
$('head', contextIframe).append($('<link>', {
href: 'dist/ui/trumbowyg.css',
rel: 'stylesheet'
}));
// Set the content to be editable.
$('body', contextIframe).append($editor);
$editor
.trumbowyg(optionTbwIframe)
.on('dblclick', function(){
$(this).trumbowyg(optionTbwIframe);
});
}, 500);
/** Editor with placeholder **/
$('#placeholder-editor')
.trumbowyg()
.on('dblclick', function(){
$(this).trumbowyg();
})
.on('tbwfocus', function(){
console.log('focus event fired');
})
.on('tbwblur', function(){
console.log('blur event fired');
});
</script>
</body>
</html>