From 2900dcc6db787c0985c438031129cb9ddc01e63e Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 4 Aug 2011 01:24:41 +0000 Subject: [PATCH] Don't allow unreasonable window positions --- .../zotero/integration/addCitationDialog.js | 14 ++++++++++++++ chrome/content/zotero/integration/quickFormat.js | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/chrome/content/zotero/integration/addCitationDialog.js b/chrome/content/zotero/integration/addCitationDialog.js index 5da4c6263..a3896b7f9 100644 --- a/chrome/content/zotero/integration/addCitationDialog.js +++ b/chrome/content/zotero/integration/addCitationDialog.js @@ -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"); diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index 2ec1d6996..8c55eb68d 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -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();