Fix bustage
This commit is contained in:
parent
09813b145d
commit
fb657bf0cf
1 changed files with 130 additions and 61 deletions
|
@ -35,7 +35,7 @@ const ZOTERO_CONFIG = {
|
||||||
API_URL: 'https://api.zotero.org/',
|
API_URL: 'https://api.zotero.org/',
|
||||||
PREF_BRANCH: 'extensions.zotero.',
|
PREF_BRANCH: 'extensions.zotero.',
|
||||||
BOOKMARKLET_URL: 'https://www.zotero.org/bookmarklet/',
|
BOOKMARKLET_URL: 'https://www.zotero.org/bookmarklet/',
|
||||||
VERSION: "3.0.2.SOURCE"
|
VERSION: "3.5a1.SOURCE"
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -46,7 +46,6 @@ const ZOTERO_CONFIG = {
|
||||||
this.init = init;
|
this.init = init;
|
||||||
this.stateCheck = stateCheck;
|
this.stateCheck = stateCheck;
|
||||||
this.getProfileDirectory = getProfileDirectory;
|
this.getProfileDirectory = getProfileDirectory;
|
||||||
this.getInstallDirectory = getInstallDirectory;
|
|
||||||
this.getZoteroDirectory = getZoteroDirectory;
|
this.getZoteroDirectory = getZoteroDirectory;
|
||||||
this.getStorageDirectory = getStorageDirectory;
|
this.getStorageDirectory = getStorageDirectory;
|
||||||
this.getZoteroDatabase = getZoteroDatabase;
|
this.getZoteroDatabase = getZoteroDatabase;
|
||||||
|
@ -224,29 +223,23 @@ const ZOTERO_CONFIG = {
|
||||||
getService(Components.interfaces.nsIXULAppInfo),
|
getService(Components.interfaces.nsIXULAppInfo),
|
||||||
platformVersion = appInfo.platformVersion;
|
platformVersion = appInfo.platformVersion;
|
||||||
this.isFx = true;
|
this.isFx = true;
|
||||||
this.isFx3 = platformVersion.indexOf('1.9') === 0;
|
this.isFx3 = false;
|
||||||
this.isFx35 = platformVersion.indexOf('1.9.1') === 0;
|
this.isFx35 = false;
|
||||||
this.isFx31 = this.isFx35;
|
this.isFx31 = false;
|
||||||
this.isFx36 = platformVersion.indexOf('1.9.2') === 0;
|
this.isFx36 = false;
|
||||||
this.isFx4 = versionComparator.compare(platformVersion, "2.0a1") >= 0;
|
this.isFx4 = true;
|
||||||
this.isFx5 = versionComparator.compare(platformVersion, "5.0a1") >= 0;
|
this.isFx5 = true;
|
||||||
|
|
||||||
this.isStandalone = appInfo.ID == ZOTERO_CONFIG['GUID'];
|
this.isStandalone = appInfo.ID == ZOTERO_CONFIG['GUID'];
|
||||||
if(this.isStandalone) {
|
if(this.isStandalone) {
|
||||||
this.version = appInfo.version;
|
this.version = appInfo.version;
|
||||||
} else if(this.isFx4) {
|
} else {
|
||||||
// Use until we collect version from extension manager
|
// Use until we collect version from extension manager
|
||||||
this.version = ZOTERO_CONFIG['VERSION'];
|
this.version = ZOTERO_CONFIG['VERSION'];
|
||||||
|
|
||||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||||
AddonManager.getAddonByID(ZOTERO_CONFIG['GUID'],
|
AddonManager.getAddonByID(ZOTERO_CONFIG['GUID'],
|
||||||
function(addon) { Zotero.version = addon.version; });
|
function(addon) { Zotero.version = addon.version; });
|
||||||
} else {
|
|
||||||
var gExtensionManager =
|
|
||||||
Components.classes["@mozilla.org/extensions/manager;1"]
|
|
||||||
.getService(Components.interfaces.nsIExtensionManager);
|
|
||||||
this.version
|
|
||||||
= gExtensionManager.getItemForID(ZOTERO_CONFIG['GUID']).version;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OS platform
|
// OS platform
|
||||||
|
@ -388,11 +381,7 @@ const ZOTERO_CONFIG = {
|
||||||
|
|
||||||
// evaluate
|
// evaluate
|
||||||
Components.utils.evalInSandbox(prefsJs, sandbox);
|
Components.utils.evalInSandbox(prefsJs, sandbox);
|
||||||
if(Zotero.isFx4) {
|
|
||||||
var prefs = sandbox.prefs;
|
var prefs = sandbox.prefs;
|
||||||
} else {
|
|
||||||
var prefs = new XPCSafeJSObjectWrapper(sandbox.prefs);
|
|
||||||
}
|
|
||||||
for(var key in prefs) {
|
for(var key in prefs) {
|
||||||
if(key.substr(0, ZOTERO_CONFIG.PREF_BRANCH.length) === ZOTERO_CONFIG.PREF_BRANCH
|
if(key.substr(0, ZOTERO_CONFIG.PREF_BRANCH.length) === ZOTERO_CONFIG.PREF_BRANCH
|
||||||
&& key !== "extensions.zotero.firstRun2") {
|
&& key !== "extensions.zotero.firstRun2") {
|
||||||
|
@ -429,7 +418,22 @@ const ZOTERO_CONFIG = {
|
||||||
var _shutdownObserver = {observe:Zotero.shutdown};
|
var _shutdownObserver = {observe:Zotero.shutdown};
|
||||||
observerService.addObserver(_shutdownObserver, "quit-application", false);
|
observerService.addObserver(_shutdownObserver, "quit-application", false);
|
||||||
|
|
||||||
|
try {
|
||||||
Zotero.IPC.init();
|
Zotero.IPC.init();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (e.name == 'NS_ERROR_FILE_ACCESS_DENIED') {
|
||||||
|
var msg = Zotero.localeJoin([
|
||||||
|
Zotero.getString('startupError.databaseCannotBeOpened'),
|
||||||
|
Zotero.getString('startupError.checkPermissions')
|
||||||
|
]);
|
||||||
|
Zotero.startupError = msg;
|
||||||
|
Zotero.debug(e);
|
||||||
|
Components.utils.reportError(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
throw (e);
|
||||||
|
}
|
||||||
|
|
||||||
var cs = Components.classes["@mozilla.org/consoleservice;1"].
|
var cs = Components.classes["@mozilla.org/consoleservice;1"].
|
||||||
getService(Components.interfaces.nsIConsoleService);
|
getService(Components.interfaces.nsIConsoleService);
|
||||||
|
@ -652,8 +656,6 @@ const ZOTERO_CONFIG = {
|
||||||
Zotero.Server.init();
|
Zotero.Server.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Zeroconf.init();
|
|
||||||
|
|
||||||
Zotero.Sync.init();
|
Zotero.Sync.init();
|
||||||
Zotero.Sync.Runner.init();
|
Zotero.Sync.Runner.init();
|
||||||
|
|
||||||
|
@ -826,17 +828,6 @@ const ZOTERO_CONFIG = {
|
||||||
.get("ProfD", Components.interfaces.nsIFile);
|
.get("ProfD", Components.interfaces.nsIFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getInstallDirectory() {
|
|
||||||
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
|
||||||
.getService(Components.interfaces.nsIChromeRegistry);
|
|
||||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
|
||||||
.getService(Components.interfaces.nsIIOService);
|
|
||||||
var zoteroURI = ioService.newURI("chrome://zotero-resource/content/", "UTF-8", null);
|
|
||||||
zoteroURI = cr.convertChromeURL(zoteroURI).QueryInterface(Components.interfaces.nsIFileURL);
|
|
||||||
return zoteroURI.file.parent.parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDefaultProfile(prefDir) {
|
function getDefaultProfile(prefDir) {
|
||||||
// find profiles.ini file
|
// find profiles.ini file
|
||||||
var profilesIni = prefDir.clone();
|
var profilesIni = prefDir.clone();
|
||||||
|
@ -1266,17 +1257,8 @@ const ZOTERO_CONFIG = {
|
||||||
callback(addons);
|
callback(addons);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.isFx4) {
|
|
||||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||||
AddonManager.getAllAddons(onHaveInstalledAddons);
|
AddonManager.getAllAddons(onHaveInstalledAddons);
|
||||||
} else {
|
|
||||||
var em = Components.classes["@mozilla.org/extensions/manager;1"].
|
|
||||||
getService(Components.interfaces.nsIExtensionManager);
|
|
||||||
var installed = em.getItemList(
|
|
||||||
Components.interfaces.nsIUpdateItem.TYPE_ANY, {}
|
|
||||||
);
|
|
||||||
onHaveInstalledAddons(installed);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1749,12 +1731,7 @@ const ZOTERO_CONFIG = {
|
||||||
for each(var menuitem in menupopup.childNodes) {
|
for each(var menuitem in menupopup.childNodes) {
|
||||||
if (menuitem.id.substr(prefixLen) == mode) {
|
if (menuitem.id.substr(prefixLen) == mode) {
|
||||||
menuitem.setAttribute('checked', true);
|
menuitem.setAttribute('checked', true);
|
||||||
if (Zotero.isFx36) {
|
|
||||||
searchBox.emptytext = modes[mode].label;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
searchBox.placeholder = modes[mode].label;
|
searchBox.placeholder = modes[mode].label;
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1795,12 +1772,7 @@ const ZOTERO_CONFIG = {
|
||||||
button.appendChild(menupopup);
|
button.appendChild(menupopup);
|
||||||
hbox.insertBefore(button, input);
|
hbox.insertBefore(button, input);
|
||||||
|
|
||||||
if (Zotero.isFx36) {
|
|
||||||
searchBox.emptytext = modes[mode].label;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
searchBox.placeholder = modes[mode].label;
|
searchBox.placeholder = modes[mode].label;
|
||||||
}
|
|
||||||
|
|
||||||
// If Alt-Up/Down, show popup
|
// If Alt-Up/Down, show popup
|
||||||
searchBox.addEventListener("keypress", function(event) {
|
searchBox.addEventListener("keypress", function(event) {
|
||||||
|
@ -1824,12 +1796,12 @@ const ZOTERO_CONFIG = {
|
||||||
Zotero.Relations.purge();
|
Zotero.Relations.purge();
|
||||||
|
|
||||||
if (!skipStoragePurge && Math.random() < 1/10) {
|
if (!skipStoragePurge && Math.random() < 1/10) {
|
||||||
Zotero.Sync.Storage.purgeDeletedStorageFiles('zfs');
|
Zotero.Sync.Storage.purgeDeletedStorageFiles('ZFS');
|
||||||
Zotero.Sync.Storage.purgeDeletedStorageFiles('webdav');
|
Zotero.Sync.Storage.purgeDeletedStorageFiles('WebDAV');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skipStoragePurge) {
|
if (!skipStoragePurge) {
|
||||||
Zotero.Sync.Storage.purgeOrphanedStorageFiles('webdav');
|
Zotero.Sync.Storage.purgeOrphanedStorageFiles('WebDAV');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1934,6 +1906,32 @@ Zotero.Prefs = new function(){
|
||||||
|
|
||||||
// Register observer to handle pref changes
|
// Register observer to handle pref changes
|
||||||
this.register();
|
this.register();
|
||||||
|
|
||||||
|
// Process pref version updates
|
||||||
|
var fromVersion = this.get('prefVersion');
|
||||||
|
if (!fromVersion) {
|
||||||
|
fromVersion = 0;
|
||||||
|
}
|
||||||
|
var toVersion = 1;
|
||||||
|
if (fromVersion < toVersion) {
|
||||||
|
for (var i = fromVersion + 1; i <= toVersion; i++) {
|
||||||
|
switch (i) {
|
||||||
|
case 1:
|
||||||
|
// If a sync username is entered and ZFS is enabled, turn
|
||||||
|
// on-demand downloading off to maintain current behavior
|
||||||
|
if (this.get('sync.server.username')) {
|
||||||
|
if (this.get('sync.storage.enabled')
|
||||||
|
&& this.get('sync.storage.protocol') == 'zotero') {
|
||||||
|
this.set('sync.storage.downloadMode.personal', 'on-sync');
|
||||||
|
}
|
||||||
|
if (this.get('sync.storage.groups.enabled')) {
|
||||||
|
this.set('sync.storage.downloadMode.groups', 'on-sync');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.set('prefVersion', toVersion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2072,9 +2070,74 @@ Zotero.Prefs = new function(){
|
||||||
if(topic!="nsPref:changed"){
|
if(topic!="nsPref:changed"){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
// subject is the nsIPrefBranch we're observing (after appropriate QI)
|
// subject is the nsIPrefBranch we're observing (after appropriate QI)
|
||||||
// data is the name of the pref that's been changed (relative to subject)
|
// data is the name of the pref that's been changed (relative to subject)
|
||||||
switch (data) {
|
switch (data) {
|
||||||
|
case "statusBarIcon":
|
||||||
|
var doc = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||||
|
.getService(Components.interfaces.nsIWindowMediator)
|
||||||
|
.getMostRecentWindow("navigator:browser").document;
|
||||||
|
|
||||||
|
var addonBar = doc.getElementById("addon-bar");
|
||||||
|
var icon = doc.getElementById("zotero-toolbar-button");
|
||||||
|
// When the customize window is open, toolbar buttons seem to
|
||||||
|
// become wrapped in toolbarpaletteitems, which we need to remove
|
||||||
|
// manually if we change the pref to hidden or else the customize
|
||||||
|
// window doesn't close.
|
||||||
|
var wrapper = doc.getElementById("wrapper-zotero-toolbar-button");
|
||||||
|
var palette = doc.getElementById("navigator-toolbox").palette;
|
||||||
|
var inAddonBar = false;
|
||||||
|
if (icon) {
|
||||||
|
// Because of the potential wrapper, don't just use .parentNode
|
||||||
|
var toolbar = Zotero.getAncestorByTagName(icon, "toolbar");
|
||||||
|
inAddonBar = toolbar == addonBar;
|
||||||
|
}
|
||||||
|
var val = this.get("statusBarIcon");
|
||||||
|
if (val == 0) {
|
||||||
|
// If showing in add-on bar, hide
|
||||||
|
if (!icon || !inAddonBar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
palette.appendChild(icon);
|
||||||
|
if (wrapper) {
|
||||||
|
addonBar.removeChild(wrapper);
|
||||||
|
}
|
||||||
|
addonBar.setAttribute("currentset", addonBar.currentSet);
|
||||||
|
doc.persist(addonBar.id, "currentset");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// If showing somewhere else, remove it from there
|
||||||
|
if (icon && !inAddonBar) {
|
||||||
|
palette.appendChild(icon);
|
||||||
|
if (wrapper) {
|
||||||
|
toolbar.removeChild(wrapper);
|
||||||
|
}
|
||||||
|
toolbar.setAttribute("currentset", toolbar.currentSet);
|
||||||
|
doc.persist(toolbar.id, "currentset");
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not showing in add-on bar, add
|
||||||
|
if (!inAddonBar) {
|
||||||
|
var icon = addonBar.insertItem("zotero-toolbar-button");
|
||||||
|
addonBar.setAttribute("currentset", addonBar.currentSet);
|
||||||
|
doc.persist(addonBar.id, "currentset");
|
||||||
|
addonBar.setAttribute("collapsed", false);
|
||||||
|
doc.persist(addonBar.id, "collapsed");
|
||||||
|
}
|
||||||
|
// And make small
|
||||||
|
if (val == 1) {
|
||||||
|
icon.setAttribute("compact", true);
|
||||||
|
}
|
||||||
|
// Or large
|
||||||
|
else if (val == 2) {
|
||||||
|
icon.removeAttribute("compact");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case "automaticScraperUpdates":
|
case "automaticScraperUpdates":
|
||||||
if (this.get('automaticScraperUpdates')){
|
if (this.get('automaticScraperUpdates')){
|
||||||
Zotero.Schema.updateFromRepository();
|
Zotero.Schema.updateFromRepository();
|
||||||
|
@ -2120,6 +2183,12 @@ Zotero.Prefs = new function(){
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
Zotero.debug(e);
|
||||||
|
throw (e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue