source: trunk/examples/ext_example-menu.php @ 895

Last change on this file since 895 was 895, checked in by ray, 12 years ago

#1087 remove the Unicode Byte-Order Mark (BOM)

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 12.1 KB
Line 
1<?php
2  $LocalPluginPath = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'plugins';
3  $LocalSkinPath = 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>270) {
104      sHeight = sHeight - 245;
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  Dialog._geckoOpenModal(url, action, init);
117};
118
119Dialog._parentEvent = function(ev) {
120  setTimeout( function() { if (Dialog._modal && !Dialog._modal.closed) { Dialog._modal.focus() } }, 50);
121  if (Dialog._modal && !Dialog._modal.closed) {
122    agt = navigator.userAgent.toLowerCase();
123    is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
124    if (is_ie) {
125      ev.cancelBubble = true;
126      ev.returnValue = false;
127    } else {
128      ev.preventDefault();
129      ev.stopPropagation();
130    }
131  }
132};
133
134
135// should be a function, the return handler of the currently opened dialog.
136Dialog._return = null;
137
138// constant, the currently opened dialog
139Dialog._modal = null;
140
141// the dialog will read it's args from this variable
142Dialog._arguments = null;
143
144Dialog._geckoOpenModal = function(url, action, init) {
145  var dlg = window.open(url, "hadialog",
146            "toolbar=no,menubar=no,personalbar=no,width=10,height=10," +
147            "scrollbars=no,resizable=yes,modal=yes,dependable=yes");
148  Dialog._modal = dlg;
149  Dialog._arguments = init;
150
151  // capture some window's events
152  function capwin(w) {
153//              Xinha._addEvent(w, "click", Dialog._parentEvent);
154//              Xinha._addEvent(w, "mousedown", Dialog._parentEvent);
155//              Xinha._addEvent(w, "focus", Dialog._parentEvent);
156  };
157  // release the captured events
158  function relwin(w) {
159//              Xinha._removeEvent(w, "click", Dialog._parentEvent);
160//              Xinha._removeEvent(w, "mousedown", Dialog._parentEvent);
161//              Xinha._removeEvent(w, "focus", Dialog._parentEvent);
162  };
163  capwin(window);
164  // capture other frames
165  for (var i = 0; i < window.frames.length; capwin(window.frames[i++]));
166  // make up a function to be called when the Dialog ends.
167  Dialog._return = function (val) {
168    if (val && action) {
169      action(val);
170    }
171    relwin(window);
172    // capture other frames
173    for (var i = 0; i < window.frames.length; relwin(window.frames[i++]));
174    Dialog._modal = null;
175  };
176};
177
178  function fExtended () {
179    Dialog("Extended.html", function(param) {
180      if(param) {
181        settings.width = param["width"];
182        settings.height = param["height"];
183        settings.sizeIncludesBars = (param["sizeIncludesBars"]=="true");
184        settings.sizeIncludesPanels = (param["sizeIncludesPanels"]=="true");
185        settings.statusBar = (param["statusBar"]=="true");
186        settings.htmlareaPaste = (param["htmlareaPaste"]=="true");
187        settings.mozParaHandler = param["mozParaHandler"];
188        settings.getHtmlMethod = param["getHtmlMethod"];
189        settings.undoSteps = param["undoSteps"];
190        settings.undoTimeout = param["undoTimeout"];
191        settings.changeJustifyWithDirection = (param["changeJustifyWithDirection"]=="true");
192        settings.fullPage = (param["fullPage"]=="true");
193        settings.pageStyle = param["pageStyle"];
194        settings.baseHref = param["baseHref"];
195        settings.expandRelativeUrl = (param["expandRelativeUrl"]=="true");
196        settings.stripBaseHref = (param["stripBaseHref"]=="true");
197        settings.stripSelfNamedAnchors = (param["stripSelfNamedAnchors"]=="true");
198        settings.only7BitPrintablesInURLs = (param["only7BitPrintablesInURLs"]=="true");
199        settings.sevenBitClean = (param["sevenBitClean"]=="true");
200        settings.killWordOnPaste = (param["killWordOnPaste"]=="true");
201        settings.makeLinkShowsTarget = (param["makeLinkShowsTarget"]=="true");
202        settings.flowToolbars = (param["flowToolbars"]=="true");
203        settings.stripScripts = (param["stripScripts"]=="true");
204        settings.CharacterMapMode = param["CharacterMapMode"];
205        settings.ListTypeMode = param["ListTypeMode"];
206        settings.showLoading = (param["showLoading"]=="true");
207        settings.showChar = (param["showChar"]=="true");
208        settings.showWord = (param["showWord"]=="true");
209        settings.showHtml = (param["showHtml"]=="true");
210      }
211    }, settings );
212  }
213
214  function init(){
215    var co = getCookie('co_ext_Xinha');
216    if(co!=null){
217      var co_values;
218      var co_entries = co.split('###');
219      for (var i in co_entries) {
220        co_values = co_entries[i].split('=');
221        if(co_values[0]=='plugins') {
222          for(var x = 0; x < document.forms[0].plugins.length; x++) {
223            if(co_values[1].indexOf(document.forms[0].plugins[x].value)!=-1) {
224              document.forms[0].plugins[x].checked = true;
225            }
226          }
227        } else if(co_values[0]!='') {
228          document.getElementById(co_values[0]).value = co_values[1];
229        }
230      }
231    }
232    _onResize();
233  };
234
235  window.onresize = _onResize;
236  window.onload = init;
237  </script>
238</head>
239
240<body>
241  <form action="ext_example-body.html" target="body" name="fsettings" id="fsettings">
242  <h1>Xinha Example</h1>
243    <fieldset>
244      <legend>Settings</legend>
245        <label>
246          Number of Editors: <input type="text" name="num" id="num" value="1" style="width:25;" maxlength="2"/>
247        </label>
248        <label>
249          Language:
250          <select name="lang" id="lang">
251          <option value="en">English</option>
252          <option value="de">German</option>
253          <option value="fr">French</option>
254          <option value="it">Italian</option>
255          <option value="no">Norwegian</option>
256          <option value="pl">Polish</option>
257          <option value="ja">Japanese</option>
258          </select>
259        </label>
260        <label>
261          Skin:
262          <select name="skin" id="skin">
263          <option value="">-- no skin --</option>
264<?php
265  $d = @dir($LocalSkinPath);
266  while (false !== ($entry = $d->read()))  //not a dot file or directory
267  { if(substr($entry,0,1) != '.')
268    { echo '<option value="' . $entry . '"> ' . $entry . '</option>'."\n";
269    }
270  }
271  $d->close();
272?>
273          </select>
274        </label>
275        <center><input type="button" value="extended Settings" onClick="fExtended();" /></center>
276
277    </fieldset>
278    <fieldset>
279      <legend>Plugins</legend>
280      <div id="div_plugins" style="width:100%; overflow:auto">
281<?php
282  $d = @dir($LocalPluginPath);
283  $dir_array = array();
284  while (false !== ($entry = $d->read()))  //not a dot file or directory
285  { if(substr($entry,0,1) != '.')
286    { $dir_array[] = $entry;
287    }
288  }
289  $d->close();
290  sort($dir_array);
291  foreach ($dir_array as $entry)
292  { echo '<label><input type="checkbox" name="plugins" id="plugins" value="' . $entry . '"> ' . $entry . '</label>'."\n";
293  }
294
295?>
296      </div>
297    </fieldset>
298    <center><button type="submit">reload editor</button></center>
299
300        <textarea id="myTextarea0" style="display:none">
301          <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
302          Aliquam et tellus vitae justo varius placerat. Suspendisse iaculis
303          velit semper dolor. Donec gravida tincidunt mi. Curabitur tristique
304          ante elementum turpis. Aliquam nisl. Nulla posuere neque non
305          tellus. Morbi vel nibh. Cum sociis natoque penatibus et magnis dis
306          parturient montes, nascetur ridiculus mus. Nam nec wisi. In wisi.
307          Curabitur pharetra bibendum lectus.</p>
308
309          <ul>
310            <li> Phasellus et massa sed diam viverra semper.  </li>
311            <li> Mauris tincidunt felis in odio.              </li>
312            <li> Nulla placerat nunc ut pede.                 </li>
313            <li> Vivamus ultrices mi sit amet urna.           </li>
314            <li> Quisque sed augue quis nunc laoreet volutpat.</li>
315            <li> Nunc sit amet metus in tortor semper mattis. </li>
316          </ul>
317        </textarea>
318
319  </form>
320  <script type="text/javascript">
321    top.frames["body"].location.href = document.location.href.replace(/ext_example-menu\.php.*/, 'ext_example-body.html')
322    var _oldSubmitHandler = null;
323    if (document.forms[0].onsubmit != null) {
324      _oldSubmitHandler = document.forms[0].onsubmit;
325    }
326    function frame_onSubmit(){
327      var thenewdate = new Date ();
328      thenewdate.setTime(thenewdate.getTime() + (5*24*60*60*1000));
329      var co_value = 'skin=' + document.getElementById('skin').options[document.getElementById('skin').selectedIndex].value + '###' +
330                     'lang=' + document.getElementById('lang').options[document.getElementById('lang').selectedIndex].value + '###' +
331                     'num=' + document.getElementById('num').value + '###';
332      var s_value='';
333      for(var x = 0; x < document.forms[0].plugins.length; x++) {
334        if(document.forms[0].plugins[x].checked)
335          s_value += document.forms[0].plugins[x].value + '/';
336      }
337      if(s_value!='') {
338        co_value += 'plugins=' + s_value + '###'
339      }
340      setCookie('co_ext_Xinha', co_value, thenewdate);
341      if (_oldSubmitHandler != null) {
342        _oldSubmitHandler();
343      }
344    }
345    document.forms[0].onsubmit = frame_onSubmit;
346  </script>
347
348</body>
349</html>
Note: See TracBrowser for help on using the repository browser.