Mask

Masks a target element (document.body if none is specified). Call static methods for ease of use or make instance for reusability.

 Mask.mask('hello');
 Mask.unmask();

Mask
//<code-header>
fiddle.title = 'Mask';
//</code-header>
new Button({
    appendTo : targetElement,
    text     : 'Show mask',
    onClick  : () => {
        Mask.mask({
            target : targetElement,
            text   : 'Masked (2 seconds)'
        });

        setTimeout(() => {
            Mask.unmask(targetElement);
        }, 2000);
    }
});

new Button({
    appendTo : targetElement,
    text     : 'Show Progress',
    style    : 'margin-inline-start: 1em',
    onClick  : () => {
        const mask = Mask.mask({
            target      : targetElement,
            text        : 'The task is in progress',
            progress    : 0,
            maxProgress : 100
        });

        const timer = setInterval(() => {
            mask.progress += 5;
            if (mask.progress >= mask.maxProgress) {
                Mask.unmask(targetElement);
                clearInterval(timer);
            }
        }, 100);
    }
});

Can show progress:

 // Using progress by calling static method
 const mask = Mask.mask({
     text        :'The task is in progress',
     progress    : 0,
     maxProgress : 100
 });

 let timer = setInterval(() => {
     mask.progress += 5;
     if (mask.progress >= mask.maxProgress) {
         Mask.unmask();
         clearInterval(timer);
     }
 }, 100);

Stacking Multiple Masks

An element can have multiple masks attached to it (for example, to handle independent asynchronous activities). When an element has multiple masks attached, only the first mask created is visible to the user. This avoids unpleasant transparency layering that would occur if all masks were visible at the same time. When the active mask is destroyed or hidden (via hide), the next oldest mask is made visible. That is, masks are displayed in FIFO order.

When a mask is hidden, it is not a candidate in the FIFO order and is ignored when looking for the next oldest mask. If the mask is shown (via show), the mask is again a candidate for being shown, and will be shown immediately if there is not already a currently visible mask. This eliminates flickering effects that would otherwise come from multiple masks competing for display.

When the last mask is hidden or destroyed, the target element becomes unmasked. Showing and hiding of masks is useful when the masks may be needed repeatedly over time.

Masking Bryntum Widgets

Shortcut to masking Bryntum components:

 // Using progress to mask a Bryntum component
 scheduler.mask({
     text:'Loading in progress',
     progress: 0,
     maxProgress: 100
 });

 let timer = setInterval(() => {
     scheduler.masked.progress += 5;
     if (scheduler.masked.progress >= scheduler.masked.maxProgress) {
         scheduler.unmask();
         clearInterval(timer);
     }
 },100);

Configs

79

Common

listenersEvents

Other

By default in versions below 8.0, the text is not HTML-encoded. Set this flag to true to automatically HTML-encode the text.

icon: String= b-icon b-icon-spinner

The icon to show next to the text. Defaults to showing a spinner

showDelay: Number

The number of milliseconds to delay before making the mask visible. If set, the mask will have an initial opacity of 0 but will function in all other ways as a normal mask. Setting this delay can reduce flicker in cases where load operations are typically short (for example, a second or less).

target: String | HTMLElement

The element to be masked. If this config is a string, that string is the name of the property of the owner that holds the HTMLElement that is the actual target of the mask.

NOTE: In prior releases, this used to be specified as the element config.

The text (or HTML) to show in the mask, the text is not HTML encoded. See also the htmlEncode config for displaying raw HTML. As of v8.0 the text is automatically HTML encoded.

columnWidget
rtlRTL
spanWidget

Accessibility

ariaLabelWidget
keyMapKeyMap

CSS

clsWidget
colorWidget
htmlClsWidget
styleWidget
uiWidget

DOM

adoptWidget
appendToWidget
contentWidget
datasetWidget
htmlWidget
idWidget
tagWidget
titleWidget

Float & align

alignWidget
anchorWidget
centeredWidget
draggableWidget
floatingWidget
xWidget
yWidget

Layout

