ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\UI\Implementation\Render\ilJavaScriptBinding Class Reference

Wraps global ilTemplate to provide JavaScriptBinding. More...

+ Inheritance diagram for ILIAS\UI\Implementation\Render\ilJavaScriptBinding:
+ Collaboration diagram for ILIAS\UI\Implementation\Render\ilJavaScriptBinding:

Public Member Functions

 __construct (private \ILIAS\UICore\GlobalTemplate $global_tpl,)
 
 createId ()
 Create a fresh unique id.This MUST return a new id on every call. More...
 
 addOnLoadCode (string $code)
 Add some JavaScript-statements to the on-load handler of the page. More...
 
 getOnLoadCodeAsync ()
 Get all the registered on-load javascript code for the async context, e.g.return all code inside <script> tags More...
 
 createId ()
 Create a fresh unique id. More...
 
 addOnLoadCode (string $code)
 Add some JavaScript-statements to the on-load handler of the page. More...
 
 getOnLoadCodeAsync ()
 Get all the registered on-load javascript code for the async context, e.g. More...
 

Data Fields

const PREFIX = "il_ui_fw_"
 

Protected Attributes

array $code = array()
 Cache for all registered JS code. More...
 

Detailed Description

Wraps global ilTemplate to provide JavaScriptBinding.

Definition at line 26 of file ilJavaScriptBinding.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\UI\Implementation\Render\ilJavaScriptBinding::__construct ( private \ILIAS\UICore\GlobalTemplate  $global_tpl)

Definition at line 35 of file ilJavaScriptBinding.php.

37 {
38 }

Member Function Documentation

◆ addOnLoadCode()

ILIAS\UI\Implementation\Render\ilJavaScriptBinding::addOnLoadCode ( string  $code)

Add some JavaScript-statements to the on-load handler of the page.

Implements ILIAS\UI\Implementation\Render\JavaScriptBinding.

Definition at line 51 of file ilJavaScriptBinding.php.

51 : void
52 {
53 $this->global_tpl->addOnLoadCode($code, 1);
54 $this->code[] = $code;
55 }
array $code
Cache for all registered JS code.

References ILIAS\UI\Implementation\Render\ilJavaScriptBinding\$code.

◆ createId()

ILIAS\UI\Implementation\Render\ilJavaScriptBinding::createId ( )

Create a fresh unique id.This MUST return a new id on every call.

Implements ILIAS\UI\Implementation\Render\JavaScriptBinding.

Definition at line 43 of file ilJavaScriptBinding.php.

43 : string
44 {
45 return str_replace(".", "_", uniqid(self::PREFIX, true));
46 }

◆ getOnLoadCodeAsync()

ILIAS\UI\Implementation\Render\ilJavaScriptBinding::getOnLoadCodeAsync ( )

Get all the registered on-load javascript code for the async context, e.g.return all code inside <script> tags

Implements ILIAS\UI\Implementation\Render\JavaScriptBinding.

Definition at line 60 of file ilJavaScriptBinding.php.

60 : string
61 {
62 if (!count($this->code)) {
63 return '';
64 }
65 $js_out = '<script data-replace-marker="script">' . implode("\n", $this->code) . '</script>';
66 $this->code = [];
67 return $js_out;
68 }

Field Documentation

◆ $code

array ILIAS\UI\Implementation\Render\ilJavaScriptBinding::$code = array()
protected

Cache for all registered JS code.

Definition at line 33 of file ilJavaScriptBinding.php.

Referenced by ILIAS\UI\Implementation\Render\ilJavaScriptBinding\addOnLoadCode().

◆ PREFIX

const ILIAS\UI\Implementation\Render\ilJavaScriptBinding::PREFIX = "il_ui_fw_"

Definition at line 28 of file ilJavaScriptBinding.php.


The documentation for this class was generated from the following file: