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