Don't allow unreasonable window positions

This commit is contained in:
Simon Kornblith 2011-08-04 01:24:41 +00:00
parent d8ca9ef438
commit 2900dcc6db
2 changed files with 28 additions and 0 deletions

View file

@ -70,6 +70,20 @@ var Zotero_Citation_Dialog = new function () {
* initialize add citation dialog
*/
function load() {
// make sure we are visible
window.setTimeout(function() {
var screenX = window.screenX;
var screenY = window.screenY;
var xRange = [window.screen.availLeft, window.screen.width-window.outerWidth];
var yRange = [window.screen.availTop, window.screen.height-window.outerHeight];
if(screenX < xRange[0] || screenX > xRange[1] || screenY < yRange[0] || screenY > yRange[1]) {
var targetX = Math.max(Math.min(screenX, xRange[1]), xRange[0]);
var targetY = Math.max(Math.min(screenY, yRange[1]), yRange[0]);
Zotero.debug("Moving window to "+targetX+", "+targetY);
window.moveTo(targetX, targetY);
}
}, 0);
document.documentElement.getButton("extra1").label = Zotero.getString("citation.multipleSources");
document.documentElement.getButton("extra2").label = Zotero.getString("citation.showEditor");

View file

@ -83,6 +83,20 @@ var Zotero_QuickFormat = new function () {
* Initialize add citation dialog
*/
this.onLoad = function() {
// make sure we are visible
window.setTimeout(function() {
var screenX = window.screenX;
var screenY = window.screenY;
var xRange = [window.screen.availLeft, window.screen.width-window.outerWidth];
var yRange = [window.screen.availTop, window.screen.height-window.outerHeight];
if(screenX < xRange[0] || screenX > xRange[1] || screenY < yRange[0] || screenY > yRange[1]) {
var targetX = Math.max(Math.min(screenX, xRange[1]), xRange[0]);
var targetY = Math.max(Math.min(screenY, yRange[1]), yRange[0]);
Zotero.debug("Moving window to "+targetX+", "+targetY);
window.moveTo(targetX, targetY);
}
}, 0);
window.focus();
qfe.focus();