Expand all

util

Constructor

new util() #

Utility library

Source:
Utility library

Properties

Promise #

Wrapper class for Promises

Source:
Wrapper class for Promises

Methods

Deferred() → {jQuery.Deferred} #

Wrapper class for the Deferred method

Source:

Returns:

Type
jQuery.Deferred
Wrapper class for the Deferred method

all(promises) → {jQuery.Promise} #

Wrapper class for the $.when that is compatible with Promise.all

Parameters:

Name Type Description
promises Array.<jQuery.Promise>
Source:

Returns:

Type
jQuery.Promise
Wrapper class for the $.when that is compatible with Promise.all

docReady(fn) → {jQuery.Object} #

Run method when document is ready.

Parameters:

Name Type Description
fn function
Source:

Returns:

Type
jQuery.Object
Run method when document is ready.

escapeSelector(selector) → {string} #

Escape a string for use as a css selector

Parameters:

Name Type Description
selector string
Source:

Returns:

Type
string
Escape a string for use as a css selector

extend() → {Object} #

Wrapper for jQuery.extend method. In future this can be bound to Object.assign when support allows.

Warning: if only one argument is supplied to util.extend(), this means the target argument was omitted. In this case, the jQuery object itself is assumed to be the target.

Source:

Returns:

Type
Object
Wrapper for jQuery.extend method.

getDir(language) → {Object} #

Determine whether a language is LTR or RTL This works around T74153 and T189036 and the fact that adding dir attribute to HTML in core at time of writing is memory-intensive (I7cd8a3117f49467e3ff26f35371459a667c71470)

Parameters:

Name Type Description
language Object

with 'lang' key.

Source:

Returns:

language with 'lang' key and new 'dir' key.

Type
Object

Determine whether a language is LTR or RTL This works around T74153 and T189036 and the fact that adding dir attribute to HTML in core at time of writing is memory-intensive (I7cd8a3117f49467e3ff26f35371459a667c71470)

getDocument() → {jQuery.Object} #

Adds a class to the document

Source:

Returns:

element representing the documentElement

Type
jQuery.Object
Adds a class to the document

getFrequentlyUsedLanguages() → {Object} #

Return a map of frequently used languages on the current device.

Source:

Returns:

Type
Object
Return a map of frequently used languages on the current device.

getWindow() → {jQuery.Object} #

Get the window object

Source:

Returns:

Type
jQuery.Object
Get the window object

parseHTML(html, [ctx]) → {jQuery.Object} #

Given some html, create new element(s). Unlike jQuery.parseHTML this will return a jQuery object not an array.

Parameters:

Name Type Attributes Description
html string
ctx Element optional

Document element to serve as the context in which the HTML fragment will be created

Source:

Returns:

Type
jQuery.Object
Given some html, create new element(s).

saveFrequentlyUsedLanguages(languageMap) #

Save the frequently used languages to the user's device

Parameters:

Name Type Description
languageMap Object
Source:
Save the frequently used languages to the user's device

saveLanguageUsageCount(languageCode, frequentlyUsedLanguages) #

Increment the current language usage by one and save it to the device. Cap the result at 100.

Parameters:

Name Type Description
languageCode string
frequentlyUsedLanguages Object

list of the frequently used languages

Source:
Increment the current language usage by one and save it to the device.