phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
HtmlProgress.php
Go to the documentation of this file.
1<?php
2
4
8
10
12
13 public function __construct($identifier, $value=NULL, $label=NULL, $attributes=array()) {
14 parent::__construct($identifier, "div", "ui progress");
15 if (isset($value))
16 $this->setProperty("data-percent", $value);
17 $this->createBar();
18 if (isset($label))
19 $this->setLabel($label);
20 $this->_states=[ State::SUCCESS,State::WARNING,State::ERROR,State::ACTIVE,State::DISABLED ];
21 $this->addToProperty("class", $attributes);
22 }
23
24 public function setLabel($label) {
25 $this->content["label"]=new HtmlSemDoubleElement("lbl-" . $this->identifier, "div", "label", $label);
26 return $this;
27 }
28
29 private function createBar() {
30 $bar=new HtmlSemDoubleElement("bar-" . $this->identifier, "div", "bar", new HtmlSemDoubleElement("progress-" . $this->identifier, "div", "progress"));
31 $this->content["bar"]=$bar;
32 return $this;
33 }
34
35 public function setTotal($value) {
36 return $this->setProperty("data-total", $value);
37 }
38
39 public function setValue($value) {
40 return $this->setProperty("data-value", $value);
41 }
42
43 public function setPercent($value) {
44 return $this->setProperty("data-percent", $value);
45 }
46
47 public function setIndicating() {
48 return $this->addToProperty("class", "indicating");
49 }
50
51 public function setWarning() {
52 return $this->addToProperty("class", "warning");
53 }
54
55 public function setError() {
56 return $this->addToProperty("class", "error");
57 }
58
65 public function compile(JsUtils $js=NULL, &$view=NULL) {
66 $this->content=JArray::sortAssociative($this->content, [ "bar","label" ]);
67 return parent::compile($js, $view);
68 }
69
70 public function jsSetValue($value) {
71 return '$("#' . $this->identifier . '").progress({value:' . $value . '});';
72 }
73
74 public function jsIncValue() {
75 return '$("#' . $this->identifier . '").progress("increment");';
76 }
77
78 public function jsDecValue() {
79 return '$("#' . $this->identifier . '").progress("decrement");';
80 }
81
92 public function setTextValues($active=false, $error=false, $success=false, $warning=false, $percent="{percent}%", $ratio="{value} of {total}") {
93 if (\is_array($active)) {
94 $array=$active;
95 $active=JArray::getDefaultValue($array, "active", false);
96 $success=JArray::getDefaultValue($array, "success", $success);
97 $warning=JArray::getDefaultValue($array, "warning", $warning);
98 $percent=JArray::getDefaultValue($array, "percent", $percent);
99 $ratio=JArray::getDefaultValue($array, "ratio", $ratio);
100 }
101 $this->_params["text"]="%{active : " . \var_export($active, true) . ",error: " . \var_export($error, true) . ",success : " . \var_export($success, true) . ",warning : " . \var_export($warning, true) . ",percent : " . \var_export($percent, true) . ",ratio : " . \var_export($ratio, true) . "}%";
102 return $this;
103 }
104
105 public function onChange($jsCode) {
106 $this->addBehavior($this->_params, "onChange", $jsCode,"%function(percent, value, total){","}%");
107 return $this;
108 }
109
110 /*
111 * (non-PHPdoc)
112 * @see BaseHtml::run()
113 */
114 public function run(JsUtils $js) {
115 if (isset($this->_bsComponent) === false)
116 $this->_bsComponent=$js->semantic()->progress("#" . $this->identifier, $this->_params);
117 $this->addEventsOnRun($js);
118 return $this->_bsComponent;
119 }
120
121 public static function create($identifier, $value=NULL, $label=NULL, $attributes=array()) {
122 return new HtmlProgress($identifier, $value, $label, $attributes);
123 }
124}
JQuery PHP library.
Definition JsUtils.php:23
semantic(Semantic $semantic=NULL)
getter or setter of the Semantic-UI variable
Definition JsUtils.php:158
Base class for Semantic double elements.
addBehavior(&$array, $key, $value, $before="", $after="")
addToProperty($name, $value, $separator=" ")
static create($identifier, $value=NULL, $label=NULL, $attributes=array())
run(JsUtils $js)
{{SimpleExtComponent\Ajax\common\html\BaseHtmlrun()\Ajax\common\html\BaseHtmlrun()}HtmlDoubleElement:...
setTextValues($active=false, $error=false, $success=false, $warning=false, $percent="{percent}%", $ratio="{value} of {total}")
compile(JsUtils $js=NULL, &$view=NULL)
{}BaseHtml::compile()
__construct($identifier, $value=NULL, $label=NULL, $attributes=array())