-
+ B92BCD256B8B7AD6F94E5F7937D0F8C1A0A478A9C1D93B2807C621011A82587B90B141DE8E674AFA79FF4A9D476364537B1BF9ABF3DF4A969217C53111ABE906
mp-wp/wp-includes/js/tinymce/utils/form_utils.js
(0 . 0)(1 . 198)
131701 /**
131702 * $Id: form_utils.js 673 2008-03-06 13:26:20Z spocke $
131703 *
131704 * Various form utilitiy functions.
131705 *
131706 * @author Moxiecode
131707 */
131708
131709 var themeBaseURL = tinyMCEPopup.editor.baseURI.toAbsolute('themes/' + tinyMCEPopup.getParam("theme"));
131710
131711 function getColorPickerHTML(id, target_form_element) {
131712 var h = "";
131713
131714 h += '<a id="' + id + '_link" href="javascript:;" onclick="tinyMCEPopup.pickColor(event,\'' + target_form_element +'\');" onmousedown="return false;" class="pickcolor">';
131715 h += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '"></span></a>';
131716
131717 return h;
131718 }
131719
131720 function updateColor(img_id, form_element_id) {
131721 document.getElementById(img_id).style.backgroundColor = document.forms[0].elements[form_element_id].value;
131722 }
131723
131724 function setBrowserDisabled(id, state) {
131725 var img = document.getElementById(id);
131726 var lnk = document.getElementById(id + "_link");
131727
131728 if (lnk) {
131729 if (state) {
131730 lnk.setAttribute("realhref", lnk.getAttribute("href"));
131731 lnk.removeAttribute("href");
131732 tinyMCEPopup.dom.addClass(img, 'disabled');
131733 } else {
131734 if (lnk.getAttribute("realhref"))
131735 lnk.setAttribute("href", lnk.getAttribute("realhref"));
131736
131737 tinyMCEPopup.dom.removeClass(img, 'disabled');
131738 }
131739 }
131740 }
131741
131742 function getBrowserHTML(id, target_form_element, type, prefix) {
131743 var option = prefix + "_" + type + "_browser_callback", cb, html;
131744
131745 cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback"));
131746
131747 if (!cb)
131748 return "";
131749
131750 html = "";
131751 html += '<a id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;" class="browse">';
131752 html += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '"></span></a>';
131753
131754 return html;
131755 }
131756
131757 function openBrowser(img_id, target_form_element, type, option) {
131758 var img = document.getElementById(img_id);
131759
131760 if (img.className != "mceButtonDisabled")
131761 tinyMCEPopup.openBrowser(target_form_element, type, option);
131762 }
131763
131764 function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
131765 if (!form_obj || !form_obj.elements[field_name])
131766 return;
131767
131768 var sel = form_obj.elements[field_name];
131769
131770 var found = false;
131771 for (var i=0; i<sel.options.length; i++) {
131772 var option = sel.options[i];
131773
131774 if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) {
131775 option.selected = true;
131776 found = true;
131777 } else
131778 option.selected = false;
131779 }
131780
131781 if (!found && add_custom && value != '') {
131782 var option = new Option(value, value);
131783 option.selected = true;
131784 sel.options[sel.options.length] = option;
131785 sel.selectedIndex = sel.options.length - 1;
131786 }
131787
131788 return found;
131789 }
131790
131791 function getSelectValue(form_obj, field_name) {
131792 var elm = form_obj.elements[field_name];
131793
131794 if (elm == null || elm.options == null)
131795 return "";
131796
131797 return elm.options[elm.selectedIndex].value;
131798 }
131799
131800 function addSelectValue(form_obj, field_name, name, value) {
131801 var s = form_obj.elements[field_name];
131802 var o = new Option(name, value);
131803 s.options[s.options.length] = o;
131804 }
131805
131806 function addClassesToList(list_id, specific_option) {
131807 // Setup class droplist
131808 var styleSelectElm = document.getElementById(list_id);
131809 var styles = tinyMCEPopup.getParam('theme_advanced_styles', false);
131810 styles = tinyMCEPopup.getParam(specific_option, styles);
131811
131812 if (styles) {
131813 var stylesAr = styles.split(';');
131814
131815 for (var i=0; i<stylesAr.length; i++) {
131816 if (stylesAr != "") {
131817 var key, value;
131818
131819 key = stylesAr[i].split('=')[0];
131820 value = stylesAr[i].split('=')[1];
131821
131822 styleSelectElm.options[styleSelectElm.length] = new Option(key, value);
131823 }
131824 }
131825 } else {
131826 tinymce.each(tinyMCEPopup.editor.dom.getClasses(), function(o) {
131827 styleSelectElm.options[styleSelectElm.length] = new Option(o.title || o['class'], o['class']);
131828 });
131829 }
131830 }
131831
131832 function isVisible(element_id) {
131833 var elm = document.getElementById(element_id);
131834
131835 return elm && elm.style.display != "none";
131836 }
131837
131838 function convertRGBToHex(col) {
131839 var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");
131840
131841 var rgb = col.replace(re, "$1,$2,$3").split(',');
131842 if (rgb.length == 3) {
131843 r = parseInt(rgb[0]).toString(16);
131844 g = parseInt(rgb[1]).toString(16);
131845 b = parseInt(rgb[2]).toString(16);
131846
131847 r = r.length == 1 ? '0' + r : r;
131848 g = g.length == 1 ? '0' + g : g;
131849 b = b.length == 1 ? '0' + b : b;
131850
131851 return "#" + r + g + b;
131852 }
131853
131854 return col;
131855 }
131856
131857 function convertHexToRGB(col) {
131858 if (col.indexOf('#') != -1) {
131859 col = col.replace(new RegExp('[^0-9A-F]', 'gi'), '');
131860
131861 r = parseInt(col.substring(0, 2), 16);
131862 g = parseInt(col.substring(2, 4), 16);
131863 b = parseInt(col.substring(4, 6), 16);
131864
131865 return "rgb(" + r + "," + g + "," + b + ")";
131866 }
131867
131868 return col;
131869 }
131870
131871 function trimSize(size) {
131872 return size.replace(/([0-9\.]+)px|(%|in|cm|mm|em|ex|pt|pc)/, '$1$2');
131873 }
131874
131875 function getCSSSize(size) {
131876 size = trimSize(size);
131877
131878 if (size == "")
131879 return "";
131880
131881 // Add px
131882 if (/^[0-9]+$/.test(size))
131883 size += 'px';
131884
131885 return size;
131886 }
131887
131888 function getStyle(elm, attrib, style) {
131889 var val = tinyMCEPopup.dom.getAttrib(elm, attrib);
131890
131891 if (val != '')
131892 return '' + val;
131893
131894 if (typeof(style) == 'undefined')
131895 style = attrib;
131896
131897 return tinyMCEPopup.dom.getStyle(elm, style);
131898 }