Allow altering text in a ProgressWindow line in OO mode

And fix progress meter display
This commit is contained in:
Dan Stillman 2017-02-08 14:32:07 -05:00
parent 12ad749087
commit 3e35764405

View File

@ -288,18 +288,15 @@ Zotero.ProgressWindow = function(options = {}) {
* Creates a new object representing a line in the progressWindow. This is the OO
* version of addLines() above.
*/
this.ItemProgress = _deferUntilWindowLoad(function(iconSrc, title, parentItemProgress) {
this._itemText = _progressWindow.document.createElement("description");
this._itemText.appendChild(_progressWindow.document.createTextNode(title));
this._itemText.setAttribute("class", "zotero-progress-item-label");
this._itemText.setAttribute("crop", "end");
this.ItemProgress = _deferUntilWindowLoad(function(iconSrc, text, parentItemProgress) {
this.setText(text);
this._image = _progressWindow.document.createElement("hbox");
this._image.setAttribute("class", "zotero-progress-item-icon");
this._image.setAttribute("flex", 0);
this._image.style.width = "16px";
this._image.style.backgroundRepeat = "no-repeat";
this._image.style.backgroundSize = "16px";
this._image.style.backgroundSize = "auto 16px";
this.setIcon(iconSrc);
this._hbox = _progressWindow.document.createElement("hbox");
@ -340,7 +337,6 @@ Zotero.ProgressWindow = function(options = {}) {
this._image.style.backgroundImage = "url('chrome://zotero/skin/progress_arcs.png')";
this._image.style.backgroundPosition = "-"+(Math.round(percent/100*nArcs)*16)+"px 0";
this._hbox.style.opacity = percent/200+.5;
this._hbox.style.filter = "alpha(opacity = "+(percent/2+50)+")";
} else if(percent == 100) {
this._image.style.backgroundImage = "url('"+this._iconSrc+"')";
this._image.style.backgroundPosition = "";
@ -359,6 +355,18 @@ Zotero.ProgressWindow = function(options = {}) {
this._iconSrc = iconSrc;
});
this.ItemProgress.prototype.setText = _deferUntilWindowLoad(function (text) {
if (!this._itemText) {
this._itemText = _progressWindow.document.createElement("description");
}
else {
this._itemText.textContent = '';
}
this._itemText.appendChild(_progressWindow.document.createTextNode(text));
this._itemText.setAttribute("class", "zotero-progress-item-label");
this._itemText.setAttribute("crop", "end");
});
/**
* Indicates that an error occurred saving this item.
*/