1<?php
2/**
3 * Mikio Syntax Plugin: Progress Bar
4 *
5 * @link        http://github.com/nomadjimbob/mikioplugin
6 * @license     GPL 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author      James Collins <james.collins@outlook.com.au>
8 */
9if (!defined('DOKU_INC')) die();
10if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11require_once(dirname(__FILE__).'/core.php');
12
13class syntax_plugin_mikioplugin_progressbar extends syntax_plugin_mikioplugin_core {
14    public $tag                 = 'progressbar';
15    public $hasEndTag           = false;
16    public $options             = array(
17        'width'     => array('type'     => 'number',    'default'   => '0'),
18        // 'height'    => array('type'     => 'size',      'default'   => '1em'),
19        'striped'   => array('type'     => 'boolean',   'default'   => 'false'),
20        'animated'  => array('type'     => 'boolean',   'default'   => 'false'),
21        'text'      => array('type'     => 'text',      'default'   => ''),
22        // 'type'      => array('type'     => 'choice',
23        //                      'data'     => array('primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'),
24        //                      'default'  => 'primary'),
25    );
26
27    public function __construct() {
28        $this->addCommonOptions('height type');
29        $this->options['type']['default'] = 'primary';
30        $this->options['height']['default'] = '1.5em';
31    }
32
33
34    public function render_lexer_special(Doku_Renderer $renderer, $data) {
35        $classes = $this->buildClass($data, array('striped', 'animated'));
36        $styles = $this->buildStyle(array('height' => $data['height']), TRUE);
37
38        $renderer->doc .= '<div class="' . $this->elemClass . ' mikiop-progress"' . $styles . '>';
39        $renderer->doc .= '<div class="' . $this->elemClass . ' mikiop-progress-bar ' . $classes . '" role="progressbar" style="width:' . $data['width'] . '%" aria-valuenow="' . $data['width'] . '" aria-valuemin="0" aria-valuemax="100">' . $data['text'] . '</div>';
40        $renderer->doc .= '</div>';
41    }
42}
43?>