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

Last change on this file since 781 was 715, checked in by htanaka, 13 years ago

Ticket #939 Japanese translation finished.
fix translation capability of Forms,FormOperations?,InsertMarquee? and NoteServer?.
append Japanese to language option in ext_example page.
(Forms became silent in updating properties, and fixed <FORM> tag update problem.)

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 11.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    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//              Xinha._addEvent(w, "click", Dialog._parentEvent);
144//              Xinha._addEvent(w, "mousedown", Dialog._parentEvent);
145//              Xinha._addEvent(w, "focus", Dialog._parentEvent);
146        };
147        // release the captured events
148        function relwin(w) {
149//              Xinha._removeEvent(w, "click", Dialog._parentEvent);
150//              Xinha._removeEvent(w, "mousedown", Dialog._parentEvent);
151//              Xinha._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          <option value="ja">Japanese</option>
238          </select>
239        </label>
240        <label>
241          Skin:
242          <select name="skin" id="skin">
243          <option value="">-- no skin --</option>
244<?php
245        $d = @dir($LocalSkinPath);
246        while (false !== ($entry = $d->read()))  //not a dot file or directory
247        {       if(substr($entry,0,1) != '.')
248                { echo '<option value="' . $entry . '"> ' . $entry . '</option>'."\n";
249                }
250        }
251        $d->close();
252?>
253          </select>
254        </label>
255        <center><input type="button" value="extended Settings" onClick="fExtended();" /></center>
256
257    </fieldset>
258    <fieldset>
259      <legend>Plugins</legend>
260      <div id="div_plugins" style="width:100%; overflow:auto">
261<?php
262        $d = @dir($LocalPluginPath);
263        $dir_array = array();
264        while (false !== ($entry = $d->read()))  //not a dot file or directory
265        {       if(substr($entry,0,1) != '.')
266                {
267                        $dir_array[] = $entry;
268                }
269        }
270        $d->close();
271        sort($dir_array);
272        foreach ($dir_array as $entry)
273        {
274                echo '<label><input type="checkbox" name="plugins" id="plugins" value="' . $entry . '"> ' . $entry . '</label>'."\n";
275        }
276
277?>
278      </div>
279    </fieldset>
280    <center><button type="submit">reload editor</button></center>
281
282        <textarea id="myTextarea0" style="display:none">
283          <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
284          Aliquam et tellus vitae justo varius placerat. Suspendisse iaculis
285          velit semper dolor. Donec gravida tincidunt mi. Curabitur tristique
286          ante elementum turpis. Aliquam nisl. Nulla posuere neque non
287          tellus. Morbi vel nibh. Cum sociis natoque penatibus et magnis dis
288          parturient montes, nascetur ridiculus mus. Nam nec wisi. In wisi.
289          Curabitur pharetra bibendum lectus.</p>
290
291          <ul>
292            <li> Phasellus et massa sed diam viverra semper.  </li>
293            <li> Mauris tincidunt felis in odio.              </li>
294            <li> Nulla placerat nunc ut pede.                 </li>
295            <li> Vivamus ultrices mi sit amet urna.           </li>
296            <li> Quisque sed augue quis nunc laoreet volutpat.</li>
297            <li> Nunc sit amet metus in tortor semper mattis. </li>
298          </ul>
299        </textarea>
300
301  </form>
302  <script type="text/javascript">
303    top.frames["body"].location.href = document.location.href.replace(/ext_example-menu\.php.*/, 'ext_example-body.html')
304    var _oldSubmitHandler = null;
305    if (document.forms[0].onsubmit != null) {
306      _oldSubmitHandler = document.forms[0].onsubmit;
307    }
308    function frame_onSubmit(){
309      var thenewdate = new Date ();
310      thenewdate.setTime(thenewdate.getTime() + (5*24*60*60*1000));
311      var co_value = 'skin=' + document.getElementById('skin').options[document.getElementById('skin').selectedIndex].value + '###' +
312                     'lang=' + document.getElementById('lang').options[document.getElementById('lang').selectedIndex].value + '###' +
313                     'num=' + document.getElementById('num').value + '###';
314      var s_value='';
315      for(var x = 0; x < document.forms[0].plugins.length; x++) {
316        if(document.forms[0].plugins[x].checked)
317          s_value += document.forms[0].plugins[x].value + '/';
318      }
319      if(s_value!='') {
320        co_value += 'plugins=' + s_value + '###'
321      }
322      setCookie('co_ext_Xinha', co_value, thenewdate);
323      if (_oldSubmitHandler != null) {
324        _oldSubmitHandler();
325      }
326    }
327    document.forms[0].onsubmit = frame_onSubmit;
328  </script>
329
330</body>
331</html>
Note: See TracBrowser for help on using the repository browser.