ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
125  function getCloseElementId()
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 ?>