phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
HtmlMessage.php
Go to the documentation of this file.
1<?php
3
10
19
20 protected $icon;
21
22 protected $close;
23
24 public function __construct($identifier, $content = "") {
25 parent::__construct($identifier, "div");
26 $this->_template = '<%tagName% id="%identifier%" %properties%>%close%%icon%%wrapContentBefore%%content%%wrapContentAfter%</%tagName%>';
27 $this->setClass("ui message");
28 $this->setContent($content);
29 }
30
37 public function addHeader($header) {
38 $headerO = $header;
39 if (\is_string($header)) {
40 $headerO = new HtmlSemDoubleElement("header-" . $this->identifier, "div");
41 $headerO->setClass("header");
42 $headerO->setContent($header);
43 }
44 return $this->addContent($headerO, true);
45 }
46
47 public function setHeader($header) {
48 return $this->addHeader($header);
49 }
50
51 public function setIcon($icon) {
52 $this->addToProperty("class", "icon");
53 $this->wrapContent("<div class='content'>", "</div>");
54 if (\is_string($icon)) {
55 $this->icon = new HtmlIcon("icon-" . $this->identifier, $icon);
56 } else {
57 $this->icon = $icon;
58 }
59 return $this;
60 }
61
74 public function getOnClose($url, $responseElement = "", $parameters = array()) {
75 if (isset($this->close)) {
76 $this->close->getOnClick($url, $responseElement, $parameters);
77 }
78 }
79
80 public function addLoader($loaderIcon = "notched circle") {
81 $this->setIcon($loaderIcon);
82 $this->icon->addToIcon("loading");
83 return $this;
84 }
85
86 public function setDismissable($dismiss = true) {
87 if ($dismiss === true)
88 $this->close = new HtmlIcon("close-" . $this->identifier, "close");
89 else
90 $this->close = NULL;
91 return $this;
92 }
93
99 public function run(JsUtils $js) {
100 if (! isset($this->_bsComponent)) {
101 if (isset($this->close)) {
102 $js->execOn("click", "#" . $this->identifier . " .close", "$(this).closest('.message').transition({$this->_closeTransition}).trigger('close-message');");
103 }
104 if (isset($this->_timeout)) {
105 $js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}).trigger('close-message'); }, {$this->_timeout});", true);
106 }
107 }
108 return parent::run($js);
109 }
110
111 public function setState($visible = true) {
112 $visible = ($visible === true) ? "visible" : "hidden";
113 return $this->addToPropertyCtrl("class", $visible, array(
114 "visible",
115 "hidden"
116 ));
117 }
118
119 public function setVariation($value = "floating") {
120 return $this->addToPropertyCtrl("class", $value, array(
121 "floating",
122 "compact"
123 ));
124 }
125
126 public function setStyle($style) {
127 return $this->addToPropertyCtrl("class", $style, Style::getConstants());
128 }
129
130 public function setError() {
131 return $this->setStyle("error");
132 }
133
134 public function setWarning() {
135 return $this->setStyle("warning");
136 }
137
138 public function setMessage($message) {
139 if (\is_array($this->content)) {
140 $this->content[\sizeof($this->content) - 1] = $message;
141 } else
142 $this->setContent($message);
143 }
144}
JQuery PHP library.
Definition JsUtils.php:23
static getConstants()
Definition BaseEnum.php:17
addContent($content, $before=false)
exec($js, $immediatly=false)
Executes the code $js.
execOn($event, $element, $js, $parameters=array())
Executes the javascript code $js when $event fires on $element.
Base class for Semantic double elements.
addToPropertyCtrl($name, $value, $typeCtrl)
addToProperty($name, $value, $separator=" ")
run(JsUtils $js)
{{SimpleExtComponent\Ajax\common\html\BaseHtmlrun()\Ajax\common\html\BaseHtmlrun()}HtmlDoubleElement:...
addHeader($header)
Adds an header to the message.
getOnClose($url, $responseElement="", $parameters=array())
Performs a get to $url on the click event on close button and display it in $responseElement.
addLoader($loaderIcon="notched circle")
__construct($identifier, $content="")
Semantic Icon component.
Definition HtmlIcon.php:14