Hint

A popup designed to show the user instruction on how to use a specific feature, for onboarding purposes.

This class is not intended to be instantiated directly, but rather to be used by the HintFlow class.

The HintFlow class must be configured with an array of hint configurations like this:

new HintFlow({
    // Default configs to apply to all hints
    defaults : {
        modal : true
    },
    hints : [{
        // CSS selector to find the target element
        target  : '.b-tabpanel-tab[data-item-index="1"]',

        // Action to take when the 'Next' button is clicked
        nextAction : {
            click : '.b-tabpanel-tab[data-item-index="1"]'
        }

        // Config props for the displayed Hint popup
        title   : 'Change tab',
        content : 'Click here to move to the next tab',
        align   : 't-n'
    }, {
        target  : '.b-button:contains(Save)',
        title   : 'Save',
        content : 'Click here to save the changes',
        nextAction : {
           click : '.b-button:contains(Save)'
        }
   }]
});

Each entry in the hints array of the HintFlow class should be an object with the following properties:

  • target: Required The target element to highlight, or a CSS selector to find the target element. If the target selector ends with a ?, the hint will be skipped if the target is not found. By default, the hint will be aligned to this element.

  • title: The title to display in the hint.

  • content: Required. The content to display in the hint.

  • align: The alignment of the hint relative to the target element. If this is specified as an AlignSpec object, the hint will be aligned to the target property of this object if present.

    • target: The element to align to, or a CSS selector to find the element to align to.
  • nextAction: The action(s) to take when the 'Next' button is clicked. Properties may be:

    • click: A CSS selector to find the target element to click.
    • type: A string to type into the target element.
    • dblclick: A CSS selector to find the target element to double click.
    • contextmenu: A CSS selector to find the target element to right click.
    • fn: A function to call when the hint is shown.
    • drag: An object with the following properties:
      • target: The target element to drag, or a CSS selector to find the target element.
      • by: The distance to drag the target element, as an array of [dx, dy].
    • waitFor: A CSS selector to wait for or the number of milliseconds to wait before continuing to the next hint.
  • previousAction: The action(s) to take when the 'Previous' button is clicked.

  • autoNext: The number of milliseconds to wait before automatically moving to the next hint, or a CSS selector to find the target element to wait for.

  • highlightTarget: Specify as true to highlight the target element with a bright outline.

  • buttons: Overrides for buttons to show in the hint. This is an object which may contain the following properties:

    • next: Override config for the 'Next' button
    • previous: Override config for the 'Previous' button
    • stop: Config to add a 'Stop' button. By default the dialog close, or typing S button is used.

