ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilJavaScriptBinding.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2016 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
6 
11 {
12  const PREFIX = "il_ui_fw_";
13 
17  private $global_tpl;
18 
24  protected $code = array();
25 
27  {
28  $this->global_tpl = $global_tpl;
29  }
30 
34  public function createId()
35  {
36  return str_replace(".", "_", uniqid(self::PREFIX, true));
37  }
38 
42  public function addOnLoadCode($code)
43  {
44  $this->global_tpl->addOnLoadCode($code);
45  $this->code[] = $code;
46  }
47 
51  public function getOnLoadCodeAsync()
52  {
53  if (!count($this->code)) {
54  return '';
55  }
56  $js_out = '<script>' . implode("\n", $this->code) . '</script>';
57  $this->code = [];
58  return $js_out;
59  }
60 }
createId()
Create a fresh unique id.This MUST return a new id on every call.string
Wraps global ilTemplate to provide JavaScriptBinding.
getOnLoadCodeAsync()
Get all the registered on-load javascript code for the async context, e.g.return all code inside <scr...
special template class to simplify handling of ITX/PEAR
Provides methods to interface with javascript.
Create styles array
The data for the language used.
addOnLoadCode($code)
Add some JavaScript-statements to the on-load handler of the page.null