]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/utils/form_utils.js
WordPress 4.3
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / utils / form_utils.js
index f6cd96a0245deadc02789594bed613dd14e144d0..45667a7b9b364edb5a4432a78fa33edf6d16c5a1 100644 (file)
@@ -1,19 +1,24 @@
 /**
- * $Id: form_utils.js 1184 2009-08-11 11:47:27Z spocke $
+ * form_utils.js
  *
- * Various form utilitiy functions.
+ * Released under LGPL License.
+ * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
  *
- * @author Moxiecode
- * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
+ * License: http://www.tinymce.com/license
+ * Contributing: http://www.tinymce.com/contributing
  */
 
 var themeBaseURL = tinyMCEPopup.editor.baseURI.toAbsolute('themes/' + tinyMCEPopup.getParam("theme"));
 
 function getColorPickerHTML(id, target_form_element) {
-       var h = "";
+       var h = "", dom = tinyMCEPopup.dom;
 
-       h += '<a id="' + id + '_link" href="javascript:;" onclick="tinyMCEPopup.pickColor(event,\'' + target_form_element +'\');" onmousedown="return false;" class="pickcolor">';
-       h += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '">&nbsp;</span></a>';
+       if (label = dom.select('label[for=' + target_form_element + ']')[0]) {
+               label.id = label.id || dom.uniqueId();
+       }
+
+       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">';
+       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>';
 
        return h;
 }
@@ -66,6 +71,9 @@ function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
        if (!form_obj || !form_obj.elements[field_name])
                return;
 
+       if (!value)
+               value = "";
+
        var sel = form_obj.elements[field_name];
 
        var found = false;
@@ -124,9 +132,9 @@ function addClassesToList(list_id, specific_option) {
                        }
                }
        } else {
-               tinymce.each(tinyMCEPopup.editor.dom.getClasses(), function(o) {
+               /*tinymce.each(tinyMCEPopup.editor.dom.getClasses(), function(o) {
                        styleSelectElm.options[styleSelectElm.length] = new Option(o.title || o['class'], o['class']);
-               });
+               });*/
        }
 }
 
@@ -170,7 +178,7 @@ function convertHexToRGB(col) {
 }
 
 function trimSize(size) {
-       return size.replace(/([0-9\.]+)px|(%|in|cm|mm|em|ex|pt|pc)/, '$1$2');
+       return size.replace(/([0-9\.]+)(px|%|in|cm|mm|em|ex|pt|pc)/i, '$1$2');
 }
 
 function getCSSSize(size) {
@@ -182,6 +190,9 @@ function getCSSSize(size) {
        // Add px
        if (/^[0-9]+$/.test(size))
                size += 'px';
+       // Sanity check, IE doesn't like broken values
+       else if (!(/^[0-9\.]+(px|%|in|cm|mm|em|ex|pt|pc)$/i.test(size)))
+               return "";
 
        return size;
 }