Adding a Button in Code Snippet Areas in DITA WebHelp Classic Output
This task will get you started with how to add an action (such as a button or link) in the code snippet areas that are displayed in WebHelp Classic output created from a DITA Map transformation. 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.xslfile.
- 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.xslfile.
- 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. It 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:template match="*[contains(@class, ' topic/pre ')]" mode="pre-fmt"> <button onclick="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>
