bgneal@45: /**
bgneal@183: * form_utils.js
bgneal@45: *
bgneal@183: * Copyright 2009, Moxiecode Systems AB
bgneal@183: * Released under LGPL License.
bgneal@45: *
bgneal@183: * License: http://tinymce.moxiecode.com/license
bgneal@183: * Contributing: http://tinymce.moxiecode.com/contributing
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