\CGExtensions\jsloaderjsloader

A utility class to manage loading and combining javascript libraries and associated stylesheets.

Summary

Methods
Properties
Constants
register()
unregister_by_module()
require_lib()
add_jsext()
add_jsfile()
add_js()
add_cssfile()
add_css()
render()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

register()

register(\CGExtensions\jsloader\libdefn $rec, bool $force)

Register a library definition

Parameters

\CGExtensions\jsloader\libdefn $rec

The library definition to register.

bool $force

Force the libdefn to be registered even if it already has been.

unregister_by_module()

unregister_by_module(string $module_name)

Unregister all javascript libraries associated with a module.

Parameters

string $module_name

require_lib()

require_lib(string $name, bool $nominify)

For this request, indicate that a javascript library is required.

Parameters

string $name
bool $nominify

If true, the library code will not be minified.

add_jsext()

add_jsext(string $url, bool $nominify)

Add an external javascript library.

[experimental]

Parameters

string $url
bool $nominify

If true, the library code will not be minified.

add_jsfile()

add_jsfile(string $file, null|string[] $depends, bool $nominify)

For this request, add a specified javascript file.

Parameters

string $file

The complete pathname to the javascript file.

null|string[] $depends

array of library names (must already be registered) that this file depends upon.

bool $nominify

If true, the library code will not be minified.

add_js()

add_js(string $code, null|string[] $depends, bool $nominify)

Add javascript code to the output for this request.

Parameters

string $code

The javascript code (script tags are not required)

null|string[] $depends

Array of required javascript libraries.

bool $nominify

If true, the library code will not be minified.

add_cssfile()

add_cssfile(string $file, null|string[] $depends, bool $nominify)

Add a css file to the output.

Parameters

string $file

The filename. If not an absolute path, then search for the file within the current module directory (if any), the uploads path, and then the root path.

null|string[] $depends

Array of libraries that this css file depends upon.

bool $nominify

If true, the library code will not be minified.

add_css()

add_css(string $styles, array $depends, bool $nominify)

Add static css text to the output.

Parameters

string $styles

The static CSS text (style tags are not needed).

array $depends

A list of libraries that this css depends upon.

bool $nominify

If true, the library code will not be minified.

render()

render(array $opts) : string

Render the output javascript and stylesheets into cachable files and output the appropriate HTML tags.

Parameters

array $opts

Options for this method (for further reference, see the {cgjs_render} smarty tag.

Returns

string —

HTML output code.