Skip to content

Commit

Permalink
add actions in toast
Browse files Browse the repository at this point in the history
update ajax url regex
  • Loading branch information
jcheron committed Apr 23, 2022
1 parent 97a77be commit 03b7214
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Ajax/common/traits/JsUtilsAjaxTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected function _getAjaxUrl($url, $attr) {
$retour .= "url=url+'" . $slash . "'+" . \substr($attr, 3) . ";\n";
} elseif ($attr !== null && $attr !== "") {
$retour .= "let elmUrl=$(this).attr('" . $attr . "')||'';";
$retour .= "url=(!/^((http|https|ftp):\/\/)/.test(elmUrl))?url+'" . $slash . "'+elmUrl:elmUrl;\n";
$retour .= "url=!(new RegExp('^((http|https|ftp):\/\/)')).test(elmUrl)?url+'" . $slash . "'+elmUrl:elmUrl;\n";
}
}
return $retour;
Expand Down
2 changes: 1 addition & 1 deletion Ajax/semantic/components/SimpleSemExtComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function setParamParts($paramParts) {

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

public function setJs(JsUtils $js){
Expand Down
14 changes: 14 additions & 0 deletions Ajax/semantic/components/Toast.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ public function setTitle($title){
$this->params['title']=$title;
return $this;
}

public function setActions(array $actions){
foreach ($actions as &$action){
if(isset($action['click'])){
$js=\str_ireplace("\"","%quote%", $action['click']);
$action['click']="%function(){".$js."}%";
}
}
$this->params['actions']=$actions;
if(count($actions)>0) {
$this->params['displayTime'] = 0;
}
return $this;
}

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

0 comments on commit 03b7214

Please sign in to comment.