Skip to content

Commit 80e0277

Browse files
committed
timeOut message
1 parent 017cb5e commit 80e0277

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Ajax/semantic/html/collections/HtmlMessage.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ class HtmlMessage extends HtmlSemDoubleElement {
1818
use AttachedTrait;
1919
protected $icon;
2020
protected $close;
21+
protected $_timeout;
22+
protected $_closeTransition="{animation : 'scale',duration : '2s'}";
23+
2124
public function __construct($identifier, $content="") {
2225
parent::__construct($identifier, "div");
2326
$this->_template="<%tagName% id='%identifier%' %properties%>%close%%icon%%wrapContentBefore%%content%%wrapContentAfter%</%tagName%>";
@@ -79,7 +82,10 @@ public function setDismissable($dismiss=true){
7982
public function run(JsUtils $js){
8083
parent::run($js);
8184
if(isset($this->close)){
82-
$js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition('fade')");
85+
$js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition({$this->_closeTransition})");
86+
}
87+
if(isset($this->_timeout)){
88+
$js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});",true);
8389
}
8490
}
8591

@@ -110,4 +116,15 @@ public function setMessage($message){
110116
}else
111117
$this->setContent($message);
112118
}
119+
120+
public function setTimeout($_timeout) {
121+
$this->_timeout=$_timeout;
122+
return $this;
123+
}
124+
125+
public function setCloseTransition($_closeTransition) {
126+
$this->_closeTransition=$_closeTransition;
127+
return $this;
128+
}
129+
113130
}

Ajax/service/AjaxCall.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function compile(JsUtils $js=null) {
2727
$hasLoader=true;
2828
$method="get";
2929
extract($this->parameters);
30-
$result=$this->_evenPreparing($preventDefault, $stopPropagation);
30+
$result=$this->_eventPreparing($preventDefault, $stopPropagation);
3131
switch($this->method) {
3232
case "get":
3333
$result.=$js->getDeferred($url, $responseElement, $params, $jsCallback, $attr,$jqueryDone,$ajaxTransition);
@@ -48,7 +48,7 @@ public function compile(JsUtils $js=null) {
4848
return $result;
4949
}
5050

51-
protected function _evenPreparing($preventDefault,$stopPropagation){
51+
protected function _eventPreparing($preventDefault,$stopPropagation){
5252
$result="";
5353
if ($preventDefault===true) {
5454
$result.=Javascript::$preventDefault;

0 commit comments

Comments
 (0)