Class: PresentationManager

mmir. PresentationManager

new mmir.PresentationManager()

Requires

  • module:dialogManager

Members

private_currentDialogObject

The currently displayed dialog object, if a dialog is displayed. Used mainly to close the dialog.
See:

private_layoutsMap

Array of layouts of the application

_pageIndexInteger

Counter that keeps track of the number of times, that a view is rendered NOTE: for implementation specific reasons, jQuery Mobile requires that each page has a different ID. This pageIndex is used to generating such a unique ID, by increasing the number on each page-change (i.e. by rendering a view) and appending it to the page's ID/name.

private_partialsMap

Array of all the partials of the application

private_renderEngineRenderEngine

Default implementation for the rendering-engine: does nothing but writing an error message to the console, if any of its functions is invoked. The rendering engine can be set via mmir.PresentationManager#setRenderEngine.

private_viewsMap

Array of all the views of the application

private,constantCONFIG_DEFAULT_LAYOUT_NAMEString

Name of the configuration property that specifies a custom name for the default layout.

NOTE: if FALSY (other than undefined) no default layout will be loaded. Rendering views may fail, if they rely on a Layout!

Example
var defaultLayout = mmir.conf.get(mmir.presentation.CONFIG_DEFAULT_LAYOUT_NAME);

private,constantDEFAULT_LAYOUT_NAMEString

Name for the default layout.

There must exist a layout definition by this name, i.e.

views/layout/.ehtml
NOTE: while the name begins with an upper case letter, the file name for the layout must start with a lower case letter, e.g. for name Default, the file name must be default.ehtml.
Example
var defaultLayoutName = mmir.conf.get(mmir.presentation.CONFIG_DEFAULT_LAYOUT);

privateloggerLogger

The logger for the PresentationManager.

constantpageIndexInteger

privatepartialSeparatorString

privatereHandlerName

privateviewSeparator

Methods

Name Type Description
layout Layout the layout to add

addPartial(ctrlName, partial)

Name Type Description
ctrlName String | Controller
partial String | Partial

addView(ctrlName, view)

Name Type Description
ctrlName String | Controller
view String | View

callRenderEngine(funcName, args)

This function allows to call custom functions of the rendering-engine that was set via setRenderEngine. IMPORTANT: note that the function will be invoked in context of rendering-engine (i.e. this references will refer to rendering-engine and not to the PresentationManager instance. For example, when mmir.PresentationManager.callRenderEngine('hideWaitDialog') is called, any this references within the hideWaitDialog implementation would refer to object, that was set in setRenderEngine(object). In comparison, when called as mmir.PresentationManager.hideWaitDialog() the this references refer to the mmir.PresentationManager instance.
NOTE that calling non-existing functions on the rendering-engine will cause an error.
Name Type Description
funcName String the name of the function, that should be invoked on the rendering engine.
args Array.<any> optional OPTIONAL the arguments for funcName invoked via Function.apply(renderingEngine, args), e.g. for args = [param1, param2, param3] the function will be called with funcName(param1, param2, param3) (note that the function receives 3 arguments, and not 1 Array-argument).

privatecreateLookupKey()

privatecreatePartialKey()

privatecreateViewKey()

getLayout(layoutName, doUseDefaultIfMissing){Object}

This function returns a layout object by name.
Name Type Description
layoutName String Name of the layout which should be returned
doUseDefaultIfMissing Boolean optional if supplied and true, the default controller's layout will be used as a fallback, in case no corresponding layout could be found
Returns:
Type Description
Object The requested layout, "false" if not found

getPartial(controllerName, viewName){Object}

This function returns a partial object by name.
Name Type Description
controllerName String Name of the controller for the view
viewName String Name of the partial which should be returned
Returns:
Type Description
Object The requested partial, "false" if not found

getView(controllerName, viewName){Object}

This function returns a view object by name.
Name Type Description
controllerName String Name of the controller for the view
viewName String Name of the view which should be returned
Returns:
Type Description
Object The requested view, false if not found
Closes a modal window / dialog (if one is open).
Hides / closes the "wait" dialog.
See:

render(ctrlName, viewName, data){void|Promise}

Gets the view for a controller, then executes helper methods on the view data. The Rendering of the view is done by the doRenderView method. Also stores the previous and current view with parameters.
Name Type Description
ctrlName String Name of the controller
viewName String Name of the view to render
data Object optional optional data for the view.
Returns:
Type Description
void | Promise if void/undefined is returned, the view is rendered synchronously, i.e. the view is rendered, when this method returns. If a Promise is returned, the view is rendered asynchronously (rendering is finished, when the promise is resolved)

setRenderEngine(theRenderEngine)

Sets the rendering engine for the views. The render engine must implement a function render and may implement functions showDialog, hideCurrentDialog, showWaitDialog, and hideWaitDialog:
  • theRenderEngine.render(ctrlName : String, viewName : String, view : View, ctrl : Controller, data : Object) : void|Promise
  • theRenderEngine.showDialog(ctrlName : String, dialogId : String, data : Object) : Dialog
  • theRenderEngine.hideCurrentDialog(): void
  • theRenderEngine.showWaitDialog(text : String, data : Object): void
  • theRenderEngine.hideWaitDialog(): void
The functions of theRenderEngine will be called in context of the PresentationManager. Custom functions of the specific rendering engine implementation (i.e. non-standard functions) can be call via callRenderEngine.
By default, the rendering-engine as defined by the module ID/path in core.viewEngine will be loaded and set during initialization of the DialogManager.
The implementation of the default view-engine is at mmirf/env/view/presentation/simpleViewEngine.js.
Name Type Description
theRenderEngine Object the render-engine for views
See:

showDialog(ctrlName, dialogId, data){Object}

Opens the dialog for ID dialogId.
Name Type Description
ctrlName String the Name of the controller
dialogId String the ID of the dialog
data Object optional OPTIONAL a data / options object
Returns:
Type Description
Object the instance of the opened dialog (void or falsy if dialog was not opened)

showWaitDialog(text, data)

Shows a "wait" dialog, i.e. "work in progress" notification.
Name Type Description
text String optional OPTIONAL the text that should be displayed. If omitted the language setting for loadingText will be used instead (from dictionary.json)
data Object optional OPTIONAL a data / options object
See: