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

Last change on this file since 480 was 433, checked in by gocher, 14 years ago

Changes to CharCounter? Plugin
and updates of extended example to check it

File size: 10.9 KB
Line 
1<?PHP
2  $LocalPluginPath = dirname(dirname(__FILE__)).'\plugins';
3  $LocalSkinPath = dirname(dirname(__File__)).'\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    statusBar: true,
34    mozParaHandler: "best",
35    undoSteps: 20,
36    baseHref: null,
37    stripBaseHref: true,
38    stripSelfNamedAnchors: true,
39    only7BitPrintablesInURLs: true,
40    sevenBitClean: false,
41    killWordOnPaste: true,
42    flowToolbars: true,
43    CharacterMapMode: "popup",
44    ListTypeMode: "toolbar",
45    showLoading: false,
46    showChar: true,
47    showWord: true,
48    showHtml: true
49  };
50
51
52    function getCookieVal (offset) {
53      var endstr = document.cookie.indexOf (";", offset);
54      if (endstr == -1)
55        endstr = document.cookie.length;
56      return unescape(document.cookie.substring(offset, endstr));
57    }
58
59    function getCookie (name) {
60      var arg = name + "=";
61      var alen = arg.length;
62      var clen = document.cookie.length;
63      var i = 0;
64      while (i < clen) {
65        var j = i + alen;
66        if (document.cookie.substring(i, j) == arg)
67          return getCookieVal (j);
68        i = document.cookie.indexOf(" ", i) + 1;
69        if (i == 0) break;
70      }
71      return null;
72    }
73
74    function setCookie (name, value) {
75      var argv = setCookie.arguments;
76      var argc = setCookie.arguments.length;
77      var expires = (argc > 2) ? argv[2] : null;
78      var path = (argc > 3) ? argv[3] : null;
79      var domain = (argc > 4) ? argv[4] : null;
80      var secure = (argc > 5) ? argv[5] : false;
81      document.cookie = name + "=" + escape (value) +
82        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
83        ((path == null) ? "" : ("; path=" + path)) +
84        ((domain == null) ? "" : ("; domain=" + domain)) +
85        ((secure == true) ? "; secure" : "");
86    }
87
88  function _onResize() {
89    var sHeight;
90    if (window.innerHeight) sHeight = window.innerHeight;
91    else if (document.body && document.body.offsetHeight) sHeight = document.body.offsetHeight;
92    else return;
93    if (sHeight>270) {
94      sHeight = sHeight - 245;
95    } else {
96      sHeight = 30
97    }
98    var div = document.getElementById("div_plugins");
99    div.style.height = sHeight + "px";
100  }
101
102function Dialog(url, action, init) {
103        if (typeof init == "undefined") {
104                init = window;  // pass this window object by default
105        }
106        Dialog._geckoOpenModal(url, action, init);
107};
108
109Dialog._parentEvent = function(ev) {
110        setTimeout( function() { if (Dialog._modal && !Dialog._modal.closed) { Dialog._modal.focus() } }, 50);
111        if (Dialog._modal && !Dialog._modal.closed) {
112                agt = navigator.userAgent.toLowerCase();
113                is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
114                if (is_ie) {
115                        ev.cancelBubble = true;
116                        ev.returnValue = false;
117                } else {
118                        ev.preventDefault();
119                        ev.stopPropagation();
120                }
121        }
122};
123
124
125// should be a function, the return handler of the currently opened dialog.
126Dialog._return = null;
127
128// constant, the currently opened dialog
129Dialog._modal = null;
130
131// the dialog will read it's args from this variable
132Dialog._arguments = null;
133
134Dialog._geckoOpenModal = function(url, action, init) {
135        var dlg = window.open(url, "hadialog",
136                              "toolbar=no,menubar=no,personalbar=no,width=10,height=10," +
137                              "scrollbars=no,resizable=yes,modal=yes,dependable=yes");
138        Dialog._modal = dlg;
139        Dialog._arguments = init;
140
141        // capture some window's events
142        function capwin(w) {
143//              HTMLArea._addEvent(w, "click", Dialog._parentEvent);
144//              HTMLArea._addEvent(w, "mousedown", Dialog._parentEvent);
145//              HTMLArea._addEvent(w, "focus", Dialog._parentEvent);
146        };
147        // release the captured events
148        function relwin(w) {
149//              HTMLArea._removeEvent(w, "click", Dialog._parentEvent);
150//              HTMLArea._removeEvent(w, "mousedown", Dialog._parentEvent);
151//              HTMLArea._removeEvent(w, "focus", Dialog._parentEvent);
152        };
153        capwin(window);
154        // capture other frames
155        for (var i = 0; i < window.frames.length; capwin(window.frames[i++]));
156        // make up a function to be called when the Dialog ends.
157        Dialog._return = function (val) {
158                if (val && action) {
159                        action(val);
160                }
161                relwin(window);
162                // capture other frames
163                for (var i = 0; i < window.frames.length; relwin(window.frames[i++]));
164                Dialog._modal = null;
165        };
166};
167
168  function fExtended () {
169    Dialog("Extended.html", function(param) {
170      if(param) {
171        settings.width = param["width"];
172        settings.height = param["height"];
173        settings.sizeIncludesBars = (param["sizeIncludesBars"]=="true");
174        settings.statusBar = (param["statusBar"]=="true");
175        settings.mozParaHandler = param["mozParaHandler"];
176        settings.undoSteps = param["undoSteps"];
177        settings.baseHref = param["baseHref"];
178        settings.stripBaseHref = (param["stripBaseHref"]=="true");
179        settings.stripSelfNamedAnchors = (param["stripSelfNamedAnchors"]=="true");
180        settings.only7BitPrintablesInURLs = (param["only7BitPrintablesInURLs"]=="true");
181        settings.sevenBitClean = (param["sevenBitClean"]=="true");
182        settings.killWordOnPaste = (param["killWordOnPaste"]=="true");
183        settings.flowToolbars = (param["flowToolbars"]=="true");
184        settings.CharacterMapMode = param["CharacterMapMode"];
185        settings.ListTypeMode = param["ListTypeMode"];
186        settings.showLoading = (param["showLoading"]=="true");
187        settings.showChar = (param["showChar"]=="true");
188        settings.showWord = (param["showWord"]=="true");
189        settings.showHtml = (param["showHtml"]=="true");
190      }
191    }, settings );
192  }
193
194  function init(){
195    var co = getCookie('co_ext_Xinha');
196    if(co!=null){
197      var co_values;
198      var co_entries = co.split('###');
199      for (var i in co_entries) {
200        co_values = co_entries[i].split('=');
201        if(co_values[0]=='plugins') {
202          for(var x = 0; x < document.forms[0].plugins.length; x++) {
203            if(co_values[1].indexOf(document.forms[0].plugins[x].value)!=-1) {
204              document.forms[0].plugins[x].checked = true;
205            }
206          }
207        } else if(co_values[0]!='') {
208          document.getElementById(co_values[0]).value = co_values[1];
209        }
210      }
211    }
212    _onResize();
213  };
214
215  window.onresize = _onResize;
216  window.onload = init;
217  </script>
218</head>
219
220<body>
221  <form action="ext_example-body.html" target="body" name="fsettings" id="fsettings">
222  <h1>Xinha Example</h1>
223    <fieldset>
224      <legend>Settings</legend>
225        <label>
226          Number of Editors: <input type="text" name="num" id="num" value="1" style="width:25;" maxlength="2"/>
227        </label>
228        <label>
229          Language:
230          <select name="lang" id="lang">
231          <option value="en">English</option>
232          <option value="de">German</option>
233          <option value="fr">French</option>
234          <option value="it">Italian</option>
235          <option value="no">Norwegian</option>
236          <option value="pl">Polish</option>
237          </select>
238        </label>
239        <label>
240          Skin:
241          <select name="skin" id="skin">
242          <option value="">-- no skin --</option>
243<?php
244        $d = @dir($LocalSkinPath);
245        while (false !== ($entry = $d->read()))  //not a dot file or directory
246        {       if(substr($entry,0,1) != '.')
247                { echo '<option value="' . $entry . '"> ' . $entry . '</option>'."\n";
248                }
249        }
250        $d->close();
251?>
252          </select>
253        </label>
254        <center><input type="button" value="extended Settings" onClick="fExtended();" /></center>
255
256    </fieldset>
257    <fieldset>
258      <legend>Plugins</legend>
259      <div id="div_plugins" style="width:100%; overflow:auto">
260<?php
261        $d = @dir($LocalPluginPath);
262        while (false !== ($entry = $d->read()))  //not a dot file or directory
263        {       if(substr($entry,0,1) != '.')
264                { echo '<label><input type="checkbox" name="plugins" id="plugins" value="' . $entry . '"> ' . $entry . '</label>'."\n";
265                }
266        }
267        $d->close();
268?>
269      </div>
270    </fieldset>
271    <center><button type="submit">reload editor</button></center>
272
273        <textarea id="myTextarea0" style="display:none">
274          <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
275          Aliquam et tellus vitae justo varius placerat. Suspendisse iaculis
276          velit semper dolor. Donec gravida tincidunt mi. Curabitur tristique
277          ante elementum turpis. Aliquam nisl. Nulla posuere neque non
278          tellus. Morbi vel nibh. Cum sociis natoque penatibus et magnis dis
279          parturient montes, nascetur ridiculus mus. Nam nec wisi. In wisi.
280          Curabitur pharetra bibendum lectus.</p>
281
282          <ul>
283            <li> Phasellus et massa sed diam viverra semper.  </li>
284            <li> Mauris tincidunt felis in odio.              </li>
285            <li> Nulla placerat nunc ut pede.                 </li>
286            <li> Vivamus ultrices mi sit amet urna.           </li>
287            <li> Quisque sed augue quis nunc laoreet volutpat.</li>
288            <li> Nunc sit amet metus in tortor semper mattis. </li>
289          </ul>
290        </textarea>
291
292  </form>
293  <script type="text/javascript">
294    top.frames["body"].location.href = document.location.href.replace(/ext_example-menu\.php.*/, 'ext_example-body.html')
295    var _oldSubmitHandler = null;
296    if (document.forms[0].onsubmit != null) {
297      _oldSubmitHandler = document.forms[0].onsubmit;
298    }
299    function frame_onSubmit(){
300      var thenewdate = new Date ();
301      thenewdate.setTime(thenewdate.getTime() + (5*24*60*60*1000));
302      var co_value = 'skin=' + document.getElementById('skin').options[document.getElementById('skin').selectedIndex].value + '###' +
303                     'lang=' + document.getElementById('lang').options[document.getElementById('lang').selectedIndex].value + '###' +
304                     'num=' + document.getElementById('num').value + '###';
305      var s_value='';
306      for(var x = 0; x < document.forms[0].plugins.length; x++) {
307        if(document.forms[0].plugins[x].checked)
308          s_value += document.forms[0].plugins[x].value + '/';
309      }
310      if(s_value!='') {
311        co_value += 'plugins=' + s_value + '###'
312      }
313      setCookie('co_ext_Xinha', co_value, thenewdate);
314      if (_oldSubmitHandler != null) {
315        _oldSubmitHandler();
316      }
317    }
318    document.forms[0].onsubmit = frame_onSubmit;
319  </script>
320
321</body>
322</html>
Note: See TracBrowser for help on using the repository browser.