ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTooltipGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
10  protected static $initialized = false;
11  protected static $library_initialized = false;
12 
20  public static function addTooltip(
21  $a_el_id,
22  $a_text,
23  $a_container = "",
24  $a_my = "bottom center",
25  $a_at = "top center",
26  $a_use_htmlspecialchars = true
27  ) {
28  // to get rid of globals here, we need to change the
29  // process in learning modules, e.g. which does not work with $DIC (since it does not
30  // use the standard template)
31  $tpl = $GLOBALS["tpl"];
32 
33  self::init();
34 
35  $code = self::getTooltip(
36  $a_el_id,
37  $a_text,
38  $a_container,
39  $a_my,
40  $a_at,
41  $a_use_htmlspecialchars
42  );
43  $tpl->addOnLoadCode($code);
44  }
45 
53  public static function getToolTip(
54  $a_el_id,
55  $a_text,
56  $a_container = "",
57  $a_my = "bottom center",
58  $a_at = "top center",
59  $a_use_htmlspecialchars = true
60  ) {
61  $addstr = "";
62 
63  // not needed, just make sure the position plugin is included
64  // $addstr.= ", position: {viewport: $('#fixed_content')}";
65 
66  if ($a_container != "") {
67  $addstr .= ", container: '" . $a_container . "'";
68  }
69 
70  if ($a_use_htmlspecialchars) {
71  $a_text = htmlspecialchars(str_replace(array("\n", "\r"), "", $a_text));
72  } else {
73  $a_text = str_replace(array("\n", "\r", "'", '"'), array("", "", "\'", '\"'), $a_text);
74  }
75  return 'il.Tooltip.add("' . $a_el_id . '", {' .
76  ' context:"' . $a_el_id . '",' .
77  ' my:"' . $a_my . '",' .
78  ' at:"' . $a_at . '",' .
79  ' text:"' . $a_text . '" ' . $addstr . '} );';
80  }
81 
85  public static function init()
86  {
87  // for globals use, see comment above
88  $tpl = $GLOBALS["tpl"];
89 
90  if (!self::$initialized) {
91  $tpl->addCss("./libs/bower/bower_components/qtip2/dist/jquery.qtip.min.css");
92  $tpl->addJavascript("./libs/bower/bower_components/qtip2/dist/jquery.qtip.min.js");
93  $tpl->addJavascript("./Services/UIComponent/Tooltip/js/ilTooltip.js");
94  $tpl->addOnLoadCode('il.Tooltip.init();', 3);
95  self::$initialized = true;
96  }
97  }
98 }
static addTooltip( $a_el_id, $a_text, $a_container="", $a_my="bottom center", $a_at="top center", $a_use_htmlspecialchars=true)
Adds a tooltip to an HTML element.
static init()
Initializes the needed tooltip libraries.
$tpl
Definition: ilias.php:10
$code
Definition: example_050.php:99
static getToolTip( $a_el_id, $a_text, $a_container="", $a_my="bottom center", $a_at="top center", $a_use_htmlspecialchars=true)
Get tooltip js code.
static $library_initialized
while(count($oldTaskList) > 0) foreach(array_keys($newTaskList) as $task) init()
Definition: build.php:77
This is a utility class for the yui tooltips.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.