ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 static protected $initialized = false;
11 static protected $library_initialized = false;
12
20 static function addTooltip($a_el_id, $a_text, $a_container = "",
21 $a_my = "bottom center", $a_at = "top center", $a_use_htmlspecialchars = true)
22 {
23 global $tpl;
24
26 if (!self::$initialized)
27 {
28 $tpl->addJavascript("./Services/UIComponent/Tooltip/js/ilTooltip.js");
29 $tpl->addOnLoadCode('il.Tooltip.init();', 3);
30 self::$initialized = true;
31 }
32
33 $code = self::getTooltip($a_el_id, $a_text, $a_container, $a_my, $a_at,
34 $a_use_htmlspecialchars);
35 $tpl->addOnLoadCode($code);
36 }
37
45 static function getToolTip($a_el_id, $a_text, $a_container = "",
46 $a_my = "bottom center", $a_at = "top center", $a_use_htmlspecialchars = true)
47 {
48 $addstr = "";
49
50 // not needed, just make sure the position plugin is included
51// $addstr.= ", position: {viewport: $('#fixed_content')}";
52
53 if ($a_container != "")
54 {
55 $addstr.= ", container: '".$a_container."'";
56 }
57
58 if ($a_use_htmlspecialchars)
59 {
60 $a_text = htmlspecialchars(str_replace(array("\n", "\r"), "", $a_text));
61 }
62 else
63 {
64 $a_text = str_replace(array("\n", "\r", "'", '"'), array("", "", "\'", '\"'), $a_text);
65 }
66 return 'il.Tooltip.add("'.$a_el_id.'", {'.
67 ' context:"'.$a_el_id.'",'.
68 ' my:"'.$a_my.'",'.
69 ' at:"'.$a_at.'",'.
70 ' text:"'.$a_text.'" '.$addstr.'} );';
71 }
72
76 static function initLibrary()
77 {
78 global $tpl;
79
80 if (self::$library_initialized)
81 return;
82
83 // include_once("./Services/YUI/classes/class.ilYuiUtil.php");
84 // ilYuiUtil::initTooltip();
85 $tpl->addCss("./Services/UIComponent/Tooltip/lib/qtip_2_2_1/jquery.qtip.min.css");
86 $tpl->addJavascript("./Services/UIComponent/Tooltip/lib/qtip_2_2_1/jquery.qtip.min.js");
87
88 self::$library_initialized = true;
89 }
90}
91?>
global $tpl
Definition: ilias.php:8
This is a utility class for the yui tooltips.
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 initLibrary()
Initializes the needed tooltip libraries.
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 $library_initialized
$code
Definition: example_050.php:99