source: CKEditor/trunk/_samples/divreplace.html

Last change on this file was 7688, checked in by Wiktor Walc, 12 years ago

Happy New Year! (Updated the copyright notices)

File size: 5.2 KB
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-2013, 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>Replace DIV &mdash; CKEditor Sample</title>
9        <meta content="text/html; charset=utf-8" http-equiv="content-type" />
10        <!-- CKReleaser %REMOVE_LINE%
11        <script type="text/javascript" src="../ckeditor.js"></script>
12        CKReleaser %REMOVE_START% -->
13        <script type="text/javascript" src="../ckeditor_source.js"></script>
14        <!-- CKReleaser %REMOVE_END% -->
15        <script src="sample.js" type="text/javascript"></script>
16        <link href="sample.css" rel="stylesheet" type="text/css" />
17        <style id="styles" type="text/css">
18
19                div.editable
20                {
21                        border: solid 2px Transparent;
22                        padding-left: 15px;
23                        padding-right: 15px;
24                }
25
26                div.editable:hover
27                {
28                        border-color: black;
29                }
30
31        </style>
32        <script type="text/javascript">
33        //<![CDATA[
34
35// Uncomment the following code to test the "Timeout Loading Method".
36// CKEDITOR.loadFullCoreTimeout = 5;
37
38window.onload = function()
39{
40        // Listen to the double click event.
41        if ( window.addEventListener )
42                document.body.addEventListener( 'dblclick', onDoubleClick, false );
43        else if ( window.attachEvent )
44                document.body.attachEvent( 'ondblclick', onDoubleClick );
45
46};
47
48function onDoubleClick( ev )
49{
50        // Get the element which fired the event. This is not necessarily the
51        // element to which the event has been attached.
52        var element = ev.target || ev.srcElement;
53
54        // Find out the div that holds this element.
55        var name;
56        do
57        {
58                element = element.parentNode;
59        }
60        while ( element && ( name = element.nodeName.toLowerCase() ) && ( name != 'div' || element.className.indexOf( 'editable' ) == -1 ) && name != 'body' )
61
62
63        if ( name == 'div' && element.className.indexOf( 'editable' ) != -1 )
64                replaceDiv( element );
65}
66
67var editor;
68
69function replaceDiv( div )
70{
71        if ( editor )
72                editor.destroy();
73
74        editor = CKEDITOR.replace( div );
75}
76
77        //]]>
78        </script>
79
80</head>
81<body>
82        <h1 class="samples">
83                CKEditor Sample &mdash; Replace DIV with CKEditor on the Fly
84        </h1>
85        <div class="description">
86        <p>
87                This sample shows how to automatically replace <code>&lt;div&gt;</code> elements
88                with a CKEditor instance on the fly, following user's doubleclick. The content
89                that was previously placed inside the <code>&lt;div&gt;</code> element will now
90                be moved into CKEditor editing area.
91        </p>
92        <p>
93                For details on how to create this setup check the source code of this sample page.
94        </p>
95        </div>
96        <!-- This <div> holds alert messages to be display in the sample page. -->
97        <div id="alerts">
98                <noscript>
99                        <p>
100                                <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
101                                support, like yours, you should still see the contents (HTML data) and you should
102                                be able to edit it normally, without a rich editor interface.
103                        </p>
104                </noscript>
105        </div>
106        <p>
107                Double-click any of the following <code>&lt;div&gt;</code> elements to transform them into
108                editor instances.</p>
109        <div class="editable">
110                <h3>
111                        Part 1</h3>
112                <p>
113                        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et ipsum quis mi
114                        semper accumsan. Integer pretium dui id massa. Suspendisse in nisl sit amet urna
115                        rutrum imperdiet. Nulla eu tellus. Donec ante nisi, ullamcorper quis, fringilla
116                        nec, sagittis eleifend, pede. Nulla commodo interdum massa. Donec id metus. Fusce
117                        eu ipsum. Suspendisse auctor. Phasellus fermentum porttitor risus.
118                </p>
119        </div>
120        <div class="editable">
121                <h3>
122                        Part 2</h3>
123                <p>
124                        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et ipsum quis mi
125                        semper accumsan. Integer pretium dui id massa. Suspendisse in nisl sit amet urna
126                        rutrum imperdiet. Nulla eu tellus. Donec ante nisi, ullamcorper quis, fringilla
127                        nec, sagittis eleifend, pede. Nulla commodo interdum massa. Donec id metus. Fusce
128                        eu ipsum. Suspendisse auctor. Phasellus fermentum porttitor risus.
129                </p>
130                <p>
131                        Donec velit. Mauris massa. Vestibulum non nulla. Nam suscipit arcu nec elit. Phasellus
132                        sollicitudin iaculis ante. Ut non mauris et sapien tincidunt adipiscing. Vestibulum
133                        vitae leo. Suspendisse nec mi tristique nulla laoreet vulputate.
134                </p>
135        </div>
136        <div class="editable">
137                <h3>
138                        Part 3</h3>
139                <p>
140                        Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et ipsum quis mi
141                        semper accumsan. Integer pretium dui id massa. Suspendisse in nisl sit amet urna
142                        rutrum imperdiet. Nulla eu tellus. Donec ante nisi, ullamcorper quis, fringilla
143                        nec, sagittis eleifend, pede. Nulla commodo interdum massa. Donec id metus. Fusce
144                        eu ipsum. Suspendisse auctor. Phasellus fermentum porttitor risus.
145                </p>
146        </div>
147        <div id="footer">
148                <hr />
149                <p>
150                        CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
151                </p>
152                <p id="copy">
153                        Copyright &copy; 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
154                        Knabben. All rights reserved.
155                </p>
156        </div>
157</body>
158</html>
Note: See TracBrowser for help on using the repository browser.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy