Completed
Push — master ( 69e9f4...3042e6 )
by Jean-Christophe
04:01
created

HtmlSemDoubleElement::addDimmer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
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\base\traits\BaseTrait;
10
use Ajax\semantic\html\modules\HtmlDimmer;
11
12
/**
13
 * Base class for Semantic double elements
14
 * @author jc
15
 * @version 1.001
16
 */
17
class HtmlSemDoubleElement extends HtmlDoubleElement {
18
	use BaseTrait;
19
	protected $_popup=NULL;
20
	protected $_dimmer=NULL;
21
22 View Code Duplication
	public function __construct($identifier, $tagName="p", $baseClass="ui", $content=NULL) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
		parent::__construct($identifier, $tagName);
24
		$this->_baseClass=$baseClass;
25
		$this->setClass($baseClass);
26
		if (isset($content)) {
27
			$this->content=$content;
28
		}
29
	}
30
31
	public function setPopupAttributes($variation=NULL, $popupEvent=NULL) {
32
		if (isset($this->_popup))
33
			$this->_popup->setAttributes($variation, $popupEvent);
34
	}
35
36
	public function addPopup($title="", $content="", $variation=NULL, $params=array()) {
37
		$this->_popup=new InternalPopup($this, $title, $content, $variation, $params);
38
		return $this;
39
	}
40
41
	public function addPopupHtml($html="", $variation=NULL, $params=array()) {
42
		$this->_popup=new InternalPopup($this);
43
		$this->_popup->setHtml($html);
44
		$this->_popup->setAttributes($variation, $params);
45
		return $this;
46
	}
47
48
	public function addDimmer($content=NULL) {
49
		$dimmer=new HtmlDimmer("dimmer-" . $this->identifier, $content);
50
		$this->addContent($dimmer);
51
		return $dimmer;
52
	}
53
54
	public function jsShowDimmer($show=true) {
55
		$status="hide";
56
		if ($show === true)
57
			$status="show";
58
		return '$("#.' . $this->identifier . ').dimmer("' . $status . '");';
59
	}
60
61
	public function compile(JsUtils $js=NULL, View $view=NULL) {
62
		if (isset($this->_popup))
63
			$this->_popup->compile();
64
		return parent::compile($js, $view);
65
	}
66
67
	public function run(JsUtils $js) {
68
		$this->_bsComponent=$js->semantic()->generic("#" . $this->identifier);
69
		parent::run($js);
70
		$this->addEventsOnRun($js);
71
		if (isset($this->_popup)) {
72
			$this->_popup->run($js);
73
		}
74
		return $this->_bsComponent;
75
	}
76
	/*
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% 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...
77
	 * public function __call($name, $arguments){
78
	 * $type=\substr($name, 0,3);
79
	 * $name=\strtolower(\substr($name, 3));
80
	 * $names=\array_merge($this->_variations,$this->_states);
81
	 * $argument=@$arguments[0];
82
	 * if(\array_search($name, $names)!==FALSE){
83
	 * switch ($type){
84
	 * case "set":
85
	 * if($argument===false){
86
	 * $this->removePropertyValue("class", $name);
87
	 * }else {
88
	 * $this->setProperty("class", $this->_baseClass." ".$name);
89
	 * }
90
	 * break;
91
	 * case "add":
92
	 * $this->addToPropertyCtrl("class", $name,array($name));
93
	 * break;
94
	 * default:
95
	 * throw new \Exception("Méthode ".$type.$name." inexistante.");
96
	 * }
97
	 * }else{
98
	 * throw new \Exception("Propriété ".$name." inexistante.");
99
	 * }
100
	 * return $this;
101
	 * }
102
	 */
103
}