1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Ensure all a tags have blank target in info sidebar

This commit is contained in:
Nick O'Leary 2017-01-19 13:52:38 +00:00
parent daca78b6cd
commit 540472a093
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -66,6 +66,15 @@ RED.sidebar.info = (function() {
return value; return value;
} }
function addTargetToExternalLinks(el) {
$(el).find("a").each(function(el) {
var href = $(this).attr('href');
if (/^https?:/.test(href)) {
$(this).attr('target','_blank');
}
});
return el;
}
function refresh(node) { function refresh(node) {
tips.stop(); tips.stop();
$(content).empty(); $(content).empty();
@ -117,15 +126,14 @@ RED.sidebar.info = (function() {
$("<hr/>").appendTo(content); $("<hr/>").appendTo(content);
if (!subflowNode && node.type != "comment") { if (!subflowNode && node.type != "comment") {
var helpText = $("script[data-help-name$='"+node.type+"']").html()||""; var helpText = $("script[data-help-name$='"+node.type+"']").html()||"";
$('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(helpText)+'">'+helpText+'</span></div>').appendTo(content); addTargetToExternalLinks($('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(helpText)+'">'+helpText+'</span></div>').appendTo(content));
} }
if (subflowNode) { if (subflowNode) {
$('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(subflowNode.info||"")+'">'+marked(subflowNode.info||"")+'</span></div>').appendTo(content); addTargetToExternalLinks($('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(subflowNode.info||"")+'">'+marked(subflowNode.info||"")+'</span></div>').appendTo(content));
} else if (node._def && node._def.info) { } else if (node._def && node._def.info) {
var info = node._def.info; var info = node._def.info;
var textInfo = (typeof info === "function" ? info.call(node) : info); var textInfo = (typeof info === "function" ? info.call(node) : info);
var ma = marked(textInfo).replace(/href=/g, 'target="_blank" href='); addTargetToExternalLinks($('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(textInfo)+'">'+marked(textInfo)+'</span></div>').appendTo(content));
$('<div class="node-help"><span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(textInfo)+'">'+ma+'</span></div>').appendTo(content);
//$('<div class="node-help">'+(typeof info === "function" ? info.call(node) : info)+'</div>'; //$('<div class="node-help">'+(typeof info === "function" ? info.call(node) : info)+'</div>';
} }