function formElement() {
return document.insert_file;
}
tinyMCEPopup.requireLangPack();
var templates = {
"window.open" : "window.open('${url}','${target}','${options}')"
};
function preinit() {
var url;
if (url = tinyMCEPopup.getParam("external_link_list_url"))
document.write('');
}
function init() {
tinyMCEPopup.resizeToInnerSize();
var formObj = formElement();
var inst = tinyMCEPopup.editor;
if(inst.selection.getContent().length > 0){
formObj.title.value = inst.selection.getContent();
}
// Resize some elements
if (isVisible('hrefbrowser'))
document.getElementById('href').style.width = '260px';
}
function checkPrefix(n) {
if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_email')))
n.value = 'mailto:' + n.value;
if (/^\s*www./i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_external')))
n.value = 'http://' + n.value;
}
function setAttrib(elm, attrib, value) {
var formObj = formElement();
var valueElm = formObj.elements[attrib.toLowerCase()];
var dom = tinyMCEPopup.editor.dom;
if (typeof(value) == "undefined" || value == null) {
value = "";
if (valueElm)
value = valueElm.value;
}
// Clean up the style
if (attrib == 'style')
value = dom.serializeStyle(dom.parseStyle(value));
dom.setAttrib(elm, attrib, value);
}
function insertAction() {
var inst = tinyMCEPopup.editor;
var elm, elementArray, i;
var formObj = formElement();
if(inst.selection.getContent().length <= 0){
inst.selection.setContent('' + formObj.title.value + '');
}
elm = inst.selection.getNode();
checkPrefix(formObj.href);
elm = inst.dom.getParent(elm, "A");
// Remove element if there is no href
if (!formObj.href.value) {
tinyMCEPopup.execCommand("mceBeginUndoLevel");
i = inst.selection.getBookmark();
inst.dom.remove(elm, 1);
inst.selection.moveToBookmark(i);
tinyMCEPopup.execCommand("mceEndUndoLevel");
tinyMCEPopup.close();
return;
}
tinyMCEPopup.execCommand("mceBeginUndoLevel");
// Create new anchor elements
if (elm == null) {
tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
elementArray = tinymce.grep(inst.dom.select("a"), function(n) {return inst.dom.getAttrib(n, 'href') == '#mce_temp_url#';});
for (i=0; i