Completed
Push — master ( 2461e8...b569b1 )
by Jean-Christophe
04:01
created

HtmlReveal::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 5
nc 1
nop 5
1
<?php
2
3
namespace Ajax\semantic\html\elements;
4
5
use Ajax\semantic\html\base\HtmlSemDoubleElement;
6
use Ajax\semantic\html\base\constants\RevealType;
7
use Ajax\semantic\html\base\constants\Direction;
8
use Ajax\common\html\html5\HtmlImg;
9
use Ajax\common\html\HtmlSingleElement;
10
11
class HtmlReveal extends HtmlSemDoubleElement {
12
13
	public function __construct($identifier, $visibleContent,$hiddenContent,$type=RevealType::FADE,$attributeType=NULL) {
14
		parent::__construct($identifier, "div", "ui reveal");
15
		$this->setElement(0, $visibleContent);
16
		$this->setElement(1, $hiddenContent);
17
		$this->setType($type,$attributeType);
18
	}
19
20
	private function setElement($index,$content){
21
		if(!$content instanceof HtmlSingleElement){
22
			$content=new HtmlLabel("",$content);
23
		}
24
		if($content instanceof HtmlSemDoubleElement){
25
			$content=new HtmlSemDoubleElement($this->identifier."-".$index,"div","",$content);
26
		}elseif ($content instanceof HtmlImg){
27
			$this->addToPropertyCtrl("class", "image", array("image"));
28
		}
29
		$content->addToProperty("class",(($index===0)?"visible":"hidden")." content");
30
		$this->content[$index]=$content;
31
		return $this;
32
	}
33
34
	public function setVisibleContent($visibleContent){
35
		return $this->setElement(0, $visibleContent);
36
	}
37
38
	public function setHiddenContent($hiddenContent){
39
		return $this->setElement(1, $hiddenContent);
40
	}
41
42
	public function getVisibleContent(){
43
		return $this->content[0];
44
	}
45
46
	public function getHiddenContent(){
47
		return $this->content[1];
48
	}
49
50
	public function setType($type,$attribute=NULL){
51
		$this->addToPropertyCtrl("class", $type, RevealType::getConstants());
52
		if(isset($attribute)){
53
			$this->addToPropertyCtrl("class", $attribute, Direction::getConstants());
54
		}
55
		return $this;
56
	}
57
58
	public function setFade($attribute=NULL){
59
		return $this->setType(RevealType::FADE,$attribute);
60
	}
61
62
	public function setMove($attribute=NULL){
63
		return $this->setType(RevealType::MOVE,$attribute);
64
	}
65
66
	public function setRotate($attribute=NULL){
67
		return $this->setType(RevealType::ROTATE,$attribute);
68
	}
69
70
	public function setCircular(){
71
		return $this->addToProperty("class", "circular");
72
	}
73
74
}