diff options
author | Alex Pott <alex.a.pott@googlemail.com> | 2020-01-28 11:36:14 +0000 |
---|---|---|
committer | Alex Pott <alex.a.pott@googlemail.com> | 2020-01-28 11:36:14 +0000 |
commit | 2dadb738bfd48510db2174323528fe769731c05a (patch) | |
tree | f6319d9bfa9af8b41dc0ca7c187bef1eaf17aee4 /core/misc/progress.js | |
parent | 09b78ffb1bc1bb62d21fb3abb85e1349a674597a (diff) | |
download | drupal-2dadb738bfd48510db2174323528fe769731c05a.tar.gz drupal-2dadb738bfd48510db2174323528fe769731c05a.zip |
Issue #3101543 by lauriii, bnjmnm, ravi.shankar: Update core JavaScript dependencies listed in package.json
Diffstat (limited to 'core/misc/progress.js')
-rw-r--r-- | core/misc/progress.js | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/core/misc/progress.js b/core/misc/progress.js index 82280aac4edd..fc532a897d36 100644 --- a/core/misc/progress.js +++ b/core/misc/progress.js @@ -7,7 +7,7 @@ (function ($, Drupal) { Drupal.theme.progressBar = function (id) { - return '<div id="' + id + '" class="progress" aria-live="polite">' + '<div class="progress__label"> </div>' + '<div class="progress__track"><div class="progress__bar"></div></div>' + '<div class="progress__percentage"></div>' + '<div class="progress__description"> </div>' + '</div>'; + return "<div id=\"".concat(id, "\" class=\"progress\" aria-live=\"polite\">") + '<div class="progress__label"> </div>' + '<div class="progress__track"><div class="progress__bar"></div></div>' + '<div class="progress__percentage"></div>' + '<div class="progress__description"> </div>' + '</div>'; }; Drupal.ProgressBar = function (id, updateCallback, method, errorCallback) { @@ -15,18 +15,19 @@ this.method = method || 'GET'; this.updateCallback = updateCallback; this.errorCallback = errorCallback; - this.element = $(Drupal.theme('progressBar', id)); }; $.extend(Drupal.ProgressBar.prototype, { setProgress: function setProgress(percentage, message, label) { if (percentage >= 0 && percentage <= 100) { - $(this.element).find('div.progress__bar').css('width', percentage + '%'); - $(this.element).find('div.progress__percentage').html(percentage + '%'); + $(this.element).find('div.progress__bar').css('width', "".concat(percentage, "%")); + $(this.element).find('div.progress__percentage').html("".concat(percentage, "%")); } + $('div.progress__description', this.element).html(message); $('div.progress__label', this.element).html(label); + if (this.updateCallback) { this.updateCallback(percentage, message, this); } @@ -38,22 +39,23 @@ }, stopMonitoring: function stopMonitoring() { clearTimeout(this.timer); - this.uri = null; }, sendPing: function sendPing() { if (this.timer) { clearTimeout(this.timer); } + if (this.uri) { var pb = this; - var uri = this.uri; + if (uri.indexOf('?') === -1) { uri += '?'; } else { uri += '&'; } + uri += '_format=json'; $.ajax({ type: this.method, @@ -67,14 +69,13 @@ } pb.setProgress(progress.percentage, progress.message, progress.label); - pb.timer = setTimeout(function () { pb.sendPing(); }, pb.delay); }, error: function error(xmlhttp) { var e = new Drupal.AjaxError(xmlhttp, pb.uri); - pb.displayError('<pre>' + e.message + '</pre>'); + pb.displayError("<pre>".concat(e.message, "</pre>")); } }); } |