Browse code

Re-add TinyMCE 2.0.1 to the site settings list - TinyMCE directoy names changed - installer submission settings layout dirty fix

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

Actually use TinyMCE 3.4.8 for TinyMCE3 option instead of original 2.0.1; that version is moved to 'tinymce2' directory

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

3.5.6 efiction version

Jimako authored on 2024/03/09 16:09:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,199 @@
1
+/**
2
+ * $Id: form_utils.js 673 2008-03-06 13:26:20Z spocke $
3
+ *
4
+ * Various form utilitiy functions.
5
+ *
6
+ * @author Moxiecode
7
+ * @copyright Copyright � 2004-2008, Moxiecode Systems AB, All rights reserved.
8
+ */
9
+
10
+var themeBaseURL = tinyMCEPopup.editor.baseURI.toAbsolute('themes/' + tinyMCEPopup.getParam("theme"));
11
+
12
+function getColorPickerHTML(id, target_form_element) {
13
+	var h = "";
14
+
15
+	h += '<a id="' + id + '_link" href="javascript:;" onclick="tinyMCEPopup.pickColor(event,\'' + target_form_element +'\');" onmousedown="return false;" class="pickcolor">';
16
+	h += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '"></span></a>';
17
+
18
+	return h;
19
+}
20
+
21
+function updateColor(img_id, form_element_id) {
22
+	document.getElementById(img_id).style.backgroundColor = document.forms[0].elements[form_element_id].value;
23
+}
24
+
25
+function setBrowserDisabled(id, state) {
26
+	var img = document.getElementById(id);
27
+	var lnk = document.getElementById(id + "_link");
28
+
29
+	if (lnk) {
30
+		if (state) {
31
+			lnk.setAttribute("realhref", lnk.getAttribute("href"));
32
+			lnk.removeAttribute("href");
33
+			tinyMCEPopup.dom.addClass(img, 'disabled');
34
+		} else {
35
+			if (lnk.getAttribute("realhref"))
36
+				lnk.setAttribute("href", lnk.getAttribute("realhref"));
37
+
38
+			tinyMCEPopup.dom.removeClass(img, 'disabled');
39
+		}
40
+	}
41
+}
42
+
43
+function getBrowserHTML(id, target_form_element, type, prefix) {
44
+	var option = prefix + "_" + type + "_browser_callback", cb, html;
45
+
46
+	cb = tinyMCEPopup.getParam(option, tinyMCEPopup.getParam("file_browser_callback"));
47
+
48
+	if (!cb)
49
+		return "";
50
+
51
+	html = "";
52
+	html += '<a id="' + id + '_link" href="javascript:openBrowser(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;" class="browse">';
53
+	html += '<span id="' + id + '" title="' + tinyMCEPopup.getLang('browse') + '"></span></a>';
54
+
55
+	return html;
56
+}
57
+
58
+function openBrowser(img_id, target_form_element, type, option) {
59
+	var img = document.getElementById(img_id);
60
+
61
+	if (img.className != "mceButtonDisabled")
62
+		tinyMCEPopup.openBrowser(target_form_element, type, option);
63
+}
64
+
65
+function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
66
+	if (!form_obj || !form_obj.elements[field_name])
67
+		return;
68
+
69
+	var sel = form_obj.elements[field_name];
70
+
71
+	var found = false;
72
+	for (var i=0; i<sel.options.length; i++) {
73
+		var option = sel.options[i];
74
+
75
+		if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) {
76
+			option.selected = true;
77
+			found = true;
78
+		} else
79
+			option.selected = false;
80
+	}
81
+
82
+	if (!found && add_custom && value != '') {
83
+		var option = new Option(value, value);
84
+		option.selected = true;
85
+		sel.options[sel.options.length] = option;
86
+		sel.selectedIndex = sel.options.length - 1;
87
+	}
88
+
89
+	return found;
90
+}
91
+
92
+function getSelectValue(form_obj, field_name) {
93
+	var elm = form_obj.elements[field_name];
94
+
95
+	if (elm == null || elm.options == null)
96
+		return "";
97
+
98
+	return elm.options[elm.selectedIndex].value;
99
+}
100
+
101
+function addSelectValue(form_obj, field_name, name, value) {
102
+	var s = form_obj.elements[field_name];
103
+	var o = new Option(name, value);
104
+	s.options[s.options.length] = o;
105
+}
106
+
107
+function addClassesToList(list_id, specific_option) {
108
+	// Setup class droplist
109
+	var styleSelectElm = document.getElementById(list_id);
110
+	var styles = tinyMCEPopup.getParam('theme_advanced_styles', false);
111
+	styles = tinyMCEPopup.getParam(specific_option, styles);
112
+
113
+	if (styles) {
114
+		var stylesAr = styles.split(';');
115
+
116
+		for (var i=0; i<stylesAr.length; i++) {
117
+			if (stylesAr != "") {
118
+				var key, value;
119
+
120
+				key = stylesAr[i].split('=')[0];
121
+				value = stylesAr[i].split('=')[1];
122
+
123
+				styleSelectElm.options[styleSelectElm.length] = new Option(key, value);
124
+			}
125
+		}
126
+	} else {
127
+		tinymce.each(tinyMCEPopup.editor.dom.getClasses(), function(o) {
128
+			styleSelectElm.options[styleSelectElm.length] = new Option(o.title || o['class'], o['class']);
129
+		});
130
+	}
131
+}
132
+
133
+function isVisible(element_id) {
134
+	var elm = document.getElementById(element_id);
135
+
136
+	return elm && elm.style.display != "none";
137
+}
138
+
139
+function convertRGBToHex(col) {
140
+	var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");
141
+
142
+	var rgb = col.replace(re, "$1,$2,$3").split(',');
143
+	if (rgb.length == 3) {
144
+		r = parseInt(rgb[0]).toString(16);
145
+		g = parseInt(rgb[1]).toString(16);
146
+		b = parseInt(rgb[2]).toString(16);
147
+
148
+		r = r.length == 1 ? '0' + r : r;
149
+		g = g.length == 1 ? '0' + g : g;
150
+		b = b.length == 1 ? '0' + b : b;
151
+
152
+		return "#" + r + g + b;
153
+	}
154
+
155
+	return col;
156
+}
157
+
158
+function convertHexToRGB(col) {
159
+	if (col.indexOf('#') != -1) {
160
+		col = col.replace(new RegExp('[^0-9A-F]', 'gi'), '');
161
+
162
+		r = parseInt(col.substring(0, 2), 16);
163
+		g = parseInt(col.substring(2, 4), 16);
164
+		b = parseInt(col.substring(4, 6), 16);
165
+
166
+		return "rgb(" + r + "," + g + "," + b + ")";
167
+	}
168
+
169
+	return col;
170
+}
171
+
172
+function trimSize(size) {
173
+	return size.replace(/([0-9\.]+)px|(%|in|cm|mm|em|ex|pt|pc)/, '$1$2');
174
+}
175
+
176
+function getCSSSize(size) {
177
+	size = trimSize(size);
178
+
179
+	if (size == "")
180
+		return "";
181
+
182
+	// Add px
183
+	if (/^[0-9]+$/.test(size))
184
+		size += 'px';
185
+
186
+	return size;
187
+}
188
+
189
+function getStyle(elm, attrib, style) {
190
+	var val = tinyMCEPopup.dom.getAttrib(elm, attrib);
191
+
192
+	if (val != '')
193
+		return '' + val;
194
+
195
+	if (typeof(style) == 'undefined')
196
+		style = attrib;
197
+
198
+	return tinyMCEPopup.dom.getStyle(elm, style);
199
+}