A class with some static helper functions. You do not need to initiate the class, just call the methods directly, e.g. FPDUtil.isIE();

Show:
FPDUtil.addThousandSep
(
  • n
)
String
static

Adds a thousand separator and returns it.

Parameters:

  • n Number

    A numeric value.

Returns:

String:

Returns a string.

FPDUtil.arrayUnique
(
  • array
)
Array
static

Makes an unique array.

Parameters:

  • array Array

    The target array.

Returns:

Array:

Returns the edited array.

FPDUtil.changeBase64DPI
(
  • string
  • number
)
String
static

Changes the DPI of a base64 image.

Parameters:

  • string DataURI

    A base64 data uri representing the image(png or jpeg).

  • number Dpi

    The target DPI.

Returns:

String:

Returns the base64 image with the new DPI.

FPDUtil.changePathColor
(
  • element
  • index
  • color
)
Array
static

Changes a single path color by index.

Parameters:

  • element fabric.Object

    The target element.

  • index Number

    The path index.

  • color String

    Hexadecimal color value.

Returns:

Array:

All colors used in the SVG.

FPDUtil.checkImageDimensions
(
  • fpdInstance
  • imageW
  • imageH
)
Array
static

Checks if the dimensions of an image is within the allowed range set in the customImageParameters of the view options.

Parameters:

  • fpdInstance FancyProductDesigner

    Instance of FancyProductDesigner.

  • imageW Number

    The image width.

  • imageH Number

    The image height.

Returns:

Array:

Returns true if image dimension is within allowed range(minW, minH, maxW, maxH).

FPDUtil.createScrollbar
(
  • target
)
static

Creates a nice scrollbar for an element.

Parameters:

  • target JQuery

    The target element.

FPDUtil.elementAvailableColors
(
  • element
  • fpdInstance
)
Array
static

Returns the available colors of an element.

Parameters:

  • element fabric.Object

    The target element.

  • fpdInstance FancyProductDesigner

    Instance of FancyProductDesigner.

Returns:

Array:

Available colors.

FPDUtil.elementHasColorSelection
(
  • element
)
Boolean
static

Checks if an element has a color selection.

Parameters:

  • element fabric.Object

    The target element.

Returns:

Boolean:

Returns true if element has colors.

FPDUtil.elementIsColorizable
(
  • element
)
String | Boolean
static

Checks if an image can be colorized and returns the image type

Parameters:

  • element fabric.Object

    The target element.

Returns:

String | Boolean:

Returns the element type(text, dataurl, png or svg) or false if the element can not be colorized.

FPDUtil.getScalingByDimesions
(
  • imgW
  • imgH
  • resizeToW
  • resizeToH
)
Number
static

Returns the scale value calculated with the passed image dimensions and the defined "resize-to" dimensions.

Parameters:

  • imgW Number

    The width of the image.

  • imgH Number

    The height of the image.

  • resizeToW Number

    The maximum width for the image.

  • resizeToH Number

    The maximum height for the image.

Returns:

Number:

The scale value to resize an image to a desired dimension.

FPDUtil.getType
(
  • fabricType
)
String
static

Returns a simpler type of a fabric object.

Parameters:

  • fabricType String

    The fabricjs type.

Returns:

String:

This could be image or text.

FPDUtil.isHex
(
  • value
)
Boolean
static

Checks if a string is a valid hexadecimal color value.

Parameters:

  • value String

    The target value.

Returns:

Boolean:

Returns true if value is a valid hexadecimal color.

FPDUtil.isIE () Boolean static

Checks if browser is IE and return version number.

Returns:

Boolean:

Returns true if browser is IE.

FPDUtil.isUrl
(
  • s
)
Boolean
static

Checks if a string is an URL.

Parameters:

  • s String

    The string.

Returns:

Boolean:

Returns true if string is an URL.

FPDUtil.isXML
(
  • string
)
Boolean
static

Checks if a string is XML formatted.

Parameters:

  • string String

    The target string.

Returns:

Boolean:

Returns true if string is XML formatted.

FPDUtil.loadGridImage
(
  • picture
  • source
)
static

Adds a preloader icon to loading picture and loads the image.

Parameters:

  • picture JQuery

    The image container.

  • source String

    The image URL.

FPDUtil.localStorageAvailable () Boolean static

Checks if the browser local storage is available.

Returns:

Boolean:

Returns true if local storage is available.

FPDUtil.log
(
  • message
  • type=log
)
static

Writes a message in the console.

Parameters:

  • message String

    The text that will be displayed in the console.

  • [type=log] String optional

    The output type - info, error, warn or log.

FPDUtil.notEmpty
(
  • value
)
Array
static

Checks if a value is not empty. 0 is allowed.

Parameters:

  • value Number | String

    The target value.

Returns:

Array:

Returns true if not empty.

FPDUtil.parseFabricObjectToFPDElement
(
  • object
)
Object
static

Parses the fabricjs options to a FPD options object.

Parameters:

  • object Object

    The target fabricjs object.

Returns:

Object:

Returns the FPD object.

FPDUtil.popupBlockerAlert
(
  • popup
)
static

If pop-up blocker is enabled, the user will get a notification modal.

Parameters:

  • popup Window

    The target popup window.

FPDUtil.refreshLazyLoad
(
  • container
  • loadByCounter
)
static

Refreshs the items using lazy load.

Parameters:

  • container JQuery

    The container.

  • loadByCounter Boolean

    If true 15 images will be loaded at once. If false all images will be loaded in the container.

FPDUtil.rekeyDeprecatedKeys
(
  • object
)
Object
static

Resets the key names of the deprecated keys.

Parameters:

  • object Object

    An object containing element parameters.

Returns:

Object:

Returns the edited object.

FPDUtil.removeFromArray
(
  • array
  • element
)
Array
static

Removes an element from an array by value.

Parameters:

  • array Array

    The target array.

  • element String

    The element value.

Returns:

Array:

Returns the edited array.

FPDUtil.showMessage
(
  • text
)
static

Shows a message in the snackbar.

Parameters:

  • text String

    The text for the message.

FPDUtil.showModal
(
  • message
)
JQuery
static

Opens the modal box with an own message.

Parameters:

  • message String

    The message you would like to display in the modal box.

Returns:

JQuery:

Returns a jQuery object containing the modal.

FPDUtil.updateTooltip
(
  • $container
)
static

Looks for the .fpd-tooltip classes and adds a nice tooltip to these elements (tooltipster).

Parameters:

  • [$container] JQuery optional

    The container to look in. If not set, the whole document will be searched.