diff --git a/chrome/content/zotero/xpcom/mimeTypeHandler.js b/chrome/content/zotero/xpcom/mimeTypeHandler.js index 84f444767..4d3b3f44b 100644 --- a/chrome/content/zotero/xpcom/mimeTypeHandler.js +++ b/chrome/content/zotero/xpcom/mimeTypeHandler.js @@ -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