From 50cc1fcb71026accc45a8ae9d11375ada6871a10 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sat, 2 Jul 2011 05:51:29 +0000 Subject: [PATCH] Fixes #1757, VIew Debug output doesn't work in standalone --- .../content/zotero/preferences/preferences.js | 33 ++-- .../content/zotero/standalone/basicViewer.js | 43 +++++ .../content/zotero/standalone/basicViewer.xul | 152 ++++++++++++++++++ 3 files changed, 217 insertions(+), 11 deletions(-) create mode 100644 chrome/content/zotero/standalone/basicViewer.js create mode 100644 chrome/content/zotero/standalone/basicViewer.xul diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js index 24a722583..abb7ddf70 100644 --- a/chrome/content/zotero/preferences/preferences.js +++ b/chrome/content/zotero/preferences/preferences.js @@ -1319,19 +1319,30 @@ Zotero_Preferences.Debug_Output = { view: function () { - var uri = "zotero://debug/"; - var features = "menubar=yes,toolbar=no,location=no,scrollbars,centerscreen,resizable"; + const uri = "zotero://debug/"; + const features = "menubar=yes,toolbar=no,location=no,scrollbars,centerscreen,resizable"; var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); - var win = wm.getMostRecentWindow("navigator:browser"); - if (win) { - win.open(uri, null, features); - } - else { - var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] - .getService(Components.interfaces.nsIWindowWatcher); - var win = ww.openWindow(null, uri, null, features + ",width=775,height=575", null); + .getService(Components.interfaces.nsIWindowMediator); + + if(Zotero.isStandalone) { + var win = wm.getMostRecentWindow("zotero:basicViewer"); + if(win) { + win.loadURI(uri); + } else { + window.openDialog("chrome://zotero/content/standalone/basicViewer.xul", + "basicViewer", "chrome,resizable,centerscreen", uri); + } + } else { + var win = wm.getMostRecentWindow("navigator:browser"); + if(win) { + win.open(uri, null, features); + } + else { + var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] + .getService(Components.interfaces.nsIWindowWatcher); + var win = ww.openWindow(null, uri, null, features + ",width=775,height=575", null); + } } }, diff --git a/chrome/content/zotero/standalone/basicViewer.js b/chrome/content/zotero/standalone/basicViewer.js new file mode 100644 index 000000000..dc2cdbccb --- /dev/null +++ b/chrome/content/zotero/standalone/basicViewer.js @@ -0,0 +1,43 @@ +/* + ***** BEGIN LICENSE BLOCK ***** + + Copyright © 2011 Center for History and New Media + George Mason University, Fairfax, Virginia, USA + http://zotero.org + + This file is part of Zotero. + + Zotero is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Zotero is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with Zotero. If not, see . + + ***** END LICENSE BLOCK ***** +*/ + +var browser; +function loadURI() { + browser.loadURI.apply(browser, arguments); +} + +window.addEventListener("load", function() { + browser = document.getElementById('my-browser'); + + // align page title with title of shown document + browser.addEventListener("pageshow", function() { + document.title = (browser.contentDocument.title + ? browser.contentDocument.title + : browser.contentDocument.location.href); + }, false); + + // show document + browser.loadURI.apply(browser, window.arguments); +}, false); \ No newline at end of file diff --git a/chrome/content/zotero/standalone/basicViewer.xul b/chrome/content/zotero/standalone/basicViewer.xul new file mode 100644 index 000000000..11d9ec4ef --- /dev/null +++ b/chrome/content/zotero/standalone/basicViewer.xul @@ -0,0 +1,152 @@ + + + + + + + + + + + %globalDTD; + %charsetDTD; + %textcontextDTD; + %standaloneDTD; + %brandDTD; + %zoteroDTD; +]> + + +