Passed
Push — master ( e756b0...18a30f )
by Jean-Christophe
02:08
created

HtmlDimmer::jsShow()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Ajax\semantic\html\modules;
3
4
use Ajax\semantic\html\base\HtmlSemDoubleElement;
5
use Ajax\semantic\html\elements\HtmlHeader;
6
use Ajax\JsUtils;
7
use Ajax\common\html\HtmlSingleElement;
8
9
class HtmlDimmer extends HtmlSemDoubleElement {
10
11
	private $_container;
12
13
	private $_inverted;
14
15
	public function __construct($identifier, $content = NULL) {
16
		parent::__construct($identifier, "div", "ui dimmer");
17
		$this->setContent($content);
18
		$this->_inverted = false;
19
	}
20
21
	public function setContent($content) {
22
		$this->content = new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content));
23
		return $this;
24
	}
25
26
	public function asIcon($icon, $title, $subHeader = NULL) {
27
		$header = new HtmlHeader("header-" . $this->identifier);
28
		$header->asIcon($icon, $title, $subHeader);
29
		if ($this->_inverted === false)
30
			$header->setInverted();
31
		return $this->setContent($header);
32
	}
33
34
	public function asPage() {
35
		return $this->addToProperty("class", "page");
36
	}
37
38
	public function setInverted($recursive = true) {
39
		parent::setInverted($recursive);
40
		$this->_inverted = true;
41
		return $this;
42
	}
43
44
	public function run(JsUtils $js) {
45
		if ($this->_container instanceof HtmlSingleElement) {
46
			$this->_bsComponent = $js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params);
47
		} else {
48
			$this->_bsComponent = $js->semantic()->dimmer("#" . $this->identifier, $this->_params);
49
		}
50
		return parent::run($js);
51
	}
52
53
	public function jsShow() {
54
		if (isset($this->_container))
55
			return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");';
56
	}
57
58
	public function setBlurring() {
59
		return $this->addToProperty("class", "blurring");
60
	}
61
62
	public function setParams($_params) {
63
		$this->_params = $_params;
64
		return $this;
65
	}
66
67
	public function setContainer($_container) {
68
		$this->_container = $_container;
69
		return $this;
70
	}
71
72
	public function setClosable($closable) {
73
		$this->_params['closable'] = $closable;
74
		return $this;
75
	}
76
}
77