34 var JobProgressDialog = {
42 _errorContainer:
null,
50 onLoad:
function JobProgressDialog_onLoad() {
54 if (
window.arguments[0] instanceof
Ci.nsIDialogParamBlock) {
55 argArray =
window.arguments[0].objects;
57 else if (
window.arguments[0] instanceof
Ci.nsIArray) {
58 argArray =
window.arguments[0];
61 throw Cr.NS_ERROR_INVALID_ARG;
64 this._job = argArray.queryElementAt(0,
Ci.sbIJobProgress);
66 if (this._job.status ==
Ci.sbIJobProgress.STATUS_SUCCEEDED) {
71 this._job.addJobProgressListener(
this);
73 this._description = document.getElementById(
"jobprogress_status_desc");
74 this._progressMeter = document.getElementById(
"jobprogress_progressmeter");
75 this._errorContainer = document.getElementById(
"jobprogress_error_box");
76 this._errorList = document.getElementById(
"jobprogress_error_list");
79 if (this._job instanceof
Ci.sbIJobCancelable) {
80 document.documentElement.buttons =
"cancel";
81 this._cancelButton = document.documentElement.getButton(
"cancel");
91 onUnLoad:
function JobProgressDialog_onUnLoad() {
93 this._job.removeJobProgressListener(
this);
103 onCancel:
function JobProgressDialog_onUnLoad() {
111 onJobProgress:
function JobProgressDialog_onJobProgress(aJob) {
112 this._updateProgressUI();
114 if (this._job.status ==
Ci.sbIJobProgress.STATUS_SUCCEEDED) {
116 }
else if (this._job.status ==
Ci.sbIJobProgress.STATUS_FAILED) {
119 if (this._job.statusText) {
120 document.documentElement.buttons =
"accept";
126 }
else if (this._job.blocked) {
136 _updateProgressUI:
function JobProgressDialog__updateUI() {
137 this._formatDescription(this._description, this._job);
138 this._setTitle(this._job.titleText);
140 if (this._cancelButton) {
141 var cancelable = this._job.canCancel;
142 if (this._cancelButton.disabled == cancelable) {
143 this._cancelButton.disabled = !cancelable;
147 if (this._job.total <= 0) {
148 this._progressMeter.mode =
"undetermined";
150 this._progressMeter.mode =
"determined";
155 if (this._job.total < 10000) {
156 this._progressMeter.max = this._job.total;
157 this._progressMeter.value = this._job.progress;
159 this._progressMeter.max = 10000;
160 this._progressMeter.value = Math.round((this._job.progress /
this._job.total) * 10000);
169 if (
window.innerHeight < 10 ||
170 window.innerHeight != document.documentElement.boxObject.height) {
178 _showErrors:
function () {
179 this._progressMeter.hidden =
true;
180 this._errorContainer.hidden =
false;
182 var messages = this._job.getErrorMessages();
184 while (messages.hasMore()) {
185 message = unescape(messages.getNext());
186 var item = this._errorList.appendItem(message);
187 item.setAttribute(
"crop",
"center");
188 item.setAttribute(
"tooltiptext", message);
191 if (this._errorList.hasAttribute(
"maxrows")) {
192 rows = parseInt(this._errorList.getAttribute(
"maxrows"));
197 this._errorList.setAttribute(
"rows", Math.min(rows,
this._job.errorCount));
203 _setTitle:
function JobProgressDialog__setTitle(aTitle) {
204 if (document.title == aTitle) {
208 document.title = aTitle;
212 var sysInfo = Components.classes[
"@mozilla.org/system-info;1"]
213 .getService(Components.interfaces.nsIPropertyBag2);
214 var platform = sysInfo.getProperty(
"name");
215 var isPlucked =
Application.prefs.getValue(
"songbird.accessibility.enabled",
false);
216 var titleBox = document.getElementById(
"jobprogress_title_box");
217 if (platform ==
"Darwin" && isPlucked &&
window.opener) {
218 var macSheetTitle = document.getElementById(
"jobprogress_title_desc");
220 macSheetTitle.value = aTitle;
224 titleBox.hidden =
true;
225 var windowTitle = document.getElementById(
'dialog-titlebar');
227 windowTitle.title = aTitle;
236 _formatDescription:
function(aDescription, aJob) {
238 if (aJob instanceof Components.interfaces.sbIJobProgressUI) {
240 aDescription.setAttribute(
"crop", aJob.crop);
243 aDescription.removeAttribute(
"crop");
246 var lines = aJob.statusText.split(
"\n");
247 if (lines.length > 1) {
248 aDescription.textContent =
"";
249 for (var
i = 0;
i < lines.length;
i++) {
250 aDescription.appendChild(document.createTextNode(lines[
i]));
251 aDescription.appendChild(document.createElementNS(
"http://www.w3.org/1999/xhtml",
"html:br"));
255 aDescription.value = lines[0];
257 aDescription.textContent = lines[0];
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
_getSelectedPageStyle s i