|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ubiquity\controllers\semantic; |
|
4
|
|
|
|
|
5
|
|
|
use Ajax\semantic\html\elements\HtmlButton; |
|
6
|
|
|
use Ubiquity\utils\base\UString; |
|
7
|
|
|
use Ajax\semantic\html\elements\HtmlDivider; |
|
8
|
|
|
use Ajax\semantic\html\base\HtmlSemDoubleElement; |
|
9
|
|
|
use Ajax\semantic\html\collections\HtmlMessage; |
|
10
|
|
|
use Ajax\JsUtils; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @author jc |
|
14
|
|
|
* @property JsUtils $jquery |
|
15
|
|
|
* |
|
16
|
|
|
*/ |
|
17
|
|
|
trait MessagesTrait { |
|
18
|
|
|
protected function showSimpleMessage($content, $type, $icon = "info", $timeout = NULL, $staticName = null): HtmlMessage { |
|
19
|
|
|
$semantic = $this->jquery->semantic (); |
|
20
|
|
|
if (! isset ( $staticName )) |
|
21
|
|
|
$staticName = "msg-" . rand ( 0, 50 ); |
|
22
|
|
|
$message = $semantic->htmlMessage ( $staticName, $content, $type ); |
|
23
|
|
|
$message->setIcon ( $icon ); |
|
24
|
|
|
$message->setDismissable (); |
|
25
|
|
|
if (isset ( $timeout )) |
|
26
|
|
|
$message->setTimeout ( 3000 ); |
|
27
|
|
|
return $message; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
protected function showConfMessage($content, $type, $url, $responseElement, $data, $attributes = NULL) { |
|
31
|
|
|
$messageDlg = $this->showSimpleMessage ( $content, $type, "help circle" ); |
|
32
|
|
|
$btOkay = new HtmlButton( "bt-okay", "Confirm", "negative" ); |
|
33
|
|
|
$btOkay->addIcon ( "check circle" ); |
|
34
|
|
|
$btOkay->postOnClick ( $url, "{data:'" . $data . "'}", $responseElement, $attributes ); |
|
35
|
|
|
$btCancel = new HtmlButton ( "bt-cancel-" . UString::cleanAttribute ( $url ), "Cancel" ); |
|
36
|
|
|
$btCancel->addIcon ( "remove circle outline" ); |
|
37
|
|
|
$btCancel->onClick ( $messageDlg->jsHide () ); |
|
38
|
|
|
$messageDlg->addContent ( [ new HtmlDivider( "" ),new HtmlSemDoubleElement( "", "div", "", [ $btOkay->floatRight (),$btCancel->floatRight () ] ) ] ); |
|
39
|
|
|
return $messageDlg; |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
|