source: trunk/examples/testbed.html @ 661

Last change on this file since 661 was 661, checked in by gogo, 13 years ago

Fix ticket:445

File size: 7.9 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE html
3     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
4    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6<head>
7
8  <!--------------------------------------:noTabs=true:tabSize=2:indentSize=2:--
9    --  Xinha example usage.  This file shows how a developer might make use of
10    --  Xinha, it forms the primary example file for the entire Xinha project.
11    --  This file can be copied and used as a template for development by the
12    --  end developer who should simply removed the area indicated at the bottom
13    --  of the file to remove the auto-example-generating code and allow for the
14    --  use of the file as a boilerplate.
15    --
16    --  $HeadURL: svn://gogo@xinha.gogo.co.nz/repository/trunk/examples/full_example-body.html $
17    --  $LastChangedDate: 2005-03-05 21:42:32 +1300 (Sat, 05 Mar 2005) $
18    --  $LastChangedRevision: 35 $
19    --  $LastChangedBy: gogo $
20    --------------------------------------------------------------------------->
21
22  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
23  <title>Example of Xinha</title>
24  <link rel="stylesheet" href="full_example.css" />
25
26  <script type="text/javascript">
27    // You must set _editor_url to the URL (including trailing slash) where
28    // where xinha is installed, it's highly recommended to use an absolute URL
29    //  eg: _editor_url = "/path/to/xinha/";
30    // You may try a relative URL if you wish]
31    //  eg: _editor_url = "../";
32    // in this example we do a little regular expression to find the absolute path.
33    _editor_url  = document.location.href.replace(/examples\/.*/, '')
34    _editor_lang = "en";      // And the language we need to use in the editor.
35  </script>
36
37  <!-- Load up the actual editor core -->
38  <script type="text/javascript" src="../htmlarea.js"></script>
39
40  <script type="text/javascript">
41    xinha_editors = null;
42    xinha_init    = null;
43    xinha_config  = null;
44    xinha_plugins = null;
45
46    // This contains the names of textareas we will make into Xinha editors
47    xinha_init = xinha_init ? xinha_init : function()
48    {
49      /** STEP 1 ***************************************************************
50       * First, what are the plugins you will be using in the editors on this
51       * page.  List all the plugins you will need, even if not all the editors
52       * will use all the plugins.
53       ************************************************************************/
54
55      xinha_plugins = xinha_plugins ? xinha_plugins :
56      [
57       
58      ];
59             // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
60             if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;
61
62      /** STEP 2 ***************************************************************
63       * Now, what are the names of the textareas you will be turning into
64       * editors?
65       ************************************************************************/
66
67      xinha_editors = xinha_editors ? xinha_editors :
68      [
69        'myTextArea'
70      ];
71
72      /** STEP 3 ***************************************************************
73       * We create a default configuration to be used by all the editors.
74       * If you wish to configure some of the editors differently this will be
75       * done in step 4.
76       *
77       * If you want to modify the default config you might do something like this.
78       *
79       *   xinha_config = new Xinha.Config();
80       *   xinha_config.width  = 640;
81       *   xinha_config.height = 420;
82       *
83       *************************************************************************/
84
85       xinha_config = xinha_config ? xinha_config : new Xinha.Config();
86       xinha_config.fullPage = true;
87/*
88       // We can load an external stylesheet like this - NOTE : YOU MUST GIVE AN ABSOLUTE URL
89      //  otherwise it won't work!
90      xinha_config.stylistLoadStylesheet(document.location.href.replace(/[^\/]*\.html/, 'stylist.css'));
91
92      // Or we can load styles directly
93      xinha_config.stylistLoadStyles('p.red_text { color:red }');
94
95      // If you want to provide "friendly" names you can do so like
96      // (you can do this for stylistLoadStylesheet as well)
97      xinha_config.stylistLoadStyles('p.pink_text { color:pink }', {'p.pink_text' : 'Pretty Pink'});
98*/
99      /** STEP 3 ***************************************************************
100       * We first create editors for the textareas.
101       *
102       * You can do this in two ways, either
103       *
104       *   xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
105       *
106       * if you want all the editor objects to use the same set of plugins, OR;
107       *
108       *   xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config);
109       *   xinha_editors['myTextArea'].registerPlugins(['Stylist','FullScreen']);
110       *   xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']);
111       *
112       * if you want to use a different set of plugins for one or more of the
113       * editors.
114       ************************************************************************/
115
116      xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
117
118      /** STEP 4 ***************************************************************
119       * If you want to change the configuration variables of any of the
120       * editors,  this is the place to do that, for example you might want to
121       * change the width and height of one of the editors, like this...
122       *
123       *   xinha_editors.myTextArea.config.width  = 640;
124       *   xinha_editors.myTextArea.config.height = 480;
125       *
126       ************************************************************************/
127
128
129      /** STEP 5 ***************************************************************
130       * Finally we "start" the editors, this turns the textareas into
131       * Xinha editors.
132       ************************************************************************/
133
134      Xinha.startEditors(xinha_editors);
135      window.onload = null;
136    }
137
138    window.onload   = xinha_init;
139    // window.onunload = Xinha.collectGarbageForIE;
140  </script>
141</head>
142
143<body>
144
145  <form action="javascript:var x = document.getElementById('editors_here');alert(x.myTextArea.value);" id="editors_here" onsubmit="alert(this.myTextArea.value);">
146    <textarea id="myTextArea" name="myTextArea" style="width:100%;height:320px;">
147      &lt;html&gt;
148      &lt;head&gt;
149        &lt;title&gt;Hello&lt;/title&gt;
150        &lt;style type="text/css"&gt;
151          li { color:red; }
152        &lt;/style&gt;
153      &lt;/head&gt;
154      &lt;body&gt;
155      &lt;p&gt;
156        Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
157        Aliquam et tellus vitae justo varius placerat. Suspendisse iaculis
158        velit semper dolor. Donec gravida tincidunt mi. Curabitur tristique
159        ante elementum turpis. Aliquam nisl. Nulla posuere neque non
160        tellus. Morbi vel nibh. Cum sociis natoque penatibus et magnis dis
161        parturient montes, nascetur ridiculus mus. Nam nec wisi. In wisi.
162        Curabitur pharetra bibendum lectus.
163      &lt;/p&gt;
164
165      &lt;ul&gt;
166        &lt;li&gt; Phasellus et massa sed diam viverra semper.  &lt;/li&gt;
167        &lt;li&gt; Mauris tincidunt felis in odio.              &lt;/li&gt;
168        &lt;li&gt; Nulla placerat nunc ut pede.                 &lt;/li&gt;
169        &lt;li&gt; Vivamus ultrices mi sit amet urna.           &lt;/li&gt;
170        &lt;li&gt; Quisque sed augue quis nunc laoreet volutpat.&lt;/li&gt;
171        &lt;li&gt; Nunc sit amet metus in tortor semper mattis. &lt;/li&gt;
172      &lt;/ul&gt;
173      &lt;/body&gt;
174      &lt;/html&gt;
175    </textarea>
176
177    <input type="submit" /> <input type="reset" />
178  </form>
179  <script language="javascript">
180    document.write(document.compatMode);
181  </script>
182  <a href="#" onclick="xinha_editors.myTextArea.hidePanels();">Hide</a>
183  <a href="#" onclick="xinha_editors.myTextArea.showPanels();">Show</a>
184</body>
185</html>
Note: See TracBrowser for help on using the repository browser.