Dave Lee – A flair for Flare

My blog about MadCap Flare and web design


6 Comments

Add a ‘close’ link to togglers and dropdowns (HTML5)

I’ve written a script that will add a ‘close’ link to the bottom of dropdowns and togglers.

This will work with HTML5 targets in Flare.

dropdown-toggler

To use this in your own Flare project, first copy and paste the following code into a text file, and save it with a *.js extension; e.g. dd_toggler_links.js.

$(document).ready(function(){
	/* Add close button to dropdowns */
	$(".dropDownBody").append("<a href='javascript:void(0);' class='dropDownClose'>Close</a>");
	$(".dropDownClose").click(function() {
		$(this).parent().prev(".dropDownHead").children(".dropDownHotspot").click();
	});
		
	/* Add close button to togglers */
	$("[data-mc-target-name]").each(function() {
		/* for each toggler target, find the target name (togglerTarget) */
		var togglerTarget = $(this).attr("data-mc-target-name");
		/* for each toggler target, add a close link (a.togglerClose) */
		var closeTarget = $("<a href='javascript:void(0);' class='togglerClose'>Close</a>");
		$(this).append(closeTarget);
		/* Create a selector for the toggler link (closeToggler), which is linked to this target. Look for open togglers, which include the togglerTarget name */
		var closeToggler = 'a.toggler[data-mc-state="open"][data-mc-targets*="' + togglerTarget + '"]';
		/* When the closeTarget link is clicked, clik the toggler link (closeToggler) */
		$(closeTarget).click(function(){
			$(closeToggler).click();
		});
	});
});

Add the javascript file to your project, and add a script link to this file from your master page; e.g. in the head section you would include something like:

<script src="../Scripts/dd_toggler_links.js"></script>

The last part is to style the links, which use the class names a.closeDropDown and a.closeToggler. Add the following CSS to your stylesheet, and include any other properties, such as a colour or background icon.

a.dropDownClose,
a.togglerClose
{
    display: block;
}

 


2 Comments

Display CSH link for current topic

I’ve written a script that will display a CSH link for the current topic, for HTML5 help outputs.

If you use CSH (aliases) in your Flare project, then it’s useful to be able to share links to your help that include the CSH ID, rather than the path and topic filename (as that might change).

For example, you’d want to share a link like:
yoursite.com/help.htm#cshid=hello

Rather than:
yoursite.com/content/folder/anotherfolder/hello_topic.htm

The script checks to see if the current topic is included in your alias file. If the topic is in the alias file, then it displays a short CSH link to that topic – for you to copy and use as you wish.

Try it out

To try this out yourself, first create a master page that contains this HTML:

<p id="page-link">Page link: <a href="#">CSH link will go here</a>
  <script type="text/javascript" src="lookup.js"></script>
</p>

Then create a file called lookup.js (in the same place as your master page), and copy and paste the following code.

$(document).ready(function()
   {
      /* hide link, unless we find a match */
      $("#page-link").css("display", "none");
      
      /* find help path */
      var helpPath = $("html").data("mc-path-to-help-system");   
      /* find help filename */   
      var helpFile = $("html").data("mc-help-system-file-name");
      /* substitute xml extension with htm */   
      var helpFile = helpFile.replace(".xml", ".htm");
      /* complete help URL */
      var helpURL = helpPath + helpFile;
      
      /* alias file URL */
      var aliasURL = helpPath + "Data/Alias.xml";

      $.ajax({
         type: "GET",
         url: aliasURL,
         dataType: "xml",
         success: function(xml) {

            
            /* get current topic filename, then decode it to remove characters like %20 */
            var currentFilename = location.pathname.substring(location.pathname.lastIndexOf('/') + 1);
            var currentFilename = decodeURIComponent(currentFilename);
            
            /* find every Map in the alias file */
            $(xml).find("Map").each(function()
            {
               /* get current Link (topic path) and Name (CSH ID) from Alias file */
               var currentLink = $(this).attr("Link");
               var currentName = $(this).attr("Name");
         
               /* check if current filename is contained in curent link */
               if ( currentLink.indexOf(currentFilename) != -1 )
               {
                  /* build CSH link */
                  var CSHlink = helpURL + "#cshid=" + currentName;
                  /* set href of link */
                  $("#page-link>a").attr("href", CSHlink);
                  /* set text in link to absolute path */
                  $("#page-link>a").text($("#page-link>a").prop("href")); 
                  /* display link */
                  $("#page-link").css("display", "block");
               }            
            });
         }
      });
      
});

And that’s it.

If the current topic is in the alias file, its CSH link will be displayed in the topic.


17 Comments

Customising the Flare HTML5 Tripane skin

ModCap

I’ve produced a full example project of how to customise the Flare HTML5 ‘Tripane’ skin.

Note: This post was originally written for the HTML5 skin in v10, which is now called the ‘Tripane’ skin in v11 onwards.

An example project with documentation can be downloaded here:
Example “Skin Mods” project (on my Google Drive)

This might be of use to anyone that needs to make modifications to the HTML5 skin which can’t be achieved using Flares’ skin editor.

The documentation shows how to:

  • Add content to the header area of the skin.
  • Add your own stylesheet to the skin, to style your own content, or change styles unavailable in the editor.
  • Move elements of the skin, such as the search box.

All details are in the linked project above, it should answer most questions.


Leave a comment

Displaying the Flare TOC as a menu

SmartMenus

I’ve produced a full example project of how to integrate a menu control into Flare, which uses the Flare TOC file.

An example project with documentation is here (topics in Introduction section):
http://ukauthor.esy.es/SmartMenusHTML5/Content/Main-Intro.htm

This might be of use to anyone that’s designing a skin-less HTML5 output, and needs a navigation system that can be integrated into topics.

The documentation shows how to:

  • Use XSLT to convert a Flare TOC file to a HTML menu.
  • Configure the project for the SmartMenus plugin.
  • Integrate the menu into topics, either by using a snippet or by dynamically loading the content.

All details are on the linked site above, it should answer most questions.


1 Comment

Search plugin for MadCap forums

The search on the MadCap forums isn’t very good, so I created a forum search plugin for FireFox.
Image

You can download the plugins here:

Installation

  1. Right-click the link and save the XML file to your PC.
  2. Put the XML file in the Firefox installation searchplugins folder, usually either:
    • Program Files (x86)\Mozilla Firefox\searchplugins
    • Program Files (x86)\Mozilla Firefox\browser\searchplugins
  3. Restart Firefox.

Using a search

  • In the search box (top right), click the icon on the left of the search box to display a menu, then select the search to use.