scratch – Blame information for rev 93

Subversion Repositories:
Rev:
Rev Author Line No. Line
58 office 1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="UTF-8">
5 <title>Trumbowyg by Alex-D</title>
6 <base href="/test/base/url/">
7 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
8 <link rel="stylesheet" href="/examples/css/main.css">
9 <link rel="stylesheet" href="/dist/ui/trumbowyg.css">
10 <link rel="stylesheet" href="/dist/plugins/colors/ui/trumbowyg.colors.css">
11 </head>
12 <body>
13 <div class="container">
14 <header>
15 <h1>Examples of use Trumbowyg</h1>
16  
17 <p>
18 Close an editor on clic on "Close" in top right corner. <br>
19 To reopen an editor, double-click on his text.
20 </p>
21 </header>
22  
23 <div id="default-editor">
24 <h2>This editor is the default build of Trumbowyg.</h2>
25 <p>
26 Lorem ipsum dolor sit amet, <a href="https://alex-d.github.io/Trumbowyg/">consectetur adipisicing</a> elit. Possimus, aliquam, minima fugiat placeat provident optio nam reiciendis eius beatae quibusdam!
27 </p>
28 <p>
29 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: &quot;Neither is there anyone who loves grief itself since it is grief and thus wants to obtain it&quot;).
30 </p>
31 <code><pre>
32 $('#default-editor').trumbowyg();
33 </pre></code>
34 </div>
35  
36 <div id="simple-editor">
37 <h2>This is a minimalist demo of Trumbowyg.</h2>
38 <p>
39 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus, aliquam, minima fugiat placeat provident optio nam reiciendis eius beatae quibusdam!
40 </p>
41 <code><pre>
42 $('#simple-editor').trumbowyg({
43 btns: [jQuery.trumbowyg.btnsGrps.semantic]
44 });
45 </pre></code>
46 </div>
47  
48 <div id="flat-buttonpane">
49 <h2>All buttons of Trumbowyg are here.</h2>
50 <p>
51 Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus, aliquam, minima fugiat placeat provident optio nam reiciendis eius beatae quibusdam!
52 </p>
53 <code><pre>
54 $('#simple-editor').trumbowyg({
55 btns: [jQuery.trumbowyg.btnsGrps.semantic]
56 });
57 </pre></code>
58 </div>
59  
60 <div id="customized-buttonpane">
61 <h2>This is a demo of Trumbowyg with a customized button pane</h2>
62 <p>
63 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: &quot;Neither is there anyone who loves grief itself since it is grief and thus wants to obtain it&quot;).
64 </p>
65 <p style="text-align: center;">
66 <img src="https://raw.githubusercontent.com/Alex-D/Trumbowyg/develop/banner.png" alt="Trumbowyg logo">
67 </p>
68 <p>
69 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.
70 </p>
71 <p>
72 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.
73 </p>
74 <code><pre>
75 /* Add new words for customs btnsDef just below */
76 $.extend(true, $.trumbowyg.langs, {
77 fr: {
78 align: 'Alignement',
79 image: 'Image'
80 }
81 });
82 $('#customized-buttonpane').trumbowyg({
83 lang: 'fr',
84 fixedBtnPane: true,
85 btnsDef: {
86 // Customizables dropdowns
87 align: {
88 dropdown: ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
89 ico: 'justifyLeft'
90 },
91 image: {
92 dropdown: ['insertImage', 'upload', 'base64'],
93 ico: 'insertImage'
94 }
95 },
96 btns: ['viewHTML',
97 ['formatting'],
98 ['btnGrp-test'],
99 ['align'],
100 ['btnGrp-lists'],
101 ['image'],
102 ['preformatted'],
103 'fullscreen', 'close']
104 });
105 </pre></code>
106 </div>
107  
108 <textarea id="form-content" cols="30" rows="10" required>
109 <h1>This editor is create from a textarea</h1>
110 <p>
111 Even though using &quot;lorem ipsum&quot; 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. &quot;Lorem ipsum&quot; also approximates a typical distribution of spaces in English. <br>
112 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.
113 </p>
114 <code><pre>
115 $('#form-content').trumbowyg({
116 lang: 'fr',
117 mobile: true,
118 fixedBtnPane: true,
119 fixedFullWidth: true,
120 semantic: true,
121 resetCss: true,
122 autoAjustHeight: true,
123 autogrow: true,
124 btnsAdd: ['close']
125 });
126 </pre></code>
127 </textarea>
128  
129 <textarea id="empty-textarea" cols="30" rows="10" required></textarea>
130  
131 <textarea id="disabled-textarea" cols="30" rows="10" disabled>
132 Disabled textarea
133 </textarea>
134 <button id="enable-disabled-textarea">Enable</button>
135 <button id="disable-disabled-textarea">Disable</button>
136  
137 <div id="dynamic-iframe-example"></div>
138 </div>
139  
140 <div class="dark-section">
141 <div class="container">
142 <form action="#">
143 <h2 class="title">The dark side of Trumbowyg</h2>
144  
145 <div class="trumbowyg-dark">
146 <textarea id="placeholder-editor" cols="30" rows="10" placeholder="This is a placeholder..." required></textarea>
147 </div>
148  
149 <button type="submit" class="form-submit">Submit</button>
150 </form>
151 </div>
152 </div>
153 <script src="/bower_components/jquery/dist/jquery.min.js"></script>
154 <script src="/dist/trumbowyg.js"></script>
155 <script src="/dist/langs/fr.min.js"></script>
156 <script src="/dist/plugins/base64/trumbowyg.base64.js"></script>
157 <script src="/dist/plugins/colors/trumbowyg.colors.js"></script>
158 <script src="/dist/plugins/noembed/trumbowyg.noembed.js"></script>
159 <script src="/dist/plugins/pasteimage/trumbowyg.pasteimage.js"></script>
160 <script src="/dist/plugins/preformatted/trumbowyg.preformatted.js"></script>
161 <script src="/dist/plugins/upload/trumbowyg.upload.js"></script>
162 <script>
163  
164 $(document).on('keydown', function (e) {
165 if (e.which === 27) {
166 console.log('ESCAPE');
167 }
168 });
169  
170  
171 /** Default editor configuration **/
172 $('#default-editor, #empty-textarea, #disabled-textarea')
173 .trumbowyg()
174 .on('dblclick', function(){
175 $(this).trumbowyg();
176 })
177 .on('tbwinit tbwfocus tbwblur tbwchange tbwresize tbwpaste tbwopenfullscreen tbwclosefullscreen tbwclose', function(e){
178 console.log(e.type);
179 });
180  
181 $('#enable-disabled-textarea').click(function () {
182 $('#disabled-textarea').trumbowyg('enable');
183 });
184 $('#disable-disabled-textarea').click(function () {
185 $('#disabled-textarea').trumbowyg('disable');
186 });
187  
188  
189 /** Default editor configuration **/
190 $('#simple-editor')
191 .trumbowyg({
192 btns: ['btnGrp-semantic']
193 })
194 .on('dblclick', function(){
195 $(this).trumbowyg();
196 });
197  
198  
199 /* Add imagur parameters to upload plugin */
200 var uploadOptions = {
201 serverPath: 'https://api.imgur.com/3/image',
202 fileFieldName: 'image',
203 headers: {'Authorization': 'Client-ID 9e57cb1c4791cea'},
204 urlPropertyName: 'data.link'
205 };
206  
207 /** Full flat button pane **/
208 $('#flat-buttonpane')
209 .trumbowyg({
210 btns: [
211 ['viewHTML'],
212 ['p', 'blockquote', 'h1', 'h2', 'h3', 'h4'],
213 ['strong', 'em', 'underline', 'del'],
214 ['superscript', 'subscript'],
215 ['createLink', 'unlink'],
216 ['insertImage'],
217 ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
218 ['unorderedList', 'orderedList'],
219 ['horizontalRule'],
220 ['removeformat'],
221  
222 ['upload', 'base64', 'noembed'],
223 ['foreColor', 'backColor'],
224 ['preformatted'],
225 ['fullscreen', 'close']
226 ],
227 plugins: {
228 upload: uploadOptions
229 }
230 });
231  
232  
233 /********************************************************
234 * Customized button pane + buttons groups + dropdowns
235 * Use upload and base64 plugins
236 *******************************************************/
237  
238 /* Add new words for customs btnsDef just below */
239 $.extend(true, $.trumbowyg.langs, {
240 fr: {
241 align: 'Alignement',
242 image: 'Image'
243 }
244 });
245 var customizedButtonPaneTbwOptions = {
246 lang: 'fr',
247 fixedBtnPane: true,
248 btnsGrps: {
249 test: ['strong', 'em'] // Custom nammed group
250 },
251 btnsDef: {
252 // Customizables dropdowns
253 align: {
254 dropdown: ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
255 ico: 'justifyLeft'
256 },
257 image: {
258 dropdown: ['insertImage', 'upload', 'base64', 'noembed'],
259 ico: 'insertImage'
260 }
261 },
262 btns: [
263 ['viewHTML'],
264 ['formatting'],
265 'btnGrp-test',
266 ['align'],
267 'btnGrp-lists',
268 ['image'],
269 ['foreColor', 'backColor'],
270 ['preformatted'],
271 ['fullscreen', 'close']
272 ]
273 };
274 $('#customized-buttonpane')
275 .trumbowyg(customizedButtonPaneTbwOptions)
276 .on('dblclick', function(){
277 $(this).trumbowyg(customizedButtonPaneTbwOptions);
278 });
279  
280  
281  
282 /** Simple customization with current options **/
283 var formTbwOptions = {
284 lang: 'fr',
285 mobile: true,
286 fixedBtnPane: true,
287 fixedFullWidth: true,
288 semantic: true,
289 resetCss: true,
290 removeformatPasted: true,
291 tagsToRemove: ['script', 'style'],
292  
293 autogrow: true,
294  
295 btnsDef: {
296 strong: {
297 fn: 'bold',
298 key: 'G'
299 }
300 },
301 btnsAdd: ['close']
302 };
303 $('#form-content')
304 .trumbowyg(formTbwOptions)
305 .on('dblclick', function(){
306 $(this).trumbowyg(formTbwOptions);
307 });
308  
309  
310  
311 /** Dynamic Iframe **/
312  
313 // Create the iframe element.
314 var $iframe = $('<iframe/>').css({
315 width: '100%',
316 height: 400,
317 border: 0
318 });
319 $('#dynamic-iframe-example').append($iframe);
320 // Get the document of the iframe.
321 var $editor = $('<div>', {
322 id: 'editor'
323 }).html(
324 '<h2>This is within an iframe</h2> <p>Soc'
325 + 'tempor pulvinar ac ultricies, placerat in, elementum,'
326 + 'adipiscing pid, mid augue pulvinar eros nisi! In magn'
327 + 'magnis. Porttitor platea turpis nisi. Pulvinar massa,'
328 + ' habitasse <strong>a nunc rhoncus adipiscing</strong></p>');
329  
330 setTimeout(function(){
331 var contextIframe = $iframe.contents()[0];
332 // Set the style on the head of the iframe.
333 $('head', contextIframe).append($('<link>', {
334 href: '/dist/ui/trumbowyg.css',
335 rel: 'stylesheet'
336 }));
337 // Set the content to be editable.
338 $('body', contextIframe).append($editor);
339  
340 $editor
341 .trumbowyg()
342 .on('dblclick', function(){
343 $(this).trumbowyg();
344 });
345 }, 500);
346  
347  
348 /** Editor with placeholder **/
349 $('#placeholder-editor')
350 .trumbowyg()
351 .on('dblclick', function(){
352 $(this).trumbowyg();
353 })
354 .on('tbwfocus', function(){
355 console.log('focus event fired');
356 })
357 .on('tbwblur', function(){
358 console.log('blur event fired');
359 });
360 </script>
361 </body>
362 </html>