Completed
Push — master ( 195df7...541276 )
by Jean-Christophe
03:05
created

HtmlSemDoubleElement::setPopupAttributes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 2
eloc 3
nc 2
nop 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
	 * Adds an icon before or after
66
	 * @param string|HtmlIcon $icon
67
	 * @param boolean $before
68
	 * @param boolean $labeled
69
	 * @return \Ajax\semantic\html\elements\HtmlIcon
70
	 */
71
	public function addIcon($icon,$before=true,$labeled=false){
72
		$iconO=$icon;
73
		if(\is_string($icon)){
74
			$iconO=new HtmlIcon("icon-".$this->identifier, $icon);
75
		}
76
		if($labeled!==false){
77
			$this->addToProperty("class", "labeled icon");
78
			$this->tagName="div";
79
		}
80
		$this->addContent($iconO,$before);
81
		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...
82
	}
83
84
	/**
85
	 * show a loading indicator
86
	 * @return \Ajax\semantic\html\base\HtmlSemDoubleElement
87
	 */
88
	public function asLoader(){
89
		return $this->addToProperty("class", "loading");
90
	}
91
92
	public function compile(JsUtils $js=NULL, View $view=NULL){
93
		if(isset($this->_popup))
94
			$this->_popup->compile();
95
		return parent::compile($js,$view);
96
	}
97
	public function run(JsUtils $js){
98
		parent::run($js);
99
		if(isset($this->_popup)){
100
			$this->_popup->run($js);
101
			//$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...
102
			//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...
103
		}
104
	}
105
}