Merge branch '3.0'
This commit is contained in:
commit
83073fd72b
4 changed files with 105 additions and 76 deletions
|
@ -225,30 +225,14 @@ Zotero.Attachments = new function(){
|
||||||
|
|
||||||
// Save using a hidden browser
|
// Save using a hidden browser
|
||||||
var nativeHandlerImport = function () {
|
var nativeHandlerImport = function () {
|
||||||
var browser = Zotero.Browser.createHiddenBrowser();
|
var browser = Zotero.HTTP.processDocuments(url, function() {
|
||||||
if(cookieSandbox) cookieSandbox.attachToBrowser(browser);
|
|
||||||
var imported = false;
|
|
||||||
var onpageshow = function() {
|
|
||||||
// ignore spurious about:blank loads
|
|
||||||
if(browser.contentDocument.location.href == "about:blank") return;
|
|
||||||
|
|
||||||
// pageshow can be triggered multiple times on some pages,
|
|
||||||
// so make sure we only import once
|
|
||||||
// (https://www.zotero.org/trac/ticket/795)
|
|
||||||
if (imported) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var importCallback = function (item) {
|
var importCallback = function (item) {
|
||||||
browser.removeEventListener("pageshow", onpageshow, false);
|
|
||||||
Zotero.Browser.deleteHiddenBrowser(browser);
|
Zotero.Browser.deleteHiddenBrowser(browser);
|
||||||
if(callback) callback(item);
|
if(callback) callback(item);
|
||||||
};
|
};
|
||||||
Zotero.Attachments.importFromDocument(browser.contentDocument,
|
Zotero.Attachments.importFromDocument(browser.contentDocument,
|
||||||
sourceItemID, forceTitle, parentCollectionIDs, importCallback, libraryID);
|
sourceItemID, forceTitle, parentCollectionIDs, importCallback, libraryID);
|
||||||
imported = true;
|
}, undefined, undefined, true);
|
||||||
};
|
|
||||||
browser.addEventListener("pageshow", onpageshow, false);
|
|
||||||
browser.loadURI(url);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Save using remote web browser persist
|
// Save using remote web browser persist
|
||||||
|
@ -397,7 +381,7 @@ Zotero.Attachments = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mimeType) {
|
if (mimeType) {
|
||||||
return process(mimeType);
|
return process(mimeType, Zotero.MIME.hasNativeHandler(mimeType));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Zotero.MIME.getMIMETypeFromURL(url, function (mimeType, hasNativeHandler) {
|
Zotero.MIME.getMIMETypeFromURL(url, function (mimeType, hasNativeHandler) {
|
||||||
|
|
|
@ -1138,7 +1138,7 @@ CSL.Output.Queue.prototype.string = function (state, myblobs, blob) {
|
||||||
ret = ret.concat(addtoret);
|
ret = ret.concat(addtoret);
|
||||||
}
|
}
|
||||||
if (blobjr.strings.first_blob) {
|
if (blobjr.strings.first_blob) {
|
||||||
state.registry.registry[state.tmp.count_offset_characters].offset = state.tmp.offset_characters;
|
state.registry.registry[blobjr.strings.first_blob].offset = state.tmp.offset_characters;
|
||||||
state.tmp.count_offset_characters = false;
|
state.tmp.count_offset_characters = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2156,7 +2156,7 @@ CSL.DateParser = function () {
|
||||||
};
|
};
|
||||||
CSL.Engine = function (sys, style, lang, forceLang) {
|
CSL.Engine = function (sys, style, lang, forceLang) {
|
||||||
var attrs, langspec, localexml, locale;
|
var attrs, langspec, localexml, locale;
|
||||||
this.processor_version = "1.0.302";
|
this.processor_version = "1.0.305";
|
||||||
this.csl_version = "1.0";
|
this.csl_version = "1.0";
|
||||||
this.sys = sys;
|
this.sys = sys;
|
||||||
this.sys.xml = new CSL.System.Xml.Parsing();
|
this.sys.xml = new CSL.System.Xml.Parsing();
|
||||||
|
@ -7302,45 +7302,53 @@ CSL.Node.number = {
|
||||||
varname = this.variables[0];
|
varname = this.variables[0];
|
||||||
state.parallel.StartVariable(this.variables[0]);
|
state.parallel.StartVariable(this.variables[0]);
|
||||||
state.parallel.AppendToVariable(Item[this.variables[0]]);
|
state.parallel.AppendToVariable(Item[this.variables[0]]);
|
||||||
var node = this;
|
if (this.text_case_normal) {
|
||||||
if (!state.tmp.shadow_numbers[varname]
|
var value = Item[this.variables[0]];
|
||||||
|| (state.tmp.shadow_numbers[varname].values.length
|
if (value) {
|
||||||
&& state.tmp.shadow_numbers[varname].values[0][2] === false)) {
|
value = value.replace("\\", "");
|
||||||
if (varname === "locator") {
|
state.output.append(value, this)
|
||||||
state.processNumber(node, item, varname);
|
|
||||||
} else {
|
|
||||||
state.processNumber(node, Item, varname);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (varname === "locator") {
|
|
||||||
state.tmp.done_vars.push("locator");
|
|
||||||
}
|
|
||||||
var values = state.tmp.shadow_numbers[varname].values;
|
|
||||||
var blob;
|
|
||||||
var newstr = ""
|
|
||||||
if (state.opt["page-range-format"]
|
|
||||||
&& !this.strings.prefix && !this.strings.suffix
|
|
||||||
&& !this.strings.form) {
|
|
||||||
for (var i = 0, ilen = values.length; i < ilen; i += 1) {
|
|
||||||
newstr += values[i][1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (newstr && !newstr.match(/^[-.\u20130-9]+$/)) {
|
|
||||||
state.output.append(newstr, this);
|
|
||||||
} else {
|
} else {
|
||||||
if (values.length) {
|
var node = this;
|
||||||
state.output.openLevel("empty");
|
if (!state.tmp.shadow_numbers[varname]
|
||||||
for (var i = 0, ilen = values.length; i < ilen; i += 1) {
|
|| (state.tmp.shadow_numbers[varname].values.length
|
||||||
var blob = new CSL[values[i][0]](values[i][1], values[i][2], Item.id);
|
&& state.tmp.shadow_numbers[varname].values[0][2] === false)) {
|
||||||
if (i > 0) {
|
if (varname === "locator") {
|
||||||
blob.strings.prefix = blob.strings.prefix.replace(/^\s*/, "");
|
state.processNumber(node, item, varname);
|
||||||
}
|
} else {
|
||||||
if (i < values.length - 1) {
|
state.processNumber(node, Item, varname);
|
||||||
blob.strings.suffix = blob.strings.suffix.replace(/\s*$/, "");
|
}
|
||||||
}
|
}
|
||||||
state.output.append(blob, "literal", false, false, true);
|
if (varname === "locator") {
|
||||||
|
state.tmp.done_vars.push("locator");
|
||||||
|
}
|
||||||
|
var values = state.tmp.shadow_numbers[varname].values;
|
||||||
|
var blob;
|
||||||
|
var newstr = ""
|
||||||
|
if (state.opt["page-range-format"]
|
||||||
|
&& !this.strings.prefix && !this.strings.suffix
|
||||||
|
&& !this.strings.form) {
|
||||||
|
for (var i = 0, ilen = values.length; i < ilen; i += 1) {
|
||||||
|
newstr += values[i][1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newstr && !newstr.match(/^[-.\u20130-9]+$/)) {
|
||||||
|
state.output.append(newstr, this);
|
||||||
|
} else {
|
||||||
|
if (values.length) {
|
||||||
|
state.output.openLevel("empty");
|
||||||
|
for (var i = 0, ilen = values.length; i < ilen; i += 1) {
|
||||||
|
var blob = new CSL[values[i][0]](values[i][1], values[i][2], Item.id);
|
||||||
|
if (i > 0) {
|
||||||
|
blob.strings.prefix = blob.strings.prefix.replace(/^\s*/, "");
|
||||||
|
}
|
||||||
|
if (i < values.length - 1) {
|
||||||
|
blob.strings.suffix = blob.strings.suffix.replace(/\s*$/, "");
|
||||||
|
}
|
||||||
|
state.output.append(blob, "literal", false, false, true);
|
||||||
|
}
|
||||||
|
state.output.closeLevel("empty");
|
||||||
}
|
}
|
||||||
state.output.closeLevel("empty");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.parallel.CloseVariable("number");
|
state.parallel.CloseVariable("number");
|
||||||
|
@ -7700,6 +7708,35 @@ CSL.Node.text = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
CSL.Attributes = {};
|
CSL.Attributes = {};
|
||||||
|
CSL.Attributes["@is-plural"] = function (state, arg) {
|
||||||
|
var func = function (state, Item, item) {
|
||||||
|
var nameList = Item[arg];
|
||||||
|
var ret = false;
|
||||||
|
if (nameList && nameList.length) {
|
||||||
|
var persons = 0;
|
||||||
|
var institutions = 0;
|
||||||
|
var last_is_person = false;
|
||||||
|
for (var i = 0, ilen = nameList.length; i < ilen; i += 1) {
|
||||||
|
if (nameList[i].isInstitution && (nameList[i].literal || (nameList[i].family && !nameList[i].given))) {
|
||||||
|
institutions += 1;
|
||||||
|
last_is_person = false;
|
||||||
|
} else {
|
||||||
|
persons += 1;
|
||||||
|
last_is_person = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (persons > 1) {
|
||||||
|
ret = true;
|
||||||
|
} else if (institutions > 1) {
|
||||||
|
ret = true;
|
||||||
|
} else if (institutions && last_is_person) {
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
this.tests.push(func);
|
||||||
|
}
|
||||||
CSL.Attributes["@subjurisdictions"] = function (state, arg) {
|
CSL.Attributes["@subjurisdictions"] = function (state, arg) {
|
||||||
var trysubjurisdictions = parseInt(arg, 10);
|
var trysubjurisdictions = parseInt(arg, 10);
|
||||||
var func = function (state, Item, item) {
|
var func = function (state, Item, item) {
|
||||||
|
@ -7902,7 +7939,7 @@ CSL.Attributes["@variable"] = function (state, arg) {
|
||||||
}
|
}
|
||||||
if (Item[variable]) {
|
if (Item[variable]) {
|
||||||
for (var key in Item[variable]) {
|
for (var key in Item[variable]) {
|
||||||
if (this.dateparts.indexOf(key) === -1) {
|
if (this.dateparts.indexOf(key) === -1 && "literal" !== key) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (Item[variable][key]) {
|
if (Item[variable][key]) {
|
||||||
|
@ -8430,27 +8467,31 @@ CSL.Attributes["@page-range-format"] = function (state, arg) {
|
||||||
};
|
};
|
||||||
CSL.Attributes["@text-case"] = function (state, arg) {
|
CSL.Attributes["@text-case"] = function (state, arg) {
|
||||||
var func = function (state, Item) {
|
var func = function (state, Item) {
|
||||||
this.strings["text-case"] = arg;
|
if (arg === "normal") {
|
||||||
if (arg === "title") {
|
this.text_case_normal = true;
|
||||||
var m = false;
|
} else {
|
||||||
var default_locale = state.opt["default-locale"][0].slice(0, 2);
|
this.strings["text-case"] = arg;
|
||||||
if (Item.jurisdiction) {
|
if (arg === "title") {
|
||||||
this.strings["text-case"] = "passthrough";
|
var m = false;
|
||||||
} else if (Item.language) {
|
var default_locale = state.opt["default-locale"][0].slice(0, 2);
|
||||||
m = Item.language.match(/^\s*([A-Za-z]{2})(?:$|-| )/);
|
if (Item.jurisdiction) {
|
||||||
if (!m) {
|
|
||||||
this.strings["text-case"] = "passthrough";
|
this.strings["text-case"] = "passthrough";
|
||||||
} else if (m[1].toLowerCase() !== "en") {
|
} else if (Item.language) {
|
||||||
this.strings["text-case"] = "passthrough";
|
m = Item.language.match(/^\s*([A-Za-z]{2})(?:$|-| )/);
|
||||||
for (var i = 0, ilen = state.opt.english_locale_escapes.length; i < ilen; i += 1) {
|
if (!m) {
|
||||||
var escaper = state.opt.english_locale_escapes[i];
|
this.strings["text-case"] = "passthrough";
|
||||||
if (m[1].slice(0, escaper.length).toLowerCase() === escaper) {
|
} else if (m[1].toLowerCase() !== "en") {
|
||||||
this.strings["text-case"] = arg;
|
this.strings["text-case"] = "passthrough";
|
||||||
|
for (var i = 0, ilen = state.opt.english_locale_escapes.length; i < ilen; i += 1) {
|
||||||
|
var escaper = state.opt.english_locale_escapes[i];
|
||||||
|
if (m[1].slice(0, escaper.length).toLowerCase() === escaper) {
|
||||||
|
this.strings["text-case"] = arg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (default_locale !== "en") {
|
||||||
|
this.strings["text-case"] = "passthrough";
|
||||||
}
|
}
|
||||||
} else if (default_locale !== "en") {
|
|
||||||
this.strings["text-case"] = "passthrough";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1392,7 +1392,7 @@ Zotero.Sync.Storage = new function () {
|
||||||
// For advertising junk files, ignore a bug on Windows where
|
// For advertising junk files, ignore a bug on Windows where
|
||||||
// destFile.create() works but zipReader.extract() doesn't
|
// destFile.create() works but zipReader.extract() doesn't
|
||||||
// when the path length is close to 255.
|
// when the path length is close to 255.
|
||||||
if (destFile.leafName.match(/[a-zA-Z0-9]{130,}/)) {
|
if (destFile.leafName.match(/[a-zA-Z0-9+=]{130,}/)) {
|
||||||
var msg = "Ignoring error extracting '" + destFile.path + "'";
|
var msg = "Ignoring error extracting '" + destFile.path + "'";
|
||||||
Zotero.debug(msg, 2);
|
Zotero.debug(msg, 2);
|
||||||
Zotero.debug(e, 2);
|
Zotero.debug(e, 2);
|
||||||
|
|
|
@ -1287,6 +1287,10 @@ Zotero.Translate.Base.prototype = {
|
||||||
this._sandboxManager.importObject({"Utilities":new Zotero.Utilities.Translate(this)});
|
this._sandboxManager.importObject({"Utilities":new Zotero.Utilities.Translate(this)});
|
||||||
this._sandboxManager.sandbox.Zotero.Utilities.HTTP = this._sandboxManager.sandbox.Zotero.Utilities;
|
this._sandboxManager.sandbox.Zotero.Utilities.HTTP = this._sandboxManager.sandbox.Zotero.Utilities;
|
||||||
|
|
||||||
|
this._sandboxManager.sandbox.Zotero.isBookmarklet = Zotero.isBookmarklet || false;
|
||||||
|
this._sandboxManager.sandbox.Zotero.isConnector = Zotero.isConnector || false;
|
||||||
|
this._sandboxManager.sandbox.Zotero.isServer = Zotero.isServer || false;
|
||||||
|
|
||||||
// create shortcuts
|
// create shortcuts
|
||||||
this._sandboxManager.sandbox.Z = this._sandboxManager.sandbox.Zotero;
|
this._sandboxManager.sandbox.Z = this._sandboxManager.sandbox.Zotero;
|
||||||
this._sandboxManager.sandbox.ZU = this._sandboxManager.sandbox.Zotero.Utilities;
|
this._sandboxManager.sandbox.ZU = this._sandboxManager.sandbox.Zotero.Utilities;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue