Gadget View Changed Event

Class finesse.containerservices.GadgetViewChangedEvent

Contains information about the changed events of the gadget view. There are two types of views supported for a gadget, that is default and canvas. The default view is the default size of the gadget. Canvas view is a maximized view of the gadget.

You can set a button to toggle between default view and canvas view. Add <Content type="html" view="default,canvas"> in the gadget XML. This adds the toggle button in the top right corner of the gadget. For more information, see Gadget Height Management.

The method to subscribe to the changed gadget event is finesse.containerservices.ContainerServices.containerServices.addHandler() with a topic of finesse.containerservices.ContainerServices.Topics.GADGET_VIEW_CHANGED_EVENT.

Example
Code Snippet
Copyvar containerServices = finesse.containerservices.ContainerServices.init();
finesse.containerservices.ContainerServices.addHandler(finesse.containerservices.
ContainerServices.Topics.GADGET_VIEW_CHANGED_EVENT, function(gadgetViewChangedEvent) {
            var gadgetId = finesse.containerservices.ContainerServices.getMyGadgetId(),
                tabId = finesse.containerservices.ContainerServices.getMyTabId();
            if (gadgetViewChangedEvent.getGadgetId() === gadgetId && gadgetViewChangedEvent.getTabId() === tabId) {
                if (gadgetViewChangedEvent.getView() === 'default') {
                    gadgets.window.adjustHeight(defaultHeight);
                    $('#content').html('DEFAULT VIEW');
                    view = 'default';
                } else if (gadgetViewChangedEvent.getView() === 'canvas') {
                    gadgets.window.adjustHeight(gadgetViewChangedEvent.getMaxAvailableHeight());
                    $('#content').html('CANVAS VIEW');
                    view = 'canvas';
                }
            }

Methods

getGadgetId()

Retrieves the gadget Id.

Returns

{String} Unique Identifier for the gadget changing view.

getMaxAvailableHeight()

Retrieves the maximum available height of the gadget.

Returns

{String} The maximum available height for the gadget's view.

getTabId()

Retrieves the tab Id.

Returns

{String} Unique Identifier for the tab where the gadget changing view resides.

getView()

Retrieves the gadget view.

Returns

{String} The view type of the gadget.