fab
pb.fab()
Set up a floating action button (FAB) on the page.
To set it up, create an instance with fab(), then call its init function by passing in the desired main button and an array of additional buttons.
Fab
The fab object provides functions for updating the floating action button and its status. This object is only available on pages where a FAB would exist.
Methods
init
fabInstance.init(options)
Initializes the FAB
Returns: Object
- Returns the FAB object.
Param | Type | Description |
---|---|---|
options | Object | |
options.main | FabButton | Properties of the primary button to display when the FAB is visible. |
options.buttons | Array.<FabButton> | An array containing the secondary buttons to display when hovering over the FAB. |
open
fabInstance.open()
Opens the FAB
Returns: Object
- Returns the FAB object.
close
fabInstance.close()
Closes the FAB
Returns: Object
- Returns the FAB object.
isOpen
fabInstance.isOpen()
Check if the FAB is currently open.
Returns: boolean
- Current open status
addButton
fabInstance.addButton(options)
Adds a button to the top of the FAB.
Param | Type | Description |
---|---|---|
options | FabButton | Properties of the newly added button. |
removeButton
fabInstance.removeButton(options)
Remove a button from the FAB by its class name
Param | Type | Description |
---|---|---|
options | Object | |
options.className | string | The class of the button |
modifyButton
fabInstance.modifyButton(options)
Modify a button from the FAB by its class name
Param | Type | Description |
---|---|---|
options | Object | |
options.className | string | The class of the button |
options.classesToRemove | string | The classes you want to remove from the button |
options.classesToAdd | string | The classes you want to add to the button |
options.newDescriptionText | string | The new description text to set |
options.newAction | function | The new action for the button |
hasButton
fabInstance.hasButton(options)
Checks to see if a button exists in the fab
Returns: boolean
- Returns true or false.
Param | Type | Description |
---|---|---|
options | Object | |
options.className | string | The class of the button |
isHidden
fabInstance.isHidden()
Checks to see if a button exists in the fab
Returns: boolean
- Returns true or false.
FabButton
A FabButton is the main button or a secondary button that appears when hovering over the FAB.
Properties
Name | Type | Description |
---|---|---|
options.className | String | Class to apply to the button, should be unique |
options.icon | String | The icon to apply to the button |
[options.text] | String | The description of the button |
[options.action] | function | The function to execute when pressing the button, will ignore href if present |
[options.href] | String | The destination upon clicking, will only work if there is no action |