Global

Members

(constant) ALTER_RETURN

Copyright (c) 2000-present Liferay, Inc. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
Source:

busy :boolean

Determines if blocking action is currently in process.
Type:
  • boolean
Source:

(constant) DEFAULT_INIT

Copyright (c) 2000-present Liferay, Inc. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
Source:

(constant) defaults

Options
Properties:
Name Type Description
breakpoint String | Number The window width that defines the desktop size.
content String The class or ID of the content container.
container String The class or ID of the sidenav container.
gutter String | Number The space between the sidenav-slider and the sidenav-content.
navigation String The class or ID of the navigation container.
position String The position of the sidenav-slider. Possible values: left, right
type String The type of sidenav in desktop. Possible values: relative, fixed, fixed-push
typeMobile String The type of sidenav in mobile. Possible values: relative, fixed, fixed-push
url String | Object The URL to fetch the content to inject into .sidebar-body
width String | Number The width of the side navigation.
Source:

(constant) doHistory :boolean

Flag specifying whether history is to be processed (true if browser supports HTML5 session history APIs)
Type:
  • boolean
Source:

(constant) eventListeners :Array.<Object>

An array containing the event listeners.
Type:
  • Array.<Object>
Source:

(constant) eventListenersQueue :Array.<Object>

An array containing the event listeners currently queued for being dispatched.
Type:
  • Array.<Object>
Source:

(constant) eventNamesToSelectors

Keys are event names (eg. "click"). Values are objects mapping selectors to EventEmitters.
Source:

(constant) IDENTITY_ATTRIBUTES

A list of attributes that can contribute to the "identity" of an element, for the purposes of delegated event handling.
Source:

(constant) INSTANCE_MAP

Map from toggler DOM nodes to sidenav instances.
Source:

(constant) MAX_TIMEOUT

Copyright (c) 2000-present Liferay, Inc. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
Source:

pageRenderState :Object

The page render state containing the all portlets and public parameters map.
Type:
  • Object
Source:

(constant) portletRegex :string

Regex for portlet-level events
Type:
  • string
Source:

Methods

cancelDebounce(debounced)

Cancels the scheduled debounced function.
Parameters:
Name Type Description
debounced function
Source:

component(id, value, componentConfig) → {object}

Registers a component and retrieves its instance from the global registry.
Parameters:
Name Type Description
id string The ID of the component to retrieve or register.
value object The component instance or a component constructor. If a constructor is provided, it will be invoked the first time the component is requested and its result will be stored and returned as the component.
componentConfig object The Custom component configuration. This can be used to provide additional hints for the system handling of the component lifecycle.
Source:
Returns:
The passed value, or the stored component for the provided ID.
Type
object

componentReady(…componentId) → {Promise}

Retrieves a list of component instances after they've been registered.
Parameters:
Name Type Attributes Description
componentId string <repeatable>
The IDs of the components to receive.
Source:
Returns:
A promise to be resolved with all the requested component instances after they've been successfully registered.
Type
Promise

debounce(fnnon-null, delay) → (non-null) {function}

Debounces function execution.
Parameters:
Name Type Description
fn function
delay number
Source:
Returns:
Type
function

decodeUpdateString(pageRenderState, updateString) → {Object}

Decodes the update strings. The update string is a JSON object containing the entire page state. This decoder returns an object containing the portlet data for portlets whose state has changed as compared to the current page state.
Parameters:
Name Type Description
pageRenderState Object The page render state.
updateString string The update string to decode.
Source:
Returns:
Type
Object

destroyComponent(componentId)

Destroys the component registered by the provided component ID. This invokes the component's own destroy lifecycle methods (destroy or dispose) and deletes the internal references to the component in the component registry.
Parameters:
Name Type Description
componentId string The ID of the component to destroy.
Source:

destroyComponents(filterFn)

Destroys registered components matching the provided filter function. If no filter function is provided, it destroys all registered components.
Parameters:
Name Type Description
filterFn function A method that receives a component's destroy options and the component itself, and returns true if the component should be destroyed.
Source:

destroyUnfulfilledPromises()

Clears the component promises map to make sure pending promises don't get accidentally resolved at a later stage if a component with the same ID appears, causing stale code to run.
Source:

encodeFormAsString(portletId, form)

Function to extract data from form and encode it as an 'application/x-www-form-urlencoded' string.
Parameters:
Name Type Description
portletId string The portlet ID.
form HTMLFormElement Form to be submitted.
Source:

encodeParameter(name, values) → {string}

Helper for encoding a multi valued parameter.
Parameters:
Name Type Description
name string The parameter's name.
values Array.<string> The parameter's value.
Source:
Returns:
Type
string

generateActionUrl(portletId, url, The) → {Object}

Generates the required options for an action URL request according to the portletId, action URL and optional form element.
Parameters:
Name Type Description
portletId string The id of the portlet.
url string The action url.
The HTMLFormElement form element.
Source:
Returns:
Type
Object

generateParameterString(pageRenderState, portletId, name, type, group)

