Ticket #5779: ckInJQueryDialog.html

File ckInJQueryDialog.html, 3.9 KB (added by Jakub Ś, 13 years ago)
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<!--
3Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
4For licensing, see LICENSE.html or http://ckeditor.com/license
5-->
6<html xmlns="http://www.w3.org/1999/xhtml">
7<head>
8        <title>Ajax &mdash; CKEditor Sample</title>
9        <meta content="text/html; charset=utf-8" http-equiv="content-type" />   
10       
11        <script type="text/javascript" src="../ckeditor_source.js"></script>
12        <script src="sample.js" type="text/javascript"></script>
13        <link href="sample.css" rel="stylesheet" type="text/css" />
14        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
15        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
16        <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/smoothness/jquery-ui.css" /> 
17
18       
19        <script type="text/javascript">
20        //<![CDATA[
21
22$(function()
23{
24        CKEDITOR.on('instanceReady', function(e)//3
25        {
26                var el = $("#editor");
27                // Update dialog on editor resize
28                e.editor.on('resize', function(e)//CK
29                {
30                        // Center dialog after resize
31                        el.dialog("option", "position", 'center');//JQ
32                });
33                e.editor.resize(el.width(), $(window).height() * 0.95 - (el.parent().height() - $("#cke_" + e.editor.name).parent().height()));//CK
34        });
35});
36
37var editor, html = '';
38var config = {};
39
40function createEditor()
41{
42        if ( editor )
43                return;
44
45        $("#editor").bind('dialogopen', function() //JQ
46        {
47                editor = CKEDITOR.appendTo('editor', config, html);//2
48        }).bind('dialogclose', function() 
49        {
50                removeEditor();//CK
51                $(this).dialog('destroy');
52        })
53        .dialog({autoOpen: false,
54                maxHeight:0.95 * $(window).height(),//1
55                width: 800,
56                modal: true,
57                position: 'top',
58                resizable: false,
59                autoResize: true }).dialog('open');
60}
61
62function removeEditor()
63{
64        if ( !editor )
65                return;
66
67        // Destroy the editor.
68        editor.destroy();
69        editor = null;
70}
71
72        //]]>
73        </script>
74</head>
75<body>
76        <h1 class="samples">
77                CKEditor Sample &mdash; Create and Destroy Editor Instances for Ajax Applications
78        </h1>
79        <div class="description">
80        <p>
81                This sample shows how to create and destroy CKEditor instances on the fly. After the removal of CKEditor the content created inside the editing
82                area will be displayed in a <code>&lt;div&gt;</code> element.
83        </p>
84        <p>
85                For details of how to create this setup check the source code of this sample page
86                for JavaScript code responsible for the creation and destruction of a CKEditor instance.
87        </p>
88        </div>
89
90        <!-- This <div> holds alert messages to be display in the sample page. -->
91        <div id="alerts">
92                <noscript>
93                        <p>
94                                <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
95                                support, like yours, you should still see the contents (HTML data) and you should
96                                be able to edit it normally, without a rich editor interface.
97                        </p>
98                </noscript>
99        </div>
100        <p>Click the buttons to create and remove a CKEditor instance.</p>
101        <p>
102                <input onclick="createEditor();" type="button" value="Create Editor" />
103                <input onclick="removeEditor();" type="button" value="Remove Editor" />
104        </p>
105        <!-- This div will hold the editor. -->
106        <div id="editor">
107        </div>
108        <div id="contents" style="display: none">
109                <p>
110                        Edited Contents:</p>
111                <!-- This div will be used to display the editor contents. -->
112                <div id="editorcontents">
113                </div>
114        </div>
115        <div id="footer">
116                <hr />
117                <p>
118                        CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
119                </p>
120                <p id="copy">
121                        Copyright &copy; 2003-2011, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
122                        Knabben. All rights reserved.
123                </p>
124        </div>
125</body>
126</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy