ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilOverlayGUI.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 $width = "";
11 protected $height = "";
12 protected $fixed_center = false;
13 protected $visible = false;
14 protected $anchor_el_id = "";
15 protected $anchor_ov_corner = "";
16 protected $anchor_anch_corner = "";
17 protected $auto_hide = false;
18 protected $close_el = null;
19
26 function __construct($a_overlay_el_id)
27 {
28 $this->overlay_el_id = $a_overlay_el_id;
29 }
30
38 function setAnchor($a_anchor_el_id, $a_ov_corner = "tl", $a_anch_corner = "bl")
39 {
40 $this->anchor_el_id = $a_anchor_el_id;
41 $this->anchor_ov_corner = $a_ov_corner;
42 $this->anchor_anch_corner = $a_anch_corner;
43 }
44
51 function setSize($a_width = "", $a_height = "")
52 {
53 $this->width = $a_width;
54 $this->height = $a_height;
55 }
56
62 function setFixedCenter($a_fixed_center = true)
63 {
64 $this->fixed_center = $a_fixed_center;
65 }
66
72 function setVisible($a_visible = true)
73 {
74 $this->visible = $a_visible;
75 }
76
83 function setTrigger($a_el_id, $a_event = "click", $a_trigger_anchor_el_id = null)
84 {
85 $this->trigger_el_id = $a_el_id;
86 $this->trigger_event = $a_event;
87 $this->trigger_anchor_el_id = $a_trigger_anchor_el_id;
88 }
89
95 function setAutoHide($a_val)
96 {
97 $this->auto_hide = $a_val;
98 }
99
105 function getAutoHide()
106 {
107 return $this->auto_hide;
108 }
109
115 function setCloseElementId($a_val)
116 {
117 $this->close_el = $a_val;
118 }
119
126 {
127 return $this->close_el;
128 }
129
133 function getOnLoadCode()
134 {
135 // yui cfg string
136 $yuicfg["visible"] = $this->visible ? true : false;
137
138 if ($this->width != "")
139 {
140 $yuicfg["width"] = $this->width;
141 }
142
143 if ($this->height != "")
144 {
145 $yuicfg["height"] = $this->height;
146 }
147 $yuicfg["fixedcenter"] = $this->fixed_center ? true : false;
148 if ($this->anchor_el_id != "")
149 {
150 $yuicfg["context"] = array($this->anchor_el_id, $this->anchor_ov_corner,
151 $this->anchor_anch_corner, array("beforeShow", "windowResize"));
152 }
153 // general cfg string
154 $cfg["yuicfg"] = $yuicfg;
155 $cfg["trigger"] = $this->trigger_el_id;
156 $cfg["trigger_event"] = $this->trigger_event;
157 $cfg["anchor_id"] = $this->trigger_anchor_el_id;
158 $cfg["auto_hide"] = $this->auto_hide;
159 $cfg["close_el"] = $this->close_el;
160
161 include_once("./Services/JSON/classes/class.ilJsonUtil.php");
162//var_dump(ilJsonUtil::encode($cfg));
163 return 'il.Overlay.add("'.$this->overlay_el_id.'", '.
164 ilJsonUtil::encode($cfg).'); ';
165 }
166
170 function add()
171 {
172 global $tpl;
173 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
174
176 $tpl->addOnLoadCode($this->getOnLoadCode());
177 }
178
185 static function initJavascript()
186 {
187 global $tpl;
188
189 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
191 $tpl->addJavascript("./Services/UIComponent/Overlay/js/ilOverlay.js");
192 }
193
194
201 function getTriggerOnLoadCode($a_tr_id, $a_tr_event, $a_anchor_el_id, $a_center = false,
202 $a_ov_corner = "tl", $a_anch_corner = "bl")
203 {
204 $center = ($a_center) ? "true" : "false";
205 return 'il.Overlay.addTrigger("'.$a_tr_id.'","'.$a_tr_event.'","'.$this->overlay_el_id.'","'.
206 $a_anchor_el_id.'", '.$center.',"'.$a_ov_corner.'","'.$a_anch_corner.'"); ';
207 }
208
212 function addTrigger($a_tr_id, $a_tr_event, $a_anchor_el_id, $a_center = false,
213 $a_ov_corner = "tl", $a_anch_corner = "bl")
214 {
215 global $tpl;
216 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
217//echo "-".$a_tr_id."-".$a_tr_event."-".$a_anchor_el_id."-";
219 $tpl->addOnLoadCode($this->getTriggerOnLoadCode($a_tr_id, $a_tr_event, $a_anchor_el_id, $a_center,
220 $a_ov_corner, $a_anch_corner));
221 }
222
223
224
225}
226?>
global $tpl
Definition: ilias.php:8
static encode($mixed, $suppress_native=false)
This is a utility class for the yui overlays.
static initJavascript()
Init javascript.
setSize($a_width="", $a_height="")
Set size.
setAnchor($a_anchor_el_id, $a_ov_corner="tl", $a_anch_corner="bl")
Set anchor element.
getCloseElementId()
Get close element id.
setVisible($a_visible=true)
Set visible.
setAutoHide($a_val)
Set auto hiding.
__construct($a_overlay_el_id)
Constructor.
addTrigger($a_tr_id, $a_tr_event, $a_anchor_el_id, $a_center=false, $a_ov_corner="tl", $a_anch_corner="bl")
Add trigger.
getAutoHide()
Get auto_hide.
setFixedCenter($a_fixed_center=true)
Set fixed center.
setTrigger($a_el_id, $a_event="click", $a_trigger_anchor_el_id=null)
Set trigger element.
setCloseElementId($a_val)
Set close element id.
getOnLoadCode()
Makes an existing HTML element an overlay.
getTriggerOnLoadCode($a_tr_id, $a_tr_event, $a_anchor_el_id, $a_center=false, $a_ov_corner="tl", $a_anch_corner="bl")
Get trigger onload code.
add()
Makes an existing HTML element an overlay.
static initOverlay()
Init YUI Overlay module.