Resource service marshals content used by a form. Content is sourced either locally (in generated form) or remotely (for design/preview).
Members
-
Resource.browserType
-
Gets the name of the user's browser. The following browsers can be identified: Opera, Firefox, Safari, IE, Edge, Edge-Chromium, Chrome, and Blink.
Examples
When using Firefox.
Resource.browserType; // => "Firefox"
When using an unrecognized browser.
Resource.browserType; // => "Unknown"
-
Resource.deviceType
-
Get the name of the user's device. The following devices can be identified: iOS, Android, BlackBerry, IEMobile, and Opera.
Examples
On an iPhone.
Resource.deviceType; // => "iOS"
On a device that can't be identified.
Resource.deviceType; // => "Unknown"
-
Resource.isMobile
-
Checks if the user's device is a mobile device. It does not provide 100% coverage, but the following devices are supported: iOS, Android, BlackBerry, IEMobile, and Opera Mini.
Examples
On a recognized mobile device.
Resource.isMobile; // => true
On an urecognized device.
Resource.isMobile; // => false
Methods
-
Resource.fontPath(path)
-
Converts the specified path to a font resource location.
Parameters:
Name Type Description path
string Returns:
- Type
- string
Examples
In "Design" or "Preview" mode.
Resource.fontPath("Roboto.ttf"); // => services/formresources/9935/fonts/Roboto.ttf
In a built and rendered form.
Resource.fontPath("Roboto.ttf"); // => ./fonts/Roboto.ttf
-
Resource.get(path)
-
Checks for the resource available locally in the form before fetching via Http.get. To get an application resource, use with its normal path (mainly relevant to form generation process). To get a form resource, convert the relative path with Resource.path method first.
Parameters:
Name Type Description path
Returns:
- Type
- Promise
-
Resource.imagePath(path)
-
Converts the specified path to an image resource location.
Parameters:
Name Type Description path
string Returns:
- Type
- string
Examples
In "Design" or "Preview" mode.
Resource.imagePath("hello-world.png"); // => "services/formresources/6728/images/hello-world.png"
In a built and rendered form.
Resource.imagePath("hello-world.png"); // => "./images/hello-world.png"
-
Resource.path(path [, formDesignVersionId])
-
Converts the specified relative path to a form resource path respective of environment.
Parameters:
Name Type Argument Description path
string formDesignVersionId
string <optional>
Can be used to explicitly set the formDesignVersionId. Otherwise the ID of the version in design is used. Returns:
- Type
- string
Examples
With the ID of the current form design version.
Resource.path("hello-world.png"); // => services/formresources/9935/hello-world.png
With the ID of the specified form design version.
Resource.path("hello-world.png", "1234"); // => services/formresources/1234/hello-world.png