Drop a lot of Fx 3.6-specific code
This commit is contained in:
parent
0f6b151ea4
commit
8d48b1de54
12 changed files with 42 additions and 192 deletions
|
@ -130,7 +130,7 @@ var Zotero_QuickFormat = new function () {
|
|||
if(event.target !== document) return;
|
||||
// make sure we are visible
|
||||
window.setTimeout(function() {
|
||||
if(!Zotero.isFx4) window.sizeToContent();
|
||||
window.sizeToContent();
|
||||
var screenX = window.screenX;
|
||||
var screenY = window.screenY;
|
||||
var xRange = [window.screen.availLeft, window.screen.width-window.outerWidth];
|
||||
|
@ -744,16 +744,7 @@ var Zotero_QuickFormat = new function () {
|
|||
if(((!referenceHeight && firstReference) || (!separatorHeight && firstSeparator)
|
||||
|| !panelFrameHeight) && !panelShowing) {
|
||||
_openReferencePanel();
|
||||
if(!Zotero.isFx4) {
|
||||
referencePanel.addEventListener("popupshown", function() {
|
||||
referencePanel.removeEventListener("popupshown", arguments.callee, false);
|
||||
panelShowing = true;
|
||||
_resize();
|
||||
}, false);
|
||||
return;
|
||||
} else {
|
||||
panelShowing = true;
|
||||
}
|
||||
panelShowing = true;
|
||||
}
|
||||
|
||||
if(!referenceHeight && firstReference) {
|
||||
|
|
|
@ -106,9 +106,7 @@ const Zotero_Lookup = new function () {
|
|||
* Focuses the field
|
||||
*/
|
||||
this.onShowing = function() {
|
||||
if(!Zotero.isFx4) {
|
||||
document.getElementById("zotero-lookup-panel").style.padding = "10px";
|
||||
}
|
||||
document.getElementById("zotero-lookup-panel").style.padding = "10px";
|
||||
|
||||
document.getElementById("zotero-lookup-progress").hidden = false;
|
||||
var identifierElement = document.getElementById("zotero-lookup-textbox");
|
||||
|
|
|
@ -119,11 +119,6 @@ function init()
|
|||
} else if(document.location.hash == "#cite") {
|
||||
document.getElementById('zotero-prefs').showPane(document.getElementById("zotero-prefpane-cite"));
|
||||
}
|
||||
|
||||
var showInAppTab;
|
||||
if(!Zotero.isFx4 && (showInAppTab = document.getElementById("zotero-prefpane-general-showIn-appTab"))) {
|
||||
showInAppTab.setAttribute("hidden", "true");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ var ZoteroTab = new function()
|
|||
this.containerWindow.gBrowser.tabContainer.addEventListener("TabSelect", listener, false);
|
||||
}
|
||||
|
||||
if(Zotero && Zotero.isFx4 && Zotero.Prefs.get("showIn") != 2) {
|
||||
if(Zotero && Zotero.Prefs.get("showIn") != 2) {
|
||||
// on Fx 4, add an event listener so the pinned tab isn't restored on close
|
||||
var pinnedTabCloser = function() {
|
||||
try {
|
||||
|
@ -104,7 +104,7 @@ var ZoteroTab = new function()
|
|||
if(tabs.length > 1) {
|
||||
window.close();
|
||||
} else {
|
||||
if(Zotero.isFx4 && tabs[0].pinned) this.containerWindow.gBrowser.unpinTab(tabs[0]);
|
||||
if(tabs[0].pinned) this.containerWindow.gBrowser.unpinTab(tabs[0]);
|
||||
document.location.replace(this.containerWindow.gHomeButton.getHomePage());
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -193,14 +193,9 @@ Zotero.Integration = new function() {
|
|||
if(callback) callback(_integrationVersionsOK);
|
||||
}
|
||||
|
||||
if(Zotero.isFx4) {
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
AddonManager.getAddonsByIDs(INTEGRATION_PLUGINS, _checkAddons);
|
||||
} else {
|
||||
var extMan = Components.classes['@mozilla.org/extensions/manager;1'].
|
||||
getService(Components.interfaces.nsIExtensionManager);
|
||||
_checkAddons([extMan.getItemForID(id) for each(id in INTEGRATION_PLUGINS)]);
|
||||
}
|
||||
var extMan = Components.classes['@mozilla.org/extensions/manager;1'].
|
||||
getService(Components.interfaces.nsIExtensionManager);
|
||||
_checkAddons([extMan.getItemForID(id) for each(id in INTEGRATION_PLUGINS)]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -289,7 +284,7 @@ Zotero.Integration = new function() {
|
|||
"Minefield":"org.mozilla.minefield"
|
||||
};
|
||||
|
||||
if(Zotero.isFx4 && win) {
|
||||
if(win) {
|
||||
Components.utils.import("resource://gre/modules/ctypes.jsm");
|
||||
|
||||
if(!_carbon) {
|
||||
|
@ -333,7 +328,7 @@ Zotero.Integration = new function() {
|
|||
_executeAppleScript('tell application id "'+BUNDLE_IDS[Zotero.appName]+'" to activate');
|
||||
}
|
||||
}
|
||||
} else if(!Zotero.isWin && Zotero.isFx4 && win) {
|
||||
} else if(!Zotero.isWin && win) {
|
||||
Components.utils.import("resource://gre/modules/ctypes.jsm");
|
||||
|
||||
if(_x11 === false) return;
|
||||
|
|
|
@ -107,23 +107,11 @@ Zotero.IPC = new function() {
|
|||
if(!lib) return false;
|
||||
|
||||
// int open(const char *path, int oflag);
|
||||
if(Zotero.isFx36) {
|
||||
open = lib.declare("open", ctypes.default_abi, ctypes.int32_t, ctypes.string, ctypes.int32_t);
|
||||
} else {
|
||||
open = lib.declare("open", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.int);
|
||||
}
|
||||
open = lib.declare("open", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.int);
|
||||
// ssize_t write(int fildes, const void *buf, size_t nbyte);
|
||||
if(Zotero.isFx36) {
|
||||
write = lib.declare("write", ctypes.default_abi, ctypes.int32_t, ctypes.int32_t, ctypes.string, ctypes.uint32_t);
|
||||
} else {
|
||||
write = lib.declare("write", ctypes.default_abi, ctypes.ssize_t, ctypes.int, ctypes.char.ptr, ctypes.size_t);
|
||||
}
|
||||
write = lib.declare("write", ctypes.default_abi, ctypes.ssize_t, ctypes.int, ctypes.char.ptr, ctypes.size_t);
|
||||
// int close(int filedes);
|
||||
if(Zotero.isFx36) {
|
||||
close = lib.declare("close", ctypes.default_abi, ctypes.int32_t, ctypes.int32_t);
|
||||
} else {
|
||||
close = lib.declare("close", ctypes.default_abi, ctypes.int, ctypes.int);
|
||||
}
|
||||
close = lib.declare("close", ctypes.default_abi, ctypes.int, ctypes.int);
|
||||
}
|
||||
|
||||
// On OS X, O_NONBLOCK = 0x0004
|
||||
|
@ -144,11 +132,6 @@ Zotero.IPC = new function() {
|
|||
*/
|
||||
this.broadcast = function(msg) {
|
||||
if(Zotero.isWin) { // communicate via WM_COPYDATA method
|
||||
// there is no ctypes struct support in Fx 3.6
|
||||
// while we could mimic it, it's easier just to require users to upgrade if they
|
||||
// want connector sharing
|
||||
if(!Zotero.isFx4) return false;
|
||||
|
||||
Components.utils.import("resource://gre/modules/ctypes.jsm");
|
||||
|
||||
// communicate via message window
|
||||
|
@ -386,11 +369,7 @@ Zotero.IPC.Pipe = new function() {
|
|||
if(!_mkfifo) {
|
||||
var libc = Zotero.IPC.getLibc();
|
||||
if(!libc) return false;
|
||||
if(Zotero.isFx36) {
|
||||
_mkfifo = libc.declare("mkfifo", ctypes.default_abi, ctypes.int32_t, ctypes.string, ctypes.uint32_t);
|
||||
} else {
|
||||
_mkfifo = libc.declare("mkfifo", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.unsigned_int);
|
||||
}
|
||||
_mkfifo = libc.declare("mkfifo", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.unsigned_int);
|
||||
}
|
||||
|
||||
// make pipe
|
||||
|
|
|
@ -112,22 +112,14 @@ Zotero.MIMETypeHandler = new function () {
|
|||
var checkValue = {"value":false};
|
||||
|
||||
// make tab-modal dialog (https://developer.mozilla.org/en/Using_tab-modal_prompts)
|
||||
if(Zotero.isFx4) {
|
||||
var prompt = Components.classes["@mozilla.org/prompter;1"]
|
||||
.getService(Components.interfaces.nsIPromptFactory)
|
||||
.getPrompt(win, Components.interfaces.nsIPrompt);
|
||||
|
||||
var bag = prompt.QueryInterface(Components.interfaces.nsIWritablePropertyBag2);
|
||||
bag.setPropertyAsBool("allowTabModal", true);
|
||||
|
||||
var continueDownload = prompt.confirmCheck(title, text, checkMsg, checkValue);
|
||||
} else {
|
||||
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(Components.interfaces.nsIPromptService);
|
||||
|
||||
var continueDownload = ps.confirmCheck(win, title, text, checkMsg, checkValue);
|
||||
}
|
||||
var prompt = Components.classes["@mozilla.org/prompter;1"]
|
||||
.getService(Components.interfaces.nsIPromptFactory)
|
||||
.getPrompt(win, Components.interfaces.nsIPrompt);
|
||||
|
||||
var bag = prompt.QueryInterface(Components.interfaces.nsIWritablePropertyBag2);
|
||||
bag.setPropertyAsBool("allowTabModal", true);
|
||||
|
||||
var continueDownload = prompt.confirmCheck(title, text, checkMsg, checkValue);
|
||||
if(!continueDownload) return;
|
||||
if(checkValue.value) {
|
||||
// add to allowed sites if desired
|
||||
|
|
|
@ -446,7 +446,7 @@ Zotero.Schema = new function(){
|
|||
.get("AChrom", Components.interfaces.nsIFile);
|
||||
_updateBundledFilesCallback(appChrome.parent, mode, skipDeleteUpdate,
|
||||
runRemoteUpdateWhenComplete);
|
||||
} else if(Zotero.isFx4) {
|
||||
} else {
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
AddonManager.getAddonByID(ZOTERO_CONFIG['GUID'],
|
||||
function(addon) {
|
||||
|
@ -454,13 +454,6 @@ Zotero.Schema = new function(){
|
|||
addon.getResourceURI().QueryInterface(Components.interfaces.nsIFileURL).file,
|
||||
mode, skipDeleteUpdate, runRemoteUpdateWhenComplete);
|
||||
});
|
||||
} else {
|
||||
var gExtensionManager = Components.classes["@mozilla.org/extensions/manager;1"]
|
||||
.getService(Components.interfaces.nsIExtensionManager);
|
||||
var itemLocation = gExtensionManager.getInstallLocation(ZOTERO_CONFIG['GUID'])
|
||||
.getItemLocation(ZOTERO_CONFIG['GUID']);
|
||||
_updateBundledFilesCallback(itemLocation, mode, skipDeleteUpdate,
|
||||
runRemoteUpdateWhenComplete);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ Zotero.Translate.Sandbox = {
|
|||
"getTranslatorObject":"r"
|
||||
};
|
||||
safeTranslator.setSearch = function(arg) {
|
||||
if(Zotero.isFx4 && !Zotero.isBookmarklet) arg = JSON.parse(JSON.stringify(arg));
|
||||
if(!Zotero.isBookmarklet) arg = JSON.parse(JSON.stringify(arg));
|
||||
return translation.setSearch(arg);
|
||||
};
|
||||
safeTranslator.setDocument = function(arg) { return translation.setDocument(arg) };
|
||||
|
|
|
@ -318,13 +318,9 @@ Zotero.Translate.DOMWrapper = new function() {
|
|||
* @return {Object} An obj that is no longer Xrayed
|
||||
*/
|
||||
this.wrap = function(obj) {
|
||||
if(Zotero.isFx4) {
|
||||
Zotero.debug(obj.toString());
|
||||
var newObj = wrapPrivileged(obj);
|
||||
return newObj;
|
||||
} else {
|
||||
return _wrapFx36(obj);
|
||||
}
|
||||
Zotero.debug(obj.toString());
|
||||
var newObj = wrapPrivileged(obj);
|
||||
return newObj;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -348,53 +344,6 @@ Zotero.Translate.DOMWrapper = new function() {
|
|||
this.isWrapped = function(obj) {
|
||||
return "__wrappedDOMObject" in obj || isWrapper(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* A really ugly way of making a DOM object not look like a DOM object, so we can pass it to the
|
||||
* sandbox under Firefox 3.6
|
||||
* @param {XPCCrossOriginWrapper} obj
|
||||
* @param {Object} parent A parent to use as |this| when applying functions
|
||||
* @return {Object} An obj that is no longer Xrayed
|
||||
*/
|
||||
function _wrapFx36(obj, parent) {
|
||||
if(obj === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var wrapFx36 = arguments.callee;
|
||||
var type = typeof obj;
|
||||
if(type === "function") {
|
||||
var val = function() {
|
||||
var nArgs = arguments.length;
|
||||
var args = new Array(nArgs);
|
||||
for(var i=0; i<nArgs; i++) {
|
||||
args[i] = (arguments[i] instanceof Object && arguments[i].__wrappedDOMObject
|
||||
? arguments[i].__wrappedDOMObject : arguments[i]);
|
||||
}
|
||||
return wrapFx36(obj.apply(parent ? parent : null, args));
|
||||
}
|
||||
} else if(type === "object") {
|
||||
if(val instanceof Array) {
|
||||
var val = [];
|
||||
} else {
|
||||
var val = {};
|
||||
}
|
||||
} else {
|
||||
return obj;
|
||||
}
|
||||
|
||||
val.__wrappedDOMObject = obj;
|
||||
val.__exposedProps__ = {};
|
||||
for(var prop in obj) {
|
||||
let localProp = prop;
|
||||
val.__exposedProps__[localProp] = "r";
|
||||
val.__defineGetter__(localProp, function() {
|
||||
return wrapFx36(obj[localProp], obj);
|
||||
});
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -429,7 +378,7 @@ Zotero.Translate.SandboxManager = function(sandboxLocation) {
|
|||
.getService(Components.interfaces.nsIIOService);
|
||||
uri = ioService.newURI(uri, "UTF-8", null);
|
||||
|
||||
if(typeof sandboxLocation === "object" && sandboxLocation.nodePrincipal && Zotero.isFx4) {
|
||||
if(typeof sandboxLocation === "object" && sandboxLocation.nodePrincipal) {
|
||||
// if sandbox specified by DOM document, use nodePrincipal property
|
||||
var principal = sandboxLocation.nodePrincipal;
|
||||
} else {
|
||||
|
@ -464,11 +413,7 @@ Zotero.Translate.SandboxManager.prototype = {
|
|||
* Evaluates code in the sandbox
|
||||
*/
|
||||
"eval":function(code, exported, path) {
|
||||
if(Zotero.isFx4) {
|
||||
Components.utils.evalInSandbox(code, this.sandbox, "1.8", path, 1);
|
||||
} else {
|
||||
Components.utils.evalInSandbox(code, this.sandbox);
|
||||
}
|
||||
Components.utils.evalInSandbox(code, this.sandbox, "1.8", path, 1);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -491,29 +436,10 @@ Zotero.Translate.SandboxManager.prototype = {
|
|||
var isObject = typeof object[localKey] === "object";
|
||||
if(isFunction || isObject) {
|
||||
if(isFunction) {
|
||||
if(Zotero.isFx4) {
|
||||
if(passAsFirstArgument) {
|
||||
attachTo[localKey] = object[localKey].bind(object, passAsFirstArgument);
|
||||
} else {
|
||||
attachTo[localKey] = object[localKey].bind(object);
|
||||
}
|
||||
if(passAsFirstArgument) {
|
||||
attachTo[localKey] = object[localKey].bind(object, passAsFirstArgument);
|
||||
} else {
|
||||
attachTo[localKey] = function() {
|
||||
if(passAsFirstArgument) {
|
||||
var args = new Array(arguments.length+1);
|
||||
args[0] = passAsFirstArgument;
|
||||
var offset = 1;
|
||||
} else {
|
||||
var args = new Array(arguments.length);
|
||||
var offset = 0;
|
||||
}
|
||||
|
||||
for(var i=0, nArgs=arguments.length; i<nArgs; i++) {
|
||||
args[i+offset] = arguments[i];
|
||||
}
|
||||
|
||||
return object[localKey].apply(object, args);
|
||||
};
|
||||
attachTo[localKey] = object[localKey].bind(object);
|
||||
}
|
||||
} else {
|
||||
attachTo[localKey] = {};
|
||||
|
|
|
@ -216,29 +216,23 @@ const ZOTERO_CONFIG = {
|
|||
getService(Components.interfaces.nsIXULAppInfo),
|
||||
platformVersion = appInfo.platformVersion;
|
||||
this.isFx = true;
|
||||
this.isFx3 = platformVersion.indexOf('1.9') === 0;
|
||||
this.isFx35 = platformVersion.indexOf('1.9.1') === 0;
|
||||
this.isFx31 = this.isFx35;
|
||||
this.isFx36 = platformVersion.indexOf('1.9.2') === 0;
|
||||
this.isFx4 = versionComparator.compare(platformVersion, "2.0a1") >= 0;
|
||||
this.isFx5 = versionComparator.compare(platformVersion, "5.0a1") >= 0;
|
||||
this.isFx3 = false;
|
||||
this.isFx35 = false;
|
||||
this.isFx31 = false;
|
||||
this.isFx36 = false;
|
||||
this.isFx4 = true;
|
||||
this.isFx5 = true;
|
||||
|
||||
this.isStandalone = appInfo.ID == ZOTERO_CONFIG['GUID'];
|
||||
if(this.isStandalone) {
|
||||
this.version = appInfo.version;
|
||||
} else if(this.isFx4) {
|
||||
} else {
|
||||
// Use until we collect version from extension manager
|
||||
this.version = ZOTERO_CONFIG['VERSION'];
|
||||
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
AddonManager.getAddonByID(ZOTERO_CONFIG['GUID'],
|
||||
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
|
||||
|
@ -380,11 +374,7 @@ const ZOTERO_CONFIG = {
|
|||
|
||||
// evaluate
|
||||
Components.utils.evalInSandbox(prefsJs, sandbox);
|
||||
if(Zotero.isFx4) {
|
||||
var prefs = sandbox.prefs;
|
||||
} else {
|
||||
var prefs = new XPCSafeJSObjectWrapper(sandbox.prefs);
|
||||
}
|
||||
var prefs = sandbox.prefs;
|
||||
for(var key in prefs) {
|
||||
if(key.substr(0, ZOTERO_CONFIG.PREF_BRANCH.length) === ZOTERO_CONFIG.PREF_BRANCH
|
||||
&& key !== "extensions.zotero.firstRun2") {
|
||||
|
@ -1278,17 +1268,8 @@ const ZOTERO_CONFIG = {
|
|||
callback(addons);
|
||||
}
|
||||
|
||||
if(this.isFx4) {
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
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);
|
||||
}
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
AddonManager.getAllAddons(onHaveInstalledAddons);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 3daf3bdf2ce13d7e1a329f5648f18937d8251dee
|
||||
Subproject commit c436aebdd02c4c75fbd0bb79d43d29bd4eb3cf72
|
Loading…
Reference in a new issue