ExtensionUtils

Description

ExtensionUtils defines utility methods for implementing extensions.

Functions Summary

Functions

Public API

addEmbeddedStyleSheet

Appends a <style> tag to the document's head.

css non-nullable string
CSS code to use as the tag's content
Returns: !HTMLStyleElement
The generated HTML node
Public API

addLinkedStyleSheet

Appends a <link> tag to the document's head.

url non-nullable string
URL to a style sheet
deferred optional $.Deferred
Optionally check for load and error events
Returns: !HTMLLinkElement
The generated HTML node
Public API

getModulePath

Returns a path to an extension module.

module non-nullable module
Module provided by RequireJS
path nullable string
Relative path from the extension folder to a file
Returns: !string
The path to the module's folder
Public API

getModuleUrl

Returns a URL to an extension module.

module non-nullable module
Module provided by RequireJS
path nullable string
Relative path from the extension folder to a file
Returns: !string
The URL to the module's folder
Public API

loadFile

Performs a GET request using a path relative to an extension module.

The resulting URL can be retrieved in the resolve callback by accessing

module non-nullable module
Module provided by RequireJS
path non-nullable string
Relative path from the extension folder to a file
Returns: !$.Promise
A promise object that is resolved with the contents of the requested file
Public API

loadStyleSheet

Loads a style sheet (CSS or LESS) relative to the extension module.

module non-nullable module
Module provided by RequireJS
path non-nullable string
Relative path from the extension folder to a CSS or LESS file
Returns: !$.Promise
A promise object that is resolved with an HTML node if the file can be loaded.
Public API

parseLessCode

Parses LESS code and returns a promise that resolves with plain CSS code.

Pass the {@link url} argument to resolve relative URLs contained in the code. Make sure URLs in the code are wrapped in quotes, like so: background-image: url("image.png");

code non-nullable string
LESS code to parse
url nullable string
URL to the file containing the code
Returns: !$.Promise
A promise object that is resolved with CSS code if the LESS code can be parsed