Edit File by line
/home/barbar84/www/wp-inclu.../js/tinymce/utils
File: form_utils.js
/**
[0] Fix | Delete
* form_utils.js
[1] Fix | Delete
*
[2] Fix | Delete
* Released under LGPL License.
[3] Fix | Delete
* Copyright (c) 1999-2017 Ephox Corp. All rights reserved
[4] Fix | Delete
*
[5] Fix | Delete
* License: http://www.tinymce.com/license
[6] Fix | Delete
* Contributing: http://www.tinymce.com/contributing
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
var themeBaseURL = tinyMCEPopup.editor.baseURI.toAbsolute('themes/' + tinyMCEPopup.getParam("theme"));
[10] Fix | Delete
[11] Fix | Delete
function getColorPickerHTML(id, target_form_element) {
[12] Fix | Delete
var h = "", dom = tinyMCEPopup.dom;
[13] Fix | Delete
[14] Fix | Delete
if (label = dom.select('label[for=' + target_form_element + ']')[0]) {
[15] Fix | Delete
label.id = label.id || dom.uniqueId();
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
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">';
[19] Fix | Delete
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>';
[20] Fix | Delete
[21] Fix | Delete
return h;
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
function updateColor(img_id, form_element_id) {
[25] Fix | Delete
document.getElementById(img_id).style.backgroundColor = document.forms[0].elements[form_element_id].value;
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
function setBrowserDisabled(id, state) {
[29] Fix | Delete
var img = document.getElementById(id);
[30] Fix | Delete
var lnk = document.getElementById(id + "_link");
[31] Fix | Delete
[32] Fix | Delete
if (lnk) {
[33] Fix | Delete
if (state) {
[34] Fix | Delete
lnk.setAttribute("realhref", lnk.getAttribute("href"));
[35] Fix | Delete
lnk.removeAttribute("href");
[36] Fix | Delete
tinyMCEPopup.dom.addClass(img, 'disabled');
[37] Fix | Delete
} else {
[38] Fix | Delete
if (lnk.getAttribute("realhref")) {
[39] Fix | Delete
lnk.setAttribute("href", lnk.getAttribute("realhref"));
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
tinyMCEPopup.dom.removeClass(img, 'disabled');
[43] Fix | Delete
}
[44] Fix | Delete
}
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
function getBrowserHTML(id, target_form_element, type, prefix) {
[48] Fix | Delete
var option = prefix + "_" + type + "_browser_callback", cb, html;
[49] Fix | Delete
[50] Fix | Delete
cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback"));
[51] Fix | Delete
[52] Fix | Delete
if (!cb) {
[53] Fix | Delete
return "";
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
html = "";
[57] Fix | Delete
html += '<a id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;" class="browse">';
[58] Fix | Delete
html += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '">&nbsp;</span></a>';
[59] Fix | Delete
[60] Fix | Delete
return html;
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
function openBrowser(img_id, target_form_element, type, option) {
[64] Fix | Delete
var img = document.getElementById(img_id);
[65] Fix | Delete
[66] Fix | Delete
if (img.className != "mceButtonDisabled") {
[67] Fix | Delete
tinyMCEPopup.openBrowser(target_form_element, type, option);
[68] Fix | Delete
}
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
[72] Fix | Delete
if (!form_obj || !form_obj.elements[field_name]) {
[73] Fix | Delete
return;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
if (!value) {
[77] Fix | Delete
value = "";
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
var sel = form_obj.elements[field_name];
[81] Fix | Delete
[82] Fix | Delete
var found = false;
[83] Fix | Delete
for (var i = 0; i < sel.options.length; i++) {
[84] Fix | Delete
var option = sel.options[i];
[85] Fix | Delete
[86] Fix | Delete
if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) {
[87] Fix | Delete
option.selected = true;
[88] Fix | Delete
found = true;
[89] Fix | Delete
} else {
[90] Fix | Delete
option.selected = false;
[91] Fix | Delete
}
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
if (!found && add_custom && value != '') {
[95] Fix | Delete
var option = new Option(value, value);
[96] Fix | Delete
option.selected = true;
[97] Fix | Delete
sel.options[sel.options.length] = option;
[98] Fix | Delete
sel.selectedIndex = sel.options.length - 1;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
return found;
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
function getSelectValue(form_obj, field_name) {
[105] Fix | Delete
var elm = form_obj.elements[field_name];
[106] Fix | Delete
[107] Fix | Delete
if (elm == null || elm.options == null || elm.selectedIndex === -1) {
[108] Fix | Delete
return "";
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
return elm.options[elm.selectedIndex].value;
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
function addSelectValue(form_obj, field_name, name, value) {
[115] Fix | Delete
var s = form_obj.elements[field_name];
[116] Fix | Delete
var o = new Option(name, value);
[117] Fix | Delete
s.options[s.options.length] = o;
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
function addClassesToList(list_id, specific_option) {
[121] Fix | Delete
// Setup class droplist
[122] Fix | Delete
var styleSelectElm = document.getElementById(list_id);
[123] Fix | Delete
var styles = tinyMCEPopup.getParam('theme_advanced_styles', false);
[124] Fix | Delete
styles = tinyMCEPopup.getParam(specific_option, styles);
[125] Fix | Delete
[126] Fix | Delete
if (styles) {
[127] Fix | Delete
var stylesAr = styles.split(';');
[128] Fix | Delete
[129] Fix | Delete
for (var i = 0; i < stylesAr.length; i++) {
[130] Fix | Delete
if (stylesAr != "") {
[131] Fix | Delete
var key, value;
[132] Fix | Delete
[133] Fix | Delete
key = stylesAr[i].split('=')[0];
[134] Fix | Delete
value = stylesAr[i].split('=')[1];
[135] Fix | Delete
[136] Fix | Delete
styleSelectElm.options[styleSelectElm.length] = new Option(key, value);
[137] Fix | Delete
}
[138] Fix | Delete
}
[139] Fix | Delete
} else {
[140] Fix | Delete
/*tinymce.each(tinyMCEPopup.editor.dom.getClasses(), function(o) {
[141] Fix | Delete
styleSelectElm.options[styleSelectElm.length] = new Option(o.title || o['class'], o['class']);
[142] Fix | Delete
});*/
[143] Fix | Delete
}
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
function isVisible(element_id) {
[147] Fix | Delete
var elm = document.getElementById(element_id);
[148] Fix | Delete
[149] Fix | Delete
return elm && elm.style.display != "none";
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
function convertRGBToHex(col) {
[153] Fix | Delete
var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");
[154] Fix | Delete
[155] Fix | Delete
var rgb = col.replace(re, "$1,$2,$3").split(',');
[156] Fix | Delete
if (rgb.length == 3) {
[157] Fix | Delete
r = parseInt(rgb[0]).toString(16);
[158] Fix | Delete
g = parseInt(rgb[1]).toString(16);
[159] Fix | Delete
b = parseInt(rgb[2]).toString(16);
[160] Fix | Delete
[161] Fix | Delete
r = r.length == 1 ? '0' + r : r;
[162] Fix | Delete
g = g.length == 1 ? '0' + g : g;
[163] Fix | Delete
b = b.length == 1 ? '0' + b : b;
[164] Fix | Delete
[165] Fix | Delete
return "#" + r + g + b;
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
return col;
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
function convertHexToRGB(col) {
[172] Fix | Delete
if (col.indexOf('#') != -1) {
[173] Fix | Delete
col = col.replace(new RegExp('[^0-9A-F]', 'gi'), '');
[174] Fix | Delete
[175] Fix | Delete
r = parseInt(col.substring(0, 2), 16);
[176] Fix | Delete
g = parseInt(col.substring(2, 4), 16);
[177] Fix | Delete
b = parseInt(col.substring(4, 6), 16);
[178] Fix | Delete
[179] Fix | Delete
return "rgb(" + r + "," + g + "," + b + ")";
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
return col;
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
function trimSize(size) {
[186] Fix | Delete
return size.replace(/([0-9\.]+)(px|%|in|cm|mm|em|ex|pt|pc)/i, '$1$2');
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
function getCSSSize(size) {
[190] Fix | Delete
size = trimSize(size);
[191] Fix | Delete
[192] Fix | Delete
if (size == "") {
[193] Fix | Delete
return "";
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
// Add px
[197] Fix | Delete
if (/^[0-9]+$/.test(size)) {
[198] Fix | Delete
size += 'px';
[199] Fix | Delete
}
[200] Fix | Delete
// Sanity check, IE doesn't like broken values
[201] Fix | Delete
else if (!(/^[0-9\.]+(px|%|in|cm|mm|em|ex|pt|pc)$/i.test(size))) {
[202] Fix | Delete
return "";
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
return size;
[206] Fix | Delete
}
[207] Fix | Delete
[208] Fix | Delete
function getStyle(elm, attrib, style) {
[209] Fix | Delete
var val = tinyMCEPopup.dom.getAttrib(elm, attrib);
[210] Fix | Delete
[211] Fix | Delete
if (val != '') {
[212] Fix | Delete
return '' + val;
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
if (typeof (style) == 'undefined') {
[216] Fix | Delete
style = attrib;
[217] Fix | Delete
}
[218] Fix | Delete
[219] Fix | Delete
return tinyMCEPopup.dom.getStyle(elm, style);
[220] Fix | Delete
}
[221] Fix | Delete
[222] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function