source: trunk/examples/full_example-body.html @ 166

Last change on this file since 166 was 166, checked in by gogo, 15 years ago

There are 4 things in this commit...

  1. Resizing fixes.
  2. New "flowable" toolbar
  3. Proof of concept of skins.
  4. Testbed file.

Resizing Fixes

Complete rewrite of the framing that the editor is built from,
previously it was done using nested and positioned divs, which was very
troublesome to get right. It also suffered from problems when resizing
the editor.

I have changed it to now use a table structure and have fixed the
resizing problems. This also means we can now use any CSS measurement
for setting width and height (even percentages). Resizing is handled
very well, and generally it's just better all around.

The fullscreen plugin has been adjusted to use the new methods, which
makes it's job much easier too. This won't solve the problem with
fullscreen when the editor has been placed inside a positioned element
however.

Flowable Toolbar

A new config option has been added which allows the toolbar sections
(between separators) to be treated as "possible-line-break-here",
meaning that if there is not enough room on the line, the line will
break to put the section on the next line. Newlines are treated the
same way. Of course the toolbar will re-flow when you resize the
window.

This has been set as the default (and the toolbar has been adjusted to
better suit it) because the default toolbars can get pretty long as you
add plugins. Having the flowing toolbars alleviates this problem and
allows a very small editor window :)

Skins

Ok, well, it's just a CSS file and a couple of images, but it shows the
sort of thing we can already do. I felt that this is something that
people would want to see. What I'd like in the future is to be able to
have a config option per editor to select what skin it gets, but this
will necessitate some extra work so we can have different styles apply
to each editor on a multi-editor page.

The other thing that would be nice is to be able to style the select
lists in the toolbar, which are pretty ugly.

I've set the "blue-look" skin to be used in the full example.

Testbed

This is just a simple html file using Xinha without all the extra stuff
in the full_example. You can use it to test your plugins etc, or users
could take it as a boilerplate file.

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