diff --git a/lib/javascript-static.js b/lib/javascript-static.js
index e0438e69198..dc56fe35d18 100644
--- a/lib/javascript-static.js
+++ b/lib/javascript-static.js
@@ -1300,30 +1300,33 @@ function stripHTML(str) {
}
function updateProgressBar(id, percent, msg, estimate) {
- var progressIndicator = Y.one('#' + id);
- if (!progressIndicator) {
+ var event,
+ el = document.getElementById(id),
+ eventData = {};
+
+ if (!el) {
return;
}
- var progressBar = progressIndicator.one('.bar'),
- statusIndicator = progressIndicator.one('h2'),
- estimateIndicator = progressIndicator.one('p');
+ eventData.message = msg;
+ eventData.percent = percent;
+ eventData.estimate = estimate;
- statusIndicator.set('innerHTML', Y.Escape.html(msg));
- progressBar.set('innerHTML', Y.Escape.html('' + percent + '%'));
- if (percent === 100) {
- progressIndicator.addClass('progress-success');
- estimateIndicator.set('innerHTML', null);
- } else {
- if (estimate) {
- estimateIndicator.set('innerHTML', Y.Escape.html(estimate));
- } else {
- estimateIndicator.set('innerHTML', null);
+ try {
+ event = new CustomEvent('update', {
+ bubbles: false,
+ cancelable: true,
+ detail: eventData
+ });
+ } catch (exception) {
+ if (!(exception instanceof TypeError)) {
+ throw exception;
}
- progressIndicator.removeClass('progress-success');
+ event = document.createEvent('Event');
+ event.initCustomEvent('update', false, true, eventData);
}
- progressBar.setAttribute('aria-valuenow', percent);
- progressBar.setStyle('width', percent + '%');
+
+ el.dispatchEvent(event);
}
// ===== Deprecated core Javascript functions for Moodle ====
diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php
index fc95c5d5eb2..01f6c2588c0 100644
--- a/lib/outputrenderers.php
+++ b/lib/outputrenderers.php
@@ -4333,6 +4333,20 @@ EOD;
return false;
}
}
+
+ /**
+ * Renders a progress bar.
+ *
+ * Do not use $OUTPUT->render($bar), instead use progress_bar::create().
+ *
+ * @param progress_bar $bar The bar.
+ * @return string HTML fragment
+ */
+ public function render_progress_bar(progress_bar $bar) {
+ global $PAGE;
+ $data = $bar->export_for_template($this);
+ return $this->render_from_template('core/progress_bar', $data);
+ }
}
/**
diff --git a/lib/setup.php b/lib/setup.php
index b5970239918..612f077728e 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -587,8 +587,8 @@ core_date::store_default_php_timezone();
// Load up standard libraries
require_once($CFG->libdir .'/filterlib.php'); // Functions for filtering test as it is output
require_once($CFG->libdir .'/ajax/ajaxlib.php'); // Functions for managing our use of JavaScript and YUI
-require_once($CFG->libdir .'/weblib.php'); // Functions relating to HTTP and content
require_once($CFG->libdir .'/outputlib.php'); // Functions for generating output
+require_once($CFG->libdir .'/weblib.php'); // Functions relating to HTTP and content
require_once($CFG->libdir .'/navigationlib.php'); // Class for generating Navigation structure
require_once($CFG->libdir .'/dmllib.php'); // Database access
require_once($CFG->libdir .'/datalib.php'); // Legacy lib with a big-mix of functions.
diff --git a/lib/templates/progress_bar.mustache b/lib/templates/progress_bar.mustache
new file mode 100644
index 00000000000..7a2653e80eb
--- /dev/null
+++ b/lib/templates/progress_bar.mustache
@@ -0,0 +1,64 @@
+{{!
+ This file is part of Moodle - http://moodle.org/
+
+ Moodle is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Moodle is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Moodle. If not, see