occ2 / progress-bar
Nette 框架的简单进度条控件。基于 Twitter Bootstrap 3
1.0.2
2017-10-05 12:47 UTC
Requires
- php: >=5.6
- nette/application: ^2.4
This package is not auto-updated.
Last update: 2024-09-25 03:17:54 UTC
README
Nette 框架的简单进度条控件。
要求
PHP >=5.6 Nette >=2.4 Twitter Bootstrap >=3 (不适用于版本 4) nette.ajax.js
###安装:composer require occ2/progress-bar
- 将 assets/autorefresh.ajax.js 复制到你的_www_js_dir/ext 目录,并在你的页面中建立链接。
- 别忘了在你的页面中链接 Twitter Bootstrap 的 CSS 和 JS 文件
在演示者中使用
public function createComponentProgressBar(){ $m=$this->model; $callback = function() use($m){ return $m->getValue(); //change what you need .. must return integer !! }; $config = [ "title"=>"BAR TITLE", // bar title "minValue"=>0, // minimul value "maxValue"=>100,// maximum value "valuePrefix"=>"", // text before shown value "valueSuffix"=>"%", // text after shown value "showValue"=>true, // show value in progress bar? "strippedStyle"=>true, // use stripped style "animatedStyle"=>true, // use animated bar "colorStyle"=>"success" // color style (available info/warning/success/danger) "warningThreshold"=>null, // switch to warning style (if null nothing switched) "dangerThreshold"=>null // switch to danger style (if null nothing switched) ]; $refreshTime = 3; // time to automatic AJAX refresh (set null if autorefresh disabled) return new \OCC2\ProgressBar\ProgressBar("cpuLoad", $callback, $config, $refreshTime); }
###在 Latte 模板中使用
{control progressBar}
autorefresh.ajax.sh 的使用
- 在 $.nette.init() 期间,所有具有类 .autorefresh 的元素都会被找到并读取 URL,每次都进行刷新
- 自动刷新的 URL 存在于 data-refresh-url 属性中
- 刷新时间在 data-refresh-time 属性中