Helpers
The Panel bundles a few functions that help you with common tasks.
Available helpers
this.$helper.clipboard
this.$helper.clone
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
Since 3.6.0
this.$helper.clone
Shorthand helper for
Example
Since 3.6.0
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
Since 3.6.0
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
Since 3.6.0
this.$helper.pad
Adds 0
to the left of the value
Parameters
Name | Description |
---|---|
value |
Value to be padded |
length |
Length of the returned string (default: 2 ) |
Example
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.slug
Transform a string to a valid slug according to a specified ruleset.
Parameters
Name | Description |
---|---|
string |
String to be transformed |
rules |
Array of transformation rulesets (objects themselves) |
allowed |
String of allowed characters |
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
random
Returns a random alpha-numeric string of specified length.
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) |