source: trunk/examples/Extended.html @ 887

Last change on this file since 887 was 845, checked in by gocher, 13 years ago
  • integrate new config settings in the example:

sizeIncludesPanels, htmlareaPaste, getHtmlMethod, undoTimeout, changeJustifyWithDirection, fullPage, pageStyle, expandRelativeUrl, maikeLinkShowsTarget, stripScripts

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 12.3 KB
Line 
1<html>
2
3<head>
4  <title>Settings</title>
5  <link rel="stylesheet" type="text/css" href="../popups/popup.css" />
6  <script type="text/javascript">
7
8function getAbsolutePos(el) {
9  var r = { x: el.offsetLeft, y: el.offsetTop };
10  if (el.offsetParent) {
11    var tmp = getAbsolutePos(el.offsetParent);
12    r.x += tmp.x;
13    r.y += tmp.y;
14  }
15  return r;
16};
17
18function getSelectedValue(el) {
19  if(!el)
20    return "";
21  return el[el.selectedIndex].value;
22}
23
24function setSelectedValue(el, val) {
25  if(!el)
26    return "";
27  var ops = el.getElementsByTagName("option");
28  for (var i = ops.length; --i >= 0;) {
29    var op = ops[i];
30    op.selected = (op.value == val);
31  }
32  el.value = val;
33}
34
35function getCheckedValue(el) {
36  if(!el)
37    return "";
38  var radioLength = el.length;
39  if(radioLength == undefined)
40    if(el.checked)
41      return el.value;
42    else
43      return "false";
44  for(var i = 0; i < radioLength; i++) {
45    if(el[i].checked) {
46      return el[i].value;
47    }
48  }
49  return "";
50}
51
52function setCheckedValue(el, val) {
53  if(!el)
54    return;
55  var radioLength = el.length;
56  if(radioLength == undefined) {
57    el.checked = (el.value == val.toString());
58    return;
59  }
60  for(var i = 0; i < radioLength; i++) {
61    el[i].checked = false;
62    if(el[i].value == val.toString()) {
63      el[i].checked = true;
64    }
65  }
66}
67
68function __dlg_onclose() {
69  opener.Dialog._return(null);
70};
71
72// closes the dialog and passes the return info upper.
73function __dlg_close(val) {
74  opener.Dialog._return(val);
75  window.close();
76};
77
78function __dlg_close_on_esc(ev) {
79  ev || (ev = window.event);
80  if (ev.keyCode == 27) {
81    window.close();
82    return false;
83  }
84  return true;
85};
86
87function __dlg_init(bottom) {
88  var body = document.body;
89  var body_height = 0;
90  if (typeof bottom == "undefined") {
91    var div = document.createElement("div");
92    body.appendChild(div);
93    var pos = getAbsolutePos(div);
94    body_height = pos.y;
95  } else {
96    var pos = getAbsolutePos(bottom);
97    body_height = pos.y + bottom.offsetHeight;
98  }
99  window.dialogArguments = opener.Dialog._arguments;
100  if (!document.all) {
101    window.sizeToContent();
102    window.sizeToContent();  // for reasons beyond understanding,
103          // only if we call it twice we get the
104          // correct size.
105    window.addEventListener("unload", __dlg_onclose, true);
106    window.innerWidth = body.offsetWidth + 5;
107    window.innerHeight = body_height + 2;
108    // center on parent
109    var x = opener.screenX + (opener.outerWidth - window.outerWidth) / 2;
110    var y = opener.screenY + (opener.outerHeight - window.outerHeight) / 2;
111    window.moveTo(x, y);
112  } else {
113    // window.dialogHeight = body.offsetHeight + 50 + "px";
114    // window.dialogWidth = body.offsetWidth + "px";
115    window.resizeTo(body.offsetWidth, body_height);
116    var ch = body.clientHeight;
117    var cw = body.clientWidth;
118    window.resizeBy(body.offsetWidth - cw, body_height - ch);
119    var W = body.offsetWidth;
120    var H = 2 * body_height - ch;
121    var x = (screen.availWidth - W) / 2;
122    var y = (screen.availHeight - H) / 2;
123    window.moveTo(x, y);
124  }
125  document.body.onkeypress = __dlg_close_on_esc;
126};
127
128function placeFocus() {
129var bFound = false;
130  // for each form
131  for (f=0; f < document.forms.length; f++) {
132    // for each element in each form
133    for(i=0; i < document.forms[f].length; i++) {
134      // if it's not a hidden element
135      if (document.forms[f][i].type != "hidden") {
136        // and it's not disabled
137        if (document.forms[f][i].disabled != true) {
138            // set the focus to it
139            document.forms[f][i].focus();
140            var bFound = true;
141        }
142      }
143      // if found in this element, stop looking
144      if (bFound == true)
145        break;
146    }
147    // if found in this form, stop looking
148    if (bFound == true)
149      break;
150  }
151}
152
153function Init() {
154  __dlg_init();
155  var param = window.dialogArguments;
156  if(param) {
157    var el;
158    for (var field in param) {
159      //alert(field + '="' + param[field] + '"');
160      el = document.getElementById(field);
161      if (el.tagName.toLowerCase()=="input"){
162        if ((el.type.toLowerCase()=="radio") || (el.type.toLowerCase()=="checkbox")){
163          setCheckedValue(el, param[field]);
164        } else {
165          el.value = param[field];
166        }
167      } else if (el.tagName.toLowerCase()=="select"){
168        setSelectedValue(el, param[field]);
169      } else if (el.tagName.toLowerCase()=="textarea"){
170        el.value = param[field];
171      }
172    }
173  }
174  placeFocus();
175};
176
177// pass data back to the calling window
178function onOK() {
179  var param = new Object();
180  var el = document.getElementsByTagName('input');
181  for (var i=0; i<el.length;i++){
182    if ((el[i].type.toLowerCase()=="radio") || (el[i].type.toLowerCase()=="checkbox")){
183      if (getCheckedValue(el[i])!=''){
184        param[el[i].id] = getCheckedValue(el[i]);
185      }
186    } else {
187      param[el[i].id] = el[i].value;
188    }
189  }
190  el = document.getElementsByTagName('select');
191  for (var i=0; i<el.length;i++){
192    param[el[i].id] = getSelectedValue(el[i]);
193  }
194  el = document.getElementsByTagName('textarea');
195  for (var i=0; i<el.length;i++){
196    param[el[i].id] = el[i].value;
197  }
198  __dlg_close(param);
199  return false;
200};
201
202function onCancel() {
203  __dlg_close(null);
204  return false;
205};
206
207</script>
208
209<style type="text/css">
210  label { width: 16em; float: left; padding: 2px 5px; text-align: right; }
211  br { clear: both; }
212</style>
213
214</head>
215
216<body class="dialog" onload="Init(); window.resizeTo(420, 820);">
217<div class="title">Settings</div>
218  <form action="" method="get">
219  <fieldset>
220    <legend>Xinha options</legend>
221    <label for="width">Editor width:</label>
222    <input type="text" name="width" id="width" title="Allowed values are 'auto', 'toolbar' or a numeric value followed by 'px'." /><br />
223    <label for="height">Editor height:</label>
224    <input type="text" name="height" id="height" title="Allowed values are 'auto' or a numeric value followed by 'px'." /><br />
225    <label for="sizeIncludesBars">Size includes bars</label>
226    <input type="checkbox" name="sizeIncludesBars" id="sizeIncludesBars" value="true" title="Specifies whether the toolbar should be included in the size, or are extra to it." /><br />
227    <label for="sizeIncludesPanels">Size includes panels</label>
228    <input type="checkbox" name="sizeIncludesPanels" id="sizeIncludesPanels" value="true" title="Specifies whether the panels should be included in the size, or are extra to it." /><br />
229    <label for="statusBar">Status Bar</label>
230    <input type="checkbox" name="statusBar" id="statusBar" value="true" title="Enable creation of the status bar?" /><br />
231    <label for="htmlareaPaste">Htmlarea Paste</label>
232    <input type="checkbox" name="htmlareaPaste" id="htmlareaPaste" value="true" title="Intercept ^V and use the Xinha paste command" /><br />
233    <label for="mozParaHandler">Mozilla Parameter Handler:</label>
234    <select name="mozParaHandler" id="mozParaHandler" title="Gecko only: Let the built-in routine for handling the return key decide if to enter br or p tags or use a custom implementation.">
235    <option value="built-in">built-in</option>
236    <option value="dirty">dirty</option>
237    <option value="best">best</option>
238    </select><br />
239    <label for="getHtmlMethod">GetHtml Method:</label>
240    <select name="getHtmlMethod" id="getHtmlMethod" title="This determines the method how the HTML output is generated.">
241    <option value="DOMwalk">DOMwalk</option>
242    <option value="TransformInnerHTML">TransformInnerHTML</option>
243    </select><br />
244    <label for="undoSteps">Undo steps:</label>
245    <input type="text" name="undoSteps" id="undoSteps" title="Maximum size of the undo queue."  /><br />
246    <label for="undoTimeout">Undo Timeout:</label>
247    <input type="text" name="undoTimeout" id="undoTimeout" title="The time interval at which undo samples are taken, default: 500 (1/2 sec)."  /><br />
248    <label for="changeJustifyWithDirection">change justify with direction</label>
249    <input type="checkbox" name="changeJustifyWithDirection" id="changeJustifyWithDirection" value="true" title="Set this to true if you want to explicitly right-justify when setting the text direction to right-to-left" /><br />
250    <label for="fullPage">full Page</label>
251    <input type="checkbox" name="fullPage" id="fullPage" value="true" title="If true then Xinha will retrieve the full HTML, starting with the HTML-tag." /><br />
252    <label for="pageStyle">Page style:</label>
253    <textarea name="pageStyle" id="pageStyle" title="Raw style definitions included in the edited document"></textarea>
254<!--    pageStyleSheets -->
255    <label for="baseHref">Base href:</label>
256    <input type="text" name="baseHref" id="baseHref" title="specify a base href for relative links" /><br />
257    <label for="expandRelativeUrl">expand relative Url</label>
258    <input type="checkbox" name="expandRelativeUrl" id="expandRelativeUrl" value="true" title="If true, relative URLs (../) will be made absolute"/><br />
259    <label for="stripBaseHref">Strip base href</label>
260    <input type="checkbox" name="stripBaseHref" id="stripBaseHref" value="true" title="We can strip the server part out of URL to make/leave them semi-absolute" /><br />
261    <label for="stripSelfNamedAnchors">Strip self named anchors</label>
262    <input type="checkbox" name="stripSelfNamedAnchors" id="stripSelfNamedAnchors" value="true" title="We can strip the url of the editor page from named links" /><br />
263    <label for="only7BitPrintablesInURLs">only 7bit printables in URLs</label>
264    <input type="checkbox" name="only7BitPrintablesInURLs" id="only7BitPrintablesInURLs" value="true" title="In URLs all characters above ASCII value 127 have to be encoded using % codes" /><br />
265    <label for="sevenBitClean">7bit Clean</label>
266    <input type="checkbox" name="sevenBitClean" id="sevenBitClean" value="true" title="If you are putting the HTML written in Xinha into an email you might want it to be 7-bit characters only." /><br />
267    <label for="killWordOnPaste">kill Word on paste</label>
268    <input type="checkbox" name="killWordOnPaste" id="killWordOnPaste" value="true" title="Set to true if you want Word code to be cleaned upon Paste." /><br />
269    <label for="makeLinkShowsTarget">make Link Shows Target</label>
270    <input type="checkbox" name="makeLinkShowsTarget" id="makeLinkShowsTarget" value="true" title="Enable the 'Target' field in the Make Link dialog." /><br />
271    <label for="flowToolbars">flow toolbars</label>
272    <input type="checkbox" name="flowToolbars" id="flowToolbars" value="true" /><br />
273    <label for="stripScripts">strip Scripts</label>
274    <input type="checkbox" name="stripScripts" id="stripScripts" value="true" title="Set to false if you want to allow JavaScript in the content" /><br />
275    <label for="showLoading">show loading</label>
276    <input type="checkbox" name="showLoading" id="showLoading" value="true" /><br />
277  </fieldset>
278
279  <fieldset id="CharacterMapOptions" class="options">
280    <legend>CharacterMap options</legend>
281    <label for="CharacterMapMode">Mode :</label>
282    <select id="CharacterMapMode" name="CharacterMapMode">
283    <option value="popup">popup</option>
284    <option value="panel">panel</option>
285    </select>
286  </fieldset>
287
288  <fieldset id="ListTypeOptions" class="options">
289    <legend>ListType options</legend>
290    <label class="ListTypeMode">Mode :</label>
291    <select id="ListTypeMode" name="ListTypeMode">
292    <option value="toolbar">toolbar</option>
293    <option value="panel">panel</option>
294    </select>
295  </fieldset>
296
297  <fieldset id="CharCounterOptions" class="options">
298    <legend>CharCounter options</legend>
299    <label for="showChar">show Char :</label>
300    <input type="checkbox" name="showChar" id="showChar" value="true" /><br />
301    <label for="showWord">show Word :</label>
302    <input type="checkbox" name="showWord" id="showWord" value="true" /><br />
303    <label for="showHtml">show Html :</label>
304    <input type="checkbox" name="showHtml" id="showHtml" value="true" /><br />
305  </fieldset>
306  <br />
307
308  <div id="buttons">
309    <button type="submit" name="ok" onclick="return onOK();">OK</button>
310    <button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
311  </div>
312</form>
313</body>
314</html>
Note: See TracBrowser for help on using the repository browser.