diff --git a/umbraco/presentation/umbraco_client/tinymce3/plugins/advlink/js/advlink.js b/umbraco/presentation/umbraco_client/tinymce3/plugins/advlink/js/advlink.js
index b78e82f76b..d442bfe5a3 100644
--- a/umbraco/presentation/umbraco_client/tinymce3/plugins/advlink/js/advlink.js
+++ b/umbraco/presentation/umbraco_client/tinymce3/plugins/advlink/js/advlink.js
@@ -3,524 +3,545 @@
tinyMCEPopup.requireLangPack();
var templates = {
- "window.open" : "window.open('${url}','${target}','${options}')"
+ "window.open": "window.open('${url}','${target}','${options}')"
};
function preinit() {
- var url;
+ var url;
- if (url = tinyMCEPopup.getParam("external_link_list_url"))
- document.write('');
+ if (url = tinyMCEPopup.getParam("external_link_list_url"))
+ document.write('');
}
function changeClass() {
- var f = document.forms[0];
+ var f = document.forms[0];
- f.classes.value = getSelectValue(f, 'classlist');
+ f.classes.value = getSelectValue(f, 'classlist');
}
function init() {
- tinyMCEPopup.resizeToInnerSize();
+ tinyMCEPopup.resizeToInnerSize();
- var formObj = document.forms[0];
- var inst = tinyMCEPopup.editor;
- var elm = inst.selection.getNode();
- var action = "insert";
- var html;
+ var formObj = document.forms[0];
+ var inst = tinyMCEPopup.editor;
+ var elm = inst.selection.getNode();
+ var action = "insert";
+ var html;
+ document.getElementById('anchorlistcontainer').innerHTML = getAnchorListHTML('anchorlist', 'href');
+ document.getElementById('targetlistcontainer').innerHTML = getTargetListHTML('targetlist', 'target');
- document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','advlink');
- document.getElementById('popupurlbrowsercontainer').innerHTML = getBrowserHTML('popupurlbrowser','popupurl','file','advlink');
- document.getElementById('linklisthrefcontainer').innerHTML = getLinkListHTML('linklisthref','href');
- document.getElementById('anchorlistcontainer').innerHTML = getAnchorListHTML('anchorlist','href');
- document.getElementById('targetlistcontainer').innerHTML = getTargetListHTML('targetlist','target');
+ /*
+ document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','advlink');
+ document.getElementById('popupurlbrowsercontainer').innerHTML = getBrowserHTML('popupurlbrowser','popupurl','file','advlink');
+ document.getElementById('linklisthrefcontainer').innerHTML = getLinkListHTML('linklisthref','href');
- // Link list
- html = getLinkListHTML('linklisthref','href');
- if (html == "")
- document.getElementById("linklisthrefrow").style.display = 'none';
- else
- document.getElementById("linklisthrefcontainer").innerHTML = html;
+ // Link list
+ html = getLinkListHTML('linklisthref','href');
+ if (html == "")
+ document.getElementById("linklisthrefrow").style.display = 'none';
+ else
+ document.getElementById("linklisthrefcontainer").innerHTML = html;
- // Resize some elements
- if (isVisible('hrefbrowser'))
- document.getElementById('href').style.width = '260px';
+ // Resize some elements
+ if (isVisible('hrefbrowser'))
+ document.getElementById('href').style.width = '260px';
- if (isVisible('popupurlbrowser'))
- document.getElementById('popupurl').style.width = '180px';
+ if (isVisible('popupurlbrowser'))
+ document.getElementById('popupurl').style.width = '180px';
- elm = inst.dom.getParent(elm, "A");
- if (elm != null && elm.nodeName == "A")
- action = "update";
- formObj.insert.value = tinyMCEPopup.getLang(action, 'Insert', true);
+ setPopupControlsDisabled(true);
+ */
- setPopupControlsDisabled(true);
+ elm = inst.dom.getParent(elm, "A");
+ if (elm != null && elm.nodeName == "A")
+ action = "update";
- if (action == "update") {
- var href = inst.dom.getAttrib(elm, 'href');
- var onclick = inst.dom.getAttrib(elm, 'onclick');
+ formObj.insert.value = tinyMCEPopup.getLang(action, 'Insert', true);
- // Setup form data
- setFormValue('href', href);
- setFormValue('title', inst.dom.getAttrib(elm, 'title'));
- setFormValue('id', inst.dom.getAttrib(elm, 'id'));
- setFormValue('style', inst.dom.getAttrib(elm, "style"));
- setFormValue('rel', inst.dom.getAttrib(elm, 'rel'));
- setFormValue('rev', inst.dom.getAttrib(elm, 'rev'));
- setFormValue('charset', inst.dom.getAttrib(elm, 'charset'));
- setFormValue('hreflang', inst.dom.getAttrib(elm, 'hreflang'));
- setFormValue('dir', inst.dom.getAttrib(elm, 'dir'));
- setFormValue('lang', inst.dom.getAttrib(elm, 'lang'));
- setFormValue('tabindex', inst.dom.getAttrib(elm, 'tabindex', typeof(elm.tabindex) != "undefined" ? elm.tabindex : ""));
- setFormValue('accesskey', inst.dom.getAttrib(elm, 'accesskey', typeof(elm.accesskey) != "undefined" ? elm.accesskey : ""));
- setFormValue('type', inst.dom.getAttrib(elm, 'type'));
- setFormValue('onfocus', inst.dom.getAttrib(elm, 'onfocus'));
- setFormValue('onblur', inst.dom.getAttrib(elm, 'onblur'));
- setFormValue('onclick', onclick);
- setFormValue('ondblclick', inst.dom.getAttrib(elm, 'ondblclick'));
- setFormValue('onmousedown', inst.dom.getAttrib(elm, 'onmousedown'));
- setFormValue('onmouseup', inst.dom.getAttrib(elm, 'onmouseup'));
- setFormValue('onmouseover', inst.dom.getAttrib(elm, 'onmouseover'));
- setFormValue('onmousemove', inst.dom.getAttrib(elm, 'onmousemove'));
- setFormValue('onmouseout', inst.dom.getAttrib(elm, 'onmouseout'));
- setFormValue('onkeypress', inst.dom.getAttrib(elm, 'onkeypress'));
- setFormValue('onkeydown', inst.dom.getAttrib(elm, 'onkeydown'));
- setFormValue('onkeyup', inst.dom.getAttrib(elm, 'onkeyup'));
- setFormValue('target', inst.dom.getAttrib(elm, 'target'));
- setFormValue('classes', inst.dom.getAttrib(elm, 'class'));
+ if (action == "update") {
+ // umbraco specific, check local links
+ var href = validateUmbracoLink(inst.dom.getAttrib(elm, 'href'));
+ var onclick = inst.dom.getAttrib(elm, 'onclick');
- // Parse onclick data
- if (onclick != null && onclick.indexOf('window.open') != -1)
- parseWindowOpen(onclick);
- else
- parseFunction(onclick);
+ // Setup form data
+ setFormValue('href', href);
+ setFormValue('title', inst.dom.getAttrib(elm, 'title'));
+ //setFormValue('target', inst.dom.getAttrib(elm, 'target'));
- // Select by the values
- selectByValue(formObj, 'dir', inst.dom.getAttrib(elm, 'dir'));
- selectByValue(formObj, 'rel', inst.dom.getAttrib(elm, 'rel'));
- selectByValue(formObj, 'rev', inst.dom.getAttrib(elm, 'rev'));
- selectByValue(formObj, 'linklisthref', href);
+ if (href.charAt(0) == '#')
+ selectByValue(formObj, 'anchorlist', href);
- if (href.charAt(0) == '#')
- selectByValue(formObj, 'anchorlist', href);
+ selectByValue(formObj, 'targetlist', inst.dom.getAttrib(elm, 'target'), true);
+ /*
+ // Setup form data
+ setFormValue('href', href);
+ setFormValue('title', inst.dom.getAttrib(elm, 'title'));
+ setFormValue('id', inst.dom.getAttrib(elm, 'id'));
+ setFormValue('style', inst.dom.getAttrib(elm, "style"));
+ setFormValue('rel', inst.dom.getAttrib(elm, 'rel'));
+ setFormValue('rev', inst.dom.getAttrib(elm, 'rev'));
+ setFormValue('charset', inst.dom.getAttrib(elm, 'charset'));
+ setFormValue('hreflang', inst.dom.getAttrib(elm, 'hreflang'));
+ setFormValue('dir', inst.dom.getAttrib(elm, 'dir'));
+ setFormValue('lang', inst.dom.getAttrib(elm, 'lang'));
+ setFormValue('tabindex', inst.dom.getAttrib(elm, 'tabindex', typeof(elm.tabindex) != "undefined" ? elm.tabindex : ""));
+ setFormValue('accesskey', inst.dom.getAttrib(elm, 'accesskey', typeof(elm.accesskey) != "undefined" ? elm.accesskey : ""));
+ setFormValue('type', inst.dom.getAttrib(elm, 'type'));
+ setFormValue('onfocus', inst.dom.getAttrib(elm, 'onfocus'));
+ setFormValue('onblur', inst.dom.getAttrib(elm, 'onblur'));
+ setFormValue('onclick', onclick);
+ setFormValue('ondblclick', inst.dom.getAttrib(elm, 'ondblclick'));
+ setFormValue('onmousedown', inst.dom.getAttrib(elm, 'onmousedown'));
+ setFormValue('onmouseup', inst.dom.getAttrib(elm, 'onmouseup'));
+ setFormValue('onmouseover', inst.dom.getAttrib(elm, 'onmouseover'));
+ setFormValue('onmousemove', inst.dom.getAttrib(elm, 'onmousemove'));
+ setFormValue('onmouseout', inst.dom.getAttrib(elm, 'onmouseout'));
+ setFormValue('onkeypress', inst.dom.getAttrib(elm, 'onkeypress'));
+ setFormValue('onkeydown', inst.dom.getAttrib(elm, 'onkeydown'));
+ setFormValue('onkeyup', inst.dom.getAttrib(elm, 'onkeyup'));
+ setFormValue('target', inst.dom.getAttrib(elm, 'target'));
+ setFormValue('classes', inst.dom.getAttrib(elm, 'class'));
- addClassesToList('classlist', 'advlink_styles');
+ // Parse onclick data
+ if (onclick != null && onclick.indexOf('window.open') != -1)
+ parseWindowOpen(onclick);
+ else
+ parseFunction(onclick);
- selectByValue(formObj, 'classlist', inst.dom.getAttrib(elm, 'class'), true);
- selectByValue(formObj, 'targetlist', inst.dom.getAttrib(elm, 'target'), true);
- } else
- addClassesToList('classlist', 'advlink_styles');
+ // Select by the values
+ selectByValue(formObj, 'dir', inst.dom.getAttrib(elm, 'dir'));
+ selectByValue(formObj, 'rel', inst.dom.getAttrib(elm, 'rel'));
+ selectByValue(formObj, 'rev', inst.dom.getAttrib(elm, 'rev'));
+ selectByValue(formObj, 'linklisthref', href);
+
+ if (href.charAt(0) == '#')
+ selectByValue(formObj, 'anchorlist', href);
+
+ addClassesToList('classlist', 'advlink_styles');
+
+ selectByValue(formObj, 'classlist', inst.dom.getAttrib(elm, 'class'), true);
+ selectByValue(formObj, 'targetlist', inst.dom.getAttrib(elm, 'target'), true);
+ */
+ }
+ // else
+ // addClassesToList('classlist', 'advlink_styles');
}
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 (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;
+ if (/^\s*www\./i.test(n.value) && confirm(tinyMCEPopup.getLang('advlink_dlg.is_external')))
+ n.value = 'http://' + n.value;
}
function setFormValue(name, value) {
- document.forms[0].elements[name].value = value;
+ document.forms[0].elements[name].value = value;
}
function parseWindowOpen(onclick) {
- var formObj = document.forms[0];
+ var formObj = document.forms[0];
- // Preprocess center code
- if (onclick.indexOf('return false;') != -1) {
- formObj.popupreturn.checked = true;
- onclick = onclick.replace('return false;', '');
- } else
- formObj.popupreturn.checked = false;
+ // Preprocess center code
+ if (onclick.indexOf('return false;') != -1) {
+ formObj.popupreturn.checked = true;
+ onclick = onclick.replace('return false;', '');
+ } else
+ formObj.popupreturn.checked = false;
- var onClickData = parseLink(onclick);
+ var onClickData = parseLink(onclick);
- if (onClickData != null) {
- formObj.ispopup.checked = true;
- setPopupControlsDisabled(false);
+ if (onClickData != null) {
+ formObj.ispopup.checked = true;
+ setPopupControlsDisabled(false);
- var onClickWindowOptions = parseOptions(onClickData['options']);
- var url = onClickData['url'];
+ var onClickWindowOptions = parseOptions(onClickData['options']);
+ var url = onClickData['url'];
- formObj.popupname.value = onClickData['target'];
- formObj.popupurl.value = url;
- formObj.popupwidth.value = getOption(onClickWindowOptions, 'width');
- formObj.popupheight.value = getOption(onClickWindowOptions, 'height');
+ formObj.popupname.value = onClickData['target'];
+ formObj.popupurl.value = url;
+ formObj.popupwidth.value = getOption(onClickWindowOptions, 'width');
+ formObj.popupheight.value = getOption(onClickWindowOptions, 'height');
- formObj.popupleft.value = getOption(onClickWindowOptions, 'left');
- formObj.popuptop.value = getOption(onClickWindowOptions, 'top');
+ formObj.popupleft.value = getOption(onClickWindowOptions, 'left');
+ formObj.popuptop.value = getOption(onClickWindowOptions, 'top');
- if (formObj.popupleft.value.indexOf('screen') != -1)
- formObj.popupleft.value = "c";
+ if (formObj.popupleft.value.indexOf('screen') != -1)
+ formObj.popupleft.value = "c";
- if (formObj.popuptop.value.indexOf('screen') != -1)
- formObj.popuptop.value = "c";
+ if (formObj.popuptop.value.indexOf('screen') != -1)
+ formObj.popuptop.value = "c";
- formObj.popuplocation.checked = getOption(onClickWindowOptions, 'location') == "yes";
- formObj.popupscrollbars.checked = getOption(onClickWindowOptions, 'scrollbars') == "yes";
- formObj.popupmenubar.checked = getOption(onClickWindowOptions, 'menubar') == "yes";
- formObj.popupresizable.checked = getOption(onClickWindowOptions, 'resizable') == "yes";
- formObj.popuptoolbar.checked = getOption(onClickWindowOptions, 'toolbar') == "yes";
- formObj.popupstatus.checked = getOption(onClickWindowOptions, 'status') == "yes";
- formObj.popupdependent.checked = getOption(onClickWindowOptions, 'dependent') == "yes";
+ formObj.popuplocation.checked = getOption(onClickWindowOptions, 'location') == "yes";
+ formObj.popupscrollbars.checked = getOption(onClickWindowOptions, 'scrollbars') == "yes";
+ formObj.popupmenubar.checked = getOption(onClickWindowOptions, 'menubar') == "yes";
+ formObj.popupresizable.checked = getOption(onClickWindowOptions, 'resizable') == "yes";
+ formObj.popuptoolbar.checked = getOption(onClickWindowOptions, 'toolbar') == "yes";
+ formObj.popupstatus.checked = getOption(onClickWindowOptions, 'status') == "yes";
+ formObj.popupdependent.checked = getOption(onClickWindowOptions, 'dependent') == "yes";
- buildOnClick();
- }
+ buildOnClick();
+ }
}
function parseFunction(onclick) {
- var formObj = document.forms[0];
- var onClickData = parseLink(onclick);
+ var formObj = document.forms[0];
+ var onClickData = parseLink(onclick);
- // TODO: Add stuff here
+ // TODO: Add stuff here
}
function getOption(opts, name) {
- return typeof(opts[name]) == "undefined" ? "" : opts[name];
+ return typeof (opts[name]) == "undefined" ? "" : opts[name];
}
function setPopupControlsDisabled(state) {
- var formObj = document.forms[0];
+ var formObj = document.forms[0];
- formObj.popupname.disabled = state;
- formObj.popupurl.disabled = state;
- formObj.popupwidth.disabled = state;
- formObj.popupheight.disabled = state;
- formObj.popupleft.disabled = state;
- formObj.popuptop.disabled = state;
- formObj.popuplocation.disabled = state;
- formObj.popupscrollbars.disabled = state;
- formObj.popupmenubar.disabled = state;
- formObj.popupresizable.disabled = state;
- formObj.popuptoolbar.disabled = state;
- formObj.popupstatus.disabled = state;
- formObj.popupreturn.disabled = state;
- formObj.popupdependent.disabled = state;
+ formObj.popupname.disabled = state;
+ formObj.popupurl.disabled = state;
+ formObj.popupwidth.disabled = state;
+ formObj.popupheight.disabled = state;
+ formObj.popupleft.disabled = state;
+ formObj.popuptop.disabled = state;
+ formObj.popuplocation.disabled = state;
+ formObj.popupscrollbars.disabled = state;
+ formObj.popupmenubar.disabled = state;
+ formObj.popupresizable.disabled = state;
+ formObj.popuptoolbar.disabled = state;
+ formObj.popupstatus.disabled = state;
+ formObj.popupreturn.disabled = state;
+ formObj.popupdependent.disabled = state;
- setBrowserDisabled('popupurlbrowser', state);
+ setBrowserDisabled('popupurlbrowser', state);
}
function parseLink(link) {
- link = link.replace(new RegExp(''', 'g'), "'");
+ link = link.replace(new RegExp(''', 'g'), "'");
- var fnName = link.replace(new RegExp("\\s*([A-Za-z0-9\.]*)\\s*\\(.*", "gi"), "$1");
+ var fnName = link.replace(new RegExp("\\s*([A-Za-z0-9\.]*)\\s*\\(.*", "gi"), "$1");
- // Is function name a template function
- var template = templates[fnName];
- if (template) {
- // Build regexp
- var variableNames = template.match(new RegExp("'?\\$\\{[A-Za-z0-9\.]*\\}'?", "gi"));
- var regExp = "\\s*[A-Za-z0-9\.]*\\s*\\(";
- var replaceStr = "";
- for (var i=0; i";
- } else
- regExp += ".*";
- }
+ if (i != variableNames.length - 1) {
+ regExp += "\\s*,\\s*";
+ replaceStr += "";
+ } else
+ regExp += ".*";
+ }
- regExp += "\\);?";
+ regExp += "\\);?";
- // Build variable array
- var variables = [];
- variables["_function"] = fnName;
- var variableValues = link.replace(new RegExp(regExp, "gi"), replaceStr).split('');
- for (var i=0; i');
+ for (var i = 0; i < variableNames.length; i++)
+ variables[variableNames[i]] = variableValues[i];
- return variables;
- }
+ return variables;
+ }
- return null;
+ return null;
}
function parseOptions(opts) {
- if (opts == null || opts == "")
- return [];
+ if (opts == null || opts == "")
+ return [];
- // Cleanup the options
- opts = opts.toLowerCase();
- opts = opts.replace(/;/g, ",");
- opts = opts.replace(/[^0-9a-z=,]/g, "");
+ // Cleanup the options
+ opts = opts.toLowerCase();
+ opts = opts.replace(/;/g, ",");
+ opts = opts.replace(/[^0-9a-z=,]/g, "");
- var optionChunks = opts.split(',');
- var options = [];
+ var optionChunks = opts.split(',');
+ var options = [];
- for (var i=0; i';
- html += '';
+ html += '';
+ html += '';
- return html;
+ return html;
}
function insertAction() {
- var inst = tinyMCEPopup.editor;
- var elm, elementArray, i;
+ var inst = tinyMCEPopup.editor;
+ var elm, elementArray, i;
- elm = inst.selection.getNode();
- checkPrefix(document.forms[0].href);
+ // umbraco specific - if there's a locallink, we'll grap that
+ if (document.forms[0].localUrl.value) {
+ document.forms[0].href.value = document.forms[0].localUrl.value;
+ }
- elm = inst.dom.getParent(elm, "A");
+ elm = inst.selection.getNode();
+ checkPrefix(document.forms[0].href);
- // Remove element if there is no href
- if (!document.forms[0].href.value) {
- tinyMCEPopup.execCommand("mceBeginUndoLevel");
- i = inst.selection.getBookmark();
- inst.dom.remove(elm, 1);
- inst.selection.moveToBookmark(i);
- tinyMCEPopup.execCommand("mceEndUndoLevel");
- tinyMCEPopup.close();
- return;
- }
+ elm = inst.dom.getParent(elm, "A");
- tinyMCEPopup.execCommand("mceBeginUndoLevel");
+ // Remove element if there is no href
+ if (!document.forms[0].href.value) {
+ tinyMCEPopup.execCommand("mceBeginUndoLevel");
+ i = inst.selection.getBookmark();
+ inst.dom.remove(elm, 1);
+ inst.selection.moveToBookmark(i);
+ tinyMCEPopup.execCommand("mceEndUndoLevel");
+ tinyMCEPopup.close();
+ return;
+ }
- // Create new anchor elements
- if (elm == null) {
- inst.getDoc().execCommand("unlink", false, null);
- tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
+ tinyMCEPopup.execCommand("mceBeginUndoLevel");
- elementArray = tinymce.grep(inst.dom.select("a"), function(n) {return inst.dom.getAttrib(n, 'href') == '#mce_temp_url#';});
- for (i=0; i';
+ html += '">';
- for (var i=0; i' + tinyMCELinkList[i][0] + '';
+ for (var i = 0; i < tinyMCELinkList.length; i++)
+ html += '';
- html += '';
+ html += '';
- return html;
+ return html;
- // tinyMCE.debug('-- image list start --', html, '-- image list end --');
+ // tinyMCE.debug('-- image list start --', html, '-- image list end --');
}
function getTargetListHTML(elm_id, target_form_element) {
- var targets = tinyMCEPopup.getParam('theme_advanced_link_targets', '').split(';');
- var html = '';
+ var targets = tinyMCEPopup.getParam('theme_advanced_link_targets', '').split(';');
+ var html = '';
- html += '';
- return html;
+ return html;
}
// While loading