Pages: 1
Print
Author Topic: Alpha-Sort IDs on Insert Content Reference Dialog  (Read 1737 times)
jperkins
Member

Posts: 11


« on: January 06, 2009, 08:51:59 AM »

As part of our online module authoring process, we make several dozen content references into a large topic with many IDs. To speed up the process, I created a startup macro that will alpha sort the IDs on the "Insert Content Reference" dialog, making it easier to locate a particular ID.

I thought I'd share it in case anyone else might find it useful. Just create a new .mcr file in your startup folder and paste it in.

<?xml version="1.0" encoding="utf-16"?>
<!DOCTYPE MACROS SYSTEM "macros.dtd">
<!--
 Enhancements to XMetaL's Insert Content Reference dialog, to allow
 faster creation of online module screens.
 Written by Jason Perkins, Jacquette Consulting
 -->
<MACROS>
  <MACRO name="On_Macro_File_Load" lang="JScript" hide="true">
    <![CDATA[

  // Alpha-sort the element IDs, making it easier to locate a particular ID.
 
  InsertConrefDlgDataModel.prototype._old_setCandidateElems = InsertConrefDlgDataModel.prototype.setCandidateElems;

  InsertConrefDlgDataModel.prototype.setCandidateElems = function()
  {
    this._old_setCandidateElems();

    var sortfn = function(a, b) {
         var aid = a.getAttribute("id");
         var bid = b.getAttribute("id");
         if (aid < bid)
            return -1;
         else if (aid > bid)
            return 1;
         else
            return 0;
      }
      
      this.fCandidateElems.sort(sortfn);
  }
  ]]></MACRO>
</MACROS>
Logged
Pages: 1
Print
Jump to:  

email us