www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 2900dcc6db787c0985c438031129cb9ddc01e63e
parent d8ca9ef43847bf5c48a2ae37a14589dab01aff49
Author: Simon Kornblith <simon@simonster.com>
Date:   Thu,  4 Aug 2011 01:24:41 +0000

Don't allow unreasonable window positions


Diffstat:
Mchrome/content/zotero/integration/addCitationDialog.js | 14++++++++++++++
Mchrome/content/zotero/integration/quickFormat.js | 14++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)

diff --git 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 @@ -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();