Rename Integration.Document to Integration.Interface
This commit is contained in:
parent
18e4e37b32
commit
41c93ab034
2 changed files with 13 additions and 13 deletions
|
@ -217,7 +217,7 @@ Zotero.Integration = new function() {
|
||||||
// (depending on what is possible)
|
// (depending on what is possible)
|
||||||
document = (application.getDocument && docId ? application.getDocument(docId) : application.getActiveDocument());
|
document = (application.getDocument && docId ? application.getDocument(docId) : application.getActiveDocument());
|
||||||
try {
|
try {
|
||||||
yield Zotero.Promise.resolve((new Zotero.Integration.Document(application, document))[command]());
|
yield Zotero.Promise.resolve((new Zotero.Integration.Interface(application, document))[command]());
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if(!(e instanceof Zotero.Exception.UserCancelled)) {
|
if(!(e instanceof Zotero.Exception.UserCancelled)) {
|
||||||
|
@ -508,7 +508,7 @@ const BIBLIOGRAPHY_PLACEHOLDER = "{Bibliography}";
|
||||||
* All methods for interacting with a document
|
* All methods for interacting with a document
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.Document = function(app, doc) {
|
Zotero.Integration.Interface = function(app, doc) {
|
||||||
this._app = app;
|
this._app = app;
|
||||||
this._doc = doc;
|
this._doc = doc;
|
||||||
}
|
}
|
||||||
|
@ -517,7 +517,7 @@ Zotero.Integration.Document = function(app, doc) {
|
||||||
* @param data {Zotero.Integration.DocumentData} Document data for new session
|
* @param data {Zotero.Integration.DocumentData} Document data for new session
|
||||||
* @return {Zotero.Integration.Session}
|
* @return {Zotero.Integration.Session}
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.Document.prototype._createNewSession = function _createNewSession(data) {
|
Zotero.Integration.Interface.prototype._createNewSession = function _createNewSession(data) {
|
||||||
data.sessionID = Zotero.randomString();
|
data.sessionID = Zotero.randomString();
|
||||||
var session = Zotero.Integration.sessions[data.sessionID] = new Zotero.Integration.Session(this._doc);
|
var session = Zotero.Integration.sessions[data.sessionID] = new Zotero.Integration.Session(this._doc);
|
||||||
return session;
|
return session;
|
||||||
|
@ -533,7 +533,7 @@ Zotero.Integration.Document.prototype._createNewSession = function _createNewSes
|
||||||
* dontRunSetDocPrefs is true and no session was found, or rejected with
|
* dontRunSetDocPrefs is true and no session was found, or rejected with
|
||||||
* Zotero.Exception.UserCancelled if the document preferences window was cancelled.
|
* Zotero.Exception.UserCancelled if the document preferences window was cancelled.
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.Document.prototype._getSession = Zotero.Promise.coroutine(function *(require, dontRunSetDocPrefs) {
|
Zotero.Integration.Interface.prototype._getSession = Zotero.Promise.coroutine(function *(require, dontRunSetDocPrefs) {
|
||||||
var dataString = this._doc.getDocumentData(),
|
var dataString = this._doc.getDocumentData(),
|
||||||
data,
|
data,
|
||||||
me = this;
|
me = this;
|
||||||
|
@ -673,7 +673,7 @@ Zotero.Integration.Document.prototype._getSession = Zotero.Promise.coroutine(fun
|
||||||
* Adds a citation to the current document.
|
* Adds a citation to the current document.
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.Document.prototype.addCitation = function() {
|
Zotero.Integration.Interface.prototype.addCitation = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
return this._getSession(false, false).then(function() {
|
return this._getSession(false, false).then(function() {
|
||||||
return (new Zotero.Integration.Fields(me._session, me._doc)).addEditCitation(null);
|
return (new Zotero.Integration.Fields(me._session, me._doc)).addEditCitation(null);
|
||||||
|
@ -684,7 +684,7 @@ Zotero.Integration.Document.prototype.addCitation = function() {
|
||||||
* Edits the citation at the cursor position.
|
* Edits the citation at the cursor position.
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.Document.prototype.editCitation = function() {
|
Zotero.Integration.Interface.prototype.editCitation = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
return this._getSession(true, false).then(function() {
|
return this._getSession(true, false).then(function() {
|
||||||
var field = me._doc.cursorInField(me._session.data.prefs['fieldType']);
|
var field = me._doc.cursorInField(me._session.data.prefs['fieldType']);
|
||||||
|
@ -701,7 +701,7 @@ Zotero.Integration.Document.prototype.editCitation = function() {
|
||||||
* Edits the citation at the cursor position if one exists, or else adds a new one.
|
* Edits the citation at the cursor position if one exists, or else adds a new one.
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.Document.prototype.addEditCitation = function() {
|
Zotero.Integration.Interface.prototype.addEditCitation = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
return this._getSession(false, false).then(function() {
|
return this._getSession(false, false).then(function() {
|
||||||
var field = me._doc.cursorInField(me._session.data.prefs['fieldType']);
|
var field = me._doc.cursorInField(me._session.data.prefs['fieldType']);
|
||||||
|
@ -713,7 +713,7 @@ Zotero.Integration.Document.prototype.addEditCitation = function() {
|
||||||
* Adds a bibliography to the current document.
|
* Adds a bibliography to the current document.
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.Document.prototype.addBibliography = function() {
|
Zotero.Integration.Interface.prototype.addBibliography = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
return this._getSession(true, false).then(function() {
|
return this._getSession(true, false).then(function() {
|
||||||
// Make sure we can have a bibliography
|
// Make sure we can have a bibliography
|
||||||
|
@ -736,7 +736,7 @@ Zotero.Integration.Document.prototype.addBibliography = function() {
|
||||||
* Edits bibliography metadata.
|
* Edits bibliography metadata.
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.Document.prototype.editBibliography = function() {
|
Zotero.Integration.Interface.prototype.editBibliography = function() {
|
||||||
// Make sure we have a bibliography
|
// Make sure we have a bibliography
|
||||||
var me = this, fieldGetter;
|
var me = this, fieldGetter;
|
||||||
return this._getSession(true, false).then(function() {
|
return this._getSession(true, false).then(function() {
|
||||||
|
@ -766,7 +766,7 @@ Zotero.Integration.Document.prototype.editBibliography = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Zotero.Integration.Document.prototype.addEditBibliography = Zotero.Promise.coroutine(function *() {
|
Zotero.Integration.Interface.prototype.addEditBibliography = Zotero.Promise.coroutine(function *() {
|
||||||
// Check if we have a bibliography
|
// Check if we have a bibliography
|
||||||
var session = yield this._getSession(true, false);
|
var session = yield this._getSession(true, false);
|
||||||
|
|
||||||
|
@ -803,7 +803,7 @@ Zotero.Integration.Document.prototype.addEditBibliography = Zotero.Promise.corou
|
||||||
* Updates the citation data for all citations and bibliography entries.
|
* Updates the citation data for all citations and bibliography entries.
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.Document.prototype.refresh = function() {
|
Zotero.Integration.Interface.prototype.refresh = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
return this._getSession(true, false).then(function() {
|
return this._getSession(true, false).then(function() {
|
||||||
// Send request, forcing update of citations and bibliography
|
// Send request, forcing update of citations and bibliography
|
||||||
|
@ -818,7 +818,7 @@ Zotero.Integration.Document.prototype.refresh = function() {
|
||||||
* Deletes field codes.
|
* Deletes field codes.
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
Zotero.Integration.Document.prototype.removeCodes = function() {
|
Zotero.Integration.Interface.prototype.removeCodes = function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
return this._getSession(true, false).then(function() {
|
return this._getSession(true, false).then(function() {
|
||||||
var fieldGetter = new Zotero.Integration.Fields(me._session, me._doc);
|
var fieldGetter = new Zotero.Integration.Fields(me._session, me._doc);
|
||||||
|
|
|
@ -322,7 +322,7 @@ describe("Zotero.Integration", function () {
|
||||||
return Zotero.Promise.resolve();
|
return Zotero.Promise.resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
addEditCitationSpy = sinon.spy(Zotero.Integration.Document.prototype, 'addEditCitation');
|
addEditCitationSpy = sinon.spy(Zotero.Integration.Interface.prototype, 'addEditCitation');
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
|
|
Loading…
Reference in a new issue