Fix calendar sidebar issue - changed holder from 'contentholder' to 'sidebarholder'
[elgg.git] / _tinymce / docs / customization_themes.html
blob566923bbfe88b73a210e11ced8e91577112708c9
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <title>Customization - Creating a theme</title>
5 <link href="css/screen.css" rel="stylesheet" type="text/css" />
6 </head>
7 <body>
9 <div class="header">
10 <h1>Customization - Creating a theme</h1>
11 </div>
13 <div class="content">
15 <h2>Creating your own Themes</h2>
16 <p>
17 Creating you own themes for the TinyMCE application is fairly easy if you know the basics of HTML, CSS and Javascript. The most easy way is to copy the &quot;default&quot; or the &quot;advanced&quot; template and rename it as your own name to for example &quot;mytheme&quot;. After you copy the template you need to change the red sections marked below to &quot;mytheme&quot; this is needed so that themes don't overlap in other words it gives the theme a unique name. Then just alter the HTML code as you see fit but notice some elements needs to be there so check the docs below on each function also remember that your custom themes needs to be located in tiny_mce's &quot;themes&quot; directory. If you want you may add theme specific options/settings but remember to namespace them in the following format &quot;theme_&lt;your theme&gt;_&lt;option&gt;&quot;.
18 </p>
19 <p>
20 The example below has three functions, these are explained in greater detail below.
21 </p>
22 <p>
23 <div class="example">
24 <pre>
25 function TinyMCE_<span class="marked">default</span>_getEditorTemplate(settings) {
26 var template = new Array();
28 template['html'] = '&lt;Some HTML&gt;';
29 template['delta_width'] = 0;
30 template['delta_height'] = -40;
32 return template;
35 function TinyMCE_<span class="marked">default</span>_getInsertLinkTemplate(settings) {
36 var template = new Array();
38 template['file'] = 'link.htm';
39 template['width'] = 320;
40 template['height'] = 130;
42 return template;
45 function TinyMCE_<span class="marked">default</span>_getInsertImageTemplate(settings) {
46 var template = new Array();
48 template['file'] = 'image.htm';
49 template['width'] = 320;
50 template['height'] = 130;
52 return template;
55 function TinyMCE_<span class="marked">default</span>_handleNodeChange(editor_id, node) {
56 // Check what happend
59 function TinyMCE_<span class="marked">default</span>_execCommand(editor_id, element, command, user_interface, value) {
60 // Your custom command logic
61 return false;
63 </pre>
64 </div>
65 </p>
66 <div class="separator"></div>
68 <h3>Creating popup HTML files</h3>
69 <p>
70 When creating a popup you need to include the &quot;tiny_mce_popup.js&quot; this enables you to retrive the tinyMCE global instance in all popup windows. All variables and language definitions gets replaced in the page when it loads. So language variables such as {$lang_something} can be places in the HTML code, if you need to get a language string in JavaScript simply use the tinyMCE.getLang function.
71 </p>
72 <h3>Example of simple popup file:</h3>
73 <div class="example">
74 <pre>
75 &lt;html&gt;
76 &lt;head&gt;
77 &lt;title&gt;{$lang_plugin_sample_title}&lt;/title&gt;
78 &lt;script language=&quot;javascript&quot; src=&quot;../../tiny_mce_popup.js&quot;&gt;&lt;/script&gt;
79 &lt;script language=&quot;javascript&quot;&gt;
80 // getWindowArg returns any arguments passed to the window
81 alert(tinyMCE.getWindowArg('some_arg'));
82 &lt;/script&gt;
83 &lt;body&gt;
84 &lt;strong&gt;{$lang_plugin_sample_desc}&lt;/strong&gt;
85 &lt;/body&gt;
86 </pre>
87 </div>
89 <div class="separator"></div>
90 <h3>The TinyMCE_&lt;theme&gt;_getEditorTemplate(settings) function</h3>
91 <p>
92 This function is responsible for the layout of the editor instance within the page it should return a name/value based array with some specific names. These are explained below, notice names included in [] characters are optional. The settings parameter to this function is a name/value array containing tinyMCE:s settings/options.
93 </p>
94 <p>
95 <table border="1" cellspacing="0" cellpadding="4">
96 <thead>
97 <tr>
98 <td colspan="2">Template data</td>
99 </tr>
100 </thead>
101 <tbody>
102 <tr>
103 <td><strong>html</strong></td>
104 <td>HTML template data, this value should contain all the HTML code needed to render the editor. Notice: {$&lt;variable&gt;} are replaces with values when used. More about these specific values later on.</td>
105 </tr>
106 <tr>
107 <td><strong>[delta_width]</strong></td>
108 <td>Delta width, this value should contain the relative width needed by the UI. For example if a toolbar takes 20 pixels this value should be -20. This is so the editor gets the same size as the element that are replaced.</td>
109 </tr>
110 <tr>
111 <td><strong>[delta_height]</strong></td>
112 <td>Delta height, this value should contain the relative width needed by the UI. For example if a toolbar takes 40 pixels this value should be -40. This is so the editor gets the same size as the element that are replaced.</td>
113 </tr>
114 </tbody>
115 </table>
116 </p>
118 Variables within the &quot;html&quot; value above are replaced with internal TinyMCE values. There are two types of variables one is the ones starting with the &quot;lang_&quot; prefix, these are replaced with the matching names in the language packs. So for example &lt;b&gt;{$lang_test}&lt;/b&gt; gets replaces with the &quot;tinyMCELang['lang_test']&quot; variable and the output is then &lt;b&gt;Test&lt;/b&gt;. The other variables are passed expicilty for the template used and these are listed below. Notice: Variables within [] characters are optional.
119 </p>
121 <table border="1" cellspacing="0" cellpadding="4">
122 <thead>
123 <tr>
124 <td colspan="2">Variables</td>
125 </tr>
126 </thead>
127 <tbody>
128 <tr>
129 <td><strong>editor_id</strong></td>
130 <td>This is the editor instance id and it should be placed in ID attribute of the IFRAME element that must be included in the template.</td>
131 </tr>
132 <tr>
133 <td><strong>[default_document]</strong></td>
134 <td>This will be replaced with a blank html page, this is added for MSIE security issues and should be placed in the SRC attribute of the IFRAME within the template.</td>
135 </tr>
136 <tr>
137 <td><strong>[area_width]</strong></td>
138 <td>Width of IFRAME area in pixels.</td>
139 </tr>
140 <tr>
141 <td><strong>[area_height]</strong></td>
142 <td>Height of IFRAME area in pixels.</td>
143 </tr>
144 <tr>
145 <td><strong>[width]</strong></td>
146 <td>Width of the whole editor area in pixels.</td>
147 </tr>
148 <tr>
149 <td><strong>[height]</strong></td>
150 <td>Height of the whole editor area in pixels.</td>
151 </tr>
152 <tr>
153 <td><strong>[themeurl]</strong></td>
154 <td>URL to theme location.</td>
155 </tr>
156 </tbody>
157 </table>
158 </p>
160 Notice: There are two javascript function that can be called from this template these are tinyMCE.execCommand that executes commans on the currenly selected editor area and the tinyMCE.switchClass that switches the CSS class of the element specified. For more details of commands available by execCommand check the Mozilla midas specification and the TinyMCE specific commands.
161 </p>
162 <div class="separator"></div>
163 <h3>The TinyMCE_&lt;theme&gt;_getInsertLinkTemplate(settings) function</h3>
165 This function is responsible for the layout of the insert link popup window and it should return a name/value based array with some specific names. These are explained below, notice names included in [] characters are optional. The settings parameter to this function is a name/value array containing tinyMCE:s settings/options.
166 </p>
168 <table border="1" cellspacing="0" cellpadding="4">
169 <thead>
170 <tr>
171 <td colspan="2">Template data</td>
172 </tr>
173 </thead>
174 <tbody>
175 <tr>
176 <td><strong>html</strong></td>
177 <td>HTML template data, this value should contain all the HTML code needed to render the link dialog. Notice: {$&lt;variable&gt;} are replaces with values when used. More about these specific values later on. This parameter is not needed if the &quot;file&quot; param is assigned.</td>
178 </tr>
179 <tr>
180 <td><strong>file</strong></td>
181 <td>Name of external template file to use, this may even be logic pages like .php,.asp,.jsp etc.</td>
182 </tr>
183 <tr>
184 <td><strong>[width]</strong></td>
185 <td>Width of popup window in pixels. Default is 320.</td>
186 </tr>
187 <tr>
188 <td><strong>[height]</strong></td>
189 <td>Height of popup window in pixels. Default is 200.</td>
190 </tr>
191 </tbody>
192 </table>
193 </p>
195 Variables within the &quot;html&quot; value above are replaced with internal TinyMCE values. There are two types of variables one is the ones starting with the &quot;lang_&quot; prefix, these are replaced with the matching names in the language packs. So for example &lt;b&gt;{$lang_test}&lt;/b&gt; gets replaces with the &quot;tinyMCELang['lang_test']&quot; variable and the output is then &lt;b&gt;Test&lt;/b&gt;. The other variables are passed expicilty for the template used and these are listed below. Notice: Variables within [] characters are optional.
196 </p>
198 <table border="1" cellspacing="0" cellpadding="4">
199 <thead>
200 <tr>
201 <td colspan="2">Variables/Window arguments:</td>
202 </tr>
203 </thead>
204 <tbody>
205 <tr>
206 <td><strong>[href]</strong></td>
207 <td>This variable gets replaced with the &quot;href&quot; attribute value of the selected link if one is selected.</td>
208 </tr>
209 <tr>
210 <td><strong>[target]</strong></td>
211 <td>This variable gets replaced with the &quot;target&quot; attribute value of the selected link if one is selected.</td>
212 </tr>
213 <tr>
214 <td><strong>[css]</strong></td>
215 <td>Theme popup css location.</td>
216 </tr>
217 </tbody>
218 </table>
219 </p>
221 Notice: There are a javascript function that can be called from this template &quot;window.opener.tinyMCE.insertLink(href, target)&quot; this inserts the link into the currently selected editor and should be called when for example a insert button is pressed.
222 </p>
223 <div class="separator"></div>
224 <h3>The TinyMCE_&lt;theme&gt;_getInsertImageTemplate(settings) function</h3>
226 This function is responsible for the layout of the insert image dialog, it should return a name/value based array with some specific names. These are explained below, notice names included in [] characters are optional. The settings parameter to this function is a name/value array containing tinyMCE:s settings/options.
227 </p>
229 <table border="1" cellspacing="0" cellpadding="4">
230 <thead>
231 <tr>
232 <td colspan="2">Template data</td>
233 </tr>
234 </thead>
235 <tbody>
236 <tr>
237 <td><strong>html</strong></td>
238 <td>HTML template data, this value should contain all the HTML code needed to render the image dialog. Notice: {$&lt;variable&gt;} are replaces with values when used. More about these specific values later on. This parameter is not needed if the &quot;file&quot; param is assigned.</td>
239 </tr>
240 <tr>
241 <td><strong>[width]</strong></td>
242 <td>Width of popup window in pixels. Default is 320.</td>
243 </tr>
244 <tr>
245 <td><strong>[height]</strong></td>
246 <td>Height of popup window in pixels. Default is 200.</td>
247 </tr>
248 </tbody>
249 </table>
250 </p>
252 Variables within the &quot;html&quot; value above are replaced with internal TinyMCE values. There are two types of variables one is the ones starting with the &quot;lang_&quot; prefix, these are replaced with the matchin names in the language packs. So for example &lt;b&gt;{$lang_test}&lt;/b&gt; gets replaces with the &quot;tinyMCELang['lang_test']&quot; variable and the output is then &lt;b&gt;Test&lt;/b&gt;. The other variables are passed expicilty for the template used and these are listed below. Notice: Variables within [] characters are optional.
253 </p>
255 <table border="1" cellspacing="0" cellpadding="4">
256 <thead>
257 <tr>
258 <td colspan="2">Variables/Window arguments</td>
259 </tr>
260 </thead>
261 <tbody>
262 <tr>
263 <td><strong>[src]</strong></td>
264 <td>This variable gets replaced with the &quot;src&quot; attribute value of the selected link if one is selected.</td>
265 </tr>
266 <tr>
267 <td><strong>[alt]</strong></td>
268 <td>This variable gets replaced with the &quot;alt&quot; attribute value of the selected link if one is selected.</td>
269 </tr>
270 <tr>
271 <td><strong>[border]</strong></td>
272 <td>This variable gets replaced with the &quot;border&quot; attribute value of the selected link if one is selected.</td>
273 </tr>
274 <tr>
275 <td><strong>[hspace]</strong></td>
276 <td>This variable gets replaced with the &quot;hspace&quot; attribute value of the selected link if one is selected.</td>
277 </tr>
278 <tr>
279 <td><strong>[vspace]</strong></td>
280 <td>This variable gets replaced with the &quot;vspace&quot; attribute value of the selected link if one is selected.</td>
281 </tr>
282 <tr>
283 <td><strong>[width]</strong></td>
284 <td>This variable gets replaced with the &quot;width&quot; attribute value of the selected link if one is selected.</td>
285 </tr>
286 <tr>
287 <td><strong>[height]</strong></td>
288 <td>This variable gets replaced with the &quot;height&quot; attribute value of the selected link if one is selected.</td>
289 </tr>
290 <tr>
291 <td><strong>[align]</strong></td>
292 <td>This variable gets replaced with the &quot;align&quot; attribute value of the selected link if one is selected.</td>
293 </tr>
294 <tr>
295 <td><strong>[css]</strong></td>
296 <td>Theme popup css location.</td>
297 </tr>
298 </tbody>
299 </table>
300 </p>
302 Notice: There are a javascript function that can be called from this template &quot;window.opener.tinyMCE.insertImage(src, alt, border, hspace, vspace, width, height, align)&quot; this inserts the image into the currently selected editor and should be called when for example a insert button is pressed.
303 </p>
305 <div class="separator"></div>
307 <h3>The TinyMCE_&lt;theme&gt;_handleNodeChange function (Optional)</h3>
309 This function is called when the cursor/selection of a editor instance changes. Then the currenly selected/focused node is passed to this function. This can be useful when you want to change the UI depending on what the user has selected.
310 </p>
312 <table border="1" cellspacing="0" cellpadding="4">
313 <thead>
314 <tr>
315 <td colspan="2">Parameters</td>
316 </tr>
317 </thead>
318 <tbody>
319 <tr>
320 <td><strong>editor_id</strong></td>
321 <td>Unique editor id, this is the same as the $editor_id variable in getEditorTemplate.</td>
322 </tr>
323 <tr>
324 <td><strong>node</strong></td>
325 <td>Reference to the Node element where the cursor is currenly located.</td>
326 </tr>
327 <tr>
328 <td><strong>undo_index</strong></td>
329 <td>Current undo index, this value is -1 if the custom undo/redo support is disabled.</td>
330 </tr>
331 <tr>
332 <td><strong>undo_levels</strong></td>
333 <td>Current number of undo levels, this value is -1 if the custom undo/redo support is disabled.</td>
334 </tr>
335 <tr>
336 <td><strong>visual_aid</strong></td>
337 <td>True/false state of visual aid/guidelines mode.</td>
338 </tr>
339 <tr>
340 <td><strong>any_selection</strong></td>
341 <td>Is any text or image selected.</td>
342 </tr>
343 </tbody>
344 </table>
345 </p>
347 <div class="separator"></div>
349 <h3>The TinyMCE_&lt;theme&gt;_execCommand function (Optional)</h3>
351 This function is called when a command is executed for example &quot;bold&quot; or &quot;createlink&quot; this callback/theme function may then intercept theme specific commands and do custom logic. If this command returns true the command handling is terminated and the default tinyMCE command handeling never gets executed.
352 </p>
354 <table border="1" cellspacing="0" cellpadding="4">
355 <thead>
356 <tr>
357 <td colspan="2">Parameters</td>
358 </tr>
359 </thead>
360 <tbody>
361 <tr>
362 <td><strong>editor_id</strong></td>
363 <td>Unique editor id, this is the same as the $editor_id variable in getEditorTemplate.</td>
364 </tr>
365 <tr>
366 <td><strong>element</strong></td>
367 <td>Reference to the document DOM root element of the editor instance.</td>
368 </tr>
369 <tr>
370 <td><strong>command</strong></td>
371 <td>Command that is to be executed for example &quot;myCommand&quot;.</td>
372 </tr>
373 <tr>
374 <td><strong>user_interface</strong></td>
375 <td>true/false option if a user insterace is to be used or not.</td>
376 </tr>
377 <tr>
378 <td><strong>value</strong></td>
379 <td>Custom data value passed with command, may be any data type.</td>
380 </tr>
381 </tbody>
382 </table>
383 </p>
385 Returns: <br />
386 true - Command intercepted and handled do not continue with command handling.<br />
387 false - Continue with execCommand handling, bubble.<br />
388 </p>
390 <div class="separator"></div>
392 <h3>The TinyMCE_&lt;theme&gt;_getControlHTML(control_name) function (Optional)</h3>
394 This function is called when a editor needs to render a specific control/button. This function should return the HTML template of that control or a empty string if the control_name wasn't recognized. Notice the variable {$pluginurl} gets replaced with the URL prefix for the current plugin directory.
395 </p>
397 <table border="1" cellspacing="0" cellpadding="4">
398 <thead>
399 <tr>
400 <td colspan="2">Parameters</td>
401 </tr>
402 </thead>
403 <tbody>
404 <tr>
405 <td><strong>control_name</strong></td>
406 <td>Control name to match against.</td>
407 </tr>
408 </tbody>
409 </table>
410 </p>
412 Returns: return the HTML template of that control or a empty string if the control_name wasn't recognized.
413 </p>
414 </div>
416 <div class="footer">
417 <div class="helpindexlink"><a href="index.html">Index</a></div>
418 <div class="copyright">Copyright &copy; 2005 Moxiecode Systems AB</div>
419 <br style="clear: both" />
420 </div>
422 </body>
423 </html>