Name
global.UXThemeLoader
Description
No description available
Script
var UXThemeLoader = Class.create();
UXThemeLoader.prototype = {
initialize: function() {},
fetchTheme: function(themeSysId) {
var INITIAL_THEME_SYS_ID = 'a309795273230010fd843c78caf6a724';
var themeLoaderResponse = {};
try {
themeLoaderResponse['status'] = "Success";
var themeResponse = JSON.parse(UxPageThemeUtil.getUXPageThemeByThemeId(themeSysId));
if (themeResponse.error) {
themeLoaderResponse['status'] = "Error";
themeLoaderResponse['error'] = themeResponse.error + " for sys_id " + themeSysId;
gs.log('Flow Designer Errror : ' + themeResponse.error + " for sys_id " + themeSysId);
return themeLoaderResponse;
}
//fetch default theme
var defaultThemeResponse = JSON.parse(UxPageThemeUtil.getUXPageThemeByThemeId(INITIAL_THEME_SYS_ID));
var defaultThemeJSON = defaultThemeResponse.theme;
var fullThemeJSON = defaultThemeJSON;
var builderThemeJSON = themeResponse.theme;
// merge default theme and fetched theme objects , which also handles replacing the conflicting keys from default with builder
Object.keys(builderThemeJSON).forEach(function(key) {
fullThemeJSON[key] = builderThemeJSON[key];
});
// convert theme JSON to CSS map
var toCSSString = Object.keys(fullThemeJSON).map(function(propertyName) {
return propertyName + ': ' + fullThemeJSON[propertyName] + ';';
}).join('');
themeLoaderResponse['theme'] = toCSSString;
return themeLoaderResponse;
} catch (e) {
themeLoaderResponse['status'] = "Error";
themeLoaderResponse['error'] = "Flow Designer : Exception fetching theme for sys_id " + themeSysId + " : " + e;
gs.log("Flow Designer : Exception fetching theme for sys_id " + themeSysId + " : " + e);
return themeLoaderResponse;
}
},
type: 'UXThemeLoader'
};
Sys ID
c931a67c43b82110c3d8925caab8f2e1