forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ferdinand Soethe <ferdin...@apache.org>
Subject Additional features in scales-skin
Date Fri, 25 Nov 2005 07:34:04 GMT

A few clients asked for a change in the functionality of Forrest
menus. They'd like a menu selection not only to open that menu, but to
select an index page at the same time.

And while this contradicts the no-reload concept of Forrest menues, it
makes a lot of sense in some use cases.

So I've added two new features to the scales skin that could check in
rather soon:

type='openFirstChild'

By adding the attribute type='openFirstChild' to a menu element (that
is an element that has children) in site.xml, Forrest will now open
the page referenced in the first child element when you select the
menu.

new attribute: 'openURL'

To have more flexibilty, you can add the new attribute 'openURL' to
the menuelement and specify any URI to open when the menu is clicked.
(Drawback here is that this reference can only be a valid URL since
this attribute is not yet adjusted like the content of href.)

Below I have added that changes required in scales.

wdyt?

--
Ferdinand Soethe


changes to 'book2menu.xsl'
--------------------------

 <xsl:template match="menu">
        <li>
            <h1>
                <xsl:choose>
                    <xsl:when test="@openURL">
                        <xsl:copy-of select="@openURL"/>   
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:if test="@type='openFirstChild' and (menu-item[1]/@href !=
'')">
                            <xsl:attribute name="openURL">/<xsl:value-of select="menu-item[1]/@href"/></xsl:attribute>
  
                        </xsl:if>   
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:value-of select="@label" />                
            </h1>
            <ul>
                <xsl:apply-templates />
            </ul>
        </li>
    </xsl:template>

changes to 'getMenu.js'
-------------------------

function SwitchMenu(obj, thePath)
{
var open = 'url("'+thePath + 'images/chapter_open.gif")';
var close = 'url("'+thePath + 'images/chapter.gif")';
  if(document.getElementById)  {
    var el = document.getElementById(obj);
    var el2 = document.getElementById(obj+'Title');
    var title = document.getElementById(obj+'Title');
    var openURL = el2.getAttribute('openURL','false');
    if (openURL != '') {
       // prompt(openURL);
        window.location = openURL;
    }else{
        if(el.style.display != "block"){ 
          title.style.backgroundImage = open;
          el.style.display = "block";
        }else{
          title.style.backgroundImage = close;
          el.style.display = "none";
        }
    }
    
  }// end -  if(document.getElementById) 
}//end - function SwitchMenu(obj)



Mime
View raw message