From 2eeb128d06ad37dea9bd1765784fb53e47ef527c Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Tue, 15 Nov 2011 11:47:40 -0500 Subject: [PATCH] - Fix washing styles with quoted values e.g. font-family --- program/js/tiny_mce/utils/form_utils.js | 96 ++++++++++++++++++++++++------------------------ 1 files changed, 48 insertions(+), 48 deletions(-) diff --git a/program/js/tiny_mce/utils/form_utils.js b/program/js/tiny_mce/utils/form_utils.js index f1e9358..59da013 100644 --- a/program/js/tiny_mce/utils/form_utils.js +++ b/program/js/tiny_mce/utils/form_utils.js @@ -1,31 +1,26 @@ /** - * $RCSfile: form_utils.js,v $ - * $Revision: 1.11 $ - * $Date: 2006/04/07 15:53:12 $ + * form_utils.js * - * Various form utilitiy functions. + * Copyright 2009, Moxiecode Systems AB + * Released under LGPL License. * - * @author Moxiecode - * @copyright Copyright � 2004-2006, Moxiecode Systems AB, All rights reserved. + * License: http://tinymce.moxiecode.com/license + * Contributing: http://tinymce.moxiecode.com/contributing */ +var themeBaseURL = tinyMCEPopup.editor.baseURI.toAbsolute('themes/' + tinyMCEPopup.getParam("theme")); + function getColorPickerHTML(id, target_form_element) { - var html = ""; + var h = "", dom = tinyMCEPopup.dom; - html += '<a id="' + id + '_link" href="javascript:void(0);" onkeydown="pickColor(event,\'' + target_form_element +'\');" onmousedown="pickColor(event,\'' + target_form_element +'\');return false;">'; - html += '<img id="' + id + '" src="../../themes/' + tinyMCE.getParam("theme") + '/images/color.gif"'; - html += ' onmouseover="this.className=\'mceButtonOver\'"'; - html += ' onmouseout="this.className=\'mceButtonNormal\'"'; - html += ' onmousedown="this.className=\'mceButtonDown\'"'; - html += ' width="20" height="16" border="0" title="' + tinyMCE.getLang('lang_browse') + '"'; - html += ' class="mceButtonNormal" alt="' + tinyMCE.getLang('lang_browse') + '" /></a>'; + if (label = dom.select('label[for=' + target_form_element + ']')[0]) { + label.id = label.id || dom.uniqueId(); + } - return html; -} + 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') + '"> <span id="' + id + '_label" class="mceVoiceLabel mceIconOnly" style="display:none;">' + tinyMCEPopup.getLang('browse') + '</span></span></a>'; -function pickColor(e, target_form_element) { - if ((e.keyCode == 32 || e.keyCode == 13) || e.type == "mousedown") - tinyMCEPopup.pickColor(e, target_form_element); + return h; } function updateColor(img_id, form_element_id) { @@ -40,34 +35,32 @@ if (state) { lnk.setAttribute("realhref", lnk.getAttribute("href")); lnk.removeAttribute("href"); - tinyMCE.switchClass(img, 'mceButtonDisabled', true); + tinyMCEPopup.dom.addClass(img, 'disabled'); } else { - lnk.setAttribute("href", lnk.getAttribute("realhref")); - tinyMCE.switchClass(img, 'mceButtonNormal', false); + if (lnk.getAttribute("realhref")) + lnk.setAttribute("href", lnk.getAttribute("realhref")); + + tinyMCEPopup.dom.removeClass(img, 'disabled'); } } } function getBrowserHTML(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) + var option = prefix + "_" + type + "_browser_callback", cb, html; + + cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback")); + + if (!cb) 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/' + tinyMCE.getParam("theme") + '/images/browse.gif"'; - html += ' onmouseover="this.className=\'mceButtonOver\';"'; - html += ' onmouseout="this.className=\'mceButtonNormal\';"'; - html += ' onmousedown="this.className=\'mceButtonDown\';"'; - html += ' width="20" height="18" border="0" title="' + tinyMCE.getLang('lang_browse') + '"'; - html += ' class="mceButtonNormal" alt="' + tinyMCE.getLang('lang_browse') + '" /></a>'; + html = ""; + html += '<a id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;" class="browse">'; + html += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '"> </span></a>'; return html; } -function openBrower(img_id, target_form_element, type, option) { +function openBrowser(img_id, target_form_element, type, option) { var img = document.getElementById(img_id); if (img.className != "mceButtonDisabled") @@ -77,6 +70,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]; @@ -104,7 +100,7 @@ function getSelectValue(form_obj, field_name) { var elm = form_obj.elements[field_name]; - if (elm == null || elm.options == null) + if (elm == null || elm.options == null || elm.selectedIndex === -1) return ""; return elm.options[elm.selectedIndex].value; @@ -119,8 +115,8 @@ 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); + var styles = tinyMCEPopup.getParam('theme_advanced_styles', false); + styles = tinyMCEPopup.getParam(specific_option, styles); if (styles) { var stylesAr = styles.split(';'); @@ -136,10 +132,9 @@ } } } 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]); + tinymce.each(tinyMCEPopup.editor.dom.getClasses(), function(o) { + styleSelectElm.options[styleSelectElm.length] = new Option(o.title || o['class'], o['class']); + }); } } @@ -183,7 +178,7 @@ } function trimSize(size) { - return size.replace(new RegExp('[^0-9%]', 'gi'), ''); + return size.replace(/([0-9\.]+)(px|%|in|cm|mm|em|ex|pt|pc)/i, '$1$2'); } function getCSSSize(size) { @@ -192,11 +187,18 @@ if (size == "") return ""; - return size.indexOf('%') != -1 ? size : size + "px"; + // 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; } function getStyle(elm, attrib, style) { - var val = tinyMCE.getAttrib(elm, attrib); + var val = tinyMCEPopup.dom.getAttrib(elm, attrib); if (val != '') return '' + val; @@ -204,7 +206,5 @@ if (typeof(style) == 'undefined') style = attrib; - val = eval('elm.style.' + style); - - return val == null ? '' : '' + val; + return tinyMCEPopup.dom.getStyle(elm, style); } -- Gitblit v1.9.1