|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\modules; |
|
4
|
|
|
|
|
5
|
|
|
use Ajax\semantic\html\base\HtmlSemDoubleElement; |
|
6
|
|
|
use Ajax\JsUtils; |
|
7
|
|
|
use Ajax\common\html\BaseHtml; |
|
8
|
|
|
use Ajax\semantic\html\collections\HtmlGrid; |
|
9
|
|
|
use Ajax\semantic\html\elements\HtmlList; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class HtmlPopup extends HtmlSemDoubleElement { |
|
13
|
|
|
private $params; |
|
14
|
|
|
private $_container; |
|
15
|
|
|
public function __construct(BaseHtml $container,$identifier, $content="") { |
|
16
|
|
|
parent::__construct($identifier, "div"); |
|
17
|
|
|
$this->_container=$container; |
|
18
|
|
|
$this->setClass("ui popup"); |
|
19
|
|
|
$this->content=$content; |
|
20
|
|
|
$this->params=array("on"=>"hover"); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function addList($items=array(),$header=NULL){ |
|
24
|
|
|
if(!$this->content instanceof HtmlGrid){ |
|
25
|
|
|
$this->content=new HtmlGrid("grid-".$this->identifier,1); |
|
26
|
|
|
} |
|
27
|
|
|
$grid=$this->content; |
|
28
|
|
|
|
|
29
|
|
|
$colCount=$grid->colCount(); |
|
30
|
|
|
$grid->setNumCols(++$colCount); |
|
31
|
|
|
|
|
32
|
|
|
$list=new HtmlList("",$items); |
|
33
|
|
|
$list->asLink(); |
|
34
|
|
|
if(isset($header)){ |
|
35
|
|
|
$list->addHeader(4,$header); |
|
36
|
|
|
} |
|
37
|
|
|
$grid->getCell(0,$colCount-1)->setContent($list); |
|
38
|
|
|
$grid->setDivided(); |
|
39
|
|
|
return $list; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* A popup can have no maximum width and continue to flow to fit its content |
|
44
|
|
|
*/ |
|
45
|
|
|
public function setFlowing(){ |
|
46
|
|
|
return $this->addToProperty("class", "flowing"); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* A popup can provide more basic formatting |
|
51
|
|
|
*/ |
|
52
|
|
|
public function setBasic(){ |
|
53
|
|
|
return $this->addToProperty("class", "basic"); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* {@inheritDoc} |
|
58
|
|
|
* @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
|
59
|
|
|
*/ |
|
60
|
|
|
public function run(JsUtils $js){ |
|
61
|
|
|
$this->params["popup"]="#".$this->identifier; |
|
62
|
|
|
$js->semantic()->popup("#".$this->_container->getIdentifier(),$this->params); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function setOn($event="click"){ |
|
66
|
|
|
$this->params["on"]=$event; |
|
67
|
|
|
return $this; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function setInline($value=true){ |
|
71
|
|
|
$this->params["inline"]=$value; |
|
72
|
|
|
return $this; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function setPosition($position){ |
|
76
|
|
|
$this->params["position"]=$position; |
|
77
|
|
|
return $this; |
|
78
|
|
|
} |
|
79
|
|
|
} |