2 This file is part of Moodle - http://moodle.org/
4 Moodle is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 Moodle is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 @template core/progress_bar
22 Example context (json):
24 "id": "progressbar_test",
28 <div id="{{id}}" class="row progressbar_container">
29 <div class="col-md-6 push-md-3">
30 <p id="{{id}}_status" class="text-xs-center"></p>
31 <progress id="{{id}}_bar" class="progress progress-striped progress-animated" value="0" max="100"></progress>
32 <p id="{{id}}_estimate" class="text-xs-center"></p>
36 {{! We must not use the JS helper otherwise this gets executed too late. }}
37 <script type="text/javascript">
39 var el = document.getElementById('{{id}}'),
40 progressBar = document.getElementById('{{id}}_bar'),
41 statusIndicator = document.getElementById('{{id}}_status'),
42 estimateIndicator = document.getElementById('{{id}}_estimate');
44 el.addEventListener('update', function(e) {
45 var msg = e.detail.message,
46 percent = e.detail.percent,
47 estimate = e.detail.estimate;
49 statusIndicator.textContent = msg;
50 progressBar.setAttribute('value', Math.round(percent));
51 if (percent === 100) {
52 progressBar.classList.add('progress-success');
53 estimateIndicator.textContent = '100%';
56 estimateIndicator.textContent = estimate + ' - ' + percent + '%';
58 estimateIndicator.textContent = '' + percent + '%';
60 progressBar.classList.remove('progress-success');