bgneal@312: /** bgneal@312: * form_utils.js bgneal@312: * bgneal@312: * Copyright 2009, Moxiecode Systems AB bgneal@312: * Released under LGPL License. bgneal@312: * bgneal@312: * License: http://tinymce.moxiecode.com/license bgneal@312: * Contributing: http://tinymce.moxiecode.com/contributing bgneal@312: */ bgneal@312: bgneal@312: var themeBaseURL = tinyMCEPopup.editor.baseURI.toAbsolute('themes/' + tinyMCEPopup.getParam("theme")); bgneal@312: bgneal@312: function getColorPickerHTML(id, target_form_element) { bgneal@442: var h = "", dom = tinyMCEPopup.dom; bgneal@312: bgneal@442: if (label = dom.select('label[for=' + target_form_element + ']')[0]) { bgneal@442: label.id = label.id || dom.uniqueId(); bgneal@442: } bgneal@442: bgneal@442: h += ''; bgneal@442: h += ' '; bgneal@312: bgneal@312: return h; bgneal@312: } bgneal@312: bgneal@312: function updateColor(img_id, form_element_id) { bgneal@312: document.getElementById(img_id).style.backgroundColor = document.forms[0].elements[form_element_id].value; bgneal@312: } bgneal@312: bgneal@312: function setBrowserDisabled(id, state) { bgneal@312: var img = document.getElementById(id); bgneal@312: var lnk = document.getElementById(id + "_link"); bgneal@312: bgneal@312: if (lnk) { bgneal@312: if (state) { bgneal@312: lnk.setAttribute("realhref", lnk.getAttribute("href")); bgneal@312: lnk.removeAttribute("href"); bgneal@312: tinyMCEPopup.dom.addClass(img, 'disabled'); bgneal@312: } else { bgneal@312: if (lnk.getAttribute("realhref")) bgneal@312: lnk.setAttribute("href", lnk.getAttribute("realhref")); bgneal@312: bgneal@312: tinyMCEPopup.dom.removeClass(img, 'disabled'); bgneal@312: } bgneal@312: } bgneal@312: } bgneal@312: bgneal@312: function getBrowserHTML(id, target_form_element, type, prefix) { bgneal@312: var option = prefix + "_" + type + "_browser_callback", cb, html; bgneal@312: bgneal@312: cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback")); bgneal@312: bgneal@312: if (!cb) bgneal@312: return ""; bgneal@312: bgneal@312: html = ""; bgneal@312: html += ''; bgneal@312: html += ' '; bgneal@312: bgneal@312: return html; bgneal@312: } bgneal@312: bgneal@312: function openBrowser(img_id, target_form_element, type, option) { bgneal@312: var img = document.getElementById(img_id); bgneal@312: bgneal@312: if (img.className != "mceButtonDisabled") bgneal@312: tinyMCEPopup.openBrowser(target_form_element, type, option); bgneal@312: } bgneal@312: bgneal@312: function selectByValue(form_obj, field_name, value, add_custom, ignore_case) { bgneal@312: if (!form_obj || !form_obj.elements[field_name]) bgneal@312: return; bgneal@312: bgneal@442: if (!value) bgneal@442: value = ""; bgneal@442: bgneal@312: var sel = form_obj.elements[field_name]; bgneal@312: bgneal@312: var found = false; bgneal@312: for (var i=0; i