JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
0cd8ce8b68edd7778ea9ef35fd73cd4e1d0600c4
[ckeditor.git] / _samples / ajax.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
2 <!--\r
3 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
4 For licensing, see LICENSE.html or http://ckeditor.com/license\r
5 -->\r
6 <html xmlns="http://www.w3.org/1999/xhtml">\r
7 <head>\r
8         <title>Ajax - CKEditor Sample</title>\r
9         <meta content="text/html; charset=utf-8" http-equiv="content-type" />\r
10         <script type="text/javascript" src="../ckeditor.js"></script>\r
11         <script src="sample.js" type="text/javascript"></script>\r
12         <link href="sample.css" rel="stylesheet" type="text/css" />\r
13         <script type="text/javascript">\r
14         //<![CDATA[\r
15 \r
16 var editor;\r
17 \r
18 function createEditor()\r
19 {\r
20         if ( editor )\r
21                 return;\r
22 \r
23         var html = document.getElementById( 'editorcontents' ).innerHTML;\r
24 \r
25         // Create a new editor inside the <div id="editor">\r
26         editor = CKEDITOR.appendTo( 'editor' );\r
27         editor.setData( html );\r
28 \r
29         // This sample may break here if the ckeditor_basic.js is used. In such case, the following code should be used instead:\r
30         /*\r
31         if ( editor.setData )\r
32                 editor.setData( html );\r
33         else\r
34         {\r
35                 CKEDITOR.on( 'loaded', function()\r
36                         {\r
37                                 editor.setData( html );\r
38                         });\r
39         }\r
40         */\r
41 }\r
42 \r
43 function removeEditor()\r
44 {\r
45         if ( !editor )\r
46                 return;\r
47 \r
48         // Retrieve the editor contents. In an Ajax application, this data would be\r
49         // sent to the server or used in any other way.\r
50         document.getElementById( 'editorcontents' ).innerHTML = editor.getData();\r
51         document.getElementById( 'contents' ).style.display = '';\r
52 \r
53         // Destroy the editor.\r
54         editor.destroy();\r
55         editor = null;\r
56 }\r
57 \r
58         //]]>\r
59         </script>\r
60 </head>\r
61 <body>\r
62         <h1>\r
63                 CKEditor Sample\r
64         </h1>\r
65         <!-- This <div> holds alert messages to be display in the sample page. -->\r
66         <div id="alerts">\r
67                 <noscript>\r
68                         <p>\r
69                                 <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript\r
70                                 support, like yours, you should still see the contents (HTML data) and you should\r
71                                 be able to edit it normally, without a rich editor interface.\r
72                         </p>\r
73                 </noscript>\r
74         </div>\r
75         <p>\r
76                 <input onclick="createEditor();" type="button" value="Create Editor" />\r
77                 <input onclick="removeEditor();" type="button" value="Remove Editor" />\r
78         </p>\r
79         <!-- This div will hold the editor. -->\r
80         <div id="editor">\r
81         </div>\r
82         <div id="contents" style="display: none">\r
83                 <p>\r
84                         Edited Contents:</p>\r
85                 <!-- This div will be used to display the editor contents. -->\r
86                 <div id="editorcontents">\r
87                 </div>\r
88         </div>\r
89         <div id="footer">\r
90                 <hr />\r
91                 <p>\r
92                         CKEditor - The text editor for Internet - <a href="http://ckeditor.com/">http://ckeditor.com</a>\r
93                 </p>\r
94                 <p id="copy">\r
95                         Copyright &copy; 2003-2010, <a href="http://cksource.com/">CKSource</a> - Frederico\r
96                         Knabben. All rights reserved.\r
97                 </p>\r
98         </div>\r
99 </body>\r
100 </html>\r