MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mexpanddiv.class
Ir para a documentação deste ficheiro.
1<?php
2
27$MIOLO->page->addScript('m_expanddiv.js');
28
29class MExpandDiv extends MDiv
30{
34 const STYLE_COLLAPSED = 'mExpandDivButton mExpandDivButtonCollapsed';
35 const STYLE_EXPANDED = 'mExpandDivButton mExpandDivButtonExpanded';
36 const STYLE_TEXT = 'mExpandDivText';
37
41 private $boxDiv;
42
46 private $collapsedHeight;
47
51 private $content;
52
56 private $expandButton;
57
61 private $expandedOnLoad = false;
62
72 public function __construct($name, $content, $class=NULL, $attributes=NULL, $collapsedHeight=null, $title = null)
73 {
74 $id = $name ? "{$name}box" : 'box' . rand();
75
76 if ( !$collapsedHeight )
77 {
78 $collapsedHeight = 15;
79 }
80
81 if ( $title )
82 {
83 $label = new MLabel($title);
84 $label->setBold(true);
85
86 $content = array( $label, new MSeparator(), $content );
87 }
88
89// $this->setContent($content);
90 $this->collapsedHeight = $collapsedHeight;
91 $this->boxDiv = new MDiv($id, $content, self::STYLE_TEXT);
92
93 $onclick = "mexpanddiv.expand('{$this->boxDiv->id}', '{$this->collapsedHeight}');";
94 $this->expandButton = new MDiv("{$id}Button", '', self::STYLE_COLLAPSED, array('onclick' => $onclick));
95
96 $div[] = new MDiv("{$id}Div", array( $this->expandButton, $this->boxDiv ));
97
98 parent::__construct($name, $div, $class, $attributes);
99 }
100
104 public function getBox()
105 {
106 return $this->boxDiv;
107 }
108
112 public function setBox($box)
113 {
114 $this->boxDiv = $box;
115 }
116
120 public function getCollapsedHeight()
121 {
122 return $this->collapsedHeight;
123 }
124
128 public function setCollapsedHeight($collapsedHeight)
129 {
130 $this->collapsedHeight = $collapsedHeight;
131 }
132
136 public function getContent2()
137 {
138 return $this->content;
139 }
140
148 public function setContent2($content)
149 {
150// $this->content = $content;
151 $this->content = nl2br(trim((string) $content));
152 }
153
157 public function getExpandButton()
158 {
159 return $this->expandButton;
160 }
161
165 public function setExpandButton($expandButton)
166 {
167 $this->expandButton = $expandButton;
168 }
169
173 public function getExpandedOnLoad()
174 {
175 return $this->expandedOnLoad;
176 }
177
181 public function setExpandedOnLoad($expandedOnLoad)
182 {
183 $this->expandedOnLoad = $expandedOnLoad;
184 }
185
189 public function generate()
190 {
191 if ( !$this->expandedOnLoad )
192 {
193 $this->boxDiv->addStyle('height', "{$this->collapsedHeight}px");
194 }
195 else
196 {
197 $this->expandButton->setClass(self::STYLE_EXPANDED);
198 }
199
200// $this->boxDiv->setInner($this->content);
201// $this->expandButton->addAttribute('onclick', "mexpanddiv.expand('{$this->boxDiv->id}', '{$this->collapsedHeight}');");
202
203 return parent::generate();
204 }
205}
206
207?>
setExpandedOnLoad($expandedOnLoad)
__construct($name, $content, $class=NULL, $attributes=NULL, $collapsedHeight=null, $title=null)
setContent2($content)
const STYLE_TEXT
setCollapsedHeight($collapsedHeight)
const STYLE_COLLAPSED
const STYLE_EXPANDED
setExpandButton($expandButton)
static getInstance()
Definição miolo.class:134
$MIOLO
$title
Definição base.php:3