source: sandbox/filemanager/tp/fckeditor/_samples/html/sample13.html @ 1575

Revision 1575, 5.3 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Implentação, melhorias do modulo gerenciador de arquivos

  • Property svn:executable set to *
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<!--
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
5 *
6 * == BEGIN LICENSE ==
7 *
8 * Licensed under the terms of any of the following licenses at your
9 * choice:
10 *
11 *  - GNU General Public License Version 2 or later (the "GPL")
12 *    http://www.gnu.org/licenses/gpl.html
13 *
14 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15 *    http://www.gnu.org/licenses/lgpl.html
16 *
17 *  - Mozilla Public License Version 1.1 or later (the "MPL")
18 *    http://www.mozilla.org/MPL/MPL-1.1.html
19 *
20 * == END LICENSE ==
21 *
22 * Sample page.
23-->
24<html xmlns="http://www.w3.org/1999/xhtml">
25<head>
26        <title>FCKeditor - Sample</title>
27        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
28        <meta name="robots" content="noindex, nofollow" />
29        <link href="../sample.css" rel="stylesheet" type="text/css" />
30        <script type="text/javascript" src="../../fckeditor.js"></script>
31        <script type="text/javascript">
32
33function Toggle()
34{
35        // Try to get the FCKeditor instance, if available.
36        var oEditor ;
37        if ( typeof( FCKeditorAPI ) != 'undefined' )
38                oEditor = FCKeditorAPI.GetInstance( 'DataFCKeditor' ) ;
39
40        // Get the _Textarea and _FCKeditor DIVs.
41        var eTextareaDiv        = document.getElementById( 'Textarea' ) ;
42        var eFCKeditorDiv       = document.getElementById( 'FCKeditor' ) ;
43
44        // If the _Textarea DIV is visible, switch to FCKeditor.
45        if ( eTextareaDiv.style.display != 'none' )
46        {
47                // If it is the first time, create the editor.
48                if ( !oEditor )
49                {
50                        CreateEditor() ;
51                }
52                else
53                {
54                        // Set the current text in the textarea to the editor.
55                        oEditor.SetData( document.getElementById('DataTextarea').value ) ;
56                }
57
58                // Switch the DIVs display.
59                eTextareaDiv.style.display = 'none' ;
60                eFCKeditorDiv.style.display = '' ;
61
62                // This is a hack for Gecko 1.0.x ... it stops editing when the editor is hidden.
63                if ( oEditor && !document.all )
64                {
65                        if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
66                                oEditor.MakeEditable() ;
67                }
68        }
69        else
70        {
71                // Set the textarea value to the editor value.
72                document.getElementById('DataTextarea').value = oEditor.GetXHTML() ;
73
74                // Switch the DIVs display.
75                eTextareaDiv.style.display = '' ;
76                eFCKeditorDiv.style.display = 'none' ;
77        }
78}
79
80function CreateEditor()
81{
82        // Copy the value of the current textarea, to the textarea that will be used by the editor.
83        document.getElementById('DataFCKeditor').value = document.getElementById('DataTextarea').value ;
84
85        // Automatically calculates the editor base path based on the _samples directory.
86        // This is usefull only for these samples. A real application should use something like this:
87        // oFCKeditor.BasePath = '/fckeditor/' ;        // '/fckeditor/' is the default value.
88        var sBasePath = document.location.href.substring(0,document.location.href.lastIndexOf('_samples')) ;
89
90        // Create an instance of FCKeditor (using the target textarea as the name).
91        var oFCKeditor = new FCKeditor( 'DataFCKeditor' ) ;
92        oFCKeditor.BasePath = sBasePath ;
93        oFCKeditor.Width = '100%' ;
94        oFCKeditor.Height = '350' ;
95        oFCKeditor.ReplaceTextarea() ;
96}
97
98// The FCKeditor_OnComplete function is a special function called everytime an
99// editor instance is completely loaded and available for API interactions.
100function FCKeditor_OnComplete( editorInstance )
101{
102        // Enable the switch button. It is disabled at startup, waiting the editor to be loaded.
103        document.getElementById('BtnSwitchTextarea').disabled = false ;
104}
105
106function PrepareSave()
107{
108        // If the textarea isn't visible update the content from the editor.
109        if ( document.getElementById( 'Textarea' ).style.display == 'none' )
110        {
111                var oEditor = FCKeditorAPI.GetInstance( 'DataFCKeditor' ) ;
112                document.getElementById( 'DataTextarea' ).value = oEditor.GetXHTML() ;
113        }
114}
115
116        </script>
117</head>
118<body>
119        <h1>
120                FCKeditor - JavaScript - Sample 13
121        </h1>
122        <div>
123                This sample starts with a normal textarea and provides the ability to switch back
124                and forth between the textarea and FCKeditor. It uses the JavaScript API to do the
125                operations so it will work even if the internal implementation changes.
126        </div>
127        <hr />
128        <form action="../php/sampleposteddata.php" method="post" target="_blank" onsubmit="PrepareSave();">
129                <div id="Textarea">
130                        <input type="button" value="Switch to FCKeditor" onclick="Toggle()" />
131                        <br />
132                        <br />
133                        <textarea id="DataTextarea" name="Data" cols="80" rows="20" style="width: 95%">This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://www.fckeditor.net/"&gt;FCKeditor&lt;/a&gt;.</textarea>
134                </div>
135                <div id="FCKeditor" style="display: none">
136                        <!-- Note that the following button is disabled at startup.
137                                It will be enabled once the editor is completely loaded. -->
138                        <input id="BtnSwitchTextarea" type="button" disabled="disabled" value="Switch to Textarea" onclick="Toggle()" />
139                        <br />
140                        <br />
141                        <!-- Note that the following textarea doesn't have a "name", so it will not be posted. -->
142                        <textarea id="DataFCKeditor" cols="80" rows="20"></textarea>
143                </div>
144                <br />
145                <input type="submit" value="Submit" />
146        </form>
147</body>
148</html>
Note: See TracBrowser for help on using the repository browser.