MAF.application Singleton

MAF.application()

Methods

addViewConfig(config)

Add a view to the application. After this you can load it.

Parameters:

NameTypeDescription
configObject

View properties.

Example

var definedView = new MAF.Class({
    Extends: MAF.system.SidebarView,
    ClassName: 'MainView',
    createView: function() {
       new MAF.control.TextButton({
          label: this.config.data.btnLabel,
          events: {
             onSelect: function () {
                MAF.application.exit();
             }
          }
       }).appendTo(this);
    }
 });
 MAF.application.addViewConfig({
    id: 'addedView',
    data: {
       btnLabel: 'Exit application',
       value: 'This object is available on the view'
    },
    viewClass: definedView
 });
 MAF.application.loadView('addedView');

clearViewHistory()

Empty the view history.

exit()

Close the application.

getCurrentViewId() → {String}

Returns:

Containing the id of the view that is currently active.

Example

if (MAF.application.getCurrentViewId() === 'myViewId')
    MAF.application.reLoadView();
 else
    MAF.application.loadView('myViewId');

getViewConfig(id)

Parameters:

NameTypeDescription
idString

View id.

Returns:

The view config that goes with the id parameter. False if not found.

getViewProperty(id, key) → {Mixed}

Get the property of a view.

Parameters:

NameTypeDescription
idString

View identified by the id property

keyString

Property name on the view to return.

Returns:

Value stored on the key.

Example

if (MAF.application.getViewProperty('myViewId', 'visible'))
   console.log('My view is visible');

init(config)

Initialized the application with the supplied config.

Parameters:

NameTypeDescription
configObject

Application configuration object

Properties
NameTypeArgumentDescription
defaultViewIdString

Defines which view to load when the application starts or when MAF.application.loadDefaultView() is called.

settingsViewIdStringoptional 

Defines a view which will be loaded when the onActivateSettingsButton event trigger (Button on Sidebar). Also loads this view when MAF.application.loadSettingsView() is called.

viewsArray

Containing view configuration objects. Each object is defined by a view id, a view class and a optional data parameter.

isDefaultView()

Returns:

True when the currently active view is the default view.

isSidebarLoaded()

Method to check if the application has a view active which allows user interaction.

Returns:

True when a view is active that is inherited from MAF.system.WindowedView

isSidebarView()

Method to check if the application has a sidebar view active.

Returns:

True when a view is active that is inherited from MAF.system.SidebarView

launchApp() private

loadDefaultView()

Empties the view history and loads the view that is defined by the defaultViewId property.

loadSettingsView()

Load the view that is defined by the settingsViewId property.

loadView(id, params, nosave)

Parameters:

NameTypeArgumentDescription
idString

View identifier, needs to be unique.

paramsObjectoptional 

Data you want to send to the view. (view.persist)

nosaveBooleanoptional 

This will prevent that the current view will be stored in history.

previousView(params, count)

Loads the previous view by default. If there is no previous view it will close the application.

Parameters:

NameTypeArgumentDescription
paramsObjectoptional 

Data available on the view this will load (view.backParams)

countNumberoptional 

Number of views you want to go back.

reloadView(params, nosave)

The currently active view will be reloaded. This will not call the createView, but it will call updateView.

Parameters:

NameTypeArgumentDescription
paramsObjectoptional 

The view.persist object will be merged with this Object.

nosaveBooleanoptional 

Indicates if the view needs to be stored in history, including previous persist object.

removeView(ids)

Remove the view ids defined in the array or string from the application.

Parameters:

NameTypeDescription
idsArray | String

One or more view ids.

Example

MAF.application.removeView('view1');
MAF.application.removeView(['view2', 'view3']);

setHostResultToViewId(event, viewId, params)

This is a special case of a loadView method. It will clear the applications view history.

Parameters:

NameTypeArgumentDescription
eventEvent

The view config will be added on event.result

viewIdString

Id of the view to be loaded.

paramsObjectoptional 

Data you want to send to the view. (view.persist)

Events

getSnippetConfs

onActivateApp

onActivateBackButton

Fired when the back button has been selected.

onActivateFavButton

Fired when the favorite button has been selected in a sidebar.

onActivateHomeButton

Fired when the home button has been selected in a sidebar.

onActivateSettingsButton

Fired when the settings button has been selected in a sidebar.

onActivateSnippet

Fired when a user has selected the snippet.

onApplicationShutdown

Fired before the application is shutting down.

onApplicationStartup

Fired before a application is starting.

onColorKeyPress

Fired when a colored key is pressed while the application is active.

onDialogCancelled

Fired when a dialog has been cancelled.

onDialogDone

Fired when a dialog has been completed.

onHideView

Fired before a view hides.

onLoadProfile

Fired when profile has loaded.

onLoadView

Fired when the view config has loaded and before it starts to build the view.

onPlayControlKeyPress

Fired when playback controls are pressed.

onSelectView

Fired before a view gets focus.

onShowView

Fired before the view becomes visible.

onUnloadProfile

Fired before a profile is unloading.

onUnloadView

Fired when the view is going to be destroyed.

onUnselectView

Fired before a view looses focus.

onViewChangeInitiated

Fired before a new view has loaded.

onWidgetKeyPress

Fired when a key is pressed while the application is active.