Completed
Push — master ( 541276...03d1b2 )
by Jean-Christophe
03:16
created

HtmlSemDoubleElement   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 18
c 4
b 0
f 0
lcom 2
cbo 5
dl 0
loc 101
rs 10

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setSize() 0 3 1
A setDisabled() 0 3 1
A setColor() 0 3 1
A setPopupAttributes() 0 4 2
A addPopup() 0 4 1
A addPopupHtml() 0 6 1
A setFluid() 0 3 1
A setInverted() 0 3 1
A addIcon() 0 12 3
A asLoader() 0 3 1
A compile() 0 5 2
A run() 0 8 2
1
<?php
2
3
namespace Ajax\semantic\html\base;
4
5
use Ajax\common\html\HtmlDoubleElement;
6
use Ajax\JsUtils;
7
use Ajax\semantic\html\content\InternalPopup;
8
use Phalcon\Mvc\View;
9
use Ajax\semantic\html\elements\HtmlIcon;
10
11
12
class HtmlSemDoubleElement extends HtmlDoubleElement {
13
	protected $_popup=NULL;
14
15
	public function __construct($identifier, $tagName="p") {
16
		parent::__construct($identifier, $tagName);
17
	}
18
19
	/**
20
	 * {@inheritDoc}
21
	 * @see \Ajax\common\html\HtmlSingleElement::setSize()
22
	 */
23
	public function setSize($size){
24
		return $this->addToPropertyCtrl("class", $size, Size::getConstants());
25
	}
26
27
	/**
28
	 * show it is currently unable to be interacted with
29
	 * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement
30
	 */
31
	public function setDisabled(){
32
		return $this->addToProperty("class", "disabled");
33
	}
34
35
	/**
36
	 * @param string $color
37
	 * @return \Ajax\semantic\html\base\HtmlSemDoubleElement
38
	 */
39
	public function setColor($color){
40
		return $this->addToPropertyCtrl("class", $color,Color::getConstants());
41
	}
42
43
	public function setPopupAttributes($variation=NULL,$popupEvent=NULL){
44
		if(isset($this->_popup))
45
			$this->_popup->setAttributes($variation,$popupEvent);
46
	}
47
48
	public function addPopup($title="",$content="",$variation=NULL,$params=array()){
49
		$this->_popup=new InternalPopup($this,$title,$content,$variation,$params);
50
		return $this;
51
	}
52
53
	public function addPopupHtml($html="",$variation=NULL,$params=array()){
54
		$this->_popup=new InternalPopup($this);
55
		$this->_popup->setHtml($html);
56
		$this->_popup->setAttributes($variation,$params);
57
		return $this;
58
	}
59
60
	public function setFluid(){
61
		$this->addToProperty("class", "fluid");
62
	}
63
64
	/**
65
	 * can be formatted to appear on dark backgrounds
66
	 */
67
	public function setInverted(){
68
		$this->addToProperty("class", "inverted");
69
	}
70
71
	/**
72
	 * Adds an icon before or after
73
	 * @param string|HtmlIcon $icon
74
	 * @param boolean $before
75
	 * @param boolean $labeled
76
	 * @return \Ajax\semantic\html\elements\HtmlIcon
77
	 */
78
	public function addIcon($icon,$before=true,$labeled=false){
79
		$iconO=$icon;
80
		if(\is_string($icon)){
81
			$iconO=new HtmlIcon("icon-".$this->identifier, $icon);
82
		}
83
		if($labeled!==false){
84
			$this->addToProperty("class", "labeled icon");
85
			$this->tagName="div";
86
		}
87
		$this->addContent($iconO,$before);
88
		return $iconO;
0 ignored issues
show
Bug Compatibility introduced by
The expression return $iconO; of type string|Ajax\semantic\html\elements\HtmlIcon is incompatible with the return type documented by Ajax\semantic\html\base\...mDoubleElement::addIcon of type Ajax\semantic\html\elements\HtmlIcon as it can also be of type string which is not included in this return type.
Loading history...
89
	}
90
91
	/**
92
	 * show a loading indicator
93
	 * @return \Ajax\semantic\html\base\HtmlSemDoubleElement
94
	 */
95
	public function asLoader(){
96
		return $this->addToProperty("class", "loading");
97
	}
98
99
	public function compile(JsUtils $js=NULL, View $view=NULL){
100
		if(isset($this->_popup))
101
			$this->_popup->compile();
102
		return parent::compile($js,$view);
103
	}
104
	public function run(JsUtils $js){
105
		parent::run($js);
106
		if(isset($this->_popup)){
107
			$this->_popup->run($js);
108
			//$this->addEventsOnRun($js);
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
109
			//return $this->_bsComponent;
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
110
		}
111
	}
112
}