Class: util

util()

new util()

Utility library

Source:

Members

Promise

Wrapper class for Promises

Source:

Methods

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

Deferred() → {jQuery.Deferred}

Wrapper class for the Deferred method

Source:
Returns:
Type
jQuery.Deferred

docReady(fn) → {jQuery.Object}

Run method when document is ready.

Parameters:
Name Type Description
fn function
Source:
Returns:
Type
jQuery.Object

escapeHash(hash) → {string}

Escape dots and colons in a hash, jQuery doesn't like them because they look like CSS classes and pseudoclasses. See http://bugs.jquery.com/ticket/5241 http://stackoverflow.com/questions/350292/how-do-i-get-jquery-to-select-elements-with-a-period-in-their-id

Parameters:
Name Type Description
hash string

A hash to escape

Source:
Returns:
Type
string

escapeSelector(selector) → {string}

Escape a string for use as a css selector

Parameters:
Name Type Description
selector string
Source:
Returns:
Type
string

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

getDir(language) → {Object}

Determine whether a language is LTR or RTL This works around T74153 and T189036

Parameters:
Name Type Description
language Object

with 'lang' key.

Source:
Returns:

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

Type
Object

getDocument() → {jQuery.Object}

Adds a class to the document

Source:
Returns:

element representing the documentElement

Type
jQuery.Object

getFrequentlyUsedLanguages() → {Object}

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

Source:
Returns:
Type
Object

getStructuredLanguages(languages, variants, frequentlyUsedLanguages, deviceLanguageopt) → {StructuredLanguages}

Return two sets of languages: suggested and all (everything else)

Suggested languages are the ones that the user has used before. This also includes the user device's primary language. Suggested languages are ordered by frequency in descending order. The device's language is always at the top. This group also includes the variants.

All languages are the languages that are not suggested. Languages in this list are ordered in the lexicographical order of their language names.

Parameters:
Name Type Attributes Description
languages Array.<Object>

list of language objects as returned by the API

variants Array | boolean

language variant objects or false if no variants exist

frequentlyUsedLanguages Object

list of the frequently used languages

deviceLanguage string <optional>

the device's primary language

Source:
Returns:
Type
StructuredLanguages

getWindow() → {jQuery.Object}

Get the window object

Source:
Returns:
Type
jQuery.Object

grep() → {jQuery.Deferred}

Wrapper class for the $.grep

Source:
Returns:
Type
jQuery.Deferred

isModifiedEvent(ev) → {boolean}

Heuristic for determining whether an Event should be handled by MobileFrontend or allowed to bubble to the browser.

Parameters:
Name Type Description
ev Event
Source:
Returns:

True if event is modified with control, alt, meta, or shift keys and should probably be handled by the browser.

todo: move this function to a ClickUtil file once bundling and code splitting is supported.

Type
boolean

isNumeric() → {boolean}

wrapper for jQuery util function to check if something is numeric

Source:
Returns:
Type
boolean

parseHTML(html, ctxopt) → {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

saveFrequentlyUsedLanguages(languageMap)

Save the frequently used languages to the user's device

Parameters:
Name Type Description
languageMap Object
Source:

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:

util()

new util()

Utility function for the structured language overlay

Source:

Members

Promise

Wrapper class for Promises

Source:

Methods

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

Deferred() → {jQuery.Deferred}

Wrapper class for the Deferred method

Source:
Returns:
Type
jQuery.Deferred

docReady(fn) → {jQuery.Object}

Run method when document is ready.

Parameters:
Name Type Description
fn function
Source:
Returns:
Type
jQuery.Object

escapeHash(hash) → {string}

Escape dots and colons in a hash, jQuery doesn't like them because they look like CSS classes and pseudoclasses. See http://bugs.jquery.com/ticket/5241 http://stackoverflow.com/questions/350292/how-do-i-get-jquery-to-select-elements-with-a-period-in-their-id

Parameters:
Name Type Description
hash string

A hash to escape

Source:
Returns:
Type
string

escapeSelector(selector) → {string}

Escape a string for use as a css selector

Parameters:
Name Type Description
selector string
Source:
Returns:
Type
string

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

getDir(language) → {Object}

Determine whether a language is LTR or RTL This works around T74153 and T189036

Parameters:
Name Type Description
language Object

with 'lang' key.

Source:
Returns:

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

Type
Object

getDocument() → {jQuery.Object}

Adds a class to the document

Source:
Returns:

element representing the documentElement

Type
jQuery.Object

getFrequentlyUsedLanguages() → {Object}

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

Source:
Returns:
Type
Object

getStructuredLanguages(languages, variants, frequentlyUsedLanguages, deviceLanguageopt) → {StructuredLanguages}

Return two sets of languages: suggested and all (everything else)

Suggested languages are the ones that the user has used before. This also includes the user device's primary language. Suggested languages are ordered by frequency in descending order. The device's language is always at the top. This group also includes the variants.

All languages are the languages that are not suggested. Languages in this list are ordered in the lexicographical order of their language names.

Parameters:
Name Type Attributes Description
languages Array.<Object>

list of language objects as returned by the API

variants Array | boolean

language variant objects or false if no variants exist

frequentlyUsedLanguages Object

list of the frequently used languages

deviceLanguage string <optional>

the device's primary language

Source:
Returns:
Type
StructuredLanguages

getWindow() → {jQuery.Object}

Get the window object

Source:
Returns:
Type
jQuery.Object

grep() → {jQuery.Deferred}

Wrapper class for the $.grep

Source:
Returns:
Type
jQuery.Deferred

isModifiedEvent(ev) → {boolean}

Heuristic for determining whether an Event should be handled by MobileFrontend or allowed to bubble to the browser.

Parameters:
Name Type Description
ev Event
Source:
Returns:

True if event is modified with control, alt, meta, or shift keys and should probably be handled by the browser.

todo: move this function to a ClickUtil file once bundling and code splitting is supported.

Type
boolean

isNumeric() → {boolean}

wrapper for jQuery util function to check if something is numeric

Source:
Returns:
Type
boolean

parseHTML(html, ctxopt) → {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

saveFrequentlyUsedLanguages(languageMap)

Save the frequently used languages to the user's device

Parameters:
Name Type Description
languageMap Object
Source:

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: