MAF.application Singleton
MAF.application()
Methods
addViewConfig(config)
Add a view to the application. After this you can load it.
Parameters:
Name Type Description config Object 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:
Name Type Description id String 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:
Name Type Description id String View identified by the id property
key String 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:
Name Type Description config Object Application configuration object
Properties
Name Type Argument Description defaultViewId String Defines which view to load when the application starts or when MAF.application.loadDefaultView() is called.
settingsViewId String optional 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.
views Array 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:
Name Type Argument Description id String View identifier, needs to be unique.
params Object optional Data you want to send to the view. (view.persist)
nosave Boolean optional 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:
Name Type Argument Description params Object optional Data available on the view this will load (view.backParams)
count Number optional 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:
Name Type Argument Description params Object optional The view.persist object will be merged with this Object.
nosave Boolean optional 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:
Name Type Description ids Array | 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:
Name Type Argument Description event Event The view config will be added on event.result
viewId String Id of the view to be loaded.
params Object optional 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.