1 | <!DOCTYPE BHTML PUBLIC "-//BC//DTD BHTML 3.2 Final//EN"> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | |
---|
5 | <!--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- |
---|
6 | -- Xinha example usage. This file shows how a developer might make use of |
---|
7 | -- Xinha, it forms the primary example file for the entire Xinha project. |
---|
8 | -- This file can be copied and used as a template for development by the |
---|
9 | -- end developer who should simply removed the area indicated at the bottom |
---|
10 | -- of the file to remove the auto-example-generating code and allow for the |
---|
11 | -- use of the file as a boilerplate. |
---|
12 | -- |
---|
13 | -- $HeadURL$ |
---|
14 | -- $LastChangedDate$ |
---|
15 | -- $LastChangedRevision$ |
---|
16 | -- $LastChangedBy$ |
---|
17 | ---------------------------------------------------------------------------> |
---|
18 | |
---|
19 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
20 | <title>Example of Xinha</title> |
---|
21 | <link rel="stylesheet" href="full_example.css" /> |
---|
22 | |
---|
23 | <script type="text/javascript"> |
---|
24 | // You must set _editor_url to the URL (including trailing slash) where |
---|
25 | // where xinha is installed, it's highly recommended to use an absolute URL |
---|
26 | // eg: _editor_url = "/path/to/xinha/"; |
---|
27 | // You may try a relative URL if you wish] |
---|
28 | // eg: _editor_url = "../"; |
---|
29 | // in this example we do a little regular expression to find the absolute path. |
---|
30 | _editor_url = document.location.href.replace(/examples\/full_example-body\.html.*/, '') |
---|
31 | _editor_lang = "en"; // And the language we need to use in the editor. |
---|
32 | </script> |
---|
33 | |
---|
34 | <!-- Load up the actual editor core --> |
---|
35 | <script type="text/javascript" src="../htmlarea.js"></script> |
---|
36 | |
---|
37 | <script type="text/javascript"> |
---|
38 | xinha_editors = null; |
---|
39 | xinha_init = null; |
---|
40 | xinha_config = null; |
---|
41 | xinha_plugins = null; |
---|
42 | |
---|
43 | // This contains the names of textareas we will make into Xinha editors |
---|
44 | xinha_init = xinha_init ? xinha_init : function() |
---|
45 | { |
---|
46 | /** STEP 1 *************************************************************** |
---|
47 | * First, what are the plugins you will be using in the editors on this |
---|
48 | * page. List all the plugins you will need, even if not all the editors |
---|
49 | * will use all the plugins. |
---|
50 | ************************************************************************/ |
---|
51 | |
---|
52 | xinha_plugins = xinha_plugins ? xinha_plugins : |
---|
53 | [ |
---|
54 | 'CharacterMap', |
---|
55 | 'ContextMenu', |
---|
56 | 'FullScreen', |
---|
57 | 'ListType', |
---|
58 | 'SpellChecker', |
---|
59 | 'Stylist', |
---|
60 | 'SuperClean', |
---|
61 | 'TableOperations' |
---|
62 | ]; |
---|
63 | |
---|
64 | // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING :) |
---|
65 | if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return; |
---|
66 | |
---|
67 | /** STEP 2 *************************************************************** |
---|
68 | * Now, what are the names of the textareas you will be turning into |
---|
69 | * editors? |
---|
70 | ************************************************************************/ |
---|
71 | |
---|
72 | xinha_editors = xinha_editors ? xinha_editors : |
---|
73 | [ |
---|
74 | 'myTextArea', |
---|
75 | 'anotherOne' |
---|
76 | ]; |
---|
77 | |
---|
78 | /** STEP 3 *************************************************************** |
---|
79 | * We create a default configuration to be used by all the editors. |
---|
80 | * If you wish to configure some of the editors differently this will be |
---|
81 | * done in step 5. |
---|
82 | * |
---|
83 | * If you want to modify the default config you might do something like this. |
---|
84 | * |
---|
85 | * xinha_config = new HTMLArea.Config(); |
---|
86 | * xinha_config.width = '640px'; |
---|
87 | * xinha_config.height = '420px'; |
---|
88 | * |
---|
89 | *************************************************************************/ |
---|
90 | |
---|
91 | xinha_config = xinha_config ? xinha_config() : new HTMLArea.Config(); |
---|
92 | |
---|
93 | /** STEP 4 *************************************************************** |
---|
94 | * We first create editors for the textareas. |
---|
95 | * |
---|
96 | * You can do this in two ways, either |
---|
97 | * |
---|
98 | * xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins); |
---|
99 | * |
---|
100 | * if you want all the editor objects to use the same set of plugins, OR; |
---|
101 | * |
---|
102 | * xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config); |
---|
103 | * xinha_editors['myTextArea'].registerPlugins(['Stylist','FullScreen']); |
---|
104 | * xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']); |
---|
105 | * |
---|
106 | * if you want to use a different set of plugins for one or more of the |
---|
107 | * editors. |
---|
108 | ************************************************************************/ |
---|
109 | |
---|
110 | xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins); |
---|
111 | |
---|
112 | /** STEP 5 *************************************************************** |
---|
113 | * If you want to change the configuration variables of any of the |
---|
114 | * editors, this is the place to do that, for example you might want to |
---|
115 | * change the width and height of one of the editors, like this... |
---|
116 | * |
---|
117 | * xinha_editors.myTextArea.config.width = '640px'; |
---|
118 | * xinha_editors.myTextArea.config.height = '480px'; |
---|
119 | * |
---|
120 | ************************************************************************/ |
---|
121 | |
---|
122 | |
---|
123 | /** STEP 6 *************************************************************** |
---|
124 | * Finally we "start" the editors, this turns the textareas into |
---|
125 | * Xinha editors. |
---|
126 | ************************************************************************/ |
---|
127 | |
---|
128 | HTMLArea.startEditors(xinha_editors); |
---|
129 | } |
---|
130 | |
---|
131 | window.onload = xinha_init; |
---|
132 | </script> |
---|
133 | <!--link type="text/css" rel="alternate stylesheet" title="blue-look" href="../skins/blue-look/skin.css" /> |
---|
134 | <link type="text/css" rel="alternate stylesheet" title="green-look" href="../skins/green-look/skin.css" /> |
---|
135 | <link type="text/css" rel="alternate stylesheet" title="xp-blue" href="../skins/xp-blue/skin.css" /> |
---|
136 | <link type="text/css" rel="alternate stylesheet" title="xp-green" href="../skins/xp-green/skin.css" /> |
---|
137 | <link type="text/css" rel="alternate stylesheet" title="inditreuse" href="../skins/inditreuse/skin.css" /> |
---|
138 | <link type="text/css" rel="alternate stylesheet" title="blue-metallic" href="../skins/blue-metallic/skin.css" /--> |
---|
139 | </head> |
---|
140 | |
---|
141 | <body> |
---|
142 | |
---|
143 | <form id="editors_here"> |
---|
144 | <textarea id="myTextArea" name="myTextArea" rows="10" cols="80" style="width:100%"></textarea> |
---|
145 | <textarea id="anotherOne" name="anotherOne" rows="10" cols="80" style="width:100%"></textarea> |
---|
146 | </form> |
---|
147 | |
---|
148 | |
---|
149 | <!-- ************************************************************************* |
---|
150 | - !! IMPORTANT !! |
---|
151 | - The html and javascript below is the code used to create the example page. |
---|
152 | - It renders a lot of the above unused because it pre-fills xinha_editors, |
---|
153 | - xinha_config and xinha_plugins for you, and creates new textareas in place |
---|
154 | - of the ones above. The items above are not used while the example is being |
---|
155 | - used! |
---|
156 | - |
---|
157 | - If you are going to take the code in this file to form the basis of your |
---|
158 | - own, then leave out this marked area. |
---|
159 | - ********************************************************************* --> |
---|
160 | |
---|
161 | <div id="lipsum" style="display:none"> |
---|
162 | <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. |
---|
163 | Aliquam et tellus vitae justo varius placerat. Suspendisse iaculis |
---|
164 | velit semper dolor. Donec gravida tincidunt mi. Curabitur tristique |
---|
165 | ante elementum turpis. Aliquam nisl. Nulla posuere neque non |
---|
166 | tellus. Morbi vel nibh. Cum sociis natoque penatibus et magnis dis |
---|
167 | parturient montes, nascetur ridiculus mus. Nam nec wisi. In wisi. |
---|
168 | Curabitur pharetra bibendum lectus.</p> |
---|
169 | |
---|
170 | <ul> |
---|
171 | <li> Phasellus et massa sed diam viverra semper. </li> |
---|
172 | <li> Mauris tincidunt felis in odio. </li> |
---|
173 | <li> Nulla placerat nunc ut pede. </li> |
---|
174 | <li> Vivamus ultrices mi sit amet urna. </li> |
---|
175 | <li> Quisque sed augue quis nunc laoreet volutpat.</li> |
---|
176 | <li> Nunc sit amet metus in tortor semper mattis. </li> |
---|
177 | </ul> |
---|
178 | </div> |
---|
179 | <script src="full_example.js"></script> |
---|
180 | |
---|
181 | <!-- ********************************************************************* --> |
---|
182 | |
---|
183 | |
---|
184 | </body> |
---|
185 | </html> |
---|