Helper for generating parameter strings for the URL
Parameters:
Name Type Description
pageRenderState Object The page render state.
portletId string The portlet ID.
name string The parameter's name.
type string The parameter's type.
group string The parameter's group.
Source:

generatePortletModeAndWindowStateString(pageRenderState, portletId) → {string}

Helper for generating portlet mode & window state strings for the URL.
Parameters:
Name Type Description
pageRenderState Object The page render state.
portletId string The portlet ID.
Source:
Returns:
Type
string

getComponentCache(componentId) → {object}

Retrieves a registered component's cached state.
Parameters:
Name Type Description
componentId string The ID used to register the component.
Source:
Returns:
The state the component had prior to the previous navigation.
Type
object

getElement()

Utility function that strips off a possible jQuery and Metal component wrappers from a DOM element.
Source:

getSessionValue(key) → {Promise}

Gets the Store utility fetch value for given key
Parameters:
Name Type Description
key String string for fetch request
Source:
Returns:
Type
Promise

getUniqueSelector()

Returns a unique selector for the supplied element. Ideally we'd just use the "id" attribute (assigning one if necessary), but the use of Metal components means that any "id" we assign will be blown away on the next state change.
Source:

getUpdatedPublicRenderParameters(pageRenderState, portletId, state) → {Object}

Gets the updated public parameters for the given portlet ID and new render state. Returns an object whose properties are the group indexes of the updated public parameters. The values are the new public parameter values.
Parameters:
Name Type Description
pageRenderState Object The page render state.
portletId string The portlet ID.
state RenderState The new render state.
Source:
Returns:
Object containing the updated public render parameters.
Type
Object

getUrl(pageRenderState, type, portletId, parameters, cache, resourceId) → {Promise}

Returns a URL of the specified type.
Parameters:
Name Type Description
pageRenderState Object The page render state.
type string The URL type.
portletId string The portlet ID.
parameters Object Additional parameters. May be null.
cache string Cacheability. Must be present if type = "RESOURCE". May be null.
resourceId string Resource ID. May be present if type = "RESOURCE". May be null.
Source:
Returns:
A promise that resolves the generated URL.
Type
Promise

indent(level) → {String}

Returns a string for starting a new line at the specified indent level
Parameters:
Name Type Description
level number The level of indentation
Source:
Returns:
Return a string for starting a new line at the specified indent level
Type
String

initComponentCache()

Initializes the component cache mechanism.
Source:

initSPA() → (non-null) {App}

Initializes a Senna App with routes that match both ActionURLs and RenderURLs. It also overrides Liferay's default Liferay.Util.submitForm to makes sure forms are properly submitted using SPA.
Source:
Returns:
The Senna App initialized
Type
App

isParameterEqual(parameter1nullable, parameter2nullable) → {boolean}

Compares two parameters and returns a boolean indicating if they're equal or not.
Parameters:
Name Type Attributes Description
parameter1 Array.<string> <nullable>
The first parameter to compare.
parameter2 Array.<string> <nullable>
The second parameter to compare.
Source:
Returns:
Type
boolean

isParameterInStateEqual(pageRenderState, portletId, state, name) → {boolean}

Compares the values of the named parameter in the new render state with the values of that parameter in the current state.
Parameters:
Name Type Description
pageRenderState Object The page render state.
portletId string The portlet ID.
state RenderState The new render state.
name string The name of the parameter to check.
Source:
Returns:
True if the new parameter's value is different from the current value.
Type
boolean

isPublicParameter(pageRenderState, portletId, name) → {boolean}

Function for checking if a parameter is public.
Parameters:
Name Type Description
pageRenderState Object The page render state.
portletId string The portlet ID.
name string The name of the parameter to check.
Source:
Returns:
Type
boolean

offsetLeft()

Replacement for jQuery's `offset().left`.
Source:

openSimpleInputModal(alert, options, checkboxFieldLabel, checkboxFieldName, checkboxFieldValue, dialogTitlenon-null, formSubmitURLnon-null, idFieldName, idFieldValue, mainFieldLabelnon-null, mainFieldNamenon-null, mainFieldPlaceholder, mainFieldValue, namespacenon-null, spritemapnon-null) → {SimpleInputModal}

