Don't require Zotero restart to change RIS/BibTeX handling preference
This commit is contained in:
parent
3f3666c972
commit
f7893ef400
|
@ -55,30 +55,50 @@ Zotero.MIMETypeHandler = new function () {
|
|||
_observers = [];
|
||||
|
||||
if(Zotero.Prefs.get("parseEndNoteMIMETypes")) {
|
||||
this.addHandler("application/x-endnote-refer", _importHandler, true);
|
||||
this.addHandler("application/x-research-info-systems", _importHandler, true);
|
||||
this.addHandler("application/x-inst-for-scientific-info", _importHandler, true);
|
||||
|
||||
this.addHandler("text/x-bibtex", _importHandler, true);
|
||||
this.addHandler("application/x-bibtex", _importHandler, true);
|
||||
|
||||
//
|
||||
// And some non-standard ones
|
||||
//
|
||||
this.addHandler("text/x-research-info-systems", _importHandler, true);
|
||||
// Nature uses this one
|
||||
this.addHandler("text/application/x-research-info-systems", _importHandler, true);
|
||||
// Cell uses this one
|
||||
this.addHandler("text/ris", _importHandler, true);
|
||||
// Not even trying
|
||||
this.addHandler("ris", _importHandler, true);
|
||||
this.registerMetadataHandlers();
|
||||
}
|
||||
Zotero.Prefs.registerObserver("parseEndNoteMIMETypes", function(val) {
|
||||
if (val) this.registerMetadataHandlers();
|
||||
else this.unregisterMetadataHandlers();
|
||||
}.bind(this));
|
||||
|
||||
this.addHandler("application/vnd.citationstyles.style+xml", function(a1, a2) { Zotero.Styles.install(a1, a2) });
|
||||
this.addHandler("text/x-csl", function(a1, a2) { Zotero.Styles.install(a1, a2) }); // deprecated
|
||||
this.addHandler("application/x-zotero-schema", Zotero.Schema.importSchema);
|
||||
this.addHandler("application/x-zotero-settings", Zotero.Prefs.importSettings);
|
||||
}
|
||||
|
||||
// MIME types that Zotero should handle when parseEndNoteMIMETypes preference
|
||||
// is enabled
|
||||
var metadataMIMETypes = [
|
||||
"application/x-endnote-refer", "application/x-research-info-systems",
|
||||
"application/x-inst-for-scientific-info",
|
||||
"text/x-bibtex", "application/x-bibtex",
|
||||
// Non-standard
|
||||
"text/x-research-info-systems",
|
||||
"text/application/x-research-info-systems", // Nature serves this
|
||||
"text/ris", // Cell serves this
|
||||
"ris" // Not even trying
|
||||
];
|
||||
|
||||
/**
|
||||
* Registers MIME types for parseEndNoteMIMETypes preference
|
||||
*/
|
||||
this.registerMetadataHandlers = function() {
|
||||
for (var i=0; i<metadataMIMETypes.length; i++) {
|
||||
this.addHandler(metadataMIMETypes[i], _importHandler, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters MIME types for parseEndNoteMIMETypes preference
|
||||
*/
|
||||
this.unregisterMetadataHandlers = function() {
|
||||
for (var i=0; i<metadataMIMETypes.length; i++) {
|
||||
this.removeHandler(metadataMIMETypes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a handler to handle a specific MIME type
|
||||
* @param {String} type MIME type to handle
|
||||
|
@ -92,6 +112,18 @@ Zotero.MIMETypeHandler = new function () {
|
|||
_ignoreContentDispositionTypes.push(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a handler for a specific MIME type
|
||||
* @param {String} type MIME type to handle
|
||||
*/
|
||||
this.removeHandler = function(type) {
|
||||
delete _typeHandlers[type];
|
||||
var i = _ignoreContentDispositionTypes.indexOf(type);
|
||||
if (i != -1) {
|
||||
_ignoreContentDispositionTypes.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an observer to inspect and possibly modify page headers
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user