Expand all

abstract OO.ui.mixin.PendingElement

Constructor

new OO.ui.mixin.PendingElement([config])abstract #

PendingElement is a mixin that is used to create elements that notify users that something is happening and that they should wait before proceeding. The pending state is visually represented with a pending texture that appears in the head of a pending process dialog or in the input field of a text input widget.

Currently, Action widgets, which mix in this class, can also be marked as pending, but only when used in message dialogs. The behavior is not currently supported for action widgets used in process dialogs.

Example

function MessageDialog( config ) {
        MessageDialog.super.call( this, config );
    }
    OO.inheritClass( MessageDialog, OO.ui.MessageDialog );

    MessageDialog.static.name = 'myMessageDialog';
    MessageDialog.static.actions = [
        { action: 'save', label: 'Done', flags: 'primary' },
        { label: 'Cancel', flags: 'safe' }
    ];

    MessageDialog.prototype.initialize = function () {
        MessageDialog.super.prototype.initialize.apply( this, arguments );
        this.content = new OO.ui.PanelLayout( { padded: true } );
        this.content.$element.append( '<p>Click the \'Done\' action widget to see its pending ' +
            'state. Note that action widgets can be marked pending in message dialogs but not ' +
            'process dialogs.</p>' );
        this.$body.append( this.content.$element );
    };
    MessageDialog.prototype.getBodyHeight = function () {
        return 100;
    }
    MessageDialog.prototype.getActionProcess = function ( action ) {
        if ( action === 'save' ) {
            this.getActions().get({actions: 'save'})[0].pushPending();
            return new OO.ui.Process()
                .next( 1000 )
                .next( () => {
                    this.getActions().get({actions: 'save'})[0].popPending();
                } );
        }
        return MessageDialog.super.prototype.getActionProcess.call( this, action );
    };

    const windowManager = new OO.ui.WindowManager();
    $( document.body ).append( windowManager.$element );

    const dialog = new MessageDialog();
    windowManager.addWindows( [ dialog ] );
    windowManager.openWindow( dialog );

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Properties:
Name Type Attributes Description
$pending jQuery optional

Element to mark as pending, defaults to this.$element

Source:

PendingElement is a mixin that is used to create elements that notify users that something is happening and that they should wait before proceeding.

Methods

isPending() → {boolean} #

Check if an element is pending.

Source:

Returns:

Element is pending

Type
boolean
Check if an element is pending.

popPending() → {OO.ui.Element}chainable #

Decrease the pending counter. The pending state will remain active until the counter is zero (i.e., the number of calls to #pushPending and #popPending is the same).

Source:

Returns:

The element, for chaining

Type
OO.ui.Element
Decrease the pending counter.

pushPending() → {OO.ui.Element}chainable #

Increase the pending counter. The pending state will remain active until the counter is zero (i.e., the number of calls to #pushPending and #popPending is the same).

Source:

Returns:

The element, for chaining

Type
OO.ui.Element
Increase the pending counter.

setPendingElement($pending) #

Set the pending element (and clean up any existing one).

Parameters:

Name Type Description
$pending jQuery

The element to set to pending.

Source:
Set the pending element (and clean up any existing one).