Tooltip   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 119
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 119
rs 10
c 0
b 0
f 0
wmc 11

11 Methods

Rating   Name   Duplication   Size   Complexity  
A setDisabled() 0 2 1
A setPosition() 0 2 1
A setShow() 0 2 1
A setHide() 0 2 1
A setContent() 0 2 1
A onOpen() 0 2 1
A setTooltipClass() 0 2 1
A __construct() 0 3 1
A setTrack() 0 2 1
A setItems() 0 2 1
A onClose() 0 2 1
1
<?php
2
namespace Ajax\ui\components;
3
4
use Ajax\JsUtils;
5
use Ajax\ui\properties\Position;
6
use Ajax\common\components\SimpleComponent;
7
8
/**
9
 * Composant JQuery UI Menu
10
 *
11
 * @author jc
12
 * @version 1.001
13
 */
14
class Tooltip extends SimpleComponent {
15
16
	public function __construct(JsUtils $js) {
17
		parent::__construct($js);
18
		$this->uiName = "tooltip";
19
	}
20
21
	/**
22
	 * The content of the tooltip.
23
	 *
24
	 * @param string $value
25
	 *        	string or function
26
	 *        	default : function returning the title attribute
27
	 * @return $this
28
	 */
29
	public function setContent($value) {
30
		return $this->setParam("content", $value);
31
	}
32
33
	/**
34
	 * Disables the tooltip if set to true.
35
	 *
36
	 * @param mixed $value
37
	 *        	default : false
38
	 * @return $this
39
	 */
40
	public function setDisabled($value) {
41
		return $this->setParamCtrl("disabled", $value, "is_bool");
42
	}
43
44
	/**
45
	 * If and how to animate the hiding of the tooltip.
46
	 *
47
	 * @param mixed $value
48
	 *        	default : true
49
	 * @return $this
50
	 */
51
	public function setHide($value) {
52
		return $this->setParam("hide", $value);
53
	}
54
55
	/**
56
	 * A selector indicating which items should show tooltips.
57
	 * Customize if you're using something other then the title attribute for the tooltip content,
58
	 * or if you need a different selector for event delegation.
59
	 *
60
	 * @param string $value
61
	 *        	default : title
62
	 * @return $this
63
	 */
64
	public function setItems($value) {
65
		return $this->setParam("items", $value);
66
	}
67
68
	/**
69
	 * Identifies the position of the tooltip in relation to the associated target element.
70
	 * The of option defaults to the target element, but you can specify another element to position against.
71
	 * You can refer to the jQuery UI Position utility for more details about the various options.
72
	 *
73
	 * @param Position $position
74
	 *        	default : { my: "left top+15", at: "left bottom", collision: "flipfit" }
75
	 * @return $this
76
	 */
77
	public function setPosition(Position $position) {
78
		return $this->setParam("position", $position->getParams());
79
	}
80
81
	/**
82
	 * If and how to animate the showing of the tooltip.
83
	 *
84
	 * @param mixed $value
85
	 *        	default : true
86
	 * @return $this
87
	 */
88
	public function setShow($value) {
89
		return $this->setParam("show", $value);
90
	}
91
92
	/**
93
	 * A class to add to the widget, can be used to display various tooltip types, like warnings or errors.
94
	 * This may get replaced by the classes option.
95
	 *
96
	 * @param string $value
97
	 *        	default : null
98
	 * @return $this
99
	 */
100
	public function setTooltipClass($value) {
101
		return $this->setParam("tooltipclass", $value);
102
	}
103
104
	/**
105
	 * Whether the tooltip should track (follow) the mouse.
106
	 *
107
	 * @param Boolean $value
108
	 *        	default :false
109
	 * @return $this
110
	 */
111
	public function setTrack($value) {
112
		return $this->setParamCtrl("track", $value, "is_bool");
113
	}
114
115
	/**
116
	 * Triggered when a tooltip is closed, triggered on focusout or mouseleave.
117
	 *
118
	 * @param string $jsCode
119
	 * @return $this
120
	 */
121
	public function onClose($jsCode) {
122
		return $this->addEvent("close", $jsCode);
123
	}
124
125
	/**
126
	 * Triggered when a tooltip is shown, triggered on focusin or mouseover.
127
	 *
128
	 * @param string $jsCode
129
	 * @return $this
130
	 */
131
	public function onOpen($jsCode) {
132
		return $this->addEvent("open", $jsCode);
133
	}
134
}
135