This task will get you started on how to add an action (such as a button or link) in
code snippet areas that are displayed in WebHelp output. You can then attach your code that
does the actual processing for the action.
Follow these steps:
Open the
DITA_OT_DIR\plugins\org.dita.xhtml\xsl\xslhtml\dita2htmlImpl.xsl
file.
Locate the <xsl:template match="*[contains(@class, ' topic/pre ')]"
mode="pre-fmt"> template to check the default behavior of this template.
Open the
DITA_OT_DIR\plugins\com.oxygenxml.webhelp\xsl\dita\desktop\fixup.xsl
file.
Create a <xsl:template match="*[contains(@class, ' topic/pre ')]"
mode="pre-fmt"> template to override the default processing.
This new template will include your code for creating the button, which will have the
action code that does the actual processing attached to it (this can be written in
JavaScript, for example).
Example of a Select all
button:
<xsl:templatematch="*[contains(@class, ' topic/pre ')]"mode="pre-fmt"><buttononclick="SelectText(element)">Select all</button><script>
function SelectText(element) {
var text = document.getElementById(element);
var range = document.body.createTextRange();
range.moveToElementText(text);
range.select();
}
</script></xsl:template>