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

Last change on this file since 1084 was 1084, checked in by ray, 6 years ago

svn keywords have stopped being replaced, don't exactly know why; maybe because of change of repository url. Trying to fix by resetting all keywords

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 12.3 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>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        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.html" 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="de">German</option>
261          <option value="fr">French</option>
262          <option value="it">Italian</option>
263          <option value="no">Norwegian</option>
264          <option value="pl">Polish</option>
265          <option value="ja">Japanese</option>
266          </select>
267        </label>
268        <label>
269          Skin:
270          <select name="skin" id="skin">
271          <option value="">-- no skin --</option>
272<?php
273  $d = @dir($LocalSkinPath);
274  while (false !== ($entry = $d->read()))  //not a dot file or directory
275  { if(substr($entry,0,1) != '.')
276    { echo '<option value="' . $entry . '"> ' . $entry . '</option>'."\n";
277    }
278  }
279  $d->close();
280?>
281          </select>
282        </label>
283        <center><input type="button" value="extended Settings" onClick="fExtended();" /></center>
284
285    </fieldset>
286    <fieldset>
287      <legend>Plugins</legend>
288      <div id="div_plugins" style="width:100%; overflow:auto">
289<?php
290  $d = @dir($LocalPluginPath);
291  $dir_array = array();
292  while (false !== ($entry = $d->read()))  //not a dot file or directory
293  { if(substr($entry,0,1) != '.')
294    { $dir_array[] = $entry;
295    }
296  }
297  $d->close();
298  sort($dir_array);
299  foreach ($dir_array as $entry)
300  { echo '<label><input type="checkbox" name="plugins" id="plugins" value="' . $entry . '"> ' . $entry . '</label>'."\n";
301  }
302
303?>
304      </div>
305    </fieldset>
306    <center><button type="submit">reload editor</button></center>
307
308        <textarea id="myTextarea0" style="display:none">
309          <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
310          Aliquam et tellus vitae justo varius placerat. Suspendisse iaculis
311          velit semper dolor. Donec gravida tincidunt mi. Curabitur tristique
312          ante elementum turpis. Aliquam nisl. Nulla posuere neque non
313          tellus. Morbi vel nibh. Cum sociis natoque penatibus et magnis dis
314          parturient montes, nascetur ridiculus mus. Nam nec wisi. In wisi.
315          Curabitur pharetra bibendum lectus.</p>
316
317          <ul>
318            <li> Phasellus et massa sed diam viverra semper.  </li>
319            <li> Mauris tincidunt felis in odio.              </li>
320            <li> Nulla placerat nunc ut pede.                 </li>
321            <li> Vivamus ultrices mi sit amet urna.           </li>
322            <li> Quisque sed augue quis nunc laoreet volutpat.</li>
323            <li> Nunc sit amet metus in tortor semper mattis. </li>
324          </ul>
325        </textarea>
326
327  </form>
328  <script type="text/javascript">
329    top.frames["body"].location.href = document.location.href.replace(/ext_example-menu\.php.*/, 'ext_example-body.html')
330    var _oldSubmitHandler = null;
331    if (document.forms[0].onsubmit != null) {
332      _oldSubmitHandler = document.forms[0].onsubmit;
333    }
334    function frame_onSubmit(){
335      var thenewdate = new Date ();
336      thenewdate.setTime(thenewdate.getTime() + (5*24*60*60*1000));
337      var co_value = 'skin=' + document.getElementById('skin').options[document.getElementById('skin').selectedIndex].value + '###' +
338                     'lang=' + document.getElementById('lang').options[document.getElementById('lang').selectedIndex].value + '###' +
339                     'num=' + document.getElementById('num').value + '###';
340      var s_value='';
341      for(var x = 0; x < document.forms[0].plugins.length; x++) {
342        if(document.forms[0].plugins[x].checked)
343          s_value += document.forms[0].plugins[x].value + '/';
344      }
345      if(s_value!='') {
346        co_value += 'plugins=' + s_value + '###'
347      }
348      setCookie('co_ext_Xinha', co_value, thenewdate);
349      if (_oldSubmitHandler != null) {
350        _oldSubmitHandler();
351      }
352    }
353    document.forms[0].onsubmit = frame_onSubmit;
354  </script>
355
356</body>
357</html>
Note: See TracBrowser for help on using the repository browser.