Bug 562552: Set test pilot window size dynamically based on the available screen size. r=dtownsend

This commit is contained in:
Jono S Xia 2010-07-19 18:14:52 -07:00
Родитель 87ddd52922
Коммит b12419c6df
3 изменённых файлов: 33 добавлений и 11 удалений

Просмотреть файл

@ -210,6 +210,7 @@ var TestPilotXulWindow = {
Components.utils.import("resource://testpilot/modules/tasks.js");
this._stringBundle = document.getElementById("testpilot-stringbundle");
this.sizeWindow();
this._init(false);
Observers.add("testpilot:task:changed", this._onTaskStatusChanged, this);
},
@ -241,8 +242,8 @@ var TestPilotXulWindow = {
}
if (!ready) {
// If you opened the window before tasks are done loading, exit now but try
// again in a few seconds.
// If you opened the window before tasks are done loading, exit now
// but try again in a few seconds.
window.setTimeout(
function() { TestPilotXulWindow._init(aReload); }, 2000);
return;
@ -419,7 +420,28 @@ var TestPilotXulWindow = {
// Show number of studies the user finished on badge:
document.getElementById("num-finished-badge").setAttribute(
"value", numFinishedStudies);
},
sizeWindow: function() {
// Size listboxes based on available screen size, then size window to fit
// list boxes.
let currList = document.getElementById("current-studies-listbox");
let finList = document.getElementById("finished-studies-listbox");
let resultsList = document.getElementById("study-results-listbox");
let screenWidth = window.screen.availWidth;
let screenHeight = window.screen.availHeight;
let width = screenWidth >= 800 ? 700 : screenWidth - 100;
let height = screenHeight >= 800 ? 700 : screenHeight - 100;
height -= 130; // Or whatever is height of title bar plus windowdragbox
currList.width = width;
currList.height = height;
finList.width = width;
finList.height = height;
resultsList.width = width;
resultsList.height = height;
window.sizeToContent();
},

Просмотреть файл

@ -133,11 +133,6 @@ image.study-result {
font-size: 16px;
}
#test-pilot-all-studies-window {
min-width: 720px !important;
min-height: 500px !important;
}
#test-pilot-all-studies-window > .prefWindow-dlgbuttons {
display: none;
}
@ -174,13 +169,12 @@ image.study-result {
}
richlistbox.tp-study-list {
height: 522px;
width: 502px;
overflow: auto;
margin: 0px;
}
.tp-tab-panel {
background-color: -moz-dialog;
padding: 0px;
}

Просмотреть файл

@ -54,7 +54,8 @@ var TestPilotWindowUtils;
} else {
allStudiesWindow = window.openDialog(
"chrome://testpilot/content/all-studies-window.xul",
ALL_STUDIES_WINDOW_NAME, "chrome,titlebar,centerscreen,dialog=no");
ALL_STUDIES_WINDOW_NAME,
"chrome,titlebar,centerscreen,dialog=no");
}
},
@ -130,9 +131,14 @@ var TestPilotWindowUtils;
// TODO this window opening triggers studies' window-open code.
// Is that what we want or not?
let screenWidth = window.screen.availWidth;
let screenHeight = window.screen.availHeight;
let width = screenWidth >= 1200 ? 1000 : screenWidth - 200;
let height = screenHeight >= 1000 ? 800 : screenHeight - 200;
let win = window.open(url, "TestPilotStudyDetailWindow",
"chrome,centerscreen,resizable=yes,scrollbars=yes," +
"status=no,width=1000,height=800");
"status=no,width=" + width + ",height=" + height);
win.focus();
}
};