Sidebar

From MegaZine3
Jump to navigation Jump to search
{{#if: Sidebar.jpg | }} {{#if: | }}{{#if: sidebar.swf
sidebar.asul
| }}{{#if: | }}
Plugin: Sidebar
Sidebar.jpg
Name Sidebar
Since version

{{{version}}}

Files

sidebar.swf
sidebar.asul

Related plugins

{{{related}}}

This plugin adds a panel to the GUI which contains context sensitive content. This means it is possible to define different content for this panel based on the current page of the book. Until the sidebar has been opened or closed by the user manually, it will be in "automatic mode". In this mode, it will automatically open upon content changes, and closed again after a customizable amount of time.

Settings

== sidebardelay =={{#if: Integer |

  • Type: Integer}}{{#if: |
  • Valid values: {{{valid}}}}}{{#if: 1000 |
  • Default: 1000}}{{#if: |
  • Overrides: {{{overrides}}}}}{{#if: |
  • Aliases: {{{alias}}}}}{{#if: |
  • Version: {{{version}}}}}

The delay to wait in automatic mode after a content change before opening the bar.{{#if: |

  • See also: {{{see}}}}}

== sidebarslideduration =={{#if: Number |

  • Type: Number}}{{#if: |
  • Valid values: {{{valid}}}}}{{#if: 0.125 |
  • Default: 0.125}}{{#if: |
  • Overrides: {{{overrides}}}}}{{#if: |
  • Aliases: {{{alias}}}}}{{#if: |
  • Version: {{{version}}}}}

How fast to slide open / close the side bar. This is the time in seconds it takes to complete the animation.{{#if: |

  • See also: {{{see}}}}}

== sidebarclosedelay =={{#if: Integer |

  • Type: Integer}}{{#if: |
  • Valid values: {{{valid}}}}}{{#if: 10000 |
  • Default: 10000}}{{#if: |
  • Overrides: {{{overrides}}}}}{{#if: |
  • Aliases: {{{alias}}}}}{{#if: |
  • Version: {{{version}}}}}

The time in milliseconds the side bar is open in automatic mode, before it closes again. Note that this delay gets reset whenever the content of the side bar changes.{{#if: |

  • See also: {{{see}}}}}

== sidebarstartclosed =={{#if: Boolean |

  • Type: Boolean}}{{#if: |
  • Valid values: {{{valid}}}}}{{#if: false |
  • Default: false}}{{#if: |
  • Overrides: {{{overrides}}}}}{{#if: |
  • Aliases: {{{alias}}}}}{{#if: |
  • Version: {{{version}}}}}

Determines whether the sidebar will be open at start or not.{{#if: |

  • See also: {{{see}}}}}


Tags

This plugin uses an extra child node of the book node to define the contents of the sidebar.

The main node name is sidebar. This node can contain any number of child nodes named sidebarcontent, which must have an attribute named startpage. This is the page number starting at which the content defined in the sidebarcontent node gets displayed. The actual content must be defined in the form of ASUL definitions.

Example

Example 1: general use

<book plugins="sidebar" sidebardelay="5000">
    <sidebar>
        <sidebarcontent startpage="0">
            <box width="200" height="400" background="image(data/default.jpg)"/>
        </sidebarcontent>
        <sidebarcontent startpage="2">
            <box width="300" height="400" background="image(data/chapter1.jpg)"/>
        </sidebarcontent>
        <sidebarcontent startpage="10">
            <box width="200" height="300" background="image(data/chapter2.jpg)"/>
        </sidebarcontent>
        <!-- and so on... -->
    </sidebar>
    <chapter>
        <!-- Actual book content -->
    </chapter>
</book>

Example 2: specific font styles

You can adjust your text using HTML tags; like color or font size.
But keep in mind that all data within the sidebar is parsed by ASUL and not MegaZine3.
And that makes a big difference!
Not only that an ASUL TEXT object is far mor complex than a MZ3 element, it also does not allow child elements.
Reason is, that due to the clear structure of a MegaZin3 book with e.g. <book> - <chapter> - <page> - <img> - <text> - <content> elements, the ASUL structure is not as strict, which would make parsing more complicated and error prone. Therefore no child elements within ASUL objects are allowed.

Something that is valid as a CDATA child node in a MZ3 structure like:

<img>
  <txt>
    <content lang="en">
        <![CDATA[My <b>HTML</b> <i>Formatted</i> text.]]>
    </content>
  </txt>
</img>

is not allowed in ASUL syntax. There all has to be defined within the ASUL object.

This results in code like this for text of different size and color:

<sidebar>
    <sidebarcontent startpage="0">
        <text width="200" height="200" color="#e8e8e8" value="this is normal, grey text"/>
        <text y="80" width="300" height="200" font="_sans" size="24" color="#ffffff" value="this is bigger, white text"/>
        <text y="160" width="200" height="200" font="_sans" size="24" color="#00ffff" value="this is &lt;font color='#ff00ff'&gt;colored text&lt;/font&gt; in a red color"/>
        <text y="240" width="200" height="200" font="_sans" size="24" color="#ffff00" value="localize(localized_txt1)"/>
    </sidebarcontent>
</sidebar>

Please note that instead of the usual delimiters "<" and "<" their literal representation "<" and ">" must be used (because of parsing restrictions). The 4th definition is special. There a reference by an ID to a definition in the language file megazine.xml is made. The ID "localized_txt1" links to the text provided with the megazine/langs/xx/megazine.xml file (xx is the 2-letter code for the language), which will be output within the sidebar.
The content of the megazine.xml file was extended by the text to be output in the sidebar as 4th element like this:

<?xml version="1.0" encoding="utf-8"?>
<lang id="en">
	<langstring name="LNG_LANGUAGE_NAME">English</langstring>
	<langstring name="LNG_LOADING">Loading... $1%</langstring>
	<langstring name="LNG_BOOKEDGE_PAGENUMBER">Goto page $1</langstring>
	<langstring name="localized_txt1"><![CDATA[this <font size="10" color="#ff00ff">is</font> <font size="18">bigger</font>text]]></langstring>
</lang>

Everything but the 4th <langstring> definition is standard. That row defines a text in a common CDATA representation.
Advantage:
easier to read
localization of the text easily possible (language specific versions can be provided in a standard way.

Here a screenshot of the above given definitions

MegaZine3 Plugin-related articles
Plugins Anchors · Background Sounds · Batchpages · Bookmarks · Console · ElementIDs · Gallery · Google Analytics · Help · JavaScript · Keyboard Navigation · Links · NavigationBar · Options · Overlays · Password · PDFLinks · Print · PrintPDF · SWFAddress· Search · Sidebar · Slideshow · Titles
Plugin Articles Writing a plugin · Writing a plugin II · Plugin development

{{#if: | |}}