Execution flow 1. When the function is called, a delegated click event is bound to the specified elementSelector, and a SimpleInputModal component is created when fired. 2. When the form is submitted, a POST request is sent to the server and a formSubmit event is dispatched. 3. SimpleInputModal processes the response. 3.1. If the response is successful, a formSuccess event is dispatched. Then, if there is a redirectURL, it performs a redirection. Finally, the SimpleInputModal is disposed and all event listeners are detached. 3.2. If the response is an error, a formError event is dispatched. Then the given errorMessage is shown inside the modal and nothing happens until the user fixes the error and submits it again or the modal is closed. Optional fields - Checkbox: SimpleInputModal supports an optional checkbox field that can be added to the form. - Id field: if you need to edit an element, instead of creating new ones, a hidden ID field can be used. fieldValues can also be used to specify an initial value instead of an empty field. - Redirect URL: by default, the form redirects to an existing URL when it's submitted. This URL is obtained from the request response as "redirectURL." If no URL is obtained, the SimpleInputModal is disposed.
Parameters:
Name Type Description
alert Object An optional alert for the modal
options Object The list of options for the modal (see description)
checkboxFieldLabel string The label for the optional checkbox field, if it's included
checkboxFieldName string The name for the optional checkbox field, if it's included
checkboxFieldValue boolean The value for the optional checkbox field, if it's included
dialogTitle string The modal window's title
formSubmitURL string The URL where the form will be submitted
idFieldName string The ID of the optional hidden field, if it's included
idFieldValue string The value of the optional hidden field, if it's included
mainFieldLabel string The main input field's label
mainFieldName string The main input field's name
mainFieldPlaceholder string A placeholder value for main input field
mainFieldValue string The main input field's value
namespace string The namespace to prepend to field names
spritemap string The URL for the portal icons used in the modal
Source:
See:
Returns:
SimpleInputModal component instance
Type
SimpleInputModal

openToast(message, title, type) → {ClayToast}

Function that implements the Toast pattern, which allows to present feedback to user actions as a toast message in the lower left corner of the page
Parameters:
Name Type Description
message string The message to show in the toast notification
title string The title associated with the message
type string The type of notification to show. It can be one of the following: 'danger', 'info', 'success', 'warning'
Source:
Returns:
The Alert toast created
Type
ClayToast

px()

For compatibility with jQuery, which will treat "100" as "100px".
Source:

register(portletId) → {Promise}

Registers a portlet client with the portlet hub.
Parameters:
Name Type Description
portletId string The unique portlet identifier
Source:
Returns:
A Promise object. Returns an PortletInit object containing functions for use by the portlet client on successful resolution. Returns an Error object containing a descriptive message on failure.
Type
Promise

setSessionValue(key, value) → {Promise}

Sets the Store utility fetch value
Parameters:
Name Type Description
key String of the formData
value Object | String of the key for the formData
Source:
Returns:
Type
Promise

stateChanged(pageRenderState, newState, portletId) → {boolean}

Returns true if input state differs from the current page state. Throws exception if input state is malformed.
Parameters:
Name Type Description
pageRenderState Object The (current) page render state.
newState RenderState The new state to be set.
portletId string The portlet ID.
Source:
Returns:
True if the two state are different.
Type
boolean

subscribe()

Creates a delegated event listener for `eventName` events on `elementOrSelector`.
Source:

validateArguments(args, min, max, types)

Used by the portlet hub methods to check the number and types of the arguments.
Parameters:
Name Type Default Description
args Array.<string> The argument list to be checked.
min number 0 The minimum number of arguments.
max number 1 The maximum number of arguments. If this value is undefined, the function can take any number of arguments greater than max.
types Array.<string> An array containing the expected parameter types in the order of occurrance in the argument array.
Source:
Throws:
Thrown if the parameters are in some manner incorrect.
Type
TypeError

validateForm(formnullable)

Validates an HTMLFormElement
Parameters:
Name Type Attributes Description
form HTMLFormElement <nullable>
The form element to be validated.
Source:
Throws:
  • Thrown if the form is not an HTMLFormElement.
    Type
    TypeError
  • Thrown if the form's method attribute is not valid.
    Type
    TypeError
  • Thrown if the form's enctype attribute is not valid.
    Type
    TypeError
  • Thrown if the form's enctype attribute is not valid.
    Type
    TypeError

validateParameters(parameters)

Verifies that the input parameters are in valid format. Parameters must be an object containing parameter names. It may also contain no property names which represents the case of having no parameters. If properties are present, each property must refer to an array of string values. The array length must be at least 1, because each parameter must have a value. However, a value of 'null' may appear in any array entry. To represent a null value, the property value must equal [null].
Parameters:
Name Type Description
parameters Object The parameters to check.
Source:
Throws:
Thrown if the parameters are incorrect.
Type
TypeError

validatePortletId(portletId, pageRenderState) → {boolean}

Validates the specificed portletId against the list of current portlet in the pageRenderState.
Parameters:
Name Type Description
portletId string The ID of the portlet to be registered.
pageRenderState Object The current pageRenderState.
Source:
Returns:
A flag indicating if the specified portlet id is valid.
Type
boolean

validateState(state, portletData)

Verifies that the input parameters are in valid format, that the portlet mode and window state values are allowed for the portlet.
Parameters:
Name Type Description
state RenderState The render state object to check.
portletData Object The porltet render state.
Source:
Throws:
Thrown if any component of the state is incorrect.
Type
TypeError

Type Definitions

callback(selectKeynon-null) → {array}

Returns a list of regions by country
Parameters:
Name Type Description
selectKey string The selected region ID
Source:
Returns:
Array of regions by country
Type
array

callback() → {array}

Returns a list of countries
Source:
Returns:
Array of countries
Type
array