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

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

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

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