MenuTree () documon/template/assets/js/documon/menutree/MenuTree.js 69
xpath gieson.MenuTree
file documon/template/assets/js/documon/menutree/MenuTree.js

Builds a menu based on a "menu array". The menu array must conform to the following structure:

var myMenuData = [
    {
        "id"        : "foo",        // Unique ID used to identify a menu list item.
        "url"       : "foo.html",   // (optional) The URL to open when the menu item is clicked.
        "label"     : "foo",        // The display text for the menu item.
        "kind"      : "myCssRule",  // The CSS class to apply to the item -- good for including icons!
        "children"  : []            // An array of menu item just like this one.
    }
    ... etc...
];

When an item has children, a sub-menu will be constructed as the immediate "nextSibling" UL,
which will house all the items within the "children" array. Thus, one may have as many sub-menus as needed.

The menu will be build using the following HTML structure:

<ul>
    <li>foo</li> <-- opener - used to open/close the next immediate sibling UL
    <ul>
        <li>foo</li>
        <li>foo</li>
    </ul>
    <li>foo</li>
    <li>foo</li>
    <li>foo</li> <-- opener - used to open/close the next immediate sibling UL
    <ul>
        <li>foo</li>
        <li>foo</li> <-- opener - used to open/close the next immediate sibling UL
        <ul>
            <li>foo</li>
            <li>foo</li>
            <li>foo</li>
            <li>foo</li>
        </ul>
        <li>foo</li>
        <li>foo</li>
    </ul>
</ul>
Example
// For now, the only action we ping is "select"
function opHandler(action, item){
    if(action == "select"){
        //con sole.log(item);
    }

}
var myMenu = new gieson.MenuTree({
            callback : opHandler,
            menuData : MenuData // MenuData should be located on the window object, since it is loaded in via <script src="_menuData.js">
    });
Properties
listdata
documon/template/assets/js/documon/menutree/MenuTree.js193
Object

TODO: We should convert the items we store in the list to a seperate class. For berevity we've just inlined it during development.
A data store for each menu item. The keys for the listData refer to item ID's. Each item consists of the following:

    item = {
        id          // Optional (will be assigned unique one if none)
        children    // A list of other items.
        access      // Specific to documon
        inherits    // Specific to documon
        kind        // Applies a CSS class to the item
        label       // What the user sees

        // This is created and managed by MenuTree
        $mt - {

                    miid        // Menu item id.
                    liid        // The ID of the actual <li> HTML element created for this item 
                    ulid        // The ID of the parent <ul> element (this LI is a child of this UL)
                    open        // (boolean) Current state.
                    parentMiid  // The parent menu item.
                    openerid    // The opener element's ID
                    liElem      // The actual <li> element (only stored when interacted with)
                    ulElem      // The actual parent <ul> element (only stored when interacted with)
                    openerElem  // The actual opener triangle doo-dad element (only stored when interacted with)
                    ulOriginalDisplay // The source node's original css style.display kind (for open/close so we go back to normal -- defaults to "block" when not set in CSS)

        }
    }
Methods
getDataById (id) documon/template/assets/js/documon/menutree/MenuTree.js 388

Gets the item's source data as provided during init. Convient way to retrive source data without navigating the source tree becuase we maintain a flat-list cross reference. This methods simply hooks into the cross reference.

Parameters
id
string

The menu item id.

Returns object

The item's source data as provided during init.

openById (id, andSelect, scrollIntoView) documon/template/assets/js/documon/menutree/MenuTree.js 371

Opens all decendants of a branch.

Parameters
id
string

The menu item id.

andSelect
boolean optional false

Should the item be highlighted?

scrollIntoView
boolean optional false

Should the menu scroll to show the item?

Returns object

The item's source data as provided during init.

select (id) documon/template/assets/js/documon/menutree/MenuTree.js 252

Opens and/or highlights an item in the menu.

Parameters
id
string

The menu item id.

selectClick (evt, id) documon/template/assets/js/documon/menutree/MenuTree.js 232

Opens and/or highlights an item in the menu when user physically clicks.

Parameters
evt
Event

The mouse event object.

id
string

The menu item id.

toggle (id) documon/template/assets/js/documon/menutree/MenuTree.js 216

Toggles an item open/closed.

Parameters
id
string

The menu item id.

toggleClick (evt, id) documon/template/assets/js/documon/menutree/MenuTree.js 204

Used to toggle via mouse click. Toggles an item open/closed and prevents any further mouse bubbling.

Parameters
evt
Event

The mouse event object.

id
string

The menu item id.