source: trunk/examples/ext_example-body.html @ 836

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

A few more remaining instances of attempts to use FullScreen? as a
plugin in the examples.

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 8.4 KB
Line 
1<!DOCTYPE BHTML PUBLIC "-//BC//DTD BHTML 3.2 Final//EN">
2<html>
3<head>
4
5  <!-- ---------------------------------------------------------------------
6    --  $HeadURL$
7    --  $LastChangedDate$
8    --  $LastChangedRevision$
9    --  $LastChangedBy$
10    ------------------------------------------------------------------------ -->
11
12  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
13  <title>Example of Xinha</title>
14  <link rel="stylesheet" type="text/css" href="full_example.css" />
15
16  <script type="text/javascript">
17    function showError( sMsg, sUrl, sLine){
18      document.getElementById('errors').value += 'Error: ' + sMsg + '\n' +
19                                                 'Source File: ' + sUrl + '\n' +
20                                                 'Line: ' + sLine + '\n';
21      return false;
22    }
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\/ext_example-body\.html.*/, '')
30    //moved _editor_lang & _editor_skin to init function because of error thrown when frame document not ready
31  </script>
32
33  <!-- Load up the actual editor core -->
34  <script type="text/javascript" src="../XinhaCore.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    xinha_init = xinha_init ? xinha_init : function() {
43      window.onerror = showError;
44      document.onerror = showError;
45
46      var f = top.frames["menu"].document.forms["fsettings"];
47      _editor_lang = f.lang[f.lang.selectedIndex].value; // the language we need to use in the editor.
48      _editor_skin = f.skin[f.skin.selectedIndex].value; // the skin we use in the editor
49// What are the plugins you will be using in the editors on this page.
50// List all the plugins you will need, even if not all the editors will use all the plugins.
51      xinha_plugins = [ ];
52      for(var x = 0; x < f.plugins.length; x++) {
53        if(f.plugins[x].checked) xinha_plugins.push(f.plugins[x].value);
54      }
55
56      // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
57      if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;
58
59// What are the names of the textareas you will be turning into editors?
60      var num = 1;
61      num = parseInt(f.num.value);
62      if(isNaN(num)) {
63        num = 1;
64        f.num.value = 1;
65      }
66      var dest = document.getElementById("editors_here");
67      var lipsum = window.parent.menu.document.getElementById('myTextarea0').value;
68
69      xinha_editors = [ ]
70      for(var x = 0; x < num; x++) {
71        var ta = 'myTextarea' + x;
72        xinha_editors.push(ta);
73
74        var div = document.createElement('div');
75        div.className = 'area_holder';
76
77        var txta = document.createElement('textarea');
78        txta.id   = ta;
79        txta.name = ta;
80        txta.value = lipsum;
81        txta.style.width="100%";
82        txta.style.height="420px";
83
84        div.appendChild(txta);
85        dest.appendChild(div);
86      }
87
88// Create a default configuration to be used by all the editors.
89      settings = top.frames["menu"].settings;
90      xinha_config = new Xinha.Config();
91      xinha_config.width = settings.width;
92      xinha_config.height = settings.height;
93      xinha_config.sizeIncludesBars = settings.sizeIncludesBars;
94      xinha_config.statusBar = settings.statusBar;
95      xinha_config.mozParaHandler = settings.mozParaHandler;
96      xinha_config.undoSteps = settings.undoSteps;
97      xinha_config.baseHref = settings.baseHref;
98      xinha_config.stripBaseHref = settings.stripBaseHref;
99      xinha_config.stripSelfNamedAnchors = settings.stripSelfNamedAnchors;
100      xinha_config.only7BitPrintablesInURLs = settings.only7BitPrintablesInURLs;
101      xinha_config.sevenBitClean = settings.sevenBitClean;
102      xinha_config.killWordOnPaste = settings.killWordOnPaste;
103      xinha_config.flowToolbars = settings.flowToolbars;
104      xinha_config.showLoading = settings.showLoading;
105
106      if (typeof CharCounter != 'undefined') {
107        xinha_config.CharCounter.showChar = settings.showChar;
108        xinha_config.CharCounter.showWord = settings.showWord;
109        xinha_config.CharCounter.showHtml = settings.showHtml;
110      }
111
112      if (typeof CharacterMap != 'undefined') xinha_config.CharacterMap.mode = settings.CharacterMapMode;
113      if (typeof ListType != 'undefined') xinha_config.ListType.mode = settings.ListTypeMode;
114
115      if(typeof CSS != 'undefined') {
116        xinha_config.pageStyle = "@import url(custom.css);";
117      }
118
119      if(typeof Stylist != 'undefined') {
120        // We can load an external stylesheet like this - NOTE : YOU MUST GIVE AN ABSOLUTE URL
121        //  otherwise it won't work!
122        xinha_config.stylistLoadStylesheet(document.location.href.replace(/[^\/]*\.html/, 'stylist.css'));
123
124        // Or we can load styles directly
125        xinha_config.stylistLoadStyles('p.red_text { color:red }');
126
127        // If you want to provide "friendly" names you can do so like
128        // (you can do this for stylistLoadStylesheet as well)
129        xinha_config.stylistLoadStyles('p.pink_text { color:pink }', {'p.pink_text' : 'Pretty Pink'});
130      }
131
132      if(typeof DynamicCSS != 'undefined') {
133        xinha_config.pageStyle = "@import url(dynamic.css);";
134      }
135
136      if(typeof InsertWords != 'undefined') {
137        // Register the keyword/replacement list
138        var keywrds1 = new Object();
139        var keywrds2 = new Object();
140
141        keywrds1['-- Dropdown Label --'] = '';
142        keywrds1['onekey'] = 'onevalue';
143        keywrds1['twokey'] = 'twovalue';
144        keywrds1['threekey'] = 'threevalue';
145
146        keywrds2['-- Insert Keyword --'] = '';
147        keywrds2['Username'] = '%user%';
148        keywrds2['Last login date'] = '%last_login%';
149        xinha_config.InsertWords = {
150          combos : [ { options: keywrds1, context: "body" },
151                     { options: keywrds2, context: "li" } ]
152        }
153      }
154
155      if(typeof Filter != 'undefined') {
156        xinha_config.Filters = ["Word", "Paragraph"];
157      }
158
159// First create editors for the textareas.
160// You can do this in two ways, either
161//   xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
162// if you want all the editor objects to use the same set of plugins, OR;
163//   xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config);
164//   xinha_editors['myTextarea0'].registerPlugins(['Stylist']);
165//   xinha_editors['myTextarea1'].registerPlugins(['CSS','SuperClean']);
166// if you want to use a different set of plugins for one or more of the editors.
167      xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
168
169// If you want to change the configuration variables of any of the editors,
170// this is the place to do that, for example you might want to
171// change the width and height of one of the editors, like this...
172//   xinha_editors['myTextarea0'].config.width  = '640px';
173//   xinha_editors['myTextarea0'].config.height = '480px';
174
175// Finally we "start" the editors, this turns the textareas into Xinha editors.
176      Xinha.startEditors(xinha_editors);
177    }
178
179// javascript submit handler
180// this shows how to create a javascript submit button that works with the htmleditor.
181    submitHandler = function(formname) {
182      var form = document.getElementById(formname);
183      // in order for the submit to work both of these methods have to be called.
184      form.onsubmit();
185      window.parent.menu.document.getElementById('myTextarea0').value = document.getElementById('myTextarea0').value;
186      form.submit();
187      return true;
188    }
189
190    window.onload = xinha_init;
191//    window.onunload = Xinha.collectGarbageForIE;
192  </script>
193</head>
194
195<body>
196  <form id="to_submit" name="to_submit" method="post" action="ext_example-dest.php">
197  <div id="editors_here" name="editors_here"></div>
198  <button type="button" onclick="submitHandler('to_submit');">Submit</button>
199  <textarea id="errors" name="errors" style="width:100%; height:100px; background:silver;"></textarea><!-- style="display:none;" -->
200  </form>
201</body>
202</html>
Note: See TracBrowser for help on using the repository browser.