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

Last change on this file since 336 was 336, checked in by gocher, 15 years ago

Cookie for saving the settings of the ext_example-menu.php

File size: 7.9 KB
Line 
1<!DOCTYPE BHTML PUBLIC "-//BC//DTD BHTML 3.2 Final//EN">
2<html>
3<head>
4
5  <!-- ---------------------------------------------------------------------
6    --  $HeadURL: http://svn.xinha.python-hosting.com/trunk/examples/ext_example-body.html $
7    --  $LastChangedDate: 2005-07-27 16:43:19 +0200 (Mi, 27 Jul 2005) $
8    --  $LastChangedRevision: 287 $
9    --  $LastChangedBy: gocher $
10    ------------------------------------------------------------------------ -->
11
12  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
13  <title>Example of Xinha</title>
14  <link rel="stylesheet" href="full_example.css" />
15
16  <script type="text/javascript">
17    var f = window.parent.menu.document.forms[0];
18    // You must set _editor_url to the URL (including trailing slash) where
19    // where xinha is installed, it's highly recommended to use an absolute URL
20    //  eg: _editor_url = "/path/to/xinha/";
21    // You may try a relative URL if you wish]
22    //  eg: _editor_url = "../";
23    // in this example we do a little regular expression to find the absolute path.
24    _editor_url  = document.location.href.replace(/examples\/ext_example-body\.html.*/, '')
25    _editor_lang = f.lang.value; // And the language we need to use in the editor.
26    _editor_skin = f.skin.value; // the skin we use in the editor
27  </script>
28
29  <!-- Load up the actual editor core -->
30  <script type="text/javascript" src="../htmlarea.js"></script>
31
32  <script type="text/javascript">
33    xinha_editors = null;
34    xinha_init    = null;
35    xinha_config  = null;
36    xinha_plugins = null;
37   
38    xinha_init = xinha_init ? xinha_init : function() {
39      var f = window.parent.menu.document.forms[0];
40// What are the plugins you will be using in the editors on this page.
41// List all the plugins you will need, even if not all the editors will use all the plugins.
42      xinha_plugins = [ ];
43      for(var x = 0; x < f.plugins.length; x++) {
44        if(f.plugins[x].checked) xinha_plugins.push(f.plugins[x].value);
45      }
46
47      // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
48      if(!HTMLArea.loadPlugins(xinha_plugins, xinha_init)) return;
49
50// What are the names of the textareas you will be turning into editors?
51      var num = 1;
52      num = parseInt(f.num.value);
53      if(isNaN(num)) {
54        num = 1;
55        f.num.value = 1;
56      }
57      var b = document.forms[0];
58      var lipsum = window.parent.menu.document.getElementById('myTextarea0').value;
59
60      xinha_editors = [ ]
61      for(var x = 0; x < num; x++) {
62        var ta = 'myTextarea' + x;
63        xinha_editors.push(ta);
64       
65        var div = document.createElement('div');
66        div.className = 'area_holder';
67
68        var txta = document.createElement('textarea');
69        txta.id   = ta;
70        txta.name = ta;
71        txta.value = lipsum;
72        txta.style.width="100%";
73        txta.style.height="420px";
74
75        div.appendChild(txta);
76        b.appendChild(div);
77      }
78
79// Create a default configuration to be used by all the editors.
80      xinha_config = new HTMLArea.Config();
81      if (f.width) xinha_config.width = f.width.value;
82      if (f.height) xinha_config.height = f.height.value;
83      if (f.sizeIncludesBars) xinha_config.sizeIncludesBars = f.sizeIncludesBars.value;
84      if (f.statusBar) xinha_config.statusBar = f.statusBar.value;
85      if (f.mozParaHandler) xinha_config.mozParaHandler = f.mozParaHandler.value;
86      if (f.undoSteps) xinha_config.undoSteps = f.undoSteps.value;
87      if (f.baseHref) xinha_config.baseHref = f.baseHref.value;
88      if (f.stripBaseHref) xinha_config.stripBaseHref = f.stripBaseHref.value;
89      if (f.stripSelfNamedAnchors) xinha_config.stripSelfNamedAnchors = f.stripSelfNamedAnchors.value;
90      if (f.only7BitPrintablesInURLs) xinha_config.only7BitPrintablesInURLs = f.only7BitPrintablesInURLs.value;
91      if (f.sevenBitClean) xinha_config.sevenBitClean = f.sevenBitClean.value;
92      if (f.killWordOnPaste) xinha_config.killWordOnPaste = f.killWordOnPaste.value;
93      if (f.flowToolbars) xinha_config.flowToolbars = f.flowToolbars.value;
94      if ((typeof CharacterMap != 'undefined') && (f.CharacterMapMode)) xinha_config.CharacterMap.mode = f.CharacterMapMode.value;
95      if ((typeof ListType != 'undefined') && (f.ListTypeMode)) xinha_config.ListType.mode = f.ListTypeMode.value;
96
97      if(typeof CSS != 'undefined') {
98        xinha_config.pageStyle = "@import url(custom.css);";
99      }
100
101      if(typeof Stylist != 'undefined') {
102        // We can load an external stylesheet like this - NOTE : YOU MUST GIVE AN ABSOLUTE URL
103        //  otherwise it won't work!
104        xinha_config.stylistLoadStylesheet(document.location.href.replace(/[^\/]*\.html/, 'stylist.css'));
105
106        // Or we can load styles directly
107        xinha_config.stylistLoadStyles('p.red_text { color:red }');
108
109        // If you want to provide "friendly" names you can do so like
110        // (you can do this for stylistLoadStylesheet as well)
111        xinha_config.stylistLoadStyles('p.pink_text { color:pink }', {'p.pink_text' : 'Pretty Pink'});
112      }
113
114      if(typeof DynamicCSS != 'undefined') {
115        xinha_config.pageStyle = "@import url(dynamic.css);";
116      }
117
118      if(typeof InsertWords != 'undefined') {
119        // Register the keyword/replacement list
120        var keywrds1 = new Object();
121        var keywrds2 = new Object();
122
123        keywrds1['-- Dropdown Label --'] = '';
124        keywrds1['onekey'] = 'onevalue';
125        keywrds1['twokey'] = 'twovalue';
126        keywrds1['threekey'] = 'threevalue';
127
128        keywrds2['-- Insert Keyword --'] = '';
129        keywrds2['Username'] = '%user%';
130        keywrds2['Last login date'] = '%last_login%';
131        xinha_config.InsertWords = {
132          combos : [ { options: keywrds1, context: "body" },
133                     { options: keywrds2, context: "li" } ]
134        }
135      }
136
137      if(typeof InsertPicture != 'undefined') {
138        // Path for InsertPicture plugin
139        InsertPicture.PicturePath = '/schmal/pictures/';
140      }
141
142// First create editors for the textareas.
143// You can do this in two ways, either
144//   xinha_editors   = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);
145// if you want all the editor objects to use the same set of plugins, OR;
146//   xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config);
147//   xinha_editors['myTextArea'].registerPlugins(['Stylist','FullScreen']);
148//   xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']);
149// if you want to use a different set of plugins for one or more of the editors.
150      xinha_editors = HTMLArea.makeEditors(xinha_editors, xinha_config, xinha_plugins);
151
152// If you want to change the configuration variables of any of the editors, 
153// this is the place to do that, for example you might want to
154// change the width and height of one of the editors, like this...
155//   xinha_editors.myTextArea.config.width  = '640px';
156//   xinha_editors.myTextArea.config.height = '480px';
157
158// Finally we "start" the editors, this turns the textareas into Xinha editors.
159      HTMLArea.startEditors(xinha_editors);
160   
161      //check submitted values
162      var submit = document.createElement('button');
163      submit.type = "submit";
164      submit.innerHTML = "Submit";
165      b.appendChild(submit);
166    }
167
168    window.onload = xinha_init;
169  </script>
170</head>
171
172<body>
173  <form id="editors_here" method="post" action="ext_example-dest.php">
174
175  </form>
176<script type="text/javascript">
177    var _oldSubmitHandler = null;
178    if (document.forms[0].onsubmit != null) {
179      _oldSubmitHandler = document.forms[0].onsubmit;
180    }
181    function frame_onSubmit(){
182      window.parent.menu.document.getElementById('myTextarea0').value = document.getElementById('myTextarea0').value;
183      if (_oldSubmitHandler != null) {
184        _oldSubmitHandler();
185      }
186    }
187    document.forms[0].onsubmit = frame_onSubmit;
188</script>
189</body>
190</html>
Note: See TracBrowser for help on using the repository browser.