diff --git a/wp-includes/js/tinymce/utils/form_utils.js b/wp-includes/js/tinymce/utils/form_utils.js new file mode 100644 index 0000000000..96f0c3bf90 --- /dev/null +++ b/wp-includes/js/tinymce/utils/form_utils.js @@ -0,0 +1,138 @@ +/** + * $RCSfile: form_utils.js,v $ + * $Revision: 1.3 $ + * $Date: 2005/08/23 17:01:40 $ + * + * Various form utilitiy functions. + * + * @author Moxiecode + * @copyright Copyright © 2005, Moxiecode Systems AB, All rights reserved. + */ + +function renderColorPicker(id, target_form_element) { + var html = ""; + + html += ''; + html += ''; + + document.write(html); +} + +function updateColor(img_id, form_element_id) { + document.getElementById(img_id).style.backgroundColor = document.forms[0].elements[form_element_id].value; +} + +function setBrowserDisabled(id, state) { + var img = document.getElementById(id); + var lnk = document.getElementById(id + "_link"); + + if (lnk) { + if (state) { + lnk.setAttribute("realhref", lnk.getAttribute("href")); + lnk.removeAttribute("href"); + tinyMCE.switchClass(img, 'mceButtonDisabled', true); + } else { + lnk.setAttribute("href", lnk.getAttribute("realhref")); + tinyMCE.switchClass(img, 'mceButtonNormal', false); + } + } +} + +function renderBrowser(id, target_form_element, type, prefix) { + var option = prefix + "_" + type + "_browser_callback"; + var cb = tinyMCE.getParam(option, tinyMCE.getParam("file_browser_callback")); + if (cb == null) + return; + + var html = ""; + + html += ''; + html += ''; + + document.write(html); +} + +function openBrower(img_id, target_form_element, type, option) { + var img = document.getElementById(img_id); + + if (img.className != "mceButtonDisabled") + tinyMCEPopup.openBrowser(target_form_element, type, option); +} + +function selectByValue(form_obj, field_name, value, add_custom) { + if (!form_obj || !form_obj.elements[field_name]) + return; + + var sel = form_obj.elements[field_name]; + + var found = false; + for (var i=0; i 0); +} + +function validateSelection(form_name, element_name) { + return (document.forms[form_name].elements[element_name].selectedIndex > 0); +} + +function validateCheckBox(form_name, element_name) { + return document.forms[form_name].elements[element_name].checked; +} + +function validateCleanString(form_name, element_name) { + return testRegExp(form_name, element_name, '^[A-Za-z0-9_]+$'); +} + +function validateEmail(form_name, element_name) { + return testRegExp(form_name, element_name, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$'); +} + +function validateAbsUrl(form_name, element_name) { + return testRegExp(form_name, element_name, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+$'); +} + +function validateNumber(form_name, element_name, allow_blank) { + return (!allow_blank && value == '') ? false : testRegExp(form_name, element_name, '^-?[0-9]*\\.?[0-9]*$'); +} + +function validateSize(form_name, element_name,) { + return testRegExp(form_name, element_name, '^[0-9]+(px|%)?$'); +} + +function validateID(form_name, element_name,) { + return testRegExp(form_name, element_name, '^[A-Za-z_]([A-Za-z0-9_])*$'); +}