alignSelfWidget
dockWidget
flexWidget
heightWidget
hiddenWidget
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
textAlignWidget
weightWidget
widthWidget

Misc

dataFieldWidget
disabledWidget
localeClassLocalizable
localizableLocalizable
maskedWidget
ownerWidget
readOnlyWidget
refWidget
rippleWidget
tabWidget
tooltipWidget

Scrolling

Properties

69

Class hierarchy

isMask: Boolean= truereadonly
Identifies an object as an instance of Mask class, or subclass thereof.
isMask: Boolean= truereadonlystatic
Identifies an object as an instance of Mask class, or subclass thereof.
isDelayableDelayable
isEventsEvents
isKeyMapKeyMap
isLocalizableLocalizable
isWidgetWidget

Other

By default in versions below 8.0, the text is not HTML-encoded. Set this flag to true to automatically HTML-encode the text.

maxProgress: Number

The maximum value of the progress indicator

progress: Number

Number expressing the progress

The text (or HTML) to show in the mask, the text is not HTML encoded. See also the htmlEncode config for displaying raw HTML. As of v8.0 the text is automatically HTML encoded.

$namestaticWidget
columnWidget
rtlRTL
spanWidget
typestaticWidget

Accessibility

keyMapKeyMap

CSS

clsWidget

DOM

appendToWidget
contentWidget
datasetWidget
elementWidget
htmlWidget
idWidget
styleWidget

Float & align

xWidget
yWidget

Layout

alignSelfWidget
flexWidget
heightWidget
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
widthWidget

Lifecycle

configBase

Misc

cellInfoWidget
disabledWidget
localeHelperLocalizable
localeManagerLocalizable
readOnlyWidget
refWidget
tabWidget
tooltipWidget

Visibility

hiddenWidget
isVisibleWidget

Widget hierarchy

ownerWidget
parentWidget

Functions

60

Other

Close mask (removes it)

Returns: Promise -

A promise which is resolved after the mask is closed and destroyed.

getstatic

Returns the array of Mask instances for the given element.

ParameterTypeDescription
elementHTMLElement

The element for which to return Mask instances

Returns: Mask | Mask[]
maskstatic

Shows a mask with the specified message.

Masks stack, call unmask to remove the topmost mask. Or call close on the returned mask to close it specifically. Only one mask is displayed for a given target element at a time. For example, if two masks are added to an element, the first mask is displayed. If the first mask is closed, then the second mask will become visible.

ParameterTypeDescription
textString | MaskConfig

Message

targetHTMLElement

The element to mask (default is document.body)

Returns: Mask
unmaskstatic

Close the most recently created mask for the specified element.

ParameterTypeDescription
elementHTMLElement

The element to unmask (default is document.body)

Returns: Promise | null -

A promise which is resolved when the mask is gone, or null if element is not masked

composeWidget
createOnFrameDelayable
disableWidget
enableWidget
focusWidget
LstaticLocalizable
onEvents
recomposeWidget
relayAllEvents
triggerEvents
unEvents

Configuration

applyDefaultsstaticBase

Events

Float & align

alignToWidget
setXYWidget
showByWidget
toFrontWidget

Lifecycle

createstaticWidget
destroystaticBase
initClassstaticWidget

Misc

attachTooltipstaticWidget
fromElementstaticWidget
fromSelectorstaticWidget
getByIdstaticWidget
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Visibility

hideWidget
showWidget

Widget hierarchy

closestWidget
containsWidget
ownsWidget
queryWidget
queryAllWidget
upWidget

Events

14
catchAllEvents
destroyEvents
focusInWidget
focusOutWidget
hideWidget
paintWidget
readOnlyWidget
recomposeWidget
resizeWidget
showWidget

Event handlers

14

Typedefs

6

CSS variables

28
NameDescription
--b-mask-border-radiusMask border-radius
--b-mask-paddingMask padding
--b-mask-text-backgroundMask text background
--b-mask-progress-heightMask progress bar height
--b-mask-backgroundMask background
--b-mask-text-colorMask text color
--b-mask-progress-colorMask progress bar color
--b-mask-colorMask color

Inherited