Class: ThemeUtils

Oracle® JavaScript Extension Toolkit (JET)
3.2.0

E87541-01

QuickNav

oj. ThemeUtils

Version:
  • 3.2.0
Since:
  • 1.2.0
Services for getting information from the theme

Constructor

new ThemeUtils()

Source:

Methods

<static> clearCache()

clear values cached in oj.ThemeUtils.parseJSONFromFontFamily
Source:

<static> getThemeName() → {String|null}

get the name of the current theme
Source:
Returns:
the name of the theme
Type
String | null

<static> getThemeTargetPlatform() → {String|null}

get the target platform of the current theme
Source:
Returns:
the target platform can be any string the theme wants to send down, but the usual values are 'web', 'ios', 'android', 'windows'
Type
String | null

<static> parseJSONFromFontFamily(selector) → {*}

json can be sent down as the font family in classes that look something like this (on the sass side of things see the file scss/utilities/_oj.utilities.json.scss for information on jet mixins available to generate json):

Example CSS


.demo-map-json {
   font-family: '{"foo":"bar", "binky": 4}';
}

.demo-list-json {
   font-family: '["foo","bar","binky"}';
}

Example Usage


var mymap = oj.ThemeUtils.parseJSONFromFontFamily("demo-map-json");
var myarray = oj.ThemeUtils.parseJSONFromFontFamily("demo-list-json");
This function
  • Gets the font family string by creating a dom element, applying the selector passed in, calling getcomputedstyle, and then reading the value for font-family.
  • Parses the font family value by calling JSON.pars.
  • Caches the parsed value because calling getComputedStyle is a perf hit. Subsequent requests for the same selector will return the cached value. Call oj.ThemeUtils.clearCache if new css is loaded.
  • Return the parsed value.

If new css is loaded call oj.ThemeUtils.clearCache to clear the cache

Parameters:
Name Type Description
selector string a class selector name, for example 'demo-map-json';
Source:
Throws:
If JSON.parse throws a SyntaxError exception we will log an error and rethrow
Type
SyntaxError
Returns:
the result of parsing the font family with JSON.parse. The returned value is cached, so if you modify the returned value it will be reflected in the cache.
Type
*