FPDUtil Class
A class with some static helper functions. You do not need to initiate the class, just call the methods directly, e.g. FPDUtil.isIE();
Methods
- addThousandSep static
- arrayUnique static
- changeBase64DPI static
- changePathColor static
- checkImageDimensions static
- createScrollbar static
- elementAvailableColors static
- elementHasColorSelection static
- elementIsColorizable static
- getScalingByDimesions static
- getType static
- isHex static
- isIE static
- isUrl static
- isXML static
- loadGridImage static
- localStorageAvailable static
- log static
- notEmpty static
- parseFabricObjectToFPDElement static
- popupBlockerAlert static
- refreshLazyLoad static
- rekeyDeprecatedKeys static
- removeFromArray static
- showMessage static
- showModal static
- updateTooltip static
-
n
Adds a thousand separator and returns it.
Parameters:
-
n
NumberA numeric value.
Returns:
Returns a string.
-
array
Makes an unique array.
Parameters:
-
array
ArrayThe target array.
Returns:
Returns the edited array.
-
string
-
number
Changes the DPI of a base64 image.
Parameters:
-
string
DataURIA base64 data uri representing the image(png or jpeg).
-
number
DpiThe target DPI.
Returns:
Returns the base64 image with the new DPI.
-
element
-
index
-
color
Changes a single path color by index.
Parameters:
-
element
fabric.ObjectThe target element.
-
index
NumberThe path index.
-
color
StringHexadecimal color value.
Returns:
All colors used in the SVG.
-
fpdInstance
-
imageW
-
imageH
Checks if the dimensions of an image is within the allowed range set in the customImageParameters of the view options.
Parameters:
-
fpdInstance
FancyProductDesignerInstance of FancyProductDesigner.
-
imageW
NumberThe image width.
-
imageH
NumberThe image height.
Returns:
Returns true if image dimension is within allowed range(minW, minH, maxW, maxH).
-
target
Creates a nice scrollbar for an element.
Parameters:
-
target
JQueryThe target element.
-
element
-
fpdInstance
Returns the available colors of an element.
Parameters:
-
element
fabric.ObjectThe target element.
-
fpdInstance
FancyProductDesignerInstance of FancyProductDesigner.
Returns:
Available colors.
-
element
Checks if an element has a color selection.
Parameters:
-
element
fabric.ObjectThe target element.
Returns:
Returns true if element has colors.
-
element
Checks if an image can be colorized and returns the image type
Parameters:
-
element
fabric.ObjectThe target element.
Returns:
Returns the element type(text, dataurl, png or svg) or false if the element can not be colorized.
-
imgW
-
imgH
-
resizeToW
-
resizeToH
Returns the scale value calculated with the passed image dimensions and the defined "resize-to" dimensions.
Parameters:
-
imgW
NumberThe width of the image.
-
imgH
NumberThe height of the image.
-
resizeToW
NumberThe maximum width for the image.
-
resizeToH
NumberThe maximum height for the image.
Returns:
The scale value to resize an image to a desired dimension.
-
fabricType
Returns a simpler type of a fabric object.
Parameters:
-
fabricType
StringThe fabricjs type.
Returns:
This could be image or text.
-
value
Checks if a string is a valid hexadecimal color value.
Parameters:
-
value
StringThe target value.
Returns:
Returns true if value is a valid hexadecimal color.
Checks if browser is IE and return version number.
Returns:
Returns true if browser is IE.
-
s
Checks if a string is an URL.
Parameters:
-
s
StringThe string.
Returns:
Returns true if string is an URL.
-
string
Checks if a string is XML formatted.
Parameters:
-
string
StringThe target string.
Returns:
Returns true if string is XML formatted.
-
picture
-
source
Adds a preloader icon to loading picture and loads the image.
Parameters:
-
picture
JQueryThe image container.
-
source
StringThe image URL.
Checks if the browser local storage is available.
Returns:
Returns true if local storage is available.
-
message
-
type=log
Writes a message in the console.
Parameters:
-
message
StringThe text that will be displayed in the console.
-
[type=log]
String optionalThe output type - info, error, warn or log.
-
value
Checks if a value is not empty. 0 is allowed.
Parameters:
-
value
Number | StringThe target value.
Returns:
Returns true if not empty.
-
object
Parses the fabricjs options to a FPD options object.
Parameters:
-
object
ObjectThe target fabricjs object.
Returns:
Returns the FPD object.
-
popup
If pop-up blocker is enabled, the user will get a notification modal.
Parameters:
-
popup
WindowThe target popup window.
-
container
-
loadByCounter
Refreshs the items using lazy load.
Parameters:
-
container
JQueryThe container.
-
loadByCounter
BooleanIf true 15 images will be loaded at once. If false all images will be loaded in the container.
-
object
Resets the key names of the deprecated keys.
Parameters:
-
object
ObjectAn object containing element parameters.
Returns:
Returns the edited object.
-
array
-
element
Removes an element from an array by value.
Parameters:
-
array
ArrayThe target array.
-
element
StringThe element value.
Returns:
Returns the edited array.
-
text
Shows a message in the snackbar.
Parameters:
-
text
StringThe text for the message.