Class: OverlayManager

OverlayManager(router, appendToSelector)

new OverlayManager(router, appendToSelector)

Manages opening and closing overlays when the URL hash changes to one of the registered values (see OverlayManager.add()).

This allows overlays to function like real pages, with similar browser back/forward and refresh behavior.

Parameters:
Name Type Description
router Router
appendToSelector string
Source:

Methods

(static) getSingleton() → {OverlayManager}

Retrieve a singleton instance using 'mediawiki.router'.

Source:
Returns:
Type
OverlayManager

add(route, factory)

Add an overlay that should be shown for a specific fragment identifier.

The following code will display an overlay whenever a user visits a URL that end with '#/hi/name'. The value of name will be passed to the overlay.

Parameters:
Name Type Description
route RegExp

route regular expression, optionally with parameters.

factory function

a function returning an overlay or a $.Deferred which resolves to an overlay.

Source:
Example
overlayManager.add( /\/hi\/(.*)/, function ( name ) {
      var factoryResult = $.Deferred();

      mw.using( 'mobile.HiOverlay', function () {
        var HiOverlay = M.require( 'HiOverlay' );
        factoryResult.resolve( new HiOverlay( { name: name } ) );
      } );

      return factoryResult;
    } );

replaceCurrent(overlay)

Replace the currently displayed overlay with a new overlay without changing the URL. This is useful for when you want to switch overlays, but don't want to change the back button or close box behavior.

Parameters:
Name Type Description
overlay Object

The overlay to display

Source: