| 1 | <!DOCTYPE html> |
|---|
| 2 | <!-- |
|---|
| 3 | Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. |
|---|
| 4 | For licensing, see LICENSE.html or http://ckeditor.com/license |
|---|
| 5 | --> |
|---|
| 6 | <html> |
|---|
| 7 | <head> |
|---|
| 8 | <title>Replace Textarea by Code — CKEditor Sample</title> |
|---|
| 9 | <meta charset="utf-8"> |
|---|
| 10 | <script src="../ckeditor.js"></script> |
|---|
| 11 | <link href="sample.css" rel="stylesheet"> |
|---|
| 12 | </head> |
|---|
| 13 | <body> |
|---|
| 14 | <h1 class="samples"> |
|---|
| 15 | <a href="index.html">CKEditor Samples</a> » Replace Textarea Elements Using JavaScript Code |
|---|
| 16 | </h1> |
|---|
| 17 | <form action="sample_posteddata.php" method="post"> |
|---|
| 18 | <div class="description"> |
|---|
| 19 | <p> |
|---|
| 20 | This editor is using an <code><iframe></code> element-based editing area, provided by the <strong>Wysiwygarea</strong> plugin. |
|---|
| 21 | </p> |
|---|
| 22 | <pre class="samples"> |
|---|
| 23 | CKEDITOR.replace( '<em>textarea_id</em>' ) |
|---|
| 24 | </pre> |
|---|
| 25 | </div> |
|---|
| 26 | <textarea cols="80" id="editor1" name="editor1" rows="10"> |
|---|
| 27 | |
|---|
| 28 | </textarea> |
|---|
| 29 | <script> |
|---|
| 30 | |
|---|
| 31 | CKEDITOR.on('instanceReady', onCKEditorInstanceReady); |
|---|
| 32 | |
|---|
| 33 | function onCKEditorInstanceReady (event) |
|---|
| 34 | { |
|---|
| 35 | var editor = event.editor; |
|---|
| 36 | editor.on('focus', handleFocus); |
|---|
| 37 | editor.on('blur', handleBlur); |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | function handleBlur (event) |
|---|
| 41 | { |
|---|
| 42 | var editor = event.editor; |
|---|
| 43 | |
|---|
| 44 | var command = editor.getCommand( 'toolbarCollapse' ); |
|---|
| 45 | command.editorFocus = false; |
|---|
| 46 | command.exec.call(command, editor); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | function handleFocus (event) |
|---|
| 50 | { |
|---|
| 51 | var editor = event.editor; |
|---|
| 52 | |
|---|
| 53 | var command = editor.getCommand( 'toolbarCollapse' ); |
|---|
| 54 | command.editorFocus = false; |
|---|
| 55 | command.exec.call(command, editor); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | // This call can be placed at any point after the |
|---|
| 61 | // <textarea>, or inside a <head><script> in a |
|---|
| 62 | // window.onload event handler. |
|---|
| 63 | |
|---|
| 64 | // Replace the <textarea id="editor"> with an CKEditor |
|---|
| 65 | // instance, using default configurations. |
|---|
| 66 | |
|---|
| 67 | CKEDITOR.replace( 'editor1', { |
|---|
| 68 | toolbarCanCollapse : true, |
|---|
| 69 | toolbarStartupExpanded : false |
|---|
| 70 | } ); |
|---|
| 71 | |
|---|
| 72 | </script> |
|---|
| 73 | <p> |
|---|
| 74 | <input type="submit" value="Submit"> |
|---|
| 75 | </p> |
|---|
| 76 | </form> |
|---|
| 77 | <div id="footer"> |
|---|
| 78 | <hr> |
|---|
| 79 | <p> |
|---|
| 80 | CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a> |
|---|
| 81 | </p> |
|---|
| 82 | <p id="copy"> |
|---|
| 83 | Copyright © 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico |
|---|
| 84 | Knabben. All rights reserved. |
|---|
| 85 | </p> |
|---|
| 86 | </div> |
|---|
| 87 | </body> |
|---|
| 88 | </html> |
|---|