From 030f918e22c6d8734423c442e10e524ab35332ae Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Fri, 23 Sep 2011 06:38:08 +0000 Subject: [PATCH] Don't let user uncheck "Store references" checkbox if there are stored references --- chrome/content/zotero/bibliography.js | 1 + chrome/content/zotero/xpcom/integration.js | 131 ++++++++++++--------- 2 files changed, 77 insertions(+), 55 deletions(-) diff --git a/chrome/content/zotero/bibliography.js b/chrome/content/zotero/bibliography.js index eefc5f498c..c3846a14d2 100644 --- a/chrome/content/zotero/bibliography.js +++ b/chrome/content/zotero/bibliography.js @@ -113,6 +113,7 @@ var Zotero_File_Interface_Bibliography = new function() { if(document.getElementById("storeReferences")) { if(_io.storeReferences || _io.storeReferences === undefined) { document.getElementById("storeReferences").checked = true; + if(_io.requireStoreReferences) document.getElementById("storeReferences").disabled = true; } } diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 8d38751435..c174a9c9a3 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -522,18 +522,22 @@ Zotero.Integration.Document.prototype._getSession = function(require, dontRunSet this._session = this._createNewSession(data); this._session.setData(data); if(dontRunSetDocPrefs) { - callback(); + callback(false); return; } - this._session.setDocPrefs(this._app.primaryFieldType, this._app.secondaryFieldType, function() { + this._session.setDocPrefs(this._app.primaryFieldType, this._app.secondaryFieldType, function(status) { + if(status === false) { + throw new Zotero.Integration.UserCancelledException(); + } + // save doc prefs in doc me._doc.setDocumentData(me._session.data.serializeXML()); if(haveFields) { me._session.reload = true; } - callback(); + callback(true); }); } else { var data = new Zotero.Integration.DocumentData(dataString); @@ -581,7 +585,7 @@ Zotero.Integration.Document.prototype._getSession = function(require, dontRunSet this._doc.setDocumentData(this._session.data.serializeXML()); this._session.reload = true; } - callback(); + callback(true); } } @@ -716,60 +720,75 @@ Zotero.Integration.Document.prototype.removeCodes = function() { */ Zotero.Integration.Document.prototype.setDocPrefs = function() { var me = this; - this._getSession(false, true, function() { - var fieldGetter = new Zotero.Integration.Fields(me._session, me._doc); - fieldGetter.get(); - - me._session.setDocPrefs(me._app.primaryFieldType, me._app.secondaryFieldType, function(oldData) { - if(oldData) { - me._doc.setDocumentData(me._session.data.serializeXML()); - - fieldGetter.get(function(fields) { - if(fields && fields.length) { - // if there are fields, we will have to convert some things; get a list of what we need to deal with - var convertBibliographies = oldData === true || oldData.prefs.fieldType != me._session.data.prefs.fieldType; - var convertItems = convertBibliographies || oldData.prefs.noteType != me._session.data.prefs.noteType; - var fieldsToConvert = new Array(); - var fieldNoteTypes = new Array(); - for(var i=0, n=fields.length; i