Methods
(static) deleteCookie(name)
Function to delete a cookie by name.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the cookie to delete. |
(static) getCookie(name)
Function to get a cookie by name.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the cookie value to retrieve. |
(static) init(onReady)
Sets up the standard client environment.
Parameters:
| Name | Type | Description |
|---|---|---|
onReady |
function | method to be invoked when the middleware layer has initialised. |
(static) setCookie(name, value)
Function to set a cookie by name.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the cookie value to set. |
value |
string | New value. |
(static) widgetSimpleDataSource()
Defines a standard Kendo dataSource that can be used by most widgets
_addKendoWidgetFromSurveyVar(widgetName, widgetOptions, project, name, varName, isPageFilteropt, onChangeopt, placeholderopt, groupVaropt, popupContaineropt, orderopt, suppressFilterEventsopt, omitFromFiltersopt) → {object}
Creates a new Kendo UI dropdown-style widget and populates it with all the distinct values of the given survey variable. This is the common factory method for addDropdownFromSurveyVar and addComboBoxFromSurveyVar.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
widgetName |
string | The name of the Kendo widget to create (e.g., 'kendoDropDownList', 'kendoComboBox'). |
|
widgetOptions |
object | The widget-specific configuration options. |
|
project |
object | Project to use |
|
name |
string | Name of the widget (must be unique on a page) |
|
varName |
string | Name of the survey variable to use |
|
isPageFilter |
boolean |
<optional> |
True if this widget is a page filter |
onChange |
function |
<optional> |
Method to call when the widget value changes |
placeholder |
string |
<optional> |
Placeholder text |
groupVar |
string |
<optional> |
Name(s) of the variable to group the results by |
popupContainer |
string |
<optional> |
CSS selector of the element to append the popup containers to. |
order |
array |
<optional> |
Order of the dropdown items. |
suppressFilterEvents |
boolean |
<optional> |
When true updates to this widget will not generate filterChanged events. |
omitFromFilters |
boolean |
<optional> |
When true the dropdown will not add its value to the page filters. |
Returns:
- Type
- object
addAnimatedNumber(name, options) → {object}
Creates a new Animated Number widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||
options |
object | Custom widget options Options specific to this widget:
|
Returns:
- Type
- object
addAssistant(name, options) → {object}
Creates a new Research Assistant widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Example
const project = client.Globals.projects.find((project) => project.name === 'My Project');
client.addAssistant('my-assistant-container', {project});
Parameters:
| Name | Type | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||
options |
object | Custom widget options - Options specific to this widget:
|
Returns:
- Type
- object
addAutocompleteDropdownFromSurveyVar(project, name, varName, isPageFilteropt, onChangeopt, height, placeholderopt, groupVaropt, popupContaineropt, suppressFilterEventsopt, omitFromFiltersopt) → {object}
Creates a new dropdown autocomplete list widget and populates it with all the distinct values of the given survey variable. Expects a DOM input element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
project |
object | Project to use |
|
name |
string | Name of the widget (must be unique on a page) |
|
varName |
string | Name of the survey variable to use |
|
isPageFilter |
boolean |
<optional> |
True if this widget is a page filter |
onChange |
function |
<optional> |
Method to call when the widget value changes |
height |
number | Height of the dropdown |
|
placeholder |
string |
<optional> |
Placeholder value |
groupVar |
string |
<optional> |
Name(s) of the variable to group the results by |
popupContainer |
string |
<optional> |
CSS selector of the element to append the (hidden) popup containers to. |
suppressFilterEvents |
boolean |
<optional> |
When true updates to this widget will not generate filterChanged events. |
omitFromFilters |
boolean |
<optional> |
When true the dropdown will not add its value to the page filters. |
Returns:
- Type
- object
addBar(name, options) → {object}
Adds a Bar widget. Expects a DOM element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||||||||||||||||||||||||||
options |
object | Options to control the appearance and behaviour of the Bar:
|
Returns:
Bar instance.
- Type
- object
addCalendar(name, options) → {object}
- Source:
- See:
-
- kendo.ui.Calendar for options.
Creates a new Calendar widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addCategories(name, options) → {object}
Creates a new Categories widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options Options specific to this widget: project {object} The project to fetch category data from codingVar {string} The coding variable name (default: 'coding') dateVar {string} The date variable name (defaults to project.dateVar) The server fixes the columns it returns, so codingVar and dateVar only name the keys to read from each row - they do not change what is fetched. Bar length and the right-hand figure are the percentage of coded respondents who mention the category. A respondent counts once however many comment questions they answered, and respondents are multi-coded, so these do not sum to 100%. The sentiment colours within a bar are shares of that category's mentions, which is a different denominator - a respondent tagged both positively and negatively counts once in the bar length but twice there. |
Returns:
- Type
- object
addChart(name, options) → {object}
- Source:
- See:
Creates a new chart widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addComboBoxFromSurveyVar()
Creates a new combobox widget and populates it with all the distinct values of the given survey variable.
addComparison(name, options) → {object}
Creates a new comparison widget that allows the user to compare survey variables side-by-side by creating up to 6 "personas". Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||||||||||
options |
object | Custom widget options:
An example: const project = client.Globals.projects.find((project) => project.name === 'My Project'); const datePresets = { 'YearEnd 2024': client.Globals.datePreset.twoYearsAgoFinancialYear, 'YearEnd 2025': client.Globals.datePreset.lastFinancialYear, 'YearEnd 2026': client.Globals.datePreset.thisFinancialYear, } client.addComparison( 'comparison2', { project:, vars: client.getProjectVarsByCategory(project, 'compare', ['name', 'caption']), filter: '{tenant_type}="LCRA"', personaLabel: 'tenant', personaAttributes: [ { name: project.dateVar, label: 'Dates', type: 'daterange', defaultFromFilter: 'departure', presets: datePresets }, { name: 'tenure_type', label: 'Tenure', type: 'dropdown' }, { name: 'age_group', label: 'Age Group', type: 'dropdown' }, { name: 'region', label: 'Region', type: 'dropdown' }, { name: 'had_repair', label: 'Had a Repair', type: 'dropdown' }, ] }) In personaAttributes: "name" is the name of the variable. "label" is the label to use for the persona. "type" is the type of control to show for the persona. It can be one of: - dropdown - daterange "defaultFromFilter" is optional, and if present will cause the persona's attribute to be initialized from the current page filter for that variable (if any). "presets" is optional, and only works for dateranges. It defines a set of date presets that can be used to set the persona's date range. |
Returns:
- Type
- object
addDataValue(name, options) → {object}
Creates a new data container. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
options | Custom widget options - NOTE: Only options.filterChanged is supported |
Returns:
- Type
- object
addDatePicker(name, varName, optionsopt, isPageFilteropt, onChangeopt, suppressFilterEventsopt) → {object}
- Source:
- See:
Creates a new date picker widget. Expects a DOM input element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
|
varName |
string | Name of the survey variable associated with this widget. |
|
options |
object |
<optional> |
Custom widget options |
isPageFilter |
boolean |
<optional> |
True if this widget is a page filter |
onChange |
function |
<optional> |
Method to call when the widget value changes |
suppressFilterEvents |
boolean |
<optional> |
When true updates to this widget will not generate filterChanged events. |
Returns:
- Type
- object
addDateRange(name, varName, optionsopt, isPageFilteropt, onChangeopt, suppressFilterEventsopt) → {object}
Creates a new date range widget. Expects two DOM input elements with an id that matches the given name plus '-from' and '-to' to use as the base for the widget.
Pickers that select a whole period rather than a specific date (i.e. any depth coarser than "month") have their
values snapped to the start of that period for the 'from' picker and to the end of it for the 'to' picker, so
that the generated BETWEEN filter covers the whole of the selected 'to' period. Any change handler passed in
options runs first and cannot leave a half-open range behind - @see _getPeriodSnap.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
|
varName |
string | Name of the survey variable associated with this widget. |
|
options |
object |
<optional> |
Custom widget options |
isPageFilter |
boolean |
<optional> |
True if this widget is a page filter |
onChange |
function |
<optional> |
Method to call when the widget value changes |
suppressFilterEvents |
boolean |
<optional> |
When true updates to this widget will not generate filterChanged events. |
Returns:
- Type
- object
addDoughnut(name, options) → {object}
- Source:
- See:
Creates a new doughnut widget (based on a Kendo chart). Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addDropdownFromData(name, data, valueProp, textPropopt, placeholderopt, isPageFilteropt, onChangeopt, popupContaineropt, suppressFilterEventsopt, omitFromFiltersopt, multiVaropt) → {object}
Creates a new dropdown list widget and populates it with the given data. Expects a DOM input element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
|
data |
array | The widget's datasource |
|
valueProp |
string | Datasource property to use for each list item's form value |
|
textProp |
string |
<optional> |
Datasource property to use for each list item's displayed text |
placeholder |
string |
<optional> |
Placeholder value |
isPageFilter |
boolean |
<optional> |
True if this widget is a page filter |
onChange |
function |
<optional> |
Method to call when the widget value changes |
popupContainer |
string |
<optional> |
CSS selector of the element to append the popup containers to. |
suppressFilterEvents |
boolean |
<optional> |
When true updates to this widget will not generate filterChanged events. |
omitFromFilters |
boolean |
<optional> |
When true the dropdown will not add its value to the page filters. |
multiVar |
boolean |
<optional> |
When true the dropdown is given a list of variables to choose from. |
Returns:
- Type
- object
addDropdownFromDivisions(project, name, varName, divisions, extend, isPageFilteropt, onChangeopt, placeholderopt, popupContaineropt, suppressFilterEventsopt, omitFromFiltersopt) → {object}
Creates a new dropdown list widget and populates it with a ist of ranges based on the given divisions. Expects a DOM input element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
project |
object | Project to use |
|
name |
string | Name of the widget (must be unique on a page) |
|
varName |
string | Name of the survey variable to apply the given ranges to |
|
divisions |
array | Divisions that separate each range |
|
extend |
bool | If true the generated ranges include 'catch-all' ranges before and after the specified divisions |
|
isPageFilter |
boolean |
<optional> |
True if this widget is a page filter |
onChange |
function |
<optional> |
Method to call when the widget value changes |
placeholder |
string |
<optional> |
Placeholder text |
popupContainer |
string |
<optional> |
CSS selector of the element to append the (hidden) popup containers to. |
suppressFilterEvents |
boolean |
<optional> |
When true updates to this widget will not generate filterChanged events. |
omitFromFilters |
boolean |
<optional> |
When true the dropdown will not add its value to the page filters. |
Returns:
- Type
- object
addDropdownFromSurveyVar()
Creates a new dropdown list widget and populates it with all the distinct values of the given survey variable.
addDropdownFromSurveyVarCategory(project, name, categoryName, placeholderopt, isPageFilteropt, onChangeopt, popupContaineropt, suppressFilterEventsopt, omitFromFiltersopt) → {object}
- Source:
- See:
Creates a new dropdown widget and populates it with all the distinct values from all the survey variables in the given variable category. Expects a DOM input element with an id that matches the given name to use as the base for the widget.
NOTE: Each variable in the category is expected to be a nullable boolean value.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
project |
object | Project to use |
|
name |
string | Name of the widget (must be unique on a page) |
|
categoryName |
string | Name of the survey variable category to use |
|
placeholder |
string |
<optional> |
Placeholder value |
isPageFilter |
boolean |
<optional> |
True if this widget is a page filter |
onChange |
function |
<optional> |
Method to call when the widget value changes |
popupContainer |
string |
<optional> |
CSS selector of the element to append the popup containers to. |
suppressFilterEvents |
boolean |
<optional> |
When true updates to this widget will not generate filterChanged events. |
omitFromFilters |
boolean |
<optional> |
When true the dropdown will not add its value to the page filters. |
Returns:
- Type
- object
addDropdownTreeFromData(name, data, valueProp, textPropopt, isPageFilteropt, optionsopt, onChangeopt, suppressFilterEventsopt, omitFromFiltersopt) → {object}
Creates a new dropdowntree widget and populates it with the given data. Expects a DOM input element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
|
data |
array | Data to display |
|
valueProp |
string | Property to use as the list value |
|
textProp |
string |
<optional> |
Property to use as the list text |
isPageFilter |
boolean |
<optional> |
True if this widget is a page filter |
options |
object |
<optional> |
Custom widget options |
onChange |
function |
<optional> |
Method to call when the widget value changes |
suppressFilterEvents |
boolean |
<optional> |
When true updates to this widget will not generate filterChanged events. |
omitFromFilters |
boolean |
<optional> |
When true the dropdown will not add its value to the page filters. |
Returns:
- Type
- object
addFiltersHook(name, hook)
Adds a new filter hook method to the list.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the filter hook |
hook |
function | Hook function to be called when a filter is to be applied |
addGlobals(glob)
Adds additional Global variables
Parameters:
| Name | Type | Description |
|---|---|---|
glob |
object | Additional variables to be added to the client.Globals object. |
addGrid(name, options) → {object}
- Source:
- See:
Creates a new grid widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addHeatmap(name, options) → {object}
Creates a new Heatmap widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Example
const project = client.Globals.projects[0];
const vars = client.getProjectVarsByCategory(project, "var-category", ['id', 'name', 'label']);
// Classify each question by section
const sections = {
'hostel': ['hadprob2', 'hadprob3', 'hadprob5', 'hadprob6', 'hadprob10', 'hadprob12'],
'guests': ['hadprob8'],
'service': ['hadprob1', 'hadprob4', 'hadprob7', 'hadprob9', 'hadprob11'],
'other': ['hadprob13'],
}
// Custom formatter for each row that prepends the section name to the variable label
const rowHeaderFormatter = v => {
// Find which section header the given variable name belongs to
for (const section in sections) {
if (sections[section].includes(v.name)) {
// Prepend the section name to the returned header
return `<span class="section-header section-header-${section}">${section}</span><span>${v.label}</span>`;
}
}
// If no section header was found, just return the variable label
return v.label;
};
client.addHeatmap('heatmap-id', {
project,
vars,
aggr: 'prop',
aggrBase: '{hadprob}=1',
caption: 'Had a problem',
scaleMode: 'GRID',
scale: [
{
type: 'Min',
},
{
type: 'Percentile',
value: 50,
},
{
type: 'Max',
}
],
invertScale: ['hadprob10'],
rowHeaderFormatter
});
In this example the scale consists of three color stops:
First stop: minimum value of the entire grid.
Second stop: the median value of the entire grid.
Third stop: the maximum value of the entire grid.
If the scaleMode was set to 'ROW' then the minimum, median and maximum values would be individually calculated for each *row*.
If the scaleMode was set to 'COL' then the minimum, median and maximum values would be individually calculated for each *column*.
No custom colors were specified so the default colors were used (which are the same as those used by Excel's Conditional Formatting feature).
The 'hadprob1' question has a negative sense e.g. 'Something was wrong' so its color scale is inverted (i.e. low is green => high is red).
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
object | Custom widget options - Options specific to this widget:
|
Returns:
- Type
- object
addHotAlerts(name, options) → {object}
Creates a new Hot Alerts widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||||||||||||||
options |
object | Custom widget options Options specific to this widget:
|
Returns:
- Type
- object
addHouse(name, options) → {object}
Creates a new House widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||
options |
object | Custom widget options Options specific to this widget:
|
Returns:
- Type
- object
addInteractiveChart(name, options) → {object}
- Source:
- See:
Creates a new interactive chart with a UI that allows the user to change the chart. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addInterview(name, options) → {object}
Creates a new Interview widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||||||||||||||||||||||||||||||||||
options |
object | Custom widget options - Options specific to this widget:
|
Returns:
- Type
- object
addJourney(name, options) → {object}
Creates a new journey widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addMap(name, options) → {object}
Creates a new map widget (centred on the UK by default). Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addMultiSelectFromData(name, data, valueProp, textPropopt, placeholderopt, isPageFilteropt, optionsopt, onChangeopt, suppressFilterEventsopt) → {object}
- Source:
- See:
Creates a new multi-select widget and populates it with the given data. Expects a DOM input element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
|
data |
array | Data to display |
|
valueProp |
string | Property to use as the list value |
|
textProp |
string |
<optional> |
Property to use as the list text |
placeholder |
string |
<optional> |
Placeholder value |
isPageFilter |
boolean |
<optional> |
True if this widget is a page filter |
options |
object |
<optional> |
Custom widget options |
onChange |
function |
<optional> |
Method to call when the widget value changes |
suppressFilterEvents |
boolean |
<optional> |
When true updates to this widget will not generate filterChanged events. |
Returns:
- Type
- object
addMultiSelectFromSurveyVar(project, name, surveyVarName, placeholderopt, isPageFilteropt, optionsopt, onChangeopt, suppressFilterEventsopt, groupVarNameopt, orderopt) → {object}
- Source:
- See:
Creates a new multi-select widget and populates it with all the distinct values of the given survey variable. Expects a DOM input element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
project |
object | Project to use |
|
name |
string | Name of the widget (must be unique on a page) |
|
surveyVarName |
string | Name of the survey variable to use |
|
placeholder |
string |
<optional> |
Placeholder value |
isPageFilter |
boolean |
<optional> |
True if this widget is a page filter |
options |
object |
<optional> |
Custom widget options |
onChange |
function |
<optional> |
Method to call when the widget value changes |
suppressFilterEvents |
boolean |
<optional> |
When true updates to this widget will not generate filterChanged events. |
groupVarName |
string |
<optional> |
Name(s) of the variable to group the results by |
order |
array |
<optional> |
Order of the multiselect items. |
Returns:
- Type
- object
addMultiSelectFromSurveyVarCategory(project, name, categoryName, placeholderopt, isPageFilteropt, optionsopt, onChangeopt) → {object}
- Source:
- See:
Creates a new multi-select widget and populates it with all the distinct values from all the survey variables in the given variable category. Expects a DOM input element with an id that matches the given name to use as the base for the widget.
NOTE: Each variable in the category is expected to be a nullable boolean value
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
project |
object | Project to use |
|
name |
string | Name of the widget (must be unique on a page) |
|
categoryName |
string | Name of the survey variable category to use |
|
placeholder |
string |
<optional> |
Placeholder value |
isPageFilter |
boolean |
<optional> |
True if this widget is a page filter |
options |
object |
<optional> |
Custom widget options |
onChange |
function |
<optional> |
Method to call when the widget value changes |
Returns:
- Type
- object
addPerfectExperience(name, options) → {object}
Adds a Perfect Experience widget. Expects a DOM element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
object | Options to control the appearance and behaviour of the widget. Options specific to this widget:
|
Returns:
Perfect Experience instance.
- Type
- object
addPivotAnalyser(name, options) → {object}
Creates a new Pivot Analyser widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addPodium(name, options) → {object}
Creates a new podium widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addRadialGauge(name, options) → {object}
- Source:
- See:
Creates a new radial gauge widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addRangeSlider(name, options) → {object}
- Source:
- See:
Creates a new range slider widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addRings(name, options) → {object}
Creates a new Rings widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||||||||||||||||||
options |
object | Custom widget options Options specific to this widget:
|
Returns:
- Type
- object
addSlider(name, options) → {object}
- Source:
- See:
Creates a new slider widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addSoftFilters(filters)
Adds any user claims that start with 'filter_' to the given filters object and returns a new filter object including the new filters. The original filters are not modified.
Parameters:
| Name | Type | Description |
|---|---|---|
filters |
object | Original filters object. They are not modified. |
addSparkline(name, options) → {object}
- Source:
- See:
Creates a new sparkline widget i.e a simple chart with no axis, legend or tooltips. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addSphere(name, options) → {object}
Creates a new Sphere widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||||||
options |
object | Custom widget options Options specific to this widget:
|
Returns:
- Type
- object
addStage(name, options) → {object}
Creates a new stage widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addSurveyInspector(name, options) → {object}
Creates a new Survey Inspector widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||
|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||
options |
object | Custom widget options - Options specific to this widget:
|
Returns:
- Type
- object
addTabStrip(name, options) → {object}
- Source:
- See:
Creates a new TabStrip widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addTaskboard(name, options) → {object}
Creates a new Taskboard widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options Options specific to this widget: |
Returns:
- Type
- object
addTreeList(name, options, filter) → {object}
- Source:
- See:
-
- https://docs.telerik.com/kendo-ui/api/javascript/ui/treelist for TreeList options.
- https://docs.telerik.com/kendo-ui/api/javascript/ui/treelist/configuration/columns for TreeList column options.
Creates a new TreeList widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||||||||||||||||||
options |
object | Kendo TreeView widget options, plus the following TLF extensions:
Each element in the Kendo columns array may specify any of the Kendo Column options, plus the following TLF extensions:
An example hierarchy object (expanded = true means the node is expanded to show its children on first load) would be: hierarchy: [ { text: 'Overall', expanded: true }, { varName: 'area', expanded: true }, { varName: 'region' }, { varName: 'company' }, { varName: 'project_manager' }, { varName: 'respondent' } ] |
||||||||||||||||||||||||||||||||
filter |
function | A filter function that is called when the treelist's data is bound. It is passed the rows array and may modify it before returning it. |
Returns:
- Type
- object
addTreeView(name, options) → {object}
- Source:
- See:
Creates a new TreeView widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
options |
object | Custom widget options |
Returns:
- Type
- object
addUser(name, optionsopt) → {object}
Creates a new logged-in User widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
|
options |
object |
<optional> |
Custom widget options |
Returns:
- Type
- object
addVideo(name, src, options) → {object}
Adds a video player. Expects a DOM element with an id that matches the given name to use as the base for the player.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
src |
string | URL of the video file to play |
options |
object | Options to control the appearance and behaviour of the player. The following options are supported: clickAnyWhereToPlay (bool): When true the player can be toggled to play/pause by clicking anywhere in the video window. features (array): Describes the desired playback features - one or more of the following: 'play' - play/pause toggle button 'time' - current time in mm::ss 'volume' - volume control 'skip-start' - button to skip to the start of the video 'skip-backwards' - button to jump back 15 seconds 'skip-forwards' - button to jump forwards 15 seconds 'skip-end' - button to skip to the end of the video poster (string): path to an image file to show before the video is played (path is subject to CORS policy). fadeTo (string): either a CSS color value or a path to an image file (path is subject to CORS policy). The color or image is shown after the end of the video. captions (string): path to a VTT track file for text captions to be displayed while the video is playing (path is subject to CORS policy). close (bool): When true a close button is displayed to allow the user to hide the video element. |
Returns:
Video player instance.
- Type
- object
addViewFilters(name, options) → {object}
Creates a new View Filters widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||
options |
object | Custom widget options Options specific to this widget:
|
Returns:
- Type
- object
addWaffle(name, options) → {object}
Creates a new waffle chart widget. Expects a DOM div element with an id that matches the given name to use as the base for the widget.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
||||||||||||||||||||||||||||||||||||
options |
object | Custom widget options Options specific to this widget:
|
Returns:
- Type
- object
buildBucketSeries(data, buckets, categories) → {Array}
Given some data rows, a set of buckets and a sorted set of categories, returns a set of chart series suitable for a Kendo stacked bar chart.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
||
buckets |
||
categories |
Returns:
- Type
- Array
clean()
Cleans up the current view
convertFiltersToString(filterMap) → {object}
Converts the given set of filters into a string.
Parameters:
| Name | Type | Description |
|---|---|---|
filterMap |
object | Map of filter values to be converted. |
Returns:
- Type
- object
convertKendoFilters(f, nullValueopt) → {string}
Converts the given set of Kendo filters to a string that is compatible with the data API.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
f |
object | Kendo filter to convert |
|
nullValue |
string |
<optional> |
Optional string value to convert to an 'IS NULL' test |
Returns:
An API filter that can be added to a filter collection
- Type
- string
createPageFilters(filtersID, statusID, proj)
Creates a set of page filters as defined by the config.PAGE_FILTERS object.
Parameters:
| Name | Type | Description |
|---|---|---|
filtersID |
string | ID of the parent HTML element for the page filters UI |
statusID |
string | ID of the parent HTML element for the page filter status UI |
proj |
Project | Project to be filtered |
downloadAsCSV()
Downloads the given data as a CSV
escapeHTML()
escapeHTML allows HTML to be safely emitted by scripts
getAbsMax(a) → {Number}
Returns the maximum absolute value of all the given array values, ignoring any sign.
Parameters:
| Name | Type | Description |
|---|---|---|
a |
array |
Returns:
- Type
- Number
getApplicableProjects(projects) → {array}
Returns the list of Projects that the User is allowed to see, and that are appropriate to this particular portal. It also fetches all the Project variables.
Parameters:
| Name | Type | Description |
|---|---|---|
projects |
array | an array of the user's Projects |
Returns:
Projects that are relevant to the current portal and user
- Type
- array
getControl(name) → {jQuery}
Returns the underlying Kendo control for the given widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string |
Returns:
- Type
- jQuery
getLatestProjectDate(filters, cb) → {Date|null}
getLatestProjectDate returns the latest date for which there is data across all the public Projects defined in the current portal's config.
Parameters:
| Name | Type | Description |
|---|---|---|
filters |
object | Filters to apply when searching |
cb |
function | Function to call when the request completes |
Returns:
- Type
- Date | null
getPageFilters(widgetsopt) → {object}
Returns a map containing current filter values.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
widgets |
array |
<optional> |
Widget filter values to return |
Returns:
- Type
- object
getPageFiltersAsString(widgetsopt) → {object}
Returns the current set of page filters as a string.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
widgets |
array |
<optional> |
Widget filter values to return |
Returns:
- Type
- object
getParameterMap() → {function}
Returns a parameter map needed to support this widget library.
Returns:
- Type
- function
getProjectVarsByCategory(project, categories, props) → {array}
Returns a collection of Project Variables properties for variables that are in any of the given categories. If props is a string a sinple array of scalar values is returned, otherwise it's an array of objects.
Parameters:
| Name | Type | Description |
|---|---|---|
project |
object | Project to inspect |
categories |
array | string | Categories to inspect (null = get all categories) |
props |
array | string | Variable properties to return (the id property is always returned) |
Returns:
Project variables in the given categories.
- Type
- array
getSharedTooltipTemplate(aggregator, categoryVar, dataSource)
getSharedTooltipTemplate fetches a template that shows the chart series name, the aggregator value and the sample base.
Parameters:
| Name | Type | Description |
|---|---|---|
aggregator |
string | The name of the aggregator function being used |
categoryVar |
string | The variable name of the category |
dataSource |
string | The variable name of the data source |
getValidID()
getValidID returns a string that can be used as a valid ID for an HTML element
getValueLabel(v) → {string}
getValueLabel returns a label for the given value
Parameters:
| Name | Type | Description |
|---|---|---|
v |
any | Data value to inspect |
Returns:
- Type
- string
getWidget(name) → {jQuery}
Returns the given widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget to retrieve |
Returns:
- Type
- jQuery
injectCSS(cssFileUrl, onloadopt, onerroropt)
Injects the given CSS file into the page.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
cssFileUrl |
string | The URL of the CSS file to inject. |
|
onload |
function |
<optional> |
Method to call when the CSS file has loaded. |
onerror |
function |
<optional> |
Method to call if the CSS file fails to load (default is to ignore the error) |
injectScript(id, src, onloadopt)
Injects the given named script src into the page.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
id |
string | ||
src |
string | ||
onload |
function |
<optional> |
Method to call when the script has loaded |
isAdmin()
Returns true if the current user is an Admin.
isPageFilter() → {boolean}
Return true if the given widget is defined as a page filter.
Returns:
- Type
- boolean
logout()
Logs the user out.
manageRealm()
Redirects to the Keycloak console to allow the realm to be managed via the IDP.
manageUsers()
Loads a view that provides some basic user management features.
modifyLinksIfOnStaging()
Intended for staging environments where all links to a production domain (e.g., 'client.leadershipfactor.com') should be rewritten to their corresponding staging version (e.g., 'client.wr3s.leadershipfactor.com').
The update happens iff:
- The current page's URL (window.location) is already on a '.wr3s' subdomain.
- The link's hostname ends with the target base domain (e.g., 'leadershipfactor.com').
- The link's hostname does NOT already contain '.wr3s'.
normalizeToArray(val) → {Array}
Normalizes the given value to an array.
Parameters:
| Name | Type | Description |
|---|---|---|
val |
Returns:
- Type
- Array
onFilterChanged(callback)
Calls the given function whenever a filter changes. Also calls it immediately if all filters are in the ready state.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function | Callback function. |
onPageFilterChanged(callback)
Calls the given function whenever a filter changes. Also calls it immediately if all filters are in the ready state. Unlike onFilterChanged this is not deactivated when the page view changes.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function | Callback function. |
quantise(n, quantum) → {Number|NaN}
Returns the quantised value of the given number.
Parameters:
| Name | Type | Description |
|---|---|---|
n |
Number | |
quantum |
Number |
Returns:
- Type
- Number | NaN
resetPassword()
Allows the user to request a password reset.
setControl(name, ctrl)
Sets the underlying Kendo control for the given widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | |
ctrl |
jQuery |
setDebug()
Sets debug mode on
setOption(name, value, value)
Sets a widget's options.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
value |
string | Option |
value |
* | Option value |
setPageFilterNotReady() → {boolean}
Sets the given page filter state to be not ready.
Returns:
- Type
- boolean
setWidgetData(name, data)
Updates the local data in a widget.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
data |
object | New data to display |
setWidgetDataSource(name, data)
Set a widget's dataSource to a new one containing the given data.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
data |
object | New data to display |
setWidgetURL(name, url, queryopt, cacheopt)
Updates the URL used to provide the widget's data.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | Name of the widget (must be unique on a page) |
|
url |
string | New remote URL |
|
query |
object |
<optional> |
Query parameters |
cache |
bool |
<optional> |
When true (=default) the data from the server is cached. |
softFilterRows(rows)
Returns a new set of rows that have been filtered by any user claims that start with 'filter_'.
Parameters:
| Name | Type | Description |
|---|---|---|
rows |
array | Original rows object. It is not modified. |
summariseControlValue(ctrl) → {string|number}
Summarises the selected values of a widget as a short piece of text.
Parameters:
| Name | Type | Description |
|---|---|---|
ctrl |
object | A client widget's control |
Returns:
Text summary of the widget value.
- Type
- string | number
suppressAllFilterEvents(suppress) → {object}
Sets whether ot not to suppress all filter events.
Parameters:
| Name | Type | Description |
|---|---|---|
suppress |
boolean | When true all filter events are suppressed. |
Returns:
- Type
- object
switchToView(name, titleopt, addToHistoryopt)
Loads the given view into the Page.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
string | Name of the view. |
|
title |
string |
<optional> |
Title of the view (defaults to the name if not supplied) |
addToHistory |
boolean |
<optional> |
When true (default) add this view to the browser's history |
toKebabLowerCase()
toKebabLowerCase returns a lower cased string in kebab-case
toTitleCase()
toTitleCase returns a string in Title Case
truncateMiddle(fullStr, strLen, separator) → {string}
truncateMiddle returns the given string trucated to a maximum of strLen characters. with the separator (default: ...) in the middle.
Parameters:
| Name | Type | Description |
|---|---|---|
fullStr |
string | String to truncate |
strLen |
number | Maximum lenght of the truncated string |
separator |
string | Separator string to use in the middle of the truncated string. |
Returns:
- Type
- string
(inner) _getPeriodSnap(depthopt, rangeEnd, maxopt) → {function|null}
Returns a Kendo change handler that snaps a date picker's value to the start or end of whichever period its depth selects - a month at depth "year", a year at depth "decade" or coarser. Returns null for day-granularity pickers (depth "month", Kendo's default) as those select a specific date that must be left alone.
This keeps the "to" end of a date range inclusive of the whole period the user picked, so that a filter ending "23:59:59" covers all of it rather than just its first day. It also works around a bug in the version of Kendo we're using whereby a datepicker in these modes returns a date whose day-of-month value is today's date if it's ever been used to pick a date in the current year.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
depth |
string |
<optional> |
Kendo depth of the picker the handler is for |
rangeEnd |
string | Which end of the range the picker represents - either 'start' or 'end' |
|
max |
date |
<optional> |
Picker's maximum permitted value, if any |
Returns:
Change handler, or null if the picker's values need no snapping
- Type
- function | null
(inner) getDefaultView() → {string}
getDefaultView returns the first view that the logge-in user is allowed to see.
Returns:
- Type
- string