Other properties (eg modal can be added to the object, and will be passed to the Hint instance.

When using a HintFlow tutorial, pressing N will navigate to the next hint, P will navigate to the previous hint. Pressing S or ESCAPE will stop the tutorial.

Hint
//<code-header>
fiddle.title = 'Hint';
//</code-header>
targetElement.style.flexDirection = 'column';
targetElement.style.alignItems = 'flex-start';
targetElement.style.alignContent = 'flex-start';

function runHints() {
    new HintFlow({
        defaults : {
            highlightTarget : true
        },
        hints : [
            {
                target  : 'button[data-ref="learnButton"]',
                title   : 'Run hints',
                content : 'Click here to restart hint flow',
                align   : 's-e'
            },
            {
                target  : '.hint-panel .b-tool',
                title   : 'Settings',
                content : 'Click here to open Panel settings',
                align   : 's-e'
            },
            {
                target          : '.hint-panel [data-ref="email"] .b-field-inner',
                title           : 'Email',
                content         : 'Enter your email here',
                align           : 't-b',
                highlightTarget : {
                    // Expand the target zone a little
                    inflate : 5
                }
            },
            {
                target  : '.hint-panel [data-ref="send"]',
                title   : 'Send mail',
                content : 'Send the mail',
                align   : {
                    align  : 'b-t',
                    offset : [0, -5]
                },
                highlightTarget : {
                    center : '#9c37eb',
                    ping   : true
                }
            }
        ]
    });
}

new Button({
    ref      : 'learnButton',
    appendTo : targetElement,
    cls      : 'learnButton',
    text     : 'Start lesson',
    onClick  : runHints
});

new Panel({
    cls      : 'hint-panel',
    title    : 'My Panel',
    width    : 600,
    height   : '20em',
    appendTo : targetElement,
    tools    : {
        settings : {
            cls     : 'b-icon-cog',
            tooltip : 'Panel settings'
        }
    },
    items : {
        email : {
            inputType : 'email',
            type      : 'textfield',
            label     : 'Email Address'
        }
    },
    bbar : {
        items : {
            send : {
                text : 'Send Message'
            }
        }
    }
});

Configs

127

Common

listenersEvents

Other

autoNext: String | Number

Either the number of milliseconds to wait before automatically moving to the next hint, or a CSS selector to wait for before moving to the next hint.

buttons: Object<String, ButtonConfig>

Overrides for buttons to show in the hint.

By default, hints show a 'Next' button.

The last hint will show a 'Previous' button instead of 'Next'.

These buttons can be overridden by providing a buttons config object for the listed properties

ParameterTypeDescription
nextButtonConfig

Override the 'Next' button

previousButtonConfig

Override the 'Previous' button

highlightTarget: Boolean | Object= false

Specify as a truthy value to highlight the target element with a bright outline.

ParameterTypeDescription
pingBoolean

Specify as true to have the outline expand repeatedly with a "ping" animation.

centerString

Specify as a CSS color to use as the the color of a 20 pixel diameter

inflateNumber | Number[]

Arguments to inflate. Specify as a number to inflate the target rect by that many pixels, or as an array of inflate values for each edge.

keyMap: Object<String, (previous|next|stop)>

The mapping of key names to hint actions. The actions are previous, next, and stop. By default, the following key mappings are used:

  • P for previous
  • N for next
  • S for stop The key mappings can be overridden by providing a keyMap config object.
maxWait: Number= 10000

How long in milliseconds to wait for a target to become available before giving up.

The actions to take when the 'Next' button is clicked.

By default, user interaction during these actions is disabled.

The property names are the actions to take, and the values are the configuration for that action.

The actions to take when the 'Previous' button is clicked.

By default, user interaction during these actions is disabled.

The property names are the actions to take, and the values are the configuration for that action.

target: String | HTMLElement

The target element to highlight, or a CSS selector to find the target element.

columnWidget
defaultFocusContainer
drawerPanel
labelPositionContainer
modalPopup
renditionContainer
resizableResizable
rtlRTL
spanWidget

Accessibility

ariaLabelWidget

Content

bbarPanel
defaultsContainer
footerPanel
headerPanel
itemsContainer
lazyItemsContainer
namedItemsContainer
stripsPanel
tbarPanel
textContentContainer
toolsPanel

CSS

bodyClsPanel
borderContainer
clsWidget
colorWidget
htmlClsWidget
itemClsContainer
styleWidget
uiPanel

DOM

adoptWidget
appendToWidget
contentWidget
datasetWidget
htmlWidget
idWidget
tagWidget

Float & align

alignWidget
anchorWidget
centeredWidget
floatingWidget
xWidget
yWidget

Layout

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

misc

tabBarItemsContainer

Misc

dataFieldWidget
disabledWidget
iconPanel
localeClassLocalizable
localizableLocalizable
maskedWidget
ownerWidget
readOnlyWidget
refWidget
rippleWidget
tabWidget
titlePanel
tooltipWidget

Record

recordContainer

Scrolling

State

stateIdState

Properties

98

Class hierarchy

isHint: Boolean= truereadonly
Identifies an object as an instance of Hint class, or subclass thereof.
isHint: Boolean= truereadonlystatic
Identifies an object as an instance of Hint class, or subclass thereof.
isContainerContainer
isDelayableDelayable
isEventsEvents
isKeyMapKeyMap
isLocalizableLocalizable
isPanelPanel
isPopupPopup
isResizableResizable
isStateState
isToolableToolable
isWidgetWidget

Accessibility

keyMapKeyMap

Content

bbarPanel
tbarPanel

CSS

clsWidget

DOM

appendToWidget
contentWidget
datasetWidget
elementWidget
htmlWidget
idWidget
styleWidget

Float & align

xWidget
yWidget

Layout

alignSelfWidget
flexWidget
heightWidget
layoutContainer
layoutStyleContainer
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
widthWidget

Lifecycle

configBase

Misc

cellInfoWidget
disabledWidget
localeHelperLocalizable
localeManagerLocalizable
readOnlyWidget
refWidget
tabWidget
titlePanel
tooltipWidget

Other

$namestaticWidget
columnWidget
firstItemContainer
hasChangesContainer
isValidContainer
itemsContainer
labelPositionContainer
lastItemContainer
renditionContainer
resizableResizable
rtlRTL
spanWidget
toolsPanel
typestaticWidget
valuesContainer

Record

recordContainer

State

stateState

Visibility

hiddenWidget
isVisibleWidget

Widget hierarchy

ownerWidget
parentWidget
widgetMapContainer

Functions

75

Configuration

applyDefaultsstaticBase

Events

Float & align

alignToWidget
setXYWidget
showByWidget
toFrontWidget

Lifecycle

createstaticWidget
destroystaticBase
initClassstaticWidget

Misc

attachTooltipstaticWidget
fromElementstaticWidget
fromSelectorstaticWidget
getByIdstaticWidget
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

addContainer
closePopup
composeWidget
createOnFrameDelayable
disableWidget
enableWidget
focusWidget
getAtContainer
getWidgetByIdContainer
insertContainer
LstaticLocalizable
maskWidget
onEvents
recomposeWidget
relayAllEvents
removeContainer
removeAllContainer
resetValuesContainer
setValuesContainer
triggerEvents
unEvents
unmaskWidget

State

Visibility

hideWidget
showWidget

Widget hierarchy

closestWidget
containsWidget
ownsWidget
queryWidget
queryAllWidget
upWidget

Events

22

Event handlers

22

Typedefs

8

An object which describes actions to take when navigating between hints.

ParameterTypeDescription
clickString

A CSS selector to click when the 'Previous' button is clicked,

contextmenuString

A CSS selector to right-click when the 'Previous' button is clicked.

dblclickString

A CSS selector to right-click when the 'Previous' button is clicked.

typeObject | String

String to type or an object with the following properties:

type.targetString

A CSS selector to find the target element to type into.

type.textString

The string to type. May contain special characters like [Enter] or [Shift+Tab].

type.initialDelayNumber

The number of milliseconds to wait before starting to type.

type.clearNumber

Clear the input before typing.

waitForString | Number

A CSS selector to wait for or the number of milliseconds to wait.

dragObject

An object with the following properties:

drag.targetString

A CSS selector to find the target element to drag.

drag.byNumber[]

The distance to drag the target element, as an array of [dx, dy].

drag.durationNumber

The duration of the drag in milliseconds.

allowInteractionBoolean

Allow user interaction during this action. By default user interaction is blocked during navigation from hint to hint.

fnfunction

A function to call when the 'Previous' button is clicked.

AlignSpecWidget
ColorWidget

CSS variables

60