web/wp-includes/js/tinymce/utils/form_utils.js
changeset 194 32102edaa81b
parent 136 bde1974c263b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
     1 /**
     1 /**
     2  * $Id: form_utils.js 1184 2009-08-11 11:47:27Z spocke $
     2  * form_utils.js
     3  *
     3  *
     4  * Various form utilitiy functions.
     4  * Copyright 2009, Moxiecode Systems AB
       
     5  * Released under LGPL License.
     5  *
     6  *
     6  * @author Moxiecode
     7  * License: http://tinymce.moxiecode.com/license
     7  * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
     8  * Contributing: http://tinymce.moxiecode.com/contributing
     8  */
     9  */
     9 
    10 
    10 var themeBaseURL = tinyMCEPopup.editor.baseURI.toAbsolute('themes/' + tinyMCEPopup.getParam("theme"));
    11 var themeBaseURL = tinyMCEPopup.editor.baseURI.toAbsolute('themes/' + tinyMCEPopup.getParam("theme"));
    11 
    12 
    12 function getColorPickerHTML(id, target_form_element) {
    13 function getColorPickerHTML(id, target_form_element) {
    13 	var h = "";
    14 	var h = "", dom = tinyMCEPopup.dom;
    14 
    15 
    15 	h += '<a id="' + id + '_link" href="javascript:;" onclick="tinyMCEPopup.pickColor(event,\'' + target_form_element +'\');" onmousedown="return false;" class="pickcolor">';
    16 	if (label = dom.select('label[for=' + target_form_element + ']')[0]) {
    16 	h += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '">&nbsp;</span></a>';
    17 		label.id = label.id || dom.uniqueId();
       
    18 	}
       
    19 
       
    20 	h += '<a role="button" aria-labelledby="' + id + '_label" id="' + id + '_link" href="javascript:;" onclick="tinyMCEPopup.pickColor(event,\'' + target_form_element +'\');" onmousedown="return false;" class="pickcolor">';
       
    21 	h += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '">&nbsp;<span id="' + id + '_label" class="mceVoiceLabel mceIconOnly" style="display:none;">' + tinyMCEPopup.getLang('browse') + '</span></span></a>';
    17 
    22 
    18 	return h;
    23 	return h;
    19 }
    24 }
    20 
    25 
    21 function updateColor(img_id, form_element_id) {
    26 function updateColor(img_id, form_element_id) {
    64 
    69 
    65 function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
    70 function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
    66 	if (!form_obj || !form_obj.elements[field_name])
    71 	if (!form_obj || !form_obj.elements[field_name])
    67 		return;
    72 		return;
    68 
    73 
       
    74 	if (!value)
       
    75 		value = "";
       
    76 
    69 	var sel = form_obj.elements[field_name];
    77 	var sel = form_obj.elements[field_name];
    70 
    78 
    71 	var found = false;
    79 	var found = false;
    72 	for (var i=0; i<sel.options.length; i++) {
    80 	for (var i=0; i<sel.options.length; i++) {
    73 		var option = sel.options[i];
    81 		var option = sel.options[i];
   168 
   176 
   169 	return col;
   177 	return col;
   170 }
   178 }
   171 
   179 
   172 function trimSize(size) {
   180 function trimSize(size) {
   173 	return size.replace(/([0-9\.]+)px|(%|in|cm|mm|em|ex|pt|pc)/, '$1$2');
   181 	return size.replace(/([0-9\.]+)(px|%|in|cm|mm|em|ex|pt|pc)/i, '$1$2');
   174 }
   182 }
   175 
   183 
   176 function getCSSSize(size) {
   184 function getCSSSize(size) {
   177 	size = trimSize(size);
   185 	size = trimSize(size);
   178 
   186 
   180 		return "";
   188 		return "";
   181 
   189 
   182 	// Add px
   190 	// Add px
   183 	if (/^[0-9]+$/.test(size))
   191 	if (/^[0-9]+$/.test(size))
   184 		size += 'px';
   192 		size += 'px';
       
   193 	// Sanity check, IE doesn't like broken values
       
   194 	else if (!(/^[0-9\.]+(px|%|in|cm|mm|em|ex|pt|pc)$/i.test(size)))
       
   195 		return "";
   185 
   196 
   186 	return size;
   197 	return size;
   187 }
   198 }
   188 
   199 
   189 function getStyle(elm, attrib, style) {
   200 function getStyle(elm, attrib, style) {