__construct()
__construct(string $key, \cms_config $config)
Constructor
Parameters
| string | $key | A static key that is used in the unique naming of generated files. |
| \cms_config | $config | The cms config instance to use. |
A utility class to manage loading and combining javascript libraries and associated stylesheets.
register(\CGExtensions\jsloader\libdefn $rec, boolean $force = FALSE)
Register a library definition
| \CGExtensions\jsloader\libdefn | $rec | The library definition to register. |
| boolean | $force | Force the libdefn to be registered even if it already has been. |
add_jsfile(string $file, null|array<mixed,string> $depends = null, boolean $nominify = false)
For this request, add a specified javascript file.
| string | $file | The complete pathname to the javascript file. |
| null|array<mixed,string> | $depends | array of library names (must already be registered) that this file depends upon. |
| boolean | $nominify | If true, the library code will not be minified. |
add_js(string $code, null|array<mixed,string> $depends = null, boolean $nominify = true, boolean $append = false)
Add javascript code to the output for this request.
| string | $code | The javascript code (script tags are not required) |
| null|array<mixed,string> | $depends | Array of required javascript libraries. |
| boolean | $nominify | If true, the library code will not be minified. |
| boolean | $append | If true, this code will be appended after all other scripts.. otherwise included in order |
add_cssfile(string $file, null|array<mixed,string> $depends = null, boolean $nominify = true)
Add a css file to the output.
| 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|array<mixed,string> | $depends | Array of libraries that this css file depends upon. |
| boolean | $nominify | If true, the library code will not be minified. |
add_css(string $styles, array $depends = null, boolean $nominify = true, boolean $append = false)
Add static css text to the output.
| string | $styles | The static CSS text (style tags are not needed). |
| array | $depends | A list of libraries that this css depends upon. |
| boolean | $nominify | If true, the library code will not be minified. |
| boolean | $append | If true, this code will be appended after all other scripts.. otherwise included in order |
render(array $opts = null) : string
Render the output javascript and stylesheets into cachable files and output the appropriate HTML tags.
This function actually adds appropriate hook handlers to process the rendering of css and js tags during the final process of HTML rendering this removes all problems with smarty processing orders.
| array | $opts | Options for this method (for further reference, see the {cgjs_render} smarty tag. |
HTML output code.