annotate WebContent/jscripts/tiny_mce/plugins/advlink/js/advlink.js @ 8:11baadcdd2c8

start of new Annotator API implementation.
author casties
date Mon, 19 Mar 2012 14:50:28 +0100
parents 0be9d53a6967
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1 /* Functions for the advlink plugin popup */
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3 tinyMCEPopup.requireLangPack();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5 var templates = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6 "window.open" : "window.open('${url}','${target}','${options}')"
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
7 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
8
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
9 function preinit() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
10 var url;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
11
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
12 if (url = tinyMCEPopup.getParam("external_link_list_url"))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
13 document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
14 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
15
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
16 function changeClass() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
17 var f = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
18
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
19 f.classes.value = getSelectValue(f, 'classlist');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
20 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
21
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
22 function init() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
23 tinyMCEPopup.resizeToInnerSize();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
24
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
25 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
26 var inst = tinyMCEPopup.editor;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
27 var elm = inst.selection.getNode();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
28 var action = "insert";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
29 var html;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
30
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
31 document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','advlink');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
32 document.getElementById('popupurlbrowsercontainer').innerHTML = getBrowserHTML('popupurlbrowser','popupurl','file','advlink');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
33 document.getElementById('targetlistcontainer').innerHTML = getTargetListHTML('targetlist','target');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
34
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
35 // Link list
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
36 html = getLinkListHTML('linklisthref','href');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
37 if (html == "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
38 document.getElementById("linklisthrefrow").style.display = 'none';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
39 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
40 document.getElementById("linklisthrefcontainer").innerHTML = html;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
41
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
42 // Anchor list
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
43 html = getAnchorListHTML('anchorlist','href');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
44 if (html == "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
45 document.getElementById("anchorlistrow").style.display = 'none';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
46 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
47 document.getElementById("anchorlistcontainer").innerHTML = html;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
48
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
49 // Resize some elements
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
50 if (isVisible('hrefbrowser'))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
51 document.getElementById('href').style.width = '260px';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
52
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
53 if (isVisible('popupurlbrowser'))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
54 document.getElementById('popupurl').style.width = '180px';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
55
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
56 elm = inst.dom.getParent(elm, "A");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
57 if (elm != null && elm.nodeName == "A")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
58 action = "update";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
59
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
60 formObj.insert.value = tinyMCEPopup.getLang(action, 'Insert', true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
61
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
62 setPopupControlsDisabled(true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
63
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
64 if (action == "update") {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
65 var href = inst.dom.getAttrib(elm, 'href');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
66 var onclick = inst.dom.getAttrib(elm, 'onclick');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
67
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
68 // Setup form data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
69 setFormValue('href', href);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
70 setFormValue('title', inst.dom.getAttrib(elm, 'title'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
71 setFormValue('id', inst.dom.getAttrib(elm, 'id'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
72 setFormValue('style', inst.dom.getAttrib(elm, "style"));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
73 setFormValue('rel', inst.dom.getAttrib(elm, 'rel'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
74 setFormValue('rev', inst.dom.getAttrib(elm, 'rev'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
75 setFormValue('charset', inst.dom.getAttrib(elm, 'charset'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
76 setFormValue('hreflang', inst.dom.getAttrib(elm, 'hreflang'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
77 setFormValue('dir', inst.dom.getAttrib(elm, 'dir'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
78 setFormValue('lang', inst.dom.getAttrib(elm, 'lang'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
79 setFormValue('tabindex', inst.dom.getAttrib(elm, 'tabindex', typeof(elm.tabindex) != "undefined" ? elm.tabindex : ""));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
80 setFormValue('accesskey', inst.dom.getAttrib(elm, 'accesskey', typeof(elm.accesskey) != "undefined" ? elm.accesskey : ""));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
81 setFormValue('type', inst.dom.getAttrib(elm, 'type'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
82 setFormValue('onfocus', inst.dom.getAttrib(elm, 'onfocus'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
83 setFormValue('onblur', inst.dom.getAttrib(elm, 'onblur'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
84 setFormValue('onclick', onclick);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
85 setFormValue('ondblclick', inst.dom.getAttrib(elm, 'ondblclick'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
86 setFormValue('onmousedown', inst.dom.getAttrib(elm, 'onmousedown'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
87 setFormValue('onmouseup', inst.dom.getAttrib(elm, 'onmouseup'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
88 setFormValue('onmouseover', inst.dom.getAttrib(elm, 'onmouseover'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
89 setFormValue('onmousemove', inst.dom.getAttrib(elm, 'onmousemove'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
90 setFormValue('onmouseout', inst.dom.getAttrib(elm, 'onmouseout'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
91 setFormValue('onkeypress', inst.dom.getAttrib(elm, 'onkeypress'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
92 setFormValue('onkeydown', inst.dom.getAttrib(elm, 'onkeydown'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
93 setFormValue('onkeyup', inst.dom.getAttrib(elm, 'onkeyup'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
94 setFormValue('target', inst.dom.getAttrib(elm, 'target'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
95 setFormValue('classes', inst.dom.getAttrib(elm, 'class'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
96
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
97 // Parse onclick data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
98 if (onclick != null && onclick.indexOf('window.open') != -1)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
99 parseWindowOpen(onclick);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
100 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
101 parseFunction(onclick);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
102
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
103 // Select by the values
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
104 selectByValue(formObj, 'dir', inst.dom.getAttrib(elm, 'dir'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
105 selectByValue(formObj, 'rel', inst.dom.getAttrib(elm, 'rel'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
106 selectByValue(formObj, 'rev', inst.dom.getAttrib(elm, 'rev'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
107 selectByValue(formObj, 'linklisthref', href);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
108
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
109 if (href.charAt(0) == '#')
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
110 selectByValue(formObj, 'anchorlist', href);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
111
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
112 addClassesToList('classlist', 'advlink_styles');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
113
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
114 selectByValue(formObj, 'classlist', inst.dom.getAttrib(elm, 'class'), true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
115 selectByValue(formObj, 'targetlist', inst.dom.getAttrib(elm, 'target'), true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
116 } else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
117 addClassesToList('classlist', 'advlink_styles');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
118 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
119
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
120 function checkPrefix(n) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
121 if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_email')))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
122 n.value = 'mailto:' + n.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
123
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
124 if (/^\s*www\./i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_external')))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
125 n.value = 'http://' + n.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
126 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
127
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
128 function setFormValue(name, value) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
129 document.forms[0].elements[name].value = value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
130 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
131
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
132 function parseWindowOpen(onclick) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
133 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
134
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
135 // Preprocess center code
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
136 if (onclick.indexOf('return false;') != -1) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
137 formObj.popupreturn.checked = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
138 onclick = onclick.replace('return false;', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
139 } else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
140 formObj.popupreturn.checked = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
141
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
142 var onClickData = parseLink(onclick);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
143
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
144 if (onClickData != null) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
145 formObj.ispopup.checked = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
146 setPopupControlsDisabled(false);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
147
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
148 var onClickWindowOptions = parseOptions(onClickData['options']);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
149 var url = onClickData['url'];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
150
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
151 formObj.popupname.value = onClickData['target'];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
152 formObj.popupurl.value = url;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
153 formObj.popupwidth.value = getOption(onClickWindowOptions, 'width');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
154 formObj.popupheight.value = getOption(onClickWindowOptions, 'height');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
155
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
156 formObj.popupleft.value = getOption(onClickWindowOptions, 'left');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
157 formObj.popuptop.value = getOption(onClickWindowOptions, 'top');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
158
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
159 if (formObj.popupleft.value.indexOf('screen') != -1)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
160 formObj.popupleft.value = "c";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
161
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
162 if (formObj.popuptop.value.indexOf('screen') != -1)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
163 formObj.popuptop.value = "c";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
164
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
165 formObj.popuplocation.checked = getOption(onClickWindowOptions, 'location') == "yes";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
166 formObj.popupscrollbars.checked = getOption(onClickWindowOptions, 'scrollbars') == "yes";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
167 formObj.popupmenubar.checked = getOption(onClickWindowOptions, 'menubar') == "yes";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
168 formObj.popupresizable.checked = getOption(onClickWindowOptions, 'resizable') == "yes";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
169 formObj.popuptoolbar.checked = getOption(onClickWindowOptions, 'toolbar') == "yes";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
170 formObj.popupstatus.checked = getOption(onClickWindowOptions, 'status') == "yes";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
171 formObj.popupdependent.checked = getOption(onClickWindowOptions, 'dependent') == "yes";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
172
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
173 buildOnClick();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
174 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
175 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
176
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
177 function parseFunction(onclick) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
178 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
179 var onClickData = parseLink(onclick);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
180
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
181 // TODO: Add stuff here
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
182 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
183
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
184 function getOption(opts, name) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
185 return typeof(opts[name]) == "undefined" ? "" : opts[name];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
186 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
187
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
188 function setPopupControlsDisabled(state) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
189 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
190
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
191 formObj.popupname.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
192 formObj.popupurl.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
193 formObj.popupwidth.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
194 formObj.popupheight.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
195 formObj.popupleft.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
196 formObj.popuptop.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
197 formObj.popuplocation.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
198 formObj.popupscrollbars.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
199 formObj.popupmenubar.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
200 formObj.popupresizable.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
201 formObj.popuptoolbar.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
202 formObj.popupstatus.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
203 formObj.popupreturn.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
204 formObj.popupdependent.disabled = state;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
205
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
206 setBrowserDisabled('popupurlbrowser', state);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
207 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
208
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
209 function parseLink(link) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
210 link = link.replace(new RegExp('&#39;', 'g'), "'");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
211
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
212 var fnName = link.replace(new RegExp("\\s*([A-Za-z0-9\.]*)\\s*\\(.*", "gi"), "$1");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
213
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
214 // Is function name a template function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
215 var template = templates[fnName];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
216 if (template) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
217 // Build regexp
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
218 var variableNames = template.match(new RegExp("'?\\$\\{[A-Za-z0-9\.]*\\}'?", "gi"));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
219 var regExp = "\\s*[A-Za-z0-9\.]*\\s*\\(";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
220 var replaceStr = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
221 for (var i=0; i<variableNames.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
222 // Is string value
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
223 if (variableNames[i].indexOf("'${") != -1)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
224 regExp += "'(.*)'";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
225 else // Number value
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
226 regExp += "([0-9]*)";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
227
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
228 replaceStr += "$" + (i+1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
229
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
230 // Cleanup variable name
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
231 variableNames[i] = variableNames[i].replace(new RegExp("[^A-Za-z0-9]", "gi"), "");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
232
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
233 if (i != variableNames.length-1) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
234 regExp += "\\s*,\\s*";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
235 replaceStr += "<delim>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
236 } else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
237 regExp += ".*";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
238 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
239
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
240 regExp += "\\);?";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
241
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
242 // Build variable array
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
243 var variables = [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
244 variables["_function"] = fnName;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
245 var variableValues = link.replace(new RegExp(regExp, "gi"), replaceStr).split('<delim>');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
246 for (var i=0; i<variableNames.length; i++)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
247 variables[variableNames[i]] = variableValues[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
248
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
249 return variables;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
250 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
251
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
252 return null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
253 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
254
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
255 function parseOptions(opts) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
256 if (opts == null || opts == "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
257 return [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
258
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
259 // Cleanup the options
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
260 opts = opts.toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
261 opts = opts.replace(/;/g, ",");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
262 opts = opts.replace(/[^0-9a-z=,]/g, "");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
263
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
264 var optionChunks = opts.split(',');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
265 var options = [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
266
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
267 for (var i=0; i<optionChunks.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
268 var parts = optionChunks[i].split('=');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
269
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
270 if (parts.length == 2)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
271 options[parts[0]] = parts[1];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
272 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
273
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
274 return options;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
275 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
276
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
277 function buildOnClick() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
278 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
279
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
280 if (!formObj.ispopup.checked) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
281 formObj.onclick.value = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
282 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
283 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
284
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
285 var onclick = "window.open('";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
286 var url = formObj.popupurl.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
287
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
288 onclick += url + "','";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
289 onclick += formObj.popupname.value + "','";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
290
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
291 if (formObj.popuplocation.checked)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
292 onclick += "location=yes,";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
293
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
294 if (formObj.popupscrollbars.checked)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
295 onclick += "scrollbars=yes,";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
296
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
297 if (formObj.popupmenubar.checked)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
298 onclick += "menubar=yes,";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
299
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
300 if (formObj.popupresizable.checked)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
301 onclick += "resizable=yes,";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
302
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
303 if (formObj.popuptoolbar.checked)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
304 onclick += "toolbar=yes,";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
305
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
306 if (formObj.popupstatus.checked)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
307 onclick += "status=yes,";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
308
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
309 if (formObj.popupdependent.checked)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
310 onclick += "dependent=yes,";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
311
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
312 if (formObj.popupwidth.value != "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
313 onclick += "width=" + formObj.popupwidth.value + ",";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
314
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
315 if (formObj.popupheight.value != "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
316 onclick += "height=" + formObj.popupheight.value + ",";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
317
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
318 if (formObj.popupleft.value != "") {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
319 if (formObj.popupleft.value != "c")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
320 onclick += "left=" + formObj.popupleft.value + ",";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
321 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
322 onclick += "left='+(screen.availWidth/2-" + (formObj.popupwidth.value/2) + ")+',";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
323 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
324
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
325 if (formObj.popuptop.value != "") {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
326 if (formObj.popuptop.value != "c")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
327 onclick += "top=" + formObj.popuptop.value + ",";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
328 else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
329 onclick += "top='+(screen.availHeight/2-" + (formObj.popupheight.value/2) + ")+',";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
330 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
331
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
332 if (onclick.charAt(onclick.length-1) == ',')
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
333 onclick = onclick.substring(0, onclick.length-1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
334
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
335 onclick += "');";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
336
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
337 if (formObj.popupreturn.checked)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
338 onclick += "return false;";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
339
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
340 // tinyMCE.debug(onclick);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
341
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
342 formObj.onclick.value = onclick;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
343
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
344 if (formObj.href.value == "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
345 formObj.href.value = url;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
346 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
347
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
348 function setAttrib(elm, attrib, value) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
349 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
350 var valueElm = formObj.elements[attrib.toLowerCase()];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
351 var dom = tinyMCEPopup.editor.dom;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
352
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
353 if (typeof(value) == "undefined" || value == null) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
354 value = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
355
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
356 if (valueElm)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
357 value = valueElm.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
358 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
359
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
360 // Clean up the style
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
361 if (attrib == 'style')
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
362 value = dom.serializeStyle(dom.parseStyle(value), 'a');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
363
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
364 dom.setAttrib(elm, attrib, value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
365 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
366
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
367 function getAnchorListHTML(id, target) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
368 var ed = tinyMCEPopup.editor, nodes = ed.dom.select('a'), name, i, len, html = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
369
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
370 for (i=0, len=nodes.length; i<len; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
371 if ((name = ed.dom.getAttrib(nodes[i], "name")) != "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
372 html += '<option value="#' + name + '">' + name + '</option>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
373 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
374
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
375 if (html == "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
376 return "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
377
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
378 html = '<select id="' + id + '" name="' + id + '" class="mceAnchorList"'
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
379 + ' onchange="this.form.' + target + '.value=this.options[this.selectedIndex].value"'
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
380 + '>'
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
381 + '<option value="">---</option>'
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
382 + html
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
383 + '</select>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
384
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
385 return html;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
386 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
387
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
388 function insertAction() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
389 var inst = tinyMCEPopup.editor;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
390 var elm, elementArray, i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
391
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
392 elm = inst.selection.getNode();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
393 checkPrefix(document.forms[0].href);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
394
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
395 elm = inst.dom.getParent(elm, "A");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
396
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
397 // Remove element if there is no href
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
398 if (!document.forms[0].href.value) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
399 i = inst.selection.getBookmark();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
400 inst.dom.remove(elm, 1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
401 inst.selection.moveToBookmark(i);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
402 tinyMCEPopup.execCommand("mceEndUndoLevel");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
403 tinyMCEPopup.close();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
404 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
405 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
406
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
407 // Create new anchor elements
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
408 if (elm == null) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
409 inst.getDoc().execCommand("unlink", false, null);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
410 tinyMCEPopup.execCommand("mceInsertLink", false, "#mce_temp_url#", {skip_undo : 1});
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
411
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
412 elementArray = tinymce.grep(inst.dom.select("a"), function(n) {return inst.dom.getAttrib(n, 'href') == '#mce_temp_url#';});
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
413 for (i=0; i<elementArray.length; i++)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
414 setAllAttribs(elm = elementArray[i]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
415 } else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
416 setAllAttribs(elm);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
417
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
418 // Don't move caret if selection was image
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
419 if (elm.childNodes.length != 1 || elm.firstChild.nodeName != 'IMG') {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
420 inst.focus();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
421 inst.selection.select(elm);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
422 inst.selection.collapse(0);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
423 tinyMCEPopup.storeSelection();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
424 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
425
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
426 tinyMCEPopup.execCommand("mceEndUndoLevel");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
427 tinyMCEPopup.close();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
428 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
429
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
430 function setAllAttribs(elm) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
431 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
432 var href = formObj.href.value.replace(/ /g, '%20');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
433 var target = getSelectValue(formObj, 'targetlist');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
434
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
435 setAttrib(elm, 'href', href);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
436 setAttrib(elm, 'title');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
437 setAttrib(elm, 'target', target == '_self' ? '' : target);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
438 setAttrib(elm, 'id');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
439 setAttrib(elm, 'style');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
440 setAttrib(elm, 'class', getSelectValue(formObj, 'classlist'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
441 setAttrib(elm, 'rel');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
442 setAttrib(elm, 'rev');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
443 setAttrib(elm, 'charset');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
444 setAttrib(elm, 'hreflang');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
445 setAttrib(elm, 'dir');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
446 setAttrib(elm, 'lang');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
447 setAttrib(elm, 'tabindex');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
448 setAttrib(elm, 'accesskey');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
449 setAttrib(elm, 'type');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
450 setAttrib(elm, 'onfocus');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
451 setAttrib(elm, 'onblur');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
452 setAttrib(elm, 'onclick');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
453 setAttrib(elm, 'ondblclick');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
454 setAttrib(elm, 'onmousedown');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
455 setAttrib(elm, 'onmouseup');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
456 setAttrib(elm, 'onmouseover');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
457 setAttrib(elm, 'onmousemove');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
458 setAttrib(elm, 'onmouseout');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
459 setAttrib(elm, 'onkeypress');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
460 setAttrib(elm, 'onkeydown');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
461 setAttrib(elm, 'onkeyup');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
462
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
463 // Refresh in old MSIE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
464 if (tinyMCE.isMSIE5)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
465 elm.outerHTML = elm.outerHTML;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
466 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
467
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
468 function getSelectValue(form_obj, field_name) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
469 var elm = form_obj.elements[field_name];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
470
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
471 if (!elm || elm.options == null || elm.selectedIndex == -1)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
472 return "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
473
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
474 return elm.options[elm.selectedIndex].value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
475 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
476
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
477 function getLinkListHTML(elm_id, target_form_element, onchange_func) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
478 if (typeof(tinyMCELinkList) == "undefined" || tinyMCELinkList.length == 0)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
479 return "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
480
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
481 var html = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
482
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
483 html += '<select id="' + elm_id + '" name="' + elm_id + '"';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
484 html += ' class="mceLinkList" onfoc2us="tinyMCE.addSelectAccessibility(event, this, window);" onchange="this.form.' + target_form_element + '.value=';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
485 html += 'this.options[this.selectedIndex].value;';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
486
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
487 if (typeof(onchange_func) != "undefined")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
488 html += onchange_func + '(\'' + target_form_element + '\',this.options[this.selectedIndex].text,this.options[this.selectedIndex].value);';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
489
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
490 html += '"><option value="">---</option>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
491
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
492 for (var i=0; i<tinyMCELinkList.length; i++)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
493 html += '<option value="' + tinyMCELinkList[i][1] + '">' + tinyMCELinkList[i][0] + '</option>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
494
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
495 html += '</select>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
496
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
497 return html;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
498
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
499 // tinyMCE.debug('-- image list start --', html, '-- image list end --');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
500 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
501
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
502 function getTargetListHTML(elm_id, target_form_element) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
503 var targets = tinyMCEPopup.getParam('theme_advanced_link_targets', '').split(';');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
504 var html = '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
505
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
506 html += '<select id="' + elm_id + '" name="' + elm_id + '" onf2ocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="this.form.' + target_form_element + '.value=';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
507 html += 'this.options[this.selectedIndex].value;">';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
508 html += '<option value="_self">' + tinyMCEPopup.getLang('advlink_dlg.target_same') + '</option>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
509 html += '<option value="_blank">' + tinyMCEPopup.getLang('advlink_dlg.target_blank') + ' (_blank)</option>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
510 html += '<option value="_parent">' + tinyMCEPopup.getLang('advlink_dlg.target_parent') + ' (_parent)</option>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
511 html += '<option value="_top">' + tinyMCEPopup.getLang('advlink_dlg.target_top') + ' (_top)</option>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
512
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
513 for (var i=0; i<targets.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
514 var key, value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
515
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
516 if (targets[i] == "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
517 continue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
518
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
519 key = targets[i].split('=')[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
520 value = targets[i].split('=')[1];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
521
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
522 html += '<option value="' + key + '">' + value + ' (' + key + ')</option>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
523 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
524
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
525 html += '</select>';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
526
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
527 return html;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
528 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
529
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
530 // While loading
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
531 preinit();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
532 tinyMCEPopup.onInit.add(init);