ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
95 // use setTimeout as a workaround, since the last parameter is ignored
96 $tpl->addOnLoadCode('setTimeout(function() {il.Tooltip.init();}, 500);', 3);
97 self::$initialized = true;
98 }
99 }
100}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
This is a utility class for the yui tooltips.
static $library_initialized
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 init()
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.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl