77425f3cdc629ced01f2d2c6e6ae7c9a4f7722eb
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Resources / Public / JavaScript / Modules / ProgressBar.js
1 /*
2 * This file is part of the TYPO3 CMS project.
3 *
4 * It is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, either version 2
6 * of the License, or any later version.
7 *
8 * For the full copyright and license information, please read the
9 * LICENSE.txt file that was distributed with this source code.
10 *
11 * The TYPO3 project - inspiring people to share!
12 */
13
14 /**
15 * Module: TYPO3/CMS/Install/ProgressBar
16 */
17 define(['jquery', 'TYPO3/CMS/Install/Severity'], function ($, Severity) {
18 'use strict';
19
20 /**
21 * @type {{template: (*)}}
22 */
23 var ProgressBar = {
24 template: $('<div class="progress"><div class="t3js-progressbar progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"> <span class="sr-only"></span></div></div>')
25 };
26
27 /**
28 * render a ProgressBar
29 * @param {Number} severity
30 * @param {String} title
31 * @param {Number} progress
32 * @returns {jQuery}
33 */
34 ProgressBar.render = function (severity, title, progress) {
35 var progressBar = this.template.clone();
36 progressBar.addClass('progress-bar-' + Severity.getCssClass(severity));
37 if (progress) {
38 progressBar.css('width', progress + '%');
39 progressBar.attr('aria-valuenow',progresss);
40 }
41 if (title) {
42 progressBar.find('.sr-only').html(title);
43 }
44 return progressBar;
45 };
46
47 return ProgressBar;
48 });