Missing directory

git-svn-id: http://svn.automattic.com/wordpress/trunk@2954 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2005-10-18 16:40:06 +00:00
parent a6ae47a303
commit 751a663f3c
3 changed files with 264 additions and 0 deletions

View File

@ -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 += '<a id="' + id + '_link" href="javascript:tinyMCEPopup.pickColor(event,\'' + target_form_element +'\');" onmousedown="return false;">';
html += '<img id="' + id + '" src="../../themes/advanced/images/color.gif"';
html += ' onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');"';
html += ' onmouseout="tinyMCE.restoreClass(this);"';
html += ' onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');"';
html += ' width="20" height="16" border="0" title="' + tinyMCE.getLang('lang_browse') + '"';
html += ' class="mceButtonNormal" alt="' + tinyMCE.getLang('lang_browse') + '" /></a>';
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 += '<a id="' + id + '_link" href="javascript:openBrower(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;">';
html += '<img id="' + id + '" src="../../themes/advanced/images/browse.gif"';
html += ' onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');"';
html += ' onmouseout="tinyMCE.restoreClass(this);"';
html += ' onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');"';
html += ' width="20" height="18" border="0" title="' + tinyMCE.getLang('lang_browse') + '"';
html += ' class="mceButtonNormal" alt="' + tinyMCE.getLang('lang_browse') + '" /></a>';
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<sel.options.length; i++) {
var option = sel.options[i];
if (option.value == value) {
option.selected = true;
found = true;
} else
option.selected = false;
}
if (!found && add_custom && value != '') {
var option = new Option('Value: ' + value, value);
option.selected = true;
sel.options[sel.options.length] = option;
}
return found;
}
function getSelectValue(form_obj, field_name) {
var elm = form_obj.elements[field_name];
if (elm == null || elm.options == null)
return "";
return elm.options[elm.selectedIndex].value;
}
function addClassesToList(list_id, specific_option) {
// Setup class droplist
var styleSelectElm = document.getElementById(list_id);
var styles = tinyMCE.getParam('theme_advanced_styles', false);
styles = tinyMCE.getParam(specific_option, styles);
if (styles) {
var stylesAr = styles.split(';');
for (var i=0; i<stylesAr.length; i++) {
if (stylesAr != "") {
var key, value;
key = stylesAr[i].split('=')[0];
value = stylesAr[i].split('=')[1];
styleSelectElm.options[styleSelectElm.length] = new Option(key, value);
}
}
} else {
// Use auto impored classes
var csses = tinyMCE.getCSSClasses(tinyMCE.getWindowArg('editor_id'));
for (var i=0; i<csses.length; i++)
styleSelectElm.options[styleSelectElm.length] = new Option(csses[i], csses[i]);
}
}
function isVisible(element_id) {
var elm = document.getElementById(element_id);
return elm && elm.style.display != "none";
}

View File

@ -0,0 +1,76 @@
/**
* $RCSfile: mctabs.js,v $
* $Revision: 1.1 $
* $Date: 2005/08/01 18:36:35 $
*
* Moxiecode DHTML Tabs script.
*
* @author Moxiecode
* @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.
*/
function MCTabs() {
this.settings = new Array();
};
MCTabs.prototype.init = function(settings) {
this.settings = settings;
};
MCTabs.prototype.getParam = function(name, default_value) {
var value = null;
value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
// Fix bool values
if (value == "true" || value == "false")
return (value == "true");
return value;
};
MCTabs.prototype.displayTab = function(tab_id, panel_id) {
var panelElm = document.getElementById(panel_id);
var panelContainerElm = panelElm ? panelElm.parentNode : null;
var tabElm = document.getElementById(tab_id);
var tabContainerElm = tabElm ? tabElm.parentNode : null;
var selectionClass = this.getParam('selection_class', 'current');
if (tabElm && tabContainerElm) {
var nodes = tabContainerElm.childNodes;
// Hide all other tabs
for (var i=0; i<nodes.length; i++) {
if (nodes[i].nodeName == "LI")
nodes[i].className = '';
}
// Show selected tab
tabElm.className = 'current';
}
if (panelElm && panelContainerElm) {
var nodes = panelContainerElm.childNodes;
// Hide all other panels
for (var i=0; i<nodes.length; i++) {
if (nodes[i].nodeName == "DIV")
nodes[i].className = 'panel';
}
// Show selected panel
panelElm.className = 'current';
}
};
MCTabs.prototype.getAnchor = function() {
var pos, url = document.location.href;
if ((pos = url.lastIndexOf('#')) != -1)
return url.substring(pos + 1);
return "";
};
// Global instance
var mcTabs = new MCTabs();

View File

@ -0,0 +1,50 @@
/**
* $RCSfile: validate.js,v $
* $Revision: 1.2 $
* $Date: 2005/08/13 12:20:37 $
*
* Various form validation methods.
*
* @author Moxiecode
* @copyright Copyright © 2005, Moxiecode Systems AB, All rights reserved.
*/
function testRegExp(form_name, element_name, re) {
return new RegExp(re).test(document.forms[form_name].elements[element_name].value);
}
function validateString(form_name, element_name) {
return (document.forms[form_name].elements[element_name].value.length > 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_])*$');
}