1 tinyMCEPopup
.requireLangPack();
7 if (url
= tinyMCEPopup
.getParam("external_link_list_url"))
8 document
.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup
.editor
.documentBaseURI
.toAbsolute(url
) + '"></script>');
12 var f
= document
.forms
[0], ed
= tinyMCEPopup
.editor
;
14 // Setup browse button
15 document
.getElementById('hrefbrowsercontainer').innerHTML
= getBrowserHTML('hrefbrowser', 'href', 'file', 'theme_advanced_link');
16 if (isVisible('hrefbrowser'))
17 document
.getElementById('href').style
.width
= '180px';
19 this.fillClassList('class_list');
20 this.fillFileList('link_list', 'tinyMCELinkList');
21 this.fillTargetList('target_list');
23 if (e
= ed
.dom
.getParent(ed
.selection
.getNode(), 'A')) {
24 f
.href
.value
= ed
.dom
.getAttrib(e
, 'href');
25 f
.linktitle
.value
= ed
.dom
.getAttrib(e
, 'title');
26 f
.insert
.value
= ed
.getLang('update');
27 selectByValue(f
, 'link_list', f
.href
.value
);
28 selectByValue(f
, 'target_list', ed
.dom
.getAttrib(e
, 'target'));
29 selectByValue(f
, 'class_list', ed
.dom
.getAttrib(e
, 'class'));
34 var f
= document
.forms
[0], ed
= tinyMCEPopup
.editor
, e
, b
, href
= f
.href
.value
.replace(/ /g
, '%20');
36 tinyMCEPopup
.restoreSelection();
37 e
= ed
.dom
.getParent(ed
.selection
.getNode(), 'A');
39 // Remove element if there is no href
42 b
= ed
.selection
.getBookmark();
44 ed
.selection
.moveToBookmark(b
);
45 tinyMCEPopup
.execCommand("mceEndUndoLevel");
51 // Create new anchor elements
53 ed
.getDoc().execCommand("unlink", false, null);
54 tinyMCEPopup
.execCommand("mceInsertLink", false, "#mce_temp_url#", {skip_undo
: 1});
56 tinymce
.each(ed
.dom
.select("a"), function(n
) {
57 if (ed
.dom
.getAttrib(n
, 'href') == '#mce_temp_url#') {
60 ed
.dom
.setAttribs(e
, {
62 title
: f
.linktitle
.value
,
63 target
: f
.target_list
? getSelectValue(f
, "target_list") : null,
64 'class' : f
.class_list
? getSelectValue(f
, "class_list") : null
69 ed
.dom
.setAttribs(e
, {
71 title
: f
.linktitle
.value
,
72 target
: f
.target_list
? getSelectValue(f
, "target_list") : null,
73 'class' : f
.class_list
? getSelectValue(f
, "class_list") : null
77 // Don't move caret if selection was image
78 if (e
.childNodes
.length
!= 1 || e
.firstChild
.nodeName
!= 'IMG') {
80 ed
.selection
.select(e
);
81 ed
.selection
.collapse(0);
82 tinyMCEPopup
.storeSelection();
85 tinyMCEPopup
.execCommand("mceEndUndoLevel");
89 checkPrefix : function(n
) {
90 if (n
.value
&& Validator
.isEmail(n
) && !/^\s*mailto:/i.test(n
.value
) && confirm(tinyMCEPopup
.getLang('advanced_dlg.link_is_email')))
91 n
.value
= 'mailto:' + n
.value
;
93 if (/^\s*www\./i.test(n
.value
) && confirm(tinyMCEPopup
.getLang('advanced_dlg.link_is_external')))
94 n
.value
= 'http://' + n
.value
;
97 fillFileList : function(id
, l
) {
98 var dom
= tinyMCEPopup
.dom
, lst
= dom
.get(id
), v
, cl
;
102 if (l
&& l
.length
> 0) {
103 lst
.options
[lst
.options
.length
] = new Option('', '');
105 tinymce
.each(l
, function(o
) {
106 lst
.options
[lst
.options
.length
] = new Option(o
[0], o
[1]);
109 dom
.remove(dom
.getParent(id
, 'tr'));
112 fillClassList : function(id
) {
113 var dom
= tinyMCEPopup
.dom
, lst
= dom
.get(id
), v
, cl
;
115 if (v
= tinyMCEPopup
.getParam('theme_advanced_styles')) {
118 tinymce
.each(v
.split(';'), function(v
) {
119 var p
= v
.split('=');
121 cl
.push({'title' : p
[0], 'class' : p
[1]});
124 cl
= tinyMCEPopup
.editor
.dom
.getClasses();
127 lst
.options
[lst
.options
.length
] = new Option(tinyMCEPopup
.getLang('not_set'), '');
129 tinymce
.each(cl
, function(o
) {
130 lst
.options
[lst
.options
.length
] = new Option(o
.title
|| o
['class'], o
['class']);
133 dom
.remove(dom
.getParent(id
, 'tr'));
136 fillTargetList : function(id
) {
137 var dom
= tinyMCEPopup
.dom
, lst
= dom
.get(id
), v
;
139 lst
.options
[lst
.options
.length
] = new Option(tinyMCEPopup
.getLang('not_set'), '');
140 lst
.options
[lst
.options
.length
] = new Option(tinyMCEPopup
.getLang('advanced_dlg.link_target_same'), '_self');
141 lst
.options
[lst
.options
.length
] = new Option(tinyMCEPopup
.getLang('advanced_dlg.link_target_blank'), '_blank');
143 if (v
= tinyMCEPopup
.getParam('theme_advanced_link_targets')) {
144 tinymce
.each(v
.split(','), function(v
) {
146 lst
.options
[lst
.options
.length
] = new Option(v
[0], v
[1]);
152 LinkDialog
.preInit();
153 tinyMCEPopup
.onInit
.add(LinkDialog
.init
, LinkDialog
);