|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\content; |
|
4
|
|
|
|
|
5
|
|
|
use Ajax\semantic\html\base\HtmlSemDoubleElement; |
|
6
|
|
|
use Ajax\semantic\html\elements\HtmlIcon; |
|
7
|
|
|
use Ajax\JsUtils; |
|
8
|
|
|
use Phalcon\Mvc\View; |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
class HtmlAccordionItem extends HtmlSemDoubleElement { |
|
12
|
|
|
protected $titleElement; |
|
13
|
|
|
protected $_icon="dropdown"; |
|
14
|
|
|
protected $_title; |
|
15
|
|
|
protected $_active; |
|
16
|
|
|
|
|
17
|
|
|
public function __construct($identifier, $title, $content=NULL) { |
|
18
|
|
|
parent::__construct($identifier, "div", "content", $content); |
|
19
|
|
|
$this->_template="%titleElement%".$this->_template; |
|
20
|
|
|
$this->_title=$title; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function setTitle($title){ |
|
24
|
|
|
$this->_title=$title; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function setIcon($icon){ |
|
28
|
|
|
$this->_icon=$icon; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
protected function createTitleElement(){ |
|
32
|
|
|
$element=new HtmlSemDoubleElement("title-".$this->identifier,"div","title"); |
|
33
|
|
|
$element->setContent(array(new HtmlIcon("", $this->_icon),$this->_title)); |
|
34
|
|
|
if($this->_active===true) |
|
35
|
|
|
$element->addToProperty("class", "active"); |
|
36
|
|
|
return $element; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function compile(JsUtils $js=NULL, View $view=NULL){ |
|
40
|
|
|
$this->titleElement=$this->createTitleElement(); |
|
41
|
|
|
return parent::compile($js,$view); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function setActive($value=true){ |
|
45
|
|
|
$this->_active=$value; |
|
46
|
|
|
if($value===true) |
|
47
|
|
|
$this->addToPropertyCtrl("class", "active", array("active")); |
|
48
|
|
|
else |
|
49
|
|
|
$this->removePropertyValue("class", "active"); |
|
50
|
|
|
return $this; |
|
51
|
|
|
} |
|
52
|
|
|
} |