Helpers
The Panel bundles a few functions that help you with common tasks.
How to access helpers
The Panel exposes all shared helpers via this.$helper
:
Available helpers
Library | Description |
---|---|
this.$helper.clone |
|
this.$helper.debounce |
|
this.$helper.pad |
|
this.$helper.ratio |
|
this.$helper.slug |
|
this.$helper.sort |
|
this.$helper.string |
|
this.$helper.upload |
|
this.$helper.isUploadEvent |
clone
Shorthand helper for
Example
debounce
Parameters
Name | Description |
---|---|
fn |
Function to be debounced |
delay |
Delay in miliseconds |
Example
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
ratio
Receive a padding percentage for a specified image ratio.
Parameters
Name | Description |
---|---|
ratio |
e.g. 1/2 (default: 3/2 ) |
Example
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
sort
Natural sort algorithm with unicode support
Example
string
Helper that offers two methods:
ucfirst
lcfirst
upload
Helper to upload a file.
Parameters
Name | Description |
---|---|
file |
File object |
params |
Options object (see defaults below) |
isUploadEvent
Checks if a javascript event is really an upload event.