Popover popover.js

Download

To use the Popover, first include the required javascript and css files.

Next, create the popover with either a jQuery plugin call, or by creating a classic javascript object:

The jQuery plugin

    var menu1 = {
        id: "menu1", title: "Hello World",
        contents: [
            {name: "Item 1"},
            {name: "Item 2"},
            {name: "Item 3"}
        ]
    };
    $("#menu1").optionsPopover(menu1);

Creating a javascript object

    var p = new OptionsPopover("#menu1");
    p.addMenu(menu1);

Note: The id #menu1 is also the name linked to the first menu for that button. To access the starting menus from other buttons, just set the menu item's id to the starting menu's id.

Example

Show Popover! Show Another Popover!

Html

    <button id="menu1">Show Popover!</button>
    <button id="menu2">Show Another Popover!</button>

Javascript

    $("#menu1").optionsPopover({
        id: "menu1",
        title: "Hello World!",
        contents: [
            {"name": "Menu Item 1", url: "m1"},
            {"name": "Menu Item 2", id: "m2"},
            {"name": "Link to second button's menu...", id: "menu2"}
        ]
    });
    $("#menu2").optionsPopover({
        id:"menu2",
        title: "Hello Again, World!",
        contents: [
                {"name": "Another Menu Item 1", url: "am1"},
                {"name": "Another Menu Item 2", url: "am2"},
                {"name": "Link to first button's menu...", id: "menu1"}
            ]
        }
    );

Events

The following are jQuery custom events fired at different times within the popover:

Event Description Objects Passed
popover.created This event is fired at the end of the createPopover function. None
popover.resize This event is fired when the window is resized (redundant event, will be removed in future release). None
popover.setContent This event is fired at the end of the setContent function, showing the contents have been modified. None
popover.visible This event is fired at the end of the toggleVisible function and fires when the popover is visible to the user. (Currently does not wait css transitions to complete). None
popover.menuClicked This event is fired when a menu item in the popover has been clicked. None

Popover w/ jScrollPane Plugin

The popover can be easily integrated with the jScrollPane jQuery plugin. This adds mobile functionality to scrolling divs and adds more customizability to the look and feel of the popover.

Javascript

    //To initialise, use the code below:
    $(document).on("popover.created", function () {
        $("#popoverContentWrapper").jScrollPane({
            horizontalGutter: 0,
            verticalGutter: 0,
            'showArrows': false
        });
    });

    $(document).on('popover.setContent popover.visible popover.resize', function (e) {
        $("#popoverContentWrapper").data('jsp').reinitialise();
    });