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
|
|
|
use Ajax\semantic\html\base\traits\BaseTrait; |
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
|
|
|
|
21
|
|
|
public function __construct($identifier, $tagName="p",$baseClass="ui") { |
22
|
|
|
parent::__construct($identifier, $tagName); |
23
|
|
|
$this->_baseClass=$baseClass; |
24
|
|
|
$this->setClass($baseClass); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function setPopupAttributes($variation=NULL,$popupEvent=NULL){ |
28
|
|
|
if(isset($this->_popup)) |
29
|
|
|
$this->_popup->setAttributes($variation,$popupEvent); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function addPopup($title="",$content="",$variation=NULL,$params=array()){ |
33
|
|
|
$this->_popup=new InternalPopup($this,$title,$content,$variation,$params); |
34
|
|
|
return $this; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function addPopupHtml($html="",$variation=NULL,$params=array()){ |
38
|
|
|
$this->_popup=new InternalPopup($this); |
39
|
|
|
$this->_popup->setHtml($html); |
40
|
|
|
$this->_popup->setAttributes($variation,$params); |
41
|
|
|
return $this; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Adds an icon before or after |
46
|
|
|
* @param string|HtmlIcon $icon |
47
|
|
|
* @param boolean $before |
48
|
|
|
* @param boolean $labeled |
49
|
|
|
* @return \Ajax\semantic\html\elements\HtmlIcon |
50
|
|
|
*/ |
51
|
|
|
public function addIcon($icon,$before=true,$labeled=false){ |
52
|
|
|
$iconO=$icon; |
53
|
|
|
if(\is_string($icon)){ |
54
|
|
|
$iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
55
|
|
|
} |
56
|
|
|
if($labeled!==false){ |
57
|
|
|
$this->addToProperty("class", "labeled icon"); |
58
|
|
|
$this->tagName="div"; |
59
|
|
|
} |
60
|
|
|
$this->addContent($iconO,$before); |
61
|
|
|
return $iconO; |
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function compile(JsUtils $js=NULL, View $view=NULL){ |
65
|
|
|
if(isset($this->_popup)) |
66
|
|
|
$this->_popup->compile(); |
67
|
|
|
return parent::compile($js,$view); |
68
|
|
|
} |
69
|
|
|
public function run(JsUtils $js){ |
70
|
|
|
parent::run($js); |
71
|
|
|
if(isset($this->_popup)){ |
72
|
|
|
$this->_popup->run($js); |
73
|
|
|
//$this->addEventsOnRun($js); |
|
|
|
|
74
|
|
|
//return $this->_bsComponent; |
|
|
|
|
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
/* |
|
|
|
|
78
|
|
|
public function __call($name, $arguments){ |
79
|
|
|
$type=\substr($name, 0,3); |
80
|
|
|
$name=\strtolower(\substr($name, 3)); |
81
|
|
|
$names=\array_merge($this->_variations,$this->_states); |
82
|
|
|
$argument=@$arguments[0]; |
83
|
|
|
if(\array_search($name, $names)!==FALSE){ |
84
|
|
|
switch ($type){ |
85
|
|
|
case "set": |
86
|
|
|
if($argument===false){ |
87
|
|
|
$this->removePropertyValue("class", $name); |
88
|
|
|
}else { |
89
|
|
|
$this->setProperty("class", $this->_baseClass." ".$name); |
90
|
|
|
} |
91
|
|
|
break; |
92
|
|
|
case "add": |
93
|
|
|
$this->addToPropertyCtrl("class", $name,array($name)); |
94
|
|
|
break; |
95
|
|
|
default: |
96
|
|
|
throw new \Exception("Méthode ".$type.$name." inexistante."); |
97
|
|
|
} |
98
|
|
|
}else{ |
99
|
|
|
throw new \Exception("Propriété ".$name." inexistante."); |
100
|
|
|
} |
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
*/ |
104
|
|
|
} |