1 tinyMCEPopup.requireLangPack();
\r
4 preInit : function() {
\r
7 if (url = tinyMCEPopup.getParam("external_link_list_url"))
\r
8 document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
\r
12 var f = document.forms[0], ed = tinyMCEPopup.editor;
\r
14 // Setup browse button
\r
15 document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser', 'href', 'file', 'theme_advanced_link');
\r
16 if (isVisible('hrefbrowser'))
\r
17 document.getElementById('href').style.width = '180px';
\r
19 this.fillClassList('class_list');
\r
20 this.fillFileList('link_list', 'tinyMCELinkList');
\r
21 this.fillTargetList('target_list');
\r
23 if (e = ed.dom.getParent(ed.selection.getNode(), 'A')) {
\r
24 f.href.value = ed.dom.getAttrib(e, 'href');
\r
25 f.linktitle.value = ed.dom.getAttrib(e, 'title');
\r
26 f.insert.value = ed.getLang('update');
\r
27 selectByValue(f, 'link_list', f.href.value);
\r
28 selectByValue(f, 'target_list', ed.dom.getAttrib(e, 'target'));
\r
29 selectByValue(f, 'class_list', ed.dom.getAttrib(e, 'class'));
\r
33 update : function() {
\r
34 var f = document.forms[0], ed = tinyMCEPopup.editor, e, b;
\r
36 tinyMCEPopup.restoreSelection();
\r
37 e = ed.dom.getParent(ed.selection.getNode(), 'A');
\r
39 // Remove element if there is no href
\r
40 if (!f.href.value) {
\r
42 tinyMCEPopup.execCommand("mceBeginUndoLevel");
\r
43 b = ed.selection.getBookmark();
\r
44 ed.dom.remove(e, 1);
\r
45 ed.selection.moveToBookmark(b);
\r
46 tinyMCEPopup.execCommand("mceEndUndoLevel");
\r
47 tinyMCEPopup.close();
\r
52 tinyMCEPopup.execCommand("mceBeginUndoLevel");
\r
54 // Create new anchor elements
\r
56 ed.getDoc().execCommand("unlink", false, null);
\r
57 tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
\r
59 tinymce.each(ed.dom.select("a"), function(n) {
\r
60 if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
\r
63 ed.dom.setAttribs(e, {
\r
64 href : f.href.value,
\r
65 title : f.linktitle.value,
\r
66 target : f.target_list ? getSelectValue(f, "target_list") : null,
\r
67 'class' : f.class_list ? getSelectValue(f, "class_list") : null
\r
72 ed.dom.setAttribs(e, {
\r
73 href : f.href.value,
\r
74 title : f.linktitle.value,
\r
75 target : f.target_list ? getSelectValue(f, "target_list") : null,
\r
76 'class' : f.class_list ? getSelectValue(f, "class_list") : null
\r
80 // Don't move caret if selection was image
\r
81 if (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') {
\r
83 ed.selection.select(e);
\r
84 ed.selection.collapse(0);
\r
85 tinyMCEPopup.storeSelection();
\r
88 tinyMCEPopup.execCommand("mceEndUndoLevel");
\r
89 tinyMCEPopup.close();
\r
92 checkPrefix : function(n) {
\r
93 if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_email')))
\r
94 n.value = 'mailto:' + n.value;
\r
96 if (/^\s*www\./i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_external')))
\r
97 n.value = 'http://' + n.value;
\r
100 fillFileList : function(id, l) {
\r
101 var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
\r
105 if (l && l.length > 0) {
\r
106 lst.options[lst.options.length] = new Option('', '');
\r
108 tinymce.each(l, function(o) {
\r
109 lst.options[lst.options.length] = new Option(o[0], o[1]);
\r
112 dom.remove(dom.getParent(id, 'tr'));
\r
115 fillClassList : function(id) {
\r
116 var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
\r
118 if (v = tinyMCEPopup.getParam('theme_advanced_styles')) {
\r
121 tinymce.each(v.split(';'), function(v) {
\r
122 var p = v.split('=');
\r
124 cl.push({'title' : p[0], 'class' : p[1]});
\r
127 cl = tinyMCEPopup.editor.dom.getClasses();
\r
129 if (cl.length > 0) {
\r
130 lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
\r
132 tinymce.each(cl, function(o) {
\r
133 lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']);
\r
136 dom.remove(dom.getParent(id, 'tr'));
\r
139 fillTargetList : function(id) {
\r
140 var dom = tinyMCEPopup.dom, lst = dom.get(id), v;
\r
142 lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
\r
143 lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_same'), '_self');
\r
144 lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_blank'), '_blank');
\r
146 if (v = tinyMCEPopup.getParam('theme_advanced_link_targets')) {
\r
147 tinymce.each(v.split(','), function(v) {
\r
149 lst.options[lst.options.length] = new Option(v[0], v[1]);
\r
155 LinkDialog.preInit();
\r
156 tinyMCEPopup.onInit.add(LinkDialog.init, LinkDialog);
\r