bgneal@45: /** bgneal@45: * $Id: form_utils.js 996 2009-02-06 17:32:20Z spocke $ bgneal@45: * bgneal@45: * Various form utilitiy functions. bgneal@45: * bgneal@45: * @author Moxiecode bgneal@45: * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. bgneal@45: */ bgneal@45: bgneal@45: var themeBaseURL = tinyMCEPopup.editor.baseURI.toAbsolute('themes/' + tinyMCEPopup.getParam("theme")); bgneal@45: bgneal@45: function getColorPickerHTML(id, target_form_element) { bgneal@45: var h = ""; bgneal@45: bgneal@45: h += ''; bgneal@45: h += ' '; bgneal@45: bgneal@45: return h; bgneal@45: } bgneal@45: bgneal@45: function updateColor(img_id, form_element_id) { bgneal@45: document.getElementById(img_id).style.backgroundColor = document.forms[0].elements[form_element_id].value; bgneal@45: } bgneal@45: bgneal@45: function setBrowserDisabled(id, state) { bgneal@45: var img = document.getElementById(id); bgneal@45: var lnk = document.getElementById(id + "_link"); bgneal@45: bgneal@45: if (lnk) { bgneal@45: if (state) { bgneal@45: lnk.setAttribute("realhref", lnk.getAttribute("href")); bgneal@45: lnk.removeAttribute("href"); bgneal@45: tinyMCEPopup.dom.addClass(img, 'disabled'); bgneal@45: } else { bgneal@45: if (lnk.getAttribute("realhref")) bgneal@45: lnk.setAttribute("href", lnk.getAttribute("realhref")); bgneal@45: bgneal@45: tinyMCEPopup.dom.removeClass(img, 'disabled'); bgneal@45: } bgneal@45: } bgneal@45: } bgneal@45: bgneal@45: function getBrowserHTML(id, target_form_element, type, prefix) { bgneal@45: var option = prefix + "_" + type + "_browser_callback", cb, html; bgneal@45: bgneal@45: cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback")); bgneal@45: bgneal@45: if (!cb) bgneal@45: return ""; bgneal@45: bgneal@45: html = ""; bgneal@45: html += ''; bgneal@45: html += ' '; bgneal@45: bgneal@45: return html; bgneal@45: } bgneal@45: bgneal@45: function openBrowser(img_id, target_form_element, type, option) { bgneal@45: var img = document.getElementById(img_id); bgneal@45: bgneal@45: if (img.className != "mceButtonDisabled") bgneal@45: tinyMCEPopup.openBrowser(target_form_element, type, option); bgneal@45: } bgneal@45: bgneal@45: function selectByValue(form_obj, field_name, value, add_custom, ignore_case) { bgneal@45: if (!form_obj || !form_obj.elements[field_name]) bgneal@45: return; bgneal@45: bgneal@45: var sel = form_obj.elements[field_name]; bgneal@45: bgneal@45: var found = false; bgneal@45: for (var i=0; i