Various changes to take into account that Zotero.isFx may be true even if a translator is running as a bookmarklet
This commit is contained in:
parent
3c552ac628
commit
1f20615582
5 changed files with 12 additions and 11 deletions
|
@ -263,7 +263,7 @@ function load(event) {
|
|||
viewerMode = !Zotero;
|
||||
} catch(e) {};
|
||||
|
||||
if(window.chrome || window.safari) {
|
||||
if(!viewerMode && (window.chrome || window.safari)) {
|
||||
// initialize injection
|
||||
Zotero.initInject();
|
||||
// make sure that connector is online
|
||||
|
|
|
@ -53,7 +53,7 @@ Zotero.Date = new function(){
|
|||
this.getMonths = function() {
|
||||
if(_months) return _months;
|
||||
|
||||
if(Zotero.isFx) {
|
||||
if(Zotero.isFx && !Zotero.isBookmarklet) {
|
||||
var src = 'chrome://global/locale/dateFormat.properties';
|
||||
var localeService = Components.classes['@mozilla.org/intl/nslocaleservice;1'].
|
||||
getService(Components.interfaces.nsILocaleService);
|
||||
|
|
|
@ -88,7 +88,7 @@ Zotero.Debug = new function () {
|
|||
|
||||
if (_console) {
|
||||
var output = 'zotero(' + level + ')' + (_time ? deltaStr : '') + ': ' + message;
|
||||
if(Zotero.isFx) {
|
||||
if(Zotero.isFx && !Zotero.isBookmarklet) {
|
||||
dump(output+"\n\n");
|
||||
} else if(window.console) {
|
||||
window.console.log(output);
|
||||
|
|
|
@ -218,7 +218,7 @@ Zotero.Translate.Sandbox = {
|
|||
"getTranslatorObject":"r"
|
||||
};
|
||||
safeTranslator.setSearch = function(arg) {
|
||||
if(Zotero.isFx4) arg = JSON.parse(JSON.stringify(arg));
|
||||
if(Zotero.isFx4 && !Zotero.isBookmarklet) arg = JSON.parse(JSON.stringify(arg));
|
||||
return translation.setSearch(arg);
|
||||
};
|
||||
safeTranslator.setDocument = function(arg) { return translation.setDocument(arg) };
|
||||
|
@ -227,7 +227,8 @@ Zotero.Translate.Sandbox = {
|
|||
function(obj, item) {
|
||||
try {
|
||||
if(arg1 == "itemDone") {
|
||||
if(Zotero.isFx && (translate instanceof Zotero.Translate.Web
|
||||
if(Zotero.isFx && !Zotero.isBookmarklet
|
||||
&& (translate instanceof Zotero.Translate.Web
|
||||
|| translate instanceof Zotero.Translate.Search)) {
|
||||
// necessary to get around object wrappers in Firefox
|
||||
item = translate._sandboxManager.sandbox.Zotero._transferItem(JSON.stringify(item));
|
||||
|
@ -293,7 +294,7 @@ Zotero.Translate.Sandbox = {
|
|||
var haveTranslatorFunction = function(translator) {
|
||||
translation.translator[0] = translator;
|
||||
translation._loadTranslator(translator, function() {
|
||||
if(Zotero.isFx) {
|
||||
if(Zotero.isFx && !Zotero.isBookmarklet) {
|
||||
// do same origin check
|
||||
var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(Components.interfaces.nsIScriptSecurityManager);
|
||||
|
@ -342,7 +343,7 @@ Zotero.Translate.Sandbox = {
|
|||
haveTranslatorFunction(translation.translator[0]);
|
||||
return translation._sandboxManager.sandbox;
|
||||
} else {
|
||||
if(Zotero.isConnector && !Zotero.isFx && !callback) {
|
||||
if(Zotero.isConnector && (!Zotero.isFx || Zotero.isBookmarklet) && !callback) {
|
||||
throw new Error("Translator must pass a callback to getTranslatorObject() to "+
|
||||
"operate in this translation environment.");
|
||||
}
|
||||
|
@ -1219,7 +1220,7 @@ Zotero.Translate.Base.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
if(Zotero.isFx) {
|
||||
if(Zotero.isFx && !Zotero.isBookmarklet) {
|
||||
// workaround for inadvertant attempts to pass E4X back from sandbox
|
||||
src += "Zotero._transferItem = function(itemString) {"+
|
||||
"var item = JSON.parse(itemString);"+
|
||||
|
@ -1263,7 +1264,7 @@ Zotero.Translate.Base.prototype = {
|
|||
* @param {Integer} level Log level (1-5, higher numbers are higher priority)
|
||||
*/
|
||||
"_debug":function(string, level) {
|
||||
if(typeof string === "object" && Zotero.isFx36) {
|
||||
if(typeof string === "object" && Zotero.isFx36 && !Zotero.isBookmarklet) {
|
||||
string = new XPCSafeJSObjectWrapper(string);
|
||||
}
|
||||
|
||||
|
@ -1473,7 +1474,7 @@ Zotero.Translate.Web.prototype.complete = function(returnValue, error) {
|
|||
// Report translation failure if we failed
|
||||
if(oldState == "translate" && errorString && this.translator[0].inRepository && Zotero.Prefs.get("reportTranslationFailure")) {
|
||||
// Don't report failure if in private browsing mode
|
||||
if(Zotero.isFx && !Zotero.isStandalone) {
|
||||
if(Zotero.isFx && !Zotero.isBookmarklet && !Zotero.isStandalone) {
|
||||
var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
|
||||
.getService(Components.interfaces.nsIPrivateBrowsingService);
|
||||
if (pbs.privateBrowsingEnabled) {
|
||||
|
|
|
@ -221,7 +221,7 @@ Zotero.Utilities = {
|
|||
// If no tags, no need to unescape
|
||||
if(str.indexOf("<") === -1 && str.indexOf("&") === -1) return str;
|
||||
|
||||
if(Zotero.isFx) {
|
||||
if(Zotero.isFx && !Zotero.isBookmarklet) {
|
||||
if(!Zotero.Utilities._nsISUHTML) {
|
||||
Zotero.Utilities._nsISUHTML = Components.classes["@mozilla.org/feed-unescapehtml;1"]
|
||||
.getService(Components.interfaces.nsIScriptableUnescapeHTML);
|
||||
|
|
Loading…
Add table
Reference in a new issue