Helpers
The Panel bundles a few functions that help you with common tasks.
Available helpers
this.$helper.clipboard
this.$helper.color
this.$helper.debounce
this.$helper.embed
this.$helper.isComponent
this.$helper.isUploadEvent
this.$helper.keyboard
this.$helper.object
this.$helper.pad
this.$helper.ratio
this.$helper.slug
this.$helper.sort
this.$helper.string
this.$helper.upload
How to access helpers
The Panel exposes all shared helpers via this.$helper
:
Reference
this.$helper.clipboard
Helpers to read from and write to the clipboard.
Example
this.$helper.color
Turns a string into a valid CSS color making use of the Panel's custom CSS properties.
Example
this.$helper.debounce
Parameters
Name | Description |
---|---|
fn |
Function to be debounced |
delay |
Delay in miliseconds |
Example
this.$helper.embed
Helps to generate proper YouTube or Vimeo embed URLs.
Parameters
Name | Description |
---|---|
url |
URL to transform into valid embed URL |
doNotTrack |
If URL should try to enforce non-tracking (default: false ) |
Example
this.$helper.isComponent
Checks if string refers to an existing Vue component.
Example
this.$helper.isUploadEvent
Checks if a javascript event is really an upload event.
Example
this.$helper.keyboard
Collection of helpers corresponding to keyboard events
Example
this.$helper.object
Collection of helpers for JavaScript objects:
clone
Shorthand helper for cloning an object
isEmpty
Checks if a value of any type is empty
merge
Merges two objects
this.$helper.ratio
Receive a padding percentage for a specified image ratio.
Parameters
Name | Description |
---|---|
ratio |
e.g. 1/2 (default: 3/2 ) |
Example
this.$helper.sort
Natural sort algorithm with unicode support
Example
this.$helper.string
Helper that offers a couple of methods:
camelToKebab
escapeHTML
hasEmoji
lcfirst
pad
Adds 0
to the left of the value
Name | Description |
---|---|
value |
Value to be padded |
length |
Length of the returned string (default: 2 ) |
random
Returns a random alpha-numeric string of specified length.
slug
Transform a string to a valid slug according to a specified ruleset.
Name | Description |
---|---|
string |
String to be transformed |
rules |
Array of transformation rulesets (objects themselves) |
allowed |
String of allowed characters |
stripHTML
template
Replaces placeholers in a string with provided values
ucfirst
ucwords
this.$helper.upload
Helper to upload a file.
Parameters
Name | Description |
---|---|
file |
File object |
params |
Options object (see defaults below) |