Completed
Push — master ( 3042e6...b4ccca )
by Jean-Christophe
04:19
created

HtmlDimmer   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 13
c 2
b 1
f 0
lcom 2
cbo 5
dl 0
loc 59
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setContent() 0 4 1
A asIcon() 0 7 2
A asPage() 0 3 1
A setInverted() 0 5 1
A run() 0 5 2
A jsShow() 0 4 2
A setBlurring() 0 3 1
A setParams() 0 4 1
A setContainer() 0 4 1
1
<?php
2
3
namespace Ajax\semantic\html\modules;
4
5
use Ajax\semantic\html\base\HtmlSemDoubleElement;
6
use Ajax\semantic\html\elements\HtmlHeader;
7
use Ajax\JsUtils;
8
use Ajax\common\html\HtmlSingleElement;
9
10
class HtmlDimmer extends HtmlSemDoubleElement {
11
	private $_container;
12
	private $_params=array ();
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() {
39
		parent::setInverted();
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
		return parent::run($js);
48
	}
49
50
	public function jsShow() {
51
		if (isset($this->_container) === true)
52
			return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");';
53
	}
54
55
	public function setBlurring() {
56
		return $this->addToProperty("class", "blurring");
57
	}
58
59
	public function setParams($_params) {
60
		$this->_params=$_params;
61
		return $this;
62
	}
63
64
	public function setContainer($_container) {
65
		$this->_container=$_container;
66
		return $this;
67
	}
68
}