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
targetproperty 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
trueto 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.
//<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
Configs
127Common
Other
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.
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
| Parameter | Type | Description |
|---|---|---|
next | ButtonConfig | Override the 'Next' button |
previous | ButtonConfig | Override the 'Previous' button |
Specify as a truthy value to highlight the target element with a bright outline.
| Parameter | Type | Description |
|---|---|---|
ping | Boolean | Specify as |
center | String | Specify as a CSS color to use as the the color of a 20 pixel diameter |
inflate | Number | 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. |
The mapping of key names to hint actions.
The actions are previous, next, and stop.
By default, the following key mappings are used:
PforpreviousNfornextSforstopThe key mappings can be overridden by providing akeyMapconfig object.
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.
The target element to highlight, or a CSS selector to find the target element.
Content
CSS
DOM
Float & align
Layout
misc
Misc
Scrolling
Properties
98
Properties
98Class hierarchy
CSS
DOM
Layout
Misc
Other
State
Widget hierarchy
Functions
75
Functions
75Configuration
Events
Misc
Other
Widget hierarchy
Events
22
Events
22Event handlers
22
Event handlers
22Typedefs
8
Typedefs
8An object which describes actions to take when navigating between hints.
| Parameter | Type | Description |
|---|---|---|
click | String | A CSS selector to click when the 'Previous' button is clicked, |
contextmenu | String | A CSS selector to right-click when the 'Previous' button is clicked. |
dblclick | String | A CSS selector to right-click when the 'Previous' button is clicked. |
type | Object | String | String to type or an object with the following properties: |
type.target | String | A CSS selector to find the target element to type into. |
type.text | String | The string to type. May contain special characters like |
type.initialDelay | Number | The number of milliseconds to wait before starting to type. |
type.clear | Number | Clear the input before typing. |
waitFor | String | Number | A CSS selector to wait for or the number of milliseconds to wait. |
drag | Object | An object with the following properties: |
drag.target | String | A CSS selector to find the target element to drag. |
drag.by | Number[] | The distance to drag the target element, as an array of |
drag.duration | Number | The duration of the drag in milliseconds. |
allowInteraction | Boolean | Allow user interaction during this action. By default user interaction is blocked during navigation from hint to hint. |
fn | function | A function to call when the 'Previous' button is clicked. |