Skip to content

Commit 03b7214

Browse files
committed
add actions in toast
update ajax url regex
1 parent 97a77be commit 03b7214

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Ajax/common/traits/JsUtilsAjaxTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ protected function _getAjaxUrl($url, $attr) {
140140
$retour .= "url=url+'" . $slash . "'+" . \substr($attr, 3) . ";\n";
141141
} elseif ($attr !== null && $attr !== "") {
142142
$retour .= "let elmUrl=$(this).attr('" . $attr . "')||'';";
143-
$retour .= "url=(!/^((http|https|ftp):\/\/)/.test(elmUrl))?url+'" . $slash . "'+elmUrl:elmUrl;\n";
143+
$retour .= "url=!(new RegExp('^((http|https|ftp):\/\/)')).test(elmUrl)?url+'" . $slash . "'+elmUrl:elmUrl;\n";
144144
}
145145
}
146146
return $retour;

Ajax/semantic/components/SimpleSemExtComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function setParamParts($paramParts) {
4545

4646
public function addComponentEvent($event,$jsCode){
4747
$jsCode=\str_ireplace("\"","%quote%", $jsCode);
48-
return $this->setParam($event, "%function(){".$jsCode."}%");
48+
return $this->setParam($event, "%function(module){".$jsCode."}%");
4949
}
5050

5151
public function setJs(JsUtils $js){

Ajax/semantic/components/Toast.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ public function setTitle($title){
4747
$this->params['title']=$title;
4848
return $this;
4949
}
50+
51+
public function setActions(array $actions){
52+
foreach ($actions as &$action){
53+
if(isset($action['click'])){
54+
$js=\str_ireplace("\"","%quote%", $action['click']);
55+
$action['click']="%function(){".$js."}%";
56+
}
57+
}
58+
$this->params['actions']=$actions;
59+
if(count($actions)>0) {
60+
$this->params['displayTime'] = 0;
61+
}
62+
return $this;
63+
}
5064

5165
public function setMessage($message){
5266
$this->params['message']=$message;

0 commit comments

Comments
 (0)