Import xinha so we can switch from htmlarea and fix a bunch of in-browser issues that htmlarea has

This commit is contained in:
Chris Morgan
2005-09-30 02:25:07 +00:00
committed by WineHQ
parent 2311d4d572
commit 9242a68c4a
375 changed files with 26623 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
form {
border: 1px dotted red;
}

View File

@@ -0,0 +1,354 @@
// Form plugin for HTMLArea
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
function Forms(editor) {
this.editor = editor;
var cfg = editor.config;
var bl = Forms.btnList;
var self = this;
// register the toolbar buttons provided by this plugin
var toolbar = ["linebreak"];
for (var i = 0; i < bl.length; ++i) {
var btn = bl[i];
if (!btn) {
toolbar.push("separator");
} else {
var id = btn[0];
cfg.registerButton(id, HTMLArea._lc(btn[1]), editor.imgURL("ed_" + btn[0] + ".gif", "Forms"), false,
function(editor, id) {
// dispatch button press event
self.buttonPress(editor, id);
});
toolbar.push(id);
}
}
// add a new line in the toolbar
cfg.toolbar.push(toolbar);
};
Forms._pluginInfo = {
name : "Forms",
origin : "version: 1.0, by Nelson Bright, BrightWork, Inc., http://www.brightworkweb.com",
version : "2.0",
developer : "Udo Schmal",
developer_url : "",
sponsor : "L.N.Schaffrath NeueMedien",
sponsor_url : "http://www.schaffrath-neuemedien.de/",
c_owner : "Udo Schmal & Schaffrath-NeueMedien",
license : "htmlArea"
};
// the list of buttons added by this plugin
Forms.btnList = [
// form properties button
null, // separator
["form", "Form"],
null, // separator
// form elements
["textarea", "Textarea"],
["select", "Selection Field"],
["checkbox", "Checkbox"],
["radio", "Radio Button"],
["text", "Text Field"],
["password", "Password Field"],
["file", "File Field"],
["button", "Button"],
["submit", "Submit Button"],
["reset", "Reset Button"],
["image", "Image Button"],
["hidden", "Hidden Field"],
["label", "Label"],
["fieldset", "Field Set"]
];
Forms.prototype._lc = function(string) {
return HTMLArea._lc(string, 'Forms');
}
Forms.prototype.onGenerate = function() {
var style_id = "Form-style"
var style = this.editor._doc.getElementById(style_id);
if (style == null) {
style = this.editor._doc.createElement("link");
style.id = style_id;
style.rel = 'stylesheet';
style.href = _editor_url + 'plugins/Forms/forms.css';
this.editor._doc.getElementsByTagName("HEAD")[0].appendChild(style);
}
}
Forms.prototype.buttonPress = function(editor,button_id, node) {
function optionValues(text,value) {
this.text = text;
this.value = value;
}
var outparam = new Object();
var type = button_id;
var sel = editor._getSelection();
var range = editor._createRange(sel);
if (button_id=="form") { //Form
// see if selection is inside an existing 'form' tag
var pe = editor.getParentElement();
var frm = null;
while (pe && (pe.nodeType == 1) && (pe.tagName.toLowerCase() != 'body')) {
if(pe.tagName.toLowerCase() == "form") {
frm = pe;
break;
} else
pe = pe.parentNode;
}
if (frm) {
outparam.f_name = frm.name;
outparam.f_action = frm.action;
outparam.f_method = frm.method;
outparam.f_enctype = frm.enctype;
outparam.f_target = frm.target;
} else {;
outparam.f_name = "";
outparam.f_action = "";
outparam.f_method = "";
outparam.f_enctype = "";
outparam.f_target = "";
}
editor._popupDialog("plugin://Forms/form", function(param) {
if (param) {
if(frm) {
frm.name = param["f_name"];
setAttr(frm, "action", param["f_action"]);
setAttr(frm, "method", param["f_method"]);
setAttr(frm, "enctype",param["f_enctype"]);
setAttr(frm, "target", param["f_target"]);
} else {
frm = '<form name="' + param["f_name"] + '"';
if (param["f_action"] != "") frm += ' action="' + param["f_action"] + '"';
if (param["f_method"] != "") frm += ' method="' + param["f_method"] + '"';
if (param["f_enctype"] != "") frm += ' enctype="' + param["f_enctype"] + '"';
if (param["f_target"] != "") frm += ' target="' + param["f_target"] + '"';
frm += '>';
editor.surroundHTML(frm, '&nbsp;</form>');
}
}
}, outparam);
} else { // form element (checkbox, radio, text, password, textarea, select, button, submit, reset, image, hidden)
var tagName = "";
// see if selection is an form element
if (typeof node == "undefined") {
node = editor.getParentElement();
var tag = node.tagName.toLowerCase()
if (node && (tag == "legend")) {
node = node.parentElement;
tag = node.tagName.toLowerCase();
}
if (node && !(tag == "textarea" || tag == "select" || tag == "input" || tag == "label" || tag == "fieldset"))
node = null;
}
if(node) {
type = node.tagName.toLowerCase();
outparam.f_name = node.name;
tagName = node.tagName;
if (type == "input") {
outparam.f_type = node.type;
type = node.type;
}
switch (type) {
case "textarea":
outparam.f_cols = node.cols;
outparam.f_rows = node.rows;
outparam.f_text = node.innerHTML;
outparam.f_wrap = node.getAttribute("wrap");
outparam.f_readOnly = node.getAttribute("readOnly");
outparam.f_disabled = node.getAttribute("disabled");
outparam.f_tabindex = node.getAttribute("tabindex");
outparam.f_accesskey = node.getAttribute("accesskey");
break;
case "select":
outparam.f_size = parseInt(node.size);
outparam.f_multiple = node.getAttribute("multiple");
outparam.f_disabled = node.getAttribute("disabled");
outparam.f_tabindex = node.getAttribute("tabindex");
var a_options = new Array();
for (var i=0; i<=node.options.length-1; i++) {
a_options[i] = new optionValues(node.options[i].text, node.options[i].value);
};
outparam.f_options = a_options;
break;
case "text":
case "password":
outparam.f_value = node.value;
outparam.f_size = node.size;
outparam.f_maxLength = node.maxLength;
outparam.f_readOnly = node.getAttribute("readOnly");
outparam.f_disabled = node.getAttribute("disabled");
outparam.f_tabindex = node.getAttribute("tabindex");
outparam.f_accesskey = node.getAttribute("accesskey");
break;
case "hidden":
outparam.f_value = node.value;
break;
case "submit":
case "reset":
outparam.f_value = node.value;
outparam.f_disabled = node.getAttribute("disabled");
outparam.f_tabindex = node.getAttribute("tabindex");
outparam.f_accesskey = node.getAttribute("accesskey");
break;
case "checkbox":
case "radio":
outparam.f_value = node.value;
outparam.f_checked = node.checked;
outparam.f_disabled = node.getAttribute("disabled");
outparam.f_tabindex = node.getAttribute("tabindex");
outparam.f_accesskey = node.getAttribute("accesskey");
break;
case "button":
outparam.f_value = node.value;
outparam.f_onclick = node.getAttribute("onclick");
outparam.f_disabled = node.getAttribute("disabled");
outparam.f_tabindex = node.getAttribute("tabindex");
outparam.f_accesskey = node.getAttribute("accesskey");
break;
case "image":
outparam.f_value = node.value;
outparam.f_src = node.src;
outparam.f_disabled = node.getAttribute("disabled");
outparam.f_tabindex = node.getAttribute("tabindex");
outparam.f_accesskey = node.getAttribute("accesskey");
break;
case "file":
outparam.f_disabled = node.getAttribute("disabled");
outparam.f_tabindex = node.getAttribute("tabindex");
outparam.f_accesskey = node.getAttribute("accesskey");
break;
case "label":
outparam.f_text = node.innerHTML;
outparam.f_for = node.getAttribute("for");
outparam.f_accesskey = node.getAttribute("accesskey");
break;
case "fieldset":
if(node.firstChild.tagName.toLowerCase()=="legend")
outparam.f_text = node.firstChild.innerHTML;
else
outparam.f_text = "";
break;
}
} else {
outparam.f_name = "";
switch (button_id) {
case "textarea":
case "select":
case "label":
case "fieldset":
tagName = button_id;
break;
default:
tagName = "input";
outparam.f_type = button_id;
break;
}
outparam.f_options = "";
outparam.f_cols = "20";
outparam.f_rows = "4";
outparam.f_multiple = "false";
outparam.f_value = "";
outparam.f_size = "";
outparam.f_maxLength = "";
outparam.f_checked = "";
outparam.f_src = "";
outparam.f_onclick = "";
outparam.f_wrap = "";
outparam.f_readOnly = "false";
outparam.f_disabled = "false";
outparam.f_tabindex = "";
outparam.f_accesskey = "";
outparam.f_for = "";
outparam.f_text = "";
outparam.f_legend = "";
};
editor._popupDialog("plugin://Forms/" + tagName + ".html", function(param) {
if (param) {
if(param["f_cols"])
if (isNaN(parseInt(param["f_cols"],10)) || parseInt(param["f_cols"],10) <= 0)
param["f_cols"] = "";
if(param["f_rows"])
if(isNaN(parseInt(param["f_rows"],10)) || parseInt(param["f_rows"],10) <= 0)
param["f_rows"] = "";
if(param["f_size"])
if(isNaN(parseInt(param["f_size"],10)) || parseInt(param["f_size"],10) <= 0)
param["f_size"] = "";
if(param["f_maxlength"])
if(isNaN(parseInt(param["f_maxLength"],10)) || parseInt(param["f_maxLength"],10) <= 0)
param["f_maxLength"] = "";
if(node) {
//prepare existing Element
for (field in param) {
alert(field.substring(2,20) + '=' + param[field]);
if ((field=="f_text") || (field=="f_options") || (field=="f_onclick") || (field=="f_checked"))continue;
if (param[field] != "")
node.setAttribute(field.substring(2,20), param[field]);
else
node.removeAttribute(field.substring(2,20));
}
if (type == "textarea") {
node.innerHTML = param["f_text"];
} else if(type == "select") {
node.options.length = 0;
var optionsList = param["f_options"];
for (i=0; i<= optionsList.length-1; i++) {
node.options[i] = new Option(optionsList[i].text, optionsList[i].value)
}
} else if(type == "label") {
node.innerHTML = param["f_text"];
} else if(type == "fieldset") {
if(outparam.f_text != "") {
if(node.firstChild.tagName.toLowerCase()=="legend")
node.firstChild.innerHTML = param["f_text"];
} else {}// not implemented jet
} else if((type == "checkbox") || (type == "radio")) { //input
if(param["f_checked"]!="")
node.checked = true;
else
node.checked = false;
} else {
if(param["f_onclick"]){
node.onclick = "";
if(param["f_onclick"]!="")
node.onclick = param["f_onclick"];
}
}
} else {
//create Element
var text = "";
for (field in param) {
if (!param[field]) continue;
if ((param[field]=="") || (field=="f_text")|| (field=="f_options"))continue;
text += " " + field.substring(2,20) + '="' + param[field] + '"';
}
if(type == "textarea") {
text = '<textarea' + text + '>' + param["f_text"] + '</textarea>';
} else if(type == "select") {
text = '<select' + text + '>';
var optionsList = param["f_options"];
for (i=0; i<= optionsList.length-1; i++) {
text += '<option value="'+optionsList[i].value+'">'+optionsList[i].text+'</option>';
}
text += '</select>';
} else if(type == "label") {
text = '<label' + text + '>' + param["f_text"] + '</label>';
} else if(type == "fieldset") {
text = '<fieldset' + text + '>';
if (param["f_legend"] != "") text += '<legend>' + param["f_text"] + '</legend>';
text += '</fieldset>';
} else {
text = '<input type="'+type+'"' + text + '>';
}
editor.insertHTML(text);
}
}
}, outparam);
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 882 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 906 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 987 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 857 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 906 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 914 B

View File

@@ -0,0 +1,46 @@
<html>
<head>
<title>Insert/Edit Form Element FIELDSET</title>
<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
<script type="text/javascript" src="../../../popups/popup.js"></script>
<script type="text/javascript">
function Init() {
window.resizeTo(350,320);
__dlg_translate("Forms");
__dlg_init();
var param = window.dialogArguments;
document.getElementById("f_text").value = param["f_text"];
document.getElementById("f_text").focus();
};
function onOK() {
// pass data back to the calling window
var param = new Object();
param["f_text"] = document.getElementById("f_text").value;
__dlg_close(param);
return false;
};
function onCancel() {
__dlg_close(null);
return false;
};
</script>
</head>
<body class="dialog" onload="Init()">
<div id="f_type" class="title">Form Element: FIELDSET</div>
<form action="" method="get">
<div class="fr">Legend:</div>
<input type="text" name="text" id="f_text" />
<p />
<div id="buttons">
<button type="button" name="ok" onclick="return onOK();">OK</button>
<button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,90 @@
<html>
<head>
<title>Insert/Edit Form</title>
<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
<script type="text/javascript" src="../../../popups/popup.js"></script>
<script type="text/javascript">
var fields = ["f_name", "f_action", "f_method", "f_enctype", "f_target"];
function Init() {
window.resizeTo(400, 170);
__dlg_translate("Forms");
__dlg_init();
var param = window.dialogArguments;
for (var i in fields) {
document.getElementById(fields[i]).value = param[fields[i]];
}
document.getElementById("f_name").focus();
};
function onOK() {
var required = {
"f_name": "You must enter the form name"
};
for (var i in required) {
var el = document.getElementById(i);
if (!el.value) {
alert(required[i]);
el.focus();
return false;
}
}
// pass data back to the calling window
var param = new Object();
for (var i in fields) {
param[fields[i]] = document.getElementById(fields[i]).value;
}
__dlg_close(param);
return false;
};
function onCancel() {
__dlg_close(null);
return false;
};
</script>
</head>
<body class="dialog" onload="Init()">
<div class="title">Form</div>
<form action="" method="get">
<div class="fr">Form Name:</div>
<input type="text" name="name" id="f_name" size="20" title="Name" />
<p />
<fieldset>
<legend>Form handler script</legend>
<div class="space"></div>
<div class="fr">Action URL:</div>
<input name="action" id="f_action" type="text" size="30">
<p />
<div class="fr">Method:</div>
<select name="f_method" id="f_method">
<option value=""></option>
<option value="post">Post</option>
<option value="get">Get</option>
</select>
<div class="space"></div>
<div class="fr">Encoding:</div>
<select name="enctype" id="f_enctype">
<option value=""></option>
<option value="application/x-www-form-urlencoded">HTML-Form to CGI (default)</option>
<option value="multipart/form-data">multipart Form Data (File-Upload)</option>
</select>
<p />
<div class="fr">Target Frame:</div>
<input name="target" id="f_target" type="text" size="30">
<p />
</fieldset>
<div id="buttons">
<button type="button" name="ok" onclick="return onOK();">OK</button>
<button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,179 @@
<html>
<head>
<title>Insert/Edit Form Element INPUT</title>
<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
<script type="text/javascript" src="../../../popups/popup.js"></script>
<script type="text/javascript">
var fields = null;
var type;
function Init() {
__dlg_translate("Forms");
__dlg_init();
var param = window.dialogArguments;
type = param.f_type;
document.getElementById("f_type").innerHTML = 'Form Element: INPUT (' + type + ')';
document.getElementById("txt").style.display = "none";
document.getElementById("chk").style.display = "none";
document.getElementById("btn").style.display = "none";
document.getElementById("img").style.display = "none";
switch (type) {
case "text":
case "password":
fields = ["f_name", "f_value", "f_readOnly", "f_disabled", "f_tabindex", "f_accesskey", "f_size", "f_maxLength"];
height = 350;
document.getElementById("txt").style.display = "block";
break;
case "checkbox":
case "radio":
fields = ["f_name", "f_value", "f_checked", "f_disabled", "f_tabindex", "f_accesskey"];
document.getElementById("chk").style.display = "block";
height = 280;
break;
case "button":
fields = ["f_name", "f_value", "f_disabled", "f_onclick", "f_tabindex", "f_accesskey"];
document.getElementById("btn").style.display = "block";
height = 300;
break;
case "file":
fields = ["f_name", "f_disabled", "f_tabindex", "f_accesskey"];
document.getElementById("f_value").disabled = true;
height = 280;
break;
case "image":
fields = ["f_name", "f_disabled", "f_tabindex", "f_accesskey", "f_src"];
document.getElementById("img").style.display = "block";
document.getElementById("f_value").disabled = true;
height = 300;
break;
case "reset":
case "submit":
fields = ["f_name", "f_value", "f_disabled", "f_tabindex", "f_accesskey"];
height =260;
break;
case "hidden":
fields = ["f_name", "f_value"];
document.getElementById("f_disabled").disabled = true;
document.getElementById("f_tabindex").disabled = true;
document.getElementById("f_accesskey").disabled = true;
height =260;
break;
}
for (var i in fields) {
switch (fields[i]) {
case "f_readOnly":
case "f_disabled":
case "f_checked":
document.getElementById(fields[i]).checked = (param[fields[i]]==fields[i].substring(2,20)) || (param[fields[i]] == true); break;
default:
document.getElementById(fields[i]).value = param[fields[i]]; break;
}
}
window.resizeTo(320,height);
document.getElementById("f_name").focus();
};
function onOK() {
var el = document.getElementById("f_name");
if (!el.value) {
alert("You must enter a Name");
el.focus();
return false;
}
// pass data back to the calling window
var param = new Object();
for (var i in fields) {
switch (fields[i]) {
case "f_readOnly":
case "f_disabled":
case "f_checked":
if(HTMLArea.is_ie)
param[fields[i]] = (document.getElementById(fields[i]).checked)?true:"";
else
param[fields[i]] = (document.getElementById(fields[i]).checked)?fields[i].substring(2,20):"";
break;
default:
param[fields[i]] = document.getElementById(fields[i]).value; break;
}
}
__dlg_close(param);
return false;
};
function onCancel() {
__dlg_close(null);
return false;
};
</script>
</head>
<body class="dialog" onload="Init()">
<div id="f_type" class="title"></div>
<form action="" method="get">
<div class="fr">Name/ID:</div>
<input type="text" name="name" id="f_name" title="Name of the form input" />
<p />
<div class="fr">Value:</div>
<input type="text" name="value" id="f_value" title="Value of the form input" />
<p />
<div class="fr">Disabled</div>
<input type="checkbox" name="disabled" id="f_disabled" value="disabled" />
<p />
<div id="chk">
<div class="fr">Checked</div>
<input name="checked" id="f_checked" type="checkbox" />
<p />
</div>
<div class="fr">Tab Index:</div>
<input type="text" name="tabindex" id="f_tabindex" />
<p />
<div class="fr">Access Key:</div>
<input type="text" name="accesskey" id="f_accesskey" />
<p />
<div id="txt">
<div class="fr">Read Only</div>
<input type="checkbox" name="readOnly" id="f_readOnly" value="readOnly" />
<p />
<fieldset>
<legend>Dimensions</legend>
<div class="space"></div>
<div class="fr">Size:</div>
<input type="text" name="size" id="f_size" size="5" title="Size of text box in characters" />
<div class="space"></div>
<div class="fr">Max length:</div>
<input type="text" name="maxLength" id="f_maxLength" size="5" title="Maximum number of characters accepted" />
<div class="space"></div>
</fieldset>
</div>
<div id="btn">
<fieldset>
<legend> Button Script</legend>
<div class="space"></div>
<div class="fr">'onClick'=</div>
<input type="text" name="onClick" id="f_onclick" title="Javascript for button click" />
<div class="space"></div>
</fieldset>
</div>
<div id="img">
<fieldset>
<legend>Image source</legend>
<div class="space"></div>
<div class="fr">Image URL:</div>
<input type="text" name="src" id="f_src" title="URL of image" />
<div class="space"></div>
</fieldset>
</div>
<div id="buttons">
<button type="button" name="ok" onclick="return onOK();">OK</button>
<button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,59 @@
<html>
<head>
<title>Insert/Edit Form Element LABEL</title>
<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
<script type="text/javascript" src="../../../popups/popup.js"></script>
<script type="text/javascript">
var fields = ["f_text","f_for","f_accesskey"];
function Init() {
window.resizeTo(350,320);
__dlg_translate("Forms");
__dlg_init();
var param = window.dialogArguments;
for (var i in fields) {
document.getElementById(fields[i]).value = param[fields[i]];
}
document.getElementById("f_text").focus();
};
function onOK() {
// pass data back to the calling window
// pass data back to the calling window
var param = new Object();
for (var i in fields) {
param[fields[i]] = document.getElementById(fields[i]).value;
}
__dlg_close(param);
return false;
};
function onCancel() {
__dlg_close(null);
return false;
};
</script>
</head>
<body class="dialog" onload="Init()">
<div id="f_type" class="title">Form Element: LABEL</div>
<form action="" method="get">
<div class="fr">Text:</div>
<input type="text" name="text" id="f_text" />
<p />
<div class="fr">For Control:</div>
<input type="text" name="for" id="f_for" />
<p />
<div class="fr">Access Key:</div>
<input type="text" name="accesskey" id="f_accesskey" />
<p />
<div id="buttons">
<button type="button" name="ok" onclick="return onOK();">OK</button>
<button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,209 @@
<html>
<head>
<title>Insert/Edit Form Element SELECT</title>
<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
<script type="text/javascript" src="../../../popups/popup.js"></script>
<script type="text/javascript">
var fields = ["f_name", "f_size", "f_tabindex", "f_multiple", "f_disabled"];
function Init() {
window.resizeTo(350,320);
__dlg_translate("Forms");
__dlg_init();
var param = window.dialogArguments;
for (var i in fields) {
switch (fields[i]) {
case "f_multiple":
case "f_disabled":
document.getElementById(fields[i]).checked = (param[fields[i]]==fields[i].substring(2,20)) || (param[fields[i]] == true); break;
case "f_size":
document.getElementById(fields[i]).value = (param[fields[i]]<=0)?"":param[fields[i]]; break;
default:
document.getElementById(fields[i]).value = param[fields[i]]; break;
}
}
for (var i=0; i<=param.f_options.length-1; i++) {
document.getElementById("f_select").options[i] = new Option(param.f_options[i].text, param.f_options[i].value);
}
document.getElementById("f_name").focus();
};
function onOK() {
var el = document.getElementById("f_name");
if (!el.value) {
alert("You must enter a Name");
el.focus();
return false;
}
// pass data back to the calling window
var param = new Object();
for (var i in fields) {
switch (fields[i]) {
case "f_multiple":
if (document.getElementById("f_size").value=="1")
param["f_multiple"] = "";
else
param["f_multiple"] = (document.getElementById(fields[i]).checked)?"multiple":"";
break;
case "f_disabled":
param[fields[i]] = (document.getElementById(fields[i]).checked)?"disabled":""; break;
default:
param[fields[i]] = document.getElementById(fields[i]).value; break;
}
}
function optionValues(text,value) {
this.text = text;
this.value = value;
}
optionNodes = new Array(); // for option text/value pairs
for (var i=0; i<= document.getElementById("f_select").options.length-1; i++) {
optionNodes[i] = new optionValues(document.getElementById("f_select").options[i].text, document.getElementById("f_select").options[i].value);
}
param["f_options"] = optionNodes;
__dlg_close(param);
return false;
};
function onCancel() {
__dlg_close(null);
return false;
};
//functions to build select options list
//Populates Label and Value fields with selected option values
function getValues(){
var d = document;
d.getElementById("f_optionvalue").value = d.getElementById("f_select").options[d.getElementById("f_select").selectedIndex].value;
d.getElementById("f_optiontext").value = d.getElementById("f_select").options[d.getElementById("f_select").selectedIndex].text;
d.getElementById("f_update").value ="Update Option";
}
//Add or update options to the select box
function addItem(item) {
var d = document;
if (item.f_optiontext.value =="") {alert("Please enter a Label");}
else {
if (d.getElementById("f_select").options.selectedIndex != -1) { //update item
var indx = d.getElementById("f_select").options.selectedIndex;
d.getElementById("f_select").options[indx].text=d.getElementById("f_optiontext").value;
d.getElementById("f_select").options[indx].value=d.getElementById("f_optionvalue").value;
} else { //add new item
var newItem = d.getElementById("f_select").options.length++;
d.getElementById("f_select").options[newItem].text=d.getElementById("f_optiontext").value;
d.getElementById("f_select").options[newItem].value=d.getElementById("f_optionvalue").value;
}
d.getElementById("f_select").selectedIndex = -1; //deselect
d.getElementById("f_optiontext").value="";//clean up
d.getElementById("f_optionvalue").value="";
d.getElementById("f_update").value ="Add Option";
d.getElementById("f_optiontext").focus();
}
}
//Clears selected option
function deleteItem() {
var d = document;
for (var i = d.getElementById("f_select").options.length - 1; i>=0; i--) {
var opt = d.getElementById("f_select").options[i];
if (opt.selected) {
d.getElementById("f_select").options[i] = null;
}
}
d.getElementById("f_select").selectedIndex = -1;
d.getElementById("f_optiontext").value="";
d.getElementById("f_optionvalue").value="";
d.getElementById("f_optiontext").focus();
}
//Moves selected option up
function moveOptionUp() {
var d = document;
for (i=0; i<d.getElementById("f_select").options.length; i++) {
if (d.getElementById("f_select").options[i].selected) {
if (i != 0 && !d.getElementById("f_select").options[i-1].selected) {
swapOptions(d.getElementById("f_select"),i,i-1);
d.getElementById("f_select").options[i-1].selected = true;
}
}
}
}
//Moves selected option down
function moveOptionDown() {
var d = document;
for (i=d.getElementById("f_select").options.length-1; i>=0; i--) {
if (d.getElementById("f_select").options[i].selected) {
if (i != (d.getElementById("f_select").options.length-1) && ! d.getElementById("f_select").options[i+1].selected) {
swapOptions(d.getElementById("f_select"),i,i+1);
d.getElementById("f_select").options[i+1].selected = true;
}
}
}
}
function swapOptions(obj,i,j) {
var o = obj.options;
var i_selected = o[i].selected;
var j_selected = o[j].selected;
var temp = new Option(o[i].text, o[i].value);
var temp2= new Option(o[j].text, o[j].value);
o[i] = temp2;
o[j] = temp;
o[i].selected = j_selected;
o[j].selected = i_selected;
}
</script>
</head>
<body class="dialog" onload="Init()">
<div id="f_type" class="title">Form Element: SELECT</div>
<form action="" method="get">
<div class="fr">Name/ID:</div>
<input type="text" name="name" id="f_name" title="Name of the form select" />
<p />
<div class="fr">Size:</div>
<input name="size" id="f_size" type="text" value="" size="15" />
<p />
<div class="fr"><nobr>Multiple Select</nobr></div>
<input name="multiple" id="f_multiple" type="checkbox" value="multiple" />
<p />
<div class="fr">Disabled</div>
<input type="checkbox" name="disabled" id="f_disabled" value="disabled" />
<p />
<div class="fr">Tab Index:</div>
<input type="text" name="tabindex" id="f_tabindex" />
<p />
<div class="space"></div>
<fieldset id="fldLayout">
<legend>Options</legend>
<table border="0" cellspacing="0" width="100%">
<tr>
<td align="right">
<select name="select" id="f_select" Size="6" onchange="getValues();" style="width:16em">
</select>
</td>
<td align="center">
<input type="button" name="up" value="Move Up" style="width:6em" onClick="moveOptionUp()"><br />
<input type="button" name="down" value="Move Down" style="width:6em" onClick="moveOptionDown()"><br />
<input type="button" name="delete" value="Delete" style="width:6em" onClick="deleteItem();">
</td>
</tr>
</table>
<div class="space"></div>
<table border="0" cellspacing="0" width="100%">
<tr>
<td align="right">Lable:</td>
<td><input type="text" id="f_optiontext" name="optionText" value="" size="15"></td>
<td align="right">Value:</td>
<td><input name="optionValue" id="f_optionvalue" type="text" value="" size="15"></td>
<td><input type="button" name="update" id="f_update" value="Add" onclick="addItem(document.forms[0])"></td>
</tr>
</table>
</fieldset>
<div id="buttons">
<button type="button" name="ok" onclick="return onOK();">OK</button>
<button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,113 @@
<html>
<head>
<title>Insert/Edit Form Element TEXTAREA</title>
<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
<script type="text/javascript" src="../../../popups/popup.js"></script>
<script type="text/javascript">
var fields = ["f_name", "f_text", "f_cols", "f_rows", "f_wrap", "f_tabindex", "f_accesskey", "f_readOnly", "f_disabled"];
function Init() {
window.resizeTo(280,260);
__dlg_translate("Forms");
__dlg_init();
var param = window.dialogArguments;
for (var i in fields) {
switch (fields[i]) {
case "f_readOnly":
case "f_disabled":
document.getElementById(fields[i]).checked = (param[fields[i]]==fields[i].substring(2,20)) || (param[fields[i]] == true); break;
default:
document.getElementById(fields[i]).value = param[fields[i]]; break;
}
}
document.getElementById("f_name").focus();
};
function onOK() {
var el = document.getElementById("f_name");
if (!el.value) {
alert("You must enter a Name");
el.focus();
return false;
}
// pass data back to the calling window
var param = new Object();
for (var i in fields) {
switch (fields[i]) {
case "f_readOnly":
case "f_disabled":
if(HTMLArea.is_ie)
param[fields[i]] = (document.getElementById(fields[i]).checked)?true:"";
else
param[fields[i]] = (document.getElementById(fields[i]).checked)?fields[i].substring(2,20):"";
break;
default:
param[fields[i]] = document.getElementById(fields[i]).value; break;
}
}
__dlg_close(param);
return false;
};
function onCancel() {
__dlg_close(null);
return false;
};
</script>
</head>
<body class="dialog" onload="Init()">
<div id="f_type" class="title">Form Element: TEXTAREA</div>
<form action="" method="get">
<div class="fr">Name/ID:</div>
<input type="text" name="name" id="f_name" title="name of the textarea" />
<p />
<fieldset>
<legend>Dimensions</legend>
<div class="fr">Columns:</div>
<input type="text" name="cols" id="f_cols" size="5" title="Width in number of characters" />
<p />
<div class="fr">Rows:</div>
<input type="text" name="rows" id="f_rows" size="5" title="Height in number of rows" />
<p />
</fieldset>
<div class="space"></div>
<div class="fr">Wrap Mode:</div>
<select name="wrap" id="f_wrap">
<option value=""></option>
<option value="off">Off</option>
<option value="soft">Soft</option>
<option value="hard">Hard</option>
<option value="physical">Physical</option>
<option value="virtual">Virtual</option>
<option value="normal">normal</option>
<option value="nowrap">nowrap</option>
<option value="pre">pre</option>
</select>
<p />
<div class="fr">Read Only</div>
<input type="checkbox" name="readOnly" id="f_readOnly" value="readOnly" />
<p />
<div class="fr">Disabled</div>
<input type="checkbox" name="disabled" id="f_disabled" value="disabled" />
<p />
<div class="fr">Tab Index:</div>
<input type="text" name="tabindex" id="f_tabindex" />
<p />
<div class="fr">Access Key:</div>
<input type="text" name="accesskey" id="f_accesskey" />
<p />
<div class="fr">Initial Text:</div>
<input type="text" name="text" id="f_text" title="Default text (optional)" />
<div id="buttons">
<button type="button" name="ok" onclick="return onOK();">OK</button>
<button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
</div>
</form>
</body>
</html>