From 6bd59b10c785c73bb40ed6886dff36c29fdcee9a Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 24 May 2017 21:11:23 +0100 Subject: [PATCH] Ensure info tab sections are collapsible when set from palette --- editor/js/ui/palette.js | 3 +-- editor/js/ui/tab-info.js | 37 +++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/editor/js/ui/palette.js b/editor/js/ui/palette.js index b7c1b58a5..c40b3660f 100644 --- a/editor/js/ui/palette.js +++ b/editor/js/ui/palette.js @@ -210,8 +210,7 @@ RED.palette = (function() { } else { helpText = $("script[data-help-name='"+d.type+"']").html()||""; } - var help = '
'+helpText+"
"; - RED.sidebar.info.set(help); + RED.sidebar.info.set(helpText); }); var chart = $("#chart"); var chartOffset = chart.offset(); diff --git a/editor/js/ui/tab-info.js b/editor/js/ui/tab-info.js index 8355ed722..feea8c5dc 100644 --- a/editor/js/ui/tab-info.js +++ b/editor/js/ui/tab-info.js @@ -233,20 +233,7 @@ RED.sidebar.info = (function() { infoText = infoText + marked(textInfo); } if (infoText) { - var info = addTargetToExternalLinks($('
'+infoText+'
')).appendTo(infoSection.content); - info.find(".bidiAware").contents().filter(function() { return this.nodeType === 3 && this.textContent.trim() !== "" }).wrap( "" ); - var foldingHeader = "H3"; - info.find(foldingHeader).wrapInner('') - .find("a").prepend('').click(function(e) { - e.preventDefault(); - var isExpanded = $(this).hasClass('expanded'); - var el = $(this).parent().next(); - while(el.length === 1 && el[0].nodeName !== foldingHeader) { - el.toggle(!isExpanded); - el = el.next(); - } - $(this).toggleClass('expanded',!isExpanded); - }) + setInfoText(infoText); } @@ -257,8 +244,22 @@ RED.sidebar.info = (function() { $(".node-info-property-row").toggle(expandedSections["property"]); }); } - - + function setInfoText(infoText) { + var info = addTargetToExternalLinks($('
'+infoText+'
')).appendTo(infoSection.content); + info.find(".bidiAware").contents().filter(function() { return this.nodeType === 3 && this.textContent.trim() !== "" }).wrap( "" ); + var foldingHeader = "H3"; + info.find(foldingHeader).wrapInner('') + .find("a").prepend('').click(function(e) { + e.preventDefault(); + var isExpanded = $(this).hasClass('expanded'); + var el = $(this).parent().next(); + while(el.length === 1 && el[0].nodeName !== foldingHeader) { + el.toggle(!isExpanded); + el = el.next(); + } + $(this).toggleClass('expanded',!isExpanded); + }) + } var tips = (function() { var enabled = true; var startDelay = 1000; @@ -349,8 +350,8 @@ RED.sidebar.info = (function() { // tips.stop(); sections.show(); nodeSection.container.hide(); - var wrapped = $('
').html(html); - $(infoSection.content).empty().append(wrapped); + $(infoSection.content).empty(); + setInfoText(html); }