source: trunk/examples/files/ext_example-menu.php

Last change on this file was 1406, checked in by gogo, 22 months ago

A little quick tidy up of examples.

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 16.7 KB
Line 
1<?php
2  $LocalPluginPath = dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'plugins';
3  $LocalSkinPath = dirname(dirname(dirname(__File__))).DIRECTORY_SEPARATOR.'skins';
4?>
5<html>
6<head>
7
8  <!--------------------------------------:noTabs=true:tabSize=2:indentSize=2:--
9    --  Xinha example menu.  This file is used by full_example.html within a
10    --  frame to provide a menu for generating example editors using
11    --  full_example-body.html, and full_example.js.
12    --
13    --  $HeadURL$
14    --  $LastChangedDate$
15    --  $LastChangedRevision$
16    --  $LastChangedBy$
17    --------------------------------------------------------------------------->
18
19  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
20  <title>Example of Xinha</title>
21  <link rel="stylesheet" href="full_example.css" />
22  <style type="text/css">
23    h1 {font: bold 22px "Staccato222 BT", cursive;}
24    form, p {margin: 0px; padding: 0px;}
25    label { display:block;}
26  </style>
27  <script language="JavaScript" type="text/javascript">
28  var settings = null;
29  settings = {
30    width: "auto",
31    height: "auto",
32    sizeIncludesBars: true,
33    sizeIncludesPanels: true,
34    statusBar: true,
35    htmlareaPaste: false,
36    mozParaHandler: "best",
37    getHtmlMethod: "DOMwalk",
38    undoSteps: 20,
39    undoTimeout: 500,
40    changeJustifyWithDirection: false,
41    fullPage: false,
42    pageStyle: "",
43    baseHref: null,
44    expandRelativeUrl: true,
45    stripBaseHref: true,
46    stripSelfNamedAnchors: true,
47    only7BitPrintablesInURLs: true,
48    sevenBitClean: false,
49    killWordOnPaste: true,
50    makeLinkShowsTarget: true,
51    flowToolbars: true,
52    stripScripts: false,
53    CharacterMapMode: "popup",
54    ListTypeMode: "toolbar",
55    showLoading: false,
56    showChar: true,
57    showWord: true,
58    showHtml: true
59  };
60
61
62    function getCookieVal (offset) {
63      var endstr = document.cookie.indexOf (";", offset);
64      if (endstr == -1)
65        endstr = document.cookie.length;
66      return unescape(document.cookie.substring(offset, endstr));
67    }
68
69    function getCookie (name) {
70      var arg = name + "=";
71      var alen = arg.length;
72      var clen = document.cookie.length;
73      var i = 0;
74      while (i < clen) {
75        var j = i + alen;
76        if (document.cookie.substring(i, j) == arg)
77          return getCookieVal (j);
78        i = document.cookie.indexOf(" ", i) + 1;
79        if (i == 0) break;
80      }
81      return null;
82    }
83
84    function setCookie (name, value) {
85      var argv = setCookie.arguments;
86      var argc = setCookie.arguments.length;
87      var expires = (argc > 2) ? argv[2] : null;
88      var path = (argc > 3) ? argv[3] : null;
89      var domain = (argc > 4) ? argv[4] : null;
90      var secure = (argc > 5) ? argv[5] : false;
91      document.cookie = name + "=" + escape (value) +
92        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
93        ((path == null) ? "" : ("; path=" + path)) +
94        ((domain == null) ? "" : ("; domain=" + domain)) +
95        ((secure == true) ? "; secure" : "");
96    }
97
98  function _onResize() {
99    var sHeight;
100    if (window.innerHeight) sHeight = window.innerHeight;
101    else if (document.body && document.body.offsetHeight) sHeight = document.body.offsetHeight;
102    else return;
103    if (sHeight>300) {
104      sHeight = sHeight - 285;
105    } else {
106      sHeight = 30
107    }
108    var div = document.getElementById("div_plugins");
109    div.style.height = sHeight + "px";
110  }
111
112function Dialog(url, action, init) {
113        if (typeof init == "undefined") {
114                init = window;  // pass this window object by default
115        }
116        if (typeof window.showModalDialog == 'function')
117        {
118                Dialog._return = action;
119                var r = window.showModalDialog(url, init, "dialogheight=10;dialogheight=10;scroll=yes;resizable=yes");
120        }
121        else
122        {
123                Dialog._geckoOpenModal(url, action, init);
124        }
125};
126
127Dialog._parentEvent = function(ev) {
128  setTimeout( function() { if (Dialog._modal && !Dialog._modal.closed) { Dialog._modal.focus() } }, 50);
129  if (Dialog._modal && !Dialog._modal.closed) {
130    agt = navigator.userAgent.toLowerCase();
131    is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
132    if (is_ie) {
133      ev.cancelBubble = true;
134      ev.returnValue = false;
135    } else {
136      ev.preventDefault();
137      ev.stopPropagation();
138    }
139  }
140};
141
142
143// should be a function, the return handler of the currently opened dialog.
144Dialog._return = null;
145
146// constant, the currently opened dialog
147Dialog._modal = null;
148
149// the dialog will read it's args from this variable
150Dialog._arguments = null;
151
152Dialog._geckoOpenModal = function(url, action, init) {
153  var dlg = window.open(url, "hadialog",
154            "toolbar=no,menubar=no,personalbar=no,width=10,height=10," +
155            "scrollbars=no,resizable=yes,modal=yes,dependable=yes");
156  Dialog._modal = dlg;
157  Dialog._arguments = init;
158
159  // capture some window's events
160  function capwin(w) {
161//              Xinha._addEvent(w, "click", Dialog._parentEvent);
162//              Xinha._addEvent(w, "mousedown", Dialog._parentEvent);
163//              Xinha._addEvent(w, "focus", Dialog._parentEvent);
164  };
165  // release the captured events
166  function relwin(w) {
167//              Xinha._removeEvent(w, "click", Dialog._parentEvent);
168//              Xinha._removeEvent(w, "mousedown", Dialog._parentEvent);
169//              Xinha._removeEvent(w, "focus", Dialog._parentEvent);
170  };
171  capwin(window);
172  // capture other frames
173  for (var i = 0; i < window.frames.length; capwin(window.frames[i++]));
174  // make up a function to be called when the Dialog ends.
175  Dialog._return = function (val) {
176    if (val && action) {
177      action(val);
178    }
179    relwin(window);
180    // capture other frames
181    for (var i = 0; i < window.frames.length; relwin(window.frames[i++]));
182    Dialog._modal = null;
183  };
184};
185
186  function fExtended () {
187    Dialog("Extended.html", function(param) {
188      if(param) {
189        settings.width = param["width"];
190        settings.height = param["height"];
191        settings.sizeIncludesBars = (param["sizeIncludesBars"]=="true");
192        settings.sizeIncludesPanels = (param["sizeIncludesPanels"]=="true");
193        settings.statusBar = (param["statusBar"]=="true");
194        settings.htmlareaPaste = (param["htmlareaPaste"]=="true");
195        settings.mozParaHandler = param["mozParaHandler"];
196        settings.getHtmlMethod = param["getHtmlMethod"];
197        settings.undoSteps = param["undoSteps"];
198        settings.undoTimeout = param["undoTimeout"];
199        settings.changeJustifyWithDirection = (param["changeJustifyWithDirection"]=="true");
200        settings.fullPage = (param["fullPage"]=="true");
201        settings.pageStyle = param["pageStyle"];
202        settings.baseHref = param["baseHref"];
203        settings.expandRelativeUrl = (param["expandRelativeUrl"]=="true");
204        settings.stripBaseHref = (param["stripBaseHref"]=="true");
205        settings.stripSelfNamedAnchors = (param["stripSelfNamedAnchors"]=="true");
206        settings.only7BitPrintablesInURLs = (param["only7BitPrintablesInURLs"]=="true");
207        settings.sevenBitClean = (param["sevenBitClean"]=="true");
208        settings.killWordOnPaste = (param["killWordOnPaste"]=="true");
209        settings.makeLinkShowsTarget = (param["makeLinkShowsTarget"]=="true");
210        settings.flowToolbars = (param["flowToolbars"]=="true");
211        settings.stripScripts = (param["stripScripts"]=="true");
212        settings.CharacterMapMode = param["CharacterMapMode"];
213        settings.ListTypeMode = param["ListTypeMode"];
214        settings.showLoading = (param["showLoading"]=="true");
215        settings.showChar = (param["showChar"]=="true");
216        settings.showWord = (param["showWord"]=="true");
217        settings.showHtml = (param["showHtml"]=="true");
218      }
219    }, settings );
220  }
221
222  function init(){
223    var co = getCookie('co_ext_Xinha');
224    if(co!=null){
225      var co_values;
226      var co_entries = co.split('###');
227      for (var i in co_entries) {
228        co_values = co_entries[i].split('=');
229        if(co_values[0]=='plugins') {
230          for(var x = 0; x < document.forms[0].plugins.length; x++) {
231            if(co_values[1].indexOf(document.forms[0].plugins[x].value)!=-1) {
232              document.forms[0].plugins[x].checked = true;
233            }
234          }
235        } else if(co_values[0]!='') {
236          document.getElementById(co_values[0]).value = co_values[1];
237        }
238      }
239    }
240    _onResize();
241  };
242
243  window.onresize = _onResize;
244  window.onload = init;
245  </script>
246</head>
247
248<body>
249  <form action="ext_example-body.php" target="body" name="fsettings" id="fsettings">
250  <h1>Xinha Example</h1>
251    <fieldset>
252      <legend>Settings</legend>
253        <label>
254          Number of Editors: <input type="text" name="num" id="num" value="1" style="width:25;" maxlength="2"/>
255        </label>
256        <label>
257          Language:
258          <select name="lang" id="lang">
259          <option value="en">English</option>
260          <option value="en">--- By Name ---</option>
261<option value="ch">Chinese (ch)</option>
262<option value="cz">Czech</option>
263<option value="da">Danish</option>
264<option value="de">German</option>
265<option value="ee">Ewe</option>
266<option value="el">Greek</option>
267<option value="es">Spanish</option>
268<option value="eu">Basque</option>
269<option value="fa">Persian (Farsi)</option>
270<option value="fi">Finnish</option>
271<option value="fr_ca">French (Canada)</option>
272<option value="fr">French</option>
273<option value="zn_ch">Chinese (zn_ch)</option>
274<option value="he">Hebrew</option>
275<option value="hu">Hungarian</option>
276<option value="it">Italian</option>
277<option value="ja">Japanese</option>
278<option value="lt">Lithuanian</option>
279<option value="lv">Latvian</option>
280<option value="nb">Norwegian</option>
281<option value="nl">Dutch</option>
282<option value="pl">Polish</option>
283<option value="pt_br">Portuguese (Brazil)</option>
284<option value="ro">Romanian</option>
285<option value="ru">Russian</option>
286<option value="sh">Serbo-Croatian</option>
287<option value="si">Slovenian</option>
288<option value="sr">Serbian</option>
289<option value="vn">Swedish</option>
290<option value="th">Thai</option>
291<option value="tr">Turkish</option>
292<option value="vn">Vietnamese</option>
293
294          <option value="en">--- By Code ---</option>
295<option value="ch">ch</option>
296<option value="cz">cz</option>
297<option value="da">da</option>
298<option value="de">de</option>
299<option value="ee">ee</option>
300<option value="el">el</option>
301<option value="es">es</option>
302<option value="eu">eu</option>
303<option value="fa">fa</option>
304<option value="fi">fi</option>
305<option value="fr_ca">fr_ca</option>
306<option value="fr">fr</option>
307<option value="zn_ch">zn_ch</option>
308<option value="he">he</option>
309<option value="hu">hu</option>
310<option value="it">it</option>
311<option value="ja">ja</option>
312<option value="lt">lt</option>
313<option value="lv">lv</option>
314<option value="nb">nb</option>
315<option value="nl">nl</option>
316<option value="pl">pl</option>
317<option value="pt_br">pt_br</option>
318<option value="ro">ro</option>
319<option value="ru">ru</option>
320<option value="sh">sh</option>
321<option value="si">si</option>
322<option value="sr">sr</option>
323<option value="sv">sv</option>
324<option value="th">th</option>
325<option value="tr">tr</option>
326<option value="vn">vn</option>
327          </select>
328        </label>
329        <label>
330          Skin:
331          <select name="skin" id="skin">
332          <option value="">-- no skin --</option>
333<?php
334  $d = @dir($LocalSkinPath);
335  while (false !== ($entry = $d->read()))  //not a dot file or directory
336  { if(substr($entry,0,1) != '.')
337    { echo '<option value="' . $entry . '"> ' . $entry . '</option>'."\n";
338    }
339  }
340  $d->close();
341?>
342          </select>
343        </label>
344        <label>
345          Mode:
346          <select name="DocType">
347            <option value="standards">Standards</option>
348            <option value="almost">Almost Standards</option>
349            <option value="quirks">Quirks</option>
350           
351          </select>
352        </label>
353        <label>
354          Icons:
355            <select name="icons">
356              <option value="">Default/Skin</option>
357              <option value="Classic">Classic</option>
358              <option value="Crystal">Crystal</option>
359              <option value="Tango">Tango</option>
360            </select>
361        </label>
362        <center><input type="button" value="extended Settings" onClick="fExtended();" /></center>
363
364    </fieldset>
365    <fieldset>
366      <legend>Plugins</legend>
367      <div id="div_plugins" style="width:100%; overflow:auto">
368<?php
369  $d = @dir($LocalPluginPath);
370  $dir_array = array();
371  while (false !== ($entry = $d->read()))  //not a dot file or directory
372  { if(substr($entry,0,1) != '.')
373    { $dir_array[] = $entry;
374    }
375  }
376  $d->close();
377  sort($dir_array);
378  foreach ($dir_array as $entry)
379  { echo '<label><input type="checkbox" name="plugins" id="plugins" value="' . $entry . '"> ' . $entry . '</label>'."\n";
380  }
381
382?>
383      </div>
384    </fieldset>
385    <center><button type="submit">reload editor</button></center>
386
387        <textarea id="myTextarea0" style="display:none">
388          <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
389          Aliquam et tellus vitae justo varius placerat. Suspendisse iaculis
390          velit semper dolor. Donec gravida tincidunt mi. Curabitur tristique
391          ante elementum turpis. Aliquam nisl. Nulla posuere neque non
392          tellus. Morbi vel nibh. Cum sociis natoque penatibus et magnis dis
393          parturient montes, nascetur ridiculus mus. Nam nec wisi. In wisi.
394          Curabitur pharetra bibendum lectus. </p>
395<ul>
396  <li><a href="http://test.com/john%27s">test</a></li>
397  <li><a href="/absolute/test.html">test</a></li>
398  <li><a href="/test.html">test</a></li>
399  <li><a href="test.html">test</a></li>
400  <li><a href="../test.html">test</a></li>
401  <li></li>
402  <li><a href="/absolute/test.html">test</a></li>
403  <li><a href="/absolute/./test.html">test</a></li>
404  <li><a href="/absolute/./../test.html">test</a></li>
405  <li><a href="/absolute/.///./../test.html">test</a></li>
406  <li></li>
407  <li><a href="relative/test.html">test</a></li>
408  <li><a href="relative/./test.html">test</a></li>
409  <li><a href="relative/./../test.html">test</a></li>
410  <li><a href="relative/.///./../test.html">test</a></li>
411  <li></li>
412  <li><a href="../test.html">test</a></li>
413  <li><a href=".././test.html">test</a></li>
414  <li><a href=".././../test.html">test</a></li>
415  <li><a href=".././//./../test.html">test</a></li>
416  <li></li>
417  <li><a href="./relative/test.html">test</a></li>
418  <li><a href="./relative/./test.html">test</a></li>
419  <li><a href="./relative/./../test.html">test</a></li>
420  <li><a href="./relative/.///./../test.html">test</a></li>
421  <li></li>
422  <li><a href="./relative/test.html?.///./../../../abc/def">test</a></li>
423  <li><a href="./relative/./test.html#123/45/../../..///./ddd">test</a></li>
424  <li><a href="./relative/./../test.html?.///./../../../abc/def">test</a></li>
425  <li><a href="./relative/.///./../test.html#123/45/../../..///./ddd">test</a></li>
426  <li></li>
427  <li><a href="../../../../../../../../../../.././relative/test.html?.///./../../../abc/def">test</a></li>
428  <li><a href="../../.././relative/./test.html#123/45/../../..///./ddd">test</a></li>
429  <li><a href="../../../.././relative/./../test.html?.///./../../../abc/def">test</a></li>
430  <li><a href="../../../.././relative/.///./../test.html#123/45/../../..///./ddd">test</a></li>
431 
432</ul>
433          <ul>
434            <li> Phasellus et massa sed diam viverra semper.  </li>
435            <li> Mauris tincidunt felis in odio.              </li>
436            <li> Nulla placerat nunc ut pede.                 </li>
437            <li> Vivamus ultrices mi sit amet urna.           </li>
438            <li> Quisque sed augue quis nunc laoreet volutpat.</li>
439            <li> Nunc sit amet metus in tortor semper mattis. </li>
440          </ul>
441        </textarea>
442
443  </form>
444  <script type="text/javascript">
445    top.frames["body"].location.href = document.location.href.replace(/ext_example-menu\.php.*/, 'ext_example-body.php')
446    var _oldSubmitHandler = null;
447    if (document.forms[0].onsubmit != null) {
448      _oldSubmitHandler = document.forms[0].onsubmit;
449    }
450    function frame_onSubmit(){
451      var thenewdate = new Date ();
452      thenewdate.setTime(thenewdate.getTime() + (5*24*60*60*1000));
453      var co_value = 'skin=' + document.getElementById('skin').options[document.getElementById('skin').selectedIndex].value + '###' +
454                     'lang=' + document.getElementById('lang').options[document.getElementById('lang').selectedIndex].value + '###' +
455                     'num=' + document.getElementById('num').value + '###';
456      var s_value='';
457      for(var x = 0; x < document.forms[0].plugins.length; x++) {
458        if(document.forms[0].plugins[x].checked)
459          s_value += document.forms[0].plugins[x].value + '/';
460      }
461      if(s_value!='') {
462        co_value += 'plugins=' + s_value + '###'
463      }
464      setCookie('co_ext_Xinha', co_value, thenewdate);
465      if (_oldSubmitHandler != null) {
466        _oldSubmitHandler();
467      }
468    }
469    document.forms[0].onsubmit = frame_onSubmit;
470  </script>
471
472</body>
473</html>
Note: See TracBrowser for help on using the repository browser.