Completed
Push — master ( 4bf172...5f7aee )
by Jean-Christophe
03:35
created

HasTimeoutTrait::setCloseTransition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Ajax\semantic\html\base\traits;
4
5
use Ajax\JsUtils;
6
7
/**
8
 * @author jc
9
 * @property string $identifier
10
 * @property BaseComponent $_bsComponent
11
 */
12
trait HasTimeoutTrait {
13
	protected $_timeout;
14
	protected $_closeTransition="{animation : 'scale',duration : '2s'}";
15
16
	/**
17
	 * {@inheritDoc}
18
	 * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run()
19
	 */
20
	public function run(JsUtils $js){
21
		if(!isset($this->_bsComponent)){
22
			if(isset($this->_timeout)){
23
				$js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});",true);
24
			}
25
		}
26
		return parent::run($js);
27
	}
28
29
	public function setTimeout($_timeout) {
30
		$this->_timeout=$_timeout;
31
		return $this;
32
	}
33
34
	public function setCloseTransition($_closeTransition) {
35
		$this->_closeTransition=$_closeTransition;
36
		return $this;
37
	}
38
}