phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
HtmlAlert.php
Go to the documentation of this file.
1<?php
2
3namespace Ajax\bootstrap\html;
4
8
9
21 protected $button="";
22 protected $closeable;
23
24 public function __construct($identifier, $message=NULL, $cssStyle="alert-warning") {
25 parent::__construct($identifier, "div");
26 $this->_template='<div id="%identifier%" %properties%>%button%%content%</div>';
27 $this->setClass("alert");
28 $this->setRole("alert");
29 $this->setStyle($cssStyle);
30 if ($message!=NULL) {
31 $this->content=$message;
32 }
33 }
34
41 public function setStyle($cssStyle) {
42 return $this->addToPropertyCtrl("class", CssRef::getStyle($cssStyle, "alert"), CssRef::Styles("alert"));
43 }
44
45 public function addCloseButton() {
46 $button=new HtmlButton("close-".$this->identifier);
47 $button->setProperties(array (
48 "class" => "close",
49 "data-dismiss" => "alert",
50 "aria-label" => "close"
51 ));
52 $button->setValue('<span aria-hidden="true">&times;</span>');
53 $this->addToPropertyCtrl("class", "alert-dismissible", array (
54 "alert-dismissible"
55 ));
56 $this->button=$button;
57 }
58
59 public function onClose($jsCode) {
60 return $this->addEvent("close.bs.alert", $jsCode);
61 }
62
63 /*
64 * (non-PHPdoc)
65 * @see \Ajax\bootstrap\html\base\HtmlDoubleElement::run()
66 */
67 public function run(JsUtils $js) {
68 $this->_bsComponent=$js->bootstrap()->generic("#".$this->identifier);
69 $this->addEventsOnRun($js);
71 }
72
73 public function close() {
74 return "$('#".$this->identifier."').alert('close');";
75 }
76
77 /*
78 * (non-PHPdoc)
79 * @see \Ajax\bootstrap\html\base\BaseHtml::compile()
80 */
81 public function compile(JsUtils $js=NULL, &$view=NULL) {
82 if ($this->closeable&&$this->button==="") {
83 $this->addCloseButton();
84 }
85 return parent::compile($js, $view);
86 }
87
88 public function setCloseable($closeable) {
89 $this->closeable=$closeable;
90 return $this;
91 }
92
93 public function setMessage($message) {
94 $this->content=$message;
95 }
96}
JQuery PHP library.
Definition JsUtils.php:23
bootstrap(Bootstrap $bootstrap=NULL)
getter or setter of the Twitter Bootstrap variable
Definition JsUtils.php:140
Twitter Bootstrap Alert component.
Definition HtmlAlert.php:16
run(JsUtils $js)
SimpleExtComponent\Ajax\common\html\BaseHtmlrun()\Ajax\common\html\BaseHtmlrun()
Definition HtmlAlert.php:67
setStyle($cssStyle)
define the alert style avaible values : "alert-success","alert-info","alert-warning",...
Definition HtmlAlert.php:41
__construct($identifier, $message=NULL, $cssStyle="alert-warning")
Definition HtmlAlert.php:24
compile(JsUtils $js=NULL, &$view=NULL)
Definition HtmlAlert.php:81
Twitter Bootstrap Button component.
Default HTML values for Twitter Bootstrap HTML components.
Definition CssRef.php:12
addEvent($event, $jsCode, $stopPropagation=false, $preventDefault=false)