Fix itemBox.js eslint errors (#3244)
This commit is contained in:
parent
07309d7c25
commit
e44e3edef9
2 changed files with 123 additions and 123 deletions
|
@ -26,6 +26,8 @@
|
||||||
"Localization": false,
|
"Localization": false,
|
||||||
"L10nFileSource": false,
|
"L10nFileSource": false,
|
||||||
"L10nRegistry": false,
|
"L10nRegistry": false,
|
||||||
|
"ZoteroPane_Local": false,
|
||||||
|
"ZoteroPane": false
|
||||||
},
|
},
|
||||||
"extends": [
|
"extends": [
|
||||||
"@zotero",
|
"@zotero",
|
||||||
|
|
|
@ -212,7 +212,7 @@
|
||||||
|
|
||||||
this._id('zotero-doi-menu-view-online').addEventListener(
|
this._id('zotero-doi-menu-view-online').addEventListener(
|
||||||
'command',
|
'command',
|
||||||
event => ZoteroPane_Local.loadURI(this._doiMenu.dataset.doi, event)
|
event => ZoteroPane.loadURI(this._doiMenu.dataset.doi, event)
|
||||||
);
|
);
|
||||||
this._id('zotero-doi-menu-copy').addEventListener(
|
this._id('zotero-doi-menu-copy').addEventListener(
|
||||||
'command',
|
'command',
|
||||||
|
@ -334,7 +334,7 @@
|
||||||
*/
|
*/
|
||||||
set visibleFields(val) {
|
set visibleFields(val) {
|
||||||
if (val.constructor.name != 'Array') {
|
if (val.constructor.name != 'Array') {
|
||||||
throw ('visibleFields must be an array in <itembox>.visibleFields');
|
throw Error('visibleFields must be an array in <itembox>.visibleFields');
|
||||||
}
|
}
|
||||||
|
|
||||||
this._visibleFields = val;
|
this._visibleFields = val;
|
||||||
|
@ -345,7 +345,7 @@
|
||||||
*/
|
*/
|
||||||
set hiddenFields(val) {
|
set hiddenFields(val) {
|
||||||
if (val.constructor.name != 'Array') {
|
if (val.constructor.name != 'Array') {
|
||||||
throw ('hiddenFields must be an array in <itembox>.visibleFields');
|
throw Error('hiddenFields must be an array in <itembox>.visibleFields');
|
||||||
}
|
}
|
||||||
|
|
||||||
this._hiddenFields = val;
|
this._hiddenFields = val;
|
||||||
|
@ -357,7 +357,7 @@
|
||||||
*/
|
*/
|
||||||
set clickableFields(val) {
|
set clickableFields(val) {
|
||||||
if (val.constructor.name != 'Array') {
|
if (val.constructor.name != 'Array') {
|
||||||
throw ('clickableFields must be an array in <itembox>.clickableFields');
|
throw Error('clickableFields must be an array in <itembox>.clickableFields');
|
||||||
}
|
}
|
||||||
|
|
||||||
this._clickableFields = val;
|
this._clickableFields = val;
|
||||||
|
@ -369,7 +369,7 @@
|
||||||
*/
|
*/
|
||||||
set editableFields(val) {
|
set editableFields(val) {
|
||||||
if (val.constructor.name != 'Array') {
|
if (val.constructor.name != 'Array') {
|
||||||
throw ('editableFields must be an array in <itembox>.editableFields');
|
throw Error('editableFields must be an array in <itembox>.editableFields');
|
||||||
}
|
}
|
||||||
|
|
||||||
this._editableFields = val;
|
this._editableFields = val;
|
||||||
|
@ -380,11 +380,11 @@
|
||||||
*/
|
*/
|
||||||
set fieldAlternatives(val) {
|
set fieldAlternatives(val) {
|
||||||
if (val.constructor.name != 'Object') {
|
if (val.constructor.name != 'Object') {
|
||||||
throw ('fieldAlternatives must be an Object in <itembox>.fieldAlternatives');
|
throw Error('fieldAlternatives must be an Object in <itembox>.fieldAlternatives');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mode != 'fieldmerge') {
|
if (this.mode != 'fieldmerge') {
|
||||||
throw ('fieldAlternatives is valid only in fieldmerge mode in <itembox>.fieldAlternatives');
|
throw Error('fieldAlternatives is valid only in fieldmerge mode in <itembox>.fieldAlternatives');
|
||||||
}
|
}
|
||||||
|
|
||||||
this._fieldAlternatives = val;
|
this._fieldAlternatives = val;
|
||||||
|
@ -396,7 +396,7 @@
|
||||||
*/
|
*/
|
||||||
set fieldOrder(val) {
|
set fieldOrder(val) {
|
||||||
if (val.constructor.name != 'Array') {
|
if (val.constructor.name != 'Array') {
|
||||||
throw ('fieldOrder must be an array in <itembox>.fieldOrder');
|
throw Error('fieldOrder must be an array in <itembox>.fieldOrder');
|
||||||
}
|
}
|
||||||
|
|
||||||
this._fieldOrder = val;
|
this._fieldOrder = val;
|
||||||
|
@ -437,7 +437,7 @@
|
||||||
//
|
//
|
||||||
// Methods
|
// Methods
|
||||||
//
|
//
|
||||||
notify(event, type, ids) {
|
notify(event, _type, ids) {
|
||||||
if (event != 'modify' || !this.item || !this.item.id) return;
|
if (event != 'modify' || !this.item || !this.item.id) return;
|
||||||
for (let i = 0; i < ids.length; i++) {
|
for (let i = 0; i < ids.length; i++) {
|
||||||
let id = ids[i];
|
let id = ids[i];
|
||||||
|
@ -501,12 +501,12 @@
|
||||||
|
|
||||||
var fields = Zotero.ItemFields.getItemTypeFields(this.item.getField("itemTypeID"));
|
var fields = Zotero.ItemFields.getItemTypeFields(this.item.getField("itemTypeID"));
|
||||||
|
|
||||||
for (var i=0; i<fields.length; i++) {
|
for (let i = 0; i < fields.length; i++) {
|
||||||
fieldNames.push(Zotero.ItemFields.getName(fields[i]));
|
fieldNames.push(Zotero.ItemFields.getName(fields[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.item instanceof Zotero.FeedItem) {
|
if (this.item instanceof Zotero.FeedItem) {
|
||||||
let row = ZoteroPane_Local.getCollectionTreeRow();
|
let row = ZoteroPane.getCollectionTreeRow();
|
||||||
if (row && row.isFeeds()) {
|
if (row && row.isFeeds()) {
|
||||||
fieldNames.unshift("feed");
|
fieldNames.unshift("feed");
|
||||||
}
|
}
|
||||||
|
@ -516,7 +516,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i=0; i<fieldNames.length; i++) {
|
for (let i = 0; i < fieldNames.length; i++) {
|
||||||
var fieldName = fieldNames[i];
|
var fieldName = fieldNames[i];
|
||||||
var val = '';
|
var val = '';
|
||||||
|
|
||||||
|
@ -556,7 +556,8 @@
|
||||||
|
|
||||||
// Start tabindex at 1001 after creators
|
// Start tabindex at 1001 after creators
|
||||||
var tabindex = fieldIsClickable
|
var tabindex = fieldIsClickable
|
||||||
? (i>0 ? this._tabIndexMinFields + i : 1) : 0;
|
? (i > 0 ? this._tabIndexMinFields + i : 1)
|
||||||
|
: 0;
|
||||||
this._tabIndexMaxFields = Math.max(this._tabIndexMaxFields, tabindex);
|
this._tabIndexMaxFields = Math.max(this._tabIndexMaxFields, tabindex);
|
||||||
|
|
||||||
if (fieldIsClickable
|
if (fieldIsClickable
|
||||||
|
@ -612,7 +613,7 @@
|
||||||
.replace(/%/g, '%25')
|
.replace(/%/g, '%25')
|
||||||
.replace(/"/g, '%22');
|
.replace(/"/g, '%22');
|
||||||
th.classList.add("pointer");
|
th.classList.add("pointer");
|
||||||
th.addEventListener('click', event => ZoteroPane_Local.loadURI(doi, event));
|
th.addEventListener('click', event => ZoteroPane.loadURI(doi, event));
|
||||||
th.setAttribute('title', Zotero.getString('pane.item.viewOnline.tooltip'));
|
th.setAttribute('title', Zotero.getString('pane.item.viewOnline.tooltip'));
|
||||||
this._doiMenu.dataset.doi = doi;
|
this._doiMenu.dataset.doi = doi;
|
||||||
}
|
}
|
||||||
|
@ -696,12 +697,12 @@
|
||||||
var creatorTypes = Zotero.CreatorTypes.getTypesForItemType(this.item.itemTypeID);
|
var creatorTypes = Zotero.CreatorTypes.getTypesForItemType(this.item.itemTypeID);
|
||||||
|
|
||||||
var localized = {};
|
var localized = {};
|
||||||
for (var i=0; i<creatorTypes.length; i++) {
|
for (let i = 0; i < creatorTypes.length; i++) {
|
||||||
localized[creatorTypes[i]['name']]
|
localized[creatorTypes[i].name]
|
||||||
= Zotero.getString('creatorTypes.' + creatorTypes[i]['name']);
|
= Zotero.getString('creatorTypes.' + creatorTypes[i].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i in localized) {
|
for (let i in localized) {
|
||||||
var menuitem = document.createXULElement("menuitem");
|
var menuitem = document.createXULElement("menuitem");
|
||||||
menuitem.setAttribute("label", localized[i]);
|
menuitem.setAttribute("label", localized[i]);
|
||||||
menuitem.setAttribute("typeid", Zotero.CreatorTypes.getID(i));
|
menuitem.setAttribute("typeid", Zotero.CreatorTypes.getID(i));
|
||||||
|
@ -735,7 +736,7 @@
|
||||||
var titleFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(this.item.itemTypeID, 'title');
|
var titleFieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(this.item.itemTypeID, 'title');
|
||||||
var field = this._infoTable.querySelector(`[fieldname="${Zotero.ItemFields.getName(titleFieldID)}"]`);
|
var field = this._infoTable.querySelector(`[fieldname="${Zotero.ItemFields.getName(titleFieldID)}"]`);
|
||||||
if (!field) {
|
if (!field) {
|
||||||
var field = this._infoTable.querySelector('[fieldName="itemType"]');
|
field = this._infoTable.querySelector('[fieldName="itemType"]');
|
||||||
}
|
}
|
||||||
if (field) {
|
if (field) {
|
||||||
this._beforeRow = field.parentNode.nextSibling;
|
this._beforeRow = field.parentNode.nextSibling;
|
||||||
|
@ -753,7 +754,7 @@
|
||||||
if (num < max + 3 || this._displayAllCreators) {
|
if (num < max + 3 || this._displayAllCreators) {
|
||||||
max = num;
|
max = num;
|
||||||
}
|
}
|
||||||
for (var i = 0; i < max; i++) {
|
for (let i = 0; i < max; i++) {
|
||||||
let data = this.item.getCreator(i);
|
let data = this.item.getCreator(i);
|
||||||
this.addCreatorRow(data, data.creatorTypeID);
|
this.addCreatorRow(data, data.creatorTypeID);
|
||||||
|
|
||||||
|
@ -777,7 +778,7 @@
|
||||||
this._displayAllCreators = true;
|
this._displayAllCreators = true;
|
||||||
|
|
||||||
if (this._addCreatorRow) {
|
if (this._addCreatorRow) {
|
||||||
this.addCreatorRow(false, this.item.getCreator(max-1).creatorTypeID, true);
|
this.addCreatorRow(false, this.item.getCreator(max - 1).creatorTypeID, true);
|
||||||
this._addCreatorRow = false;
|
this._addCreatorRow = false;
|
||||||
this.disableCreatorAddButtons();
|
this.disableCreatorAddButtons();
|
||||||
}
|
}
|
||||||
|
@ -936,7 +937,7 @@
|
||||||
comma.className = 'comma';
|
comma.className = 'comma';
|
||||||
firstlast.appendChild(comma);
|
firstlast.appendChild(comma);
|
||||||
|
|
||||||
var fieldName = 'creator-' + rowIndex + '-firstName';
|
fieldName = 'creator-' + rowIndex + '-firstName';
|
||||||
firstlast.appendChild(
|
firstlast.appendChild(
|
||||||
this.createValueElement(
|
this.createValueElement(
|
||||||
firstName,
|
firstName,
|
||||||
|
@ -1029,7 +1030,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Focus new rows
|
// Focus new rows
|
||||||
if (unsaved && !defaultRow){
|
if (unsaved && !defaultRow) {
|
||||||
lastNameElem.click();
|
lastNameElem.click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1087,6 +1088,7 @@
|
||||||
var comma = creatorNameBox.firstChild.nextSibling;
|
var comma = creatorNameBox.firstChild.nextSibling;
|
||||||
var firstName = creatorNameBox.lastChild;
|
var firstName = creatorNameBox.lastChild;
|
||||||
|
|
||||||
|
let tab;
|
||||||
// Switch to single-field mode
|
// Switch to single-field mode
|
||||||
if (fieldMode == 1) {
|
if (fieldMode == 1) {
|
||||||
button.style.background = `url("chrome://zotero/skin/textfield-dual${Zotero.hiDPISuffix}.png") center/21px auto no-repeat`;
|
button.style.background = `url("chrome://zotero/skin/textfield-dual${Zotero.hiDPISuffix}.png") center/21px auto no-repeat`;
|
||||||
|
@ -1097,7 +1099,7 @@
|
||||||
delete lastName.style.maxWidth;
|
delete lastName.style.maxWidth;
|
||||||
|
|
||||||
// Remove firstname field from tabindex
|
// Remove firstname field from tabindex
|
||||||
var tab = parseInt(firstName.getAttribute('ztabindex'));
|
tab = parseInt(firstName.getAttribute('ztabindex'));
|
||||||
firstName.setAttribute('ztabindex', -1);
|
firstName.setAttribute('ztabindex', -1);
|
||||||
if (this._tabIndexMaxCreators == tab) {
|
if (this._tabIndexMaxCreators == tab) {
|
||||||
this._tabIndexMaxCreators--;
|
this._tabIndexMaxCreators--;
|
||||||
|
@ -1110,7 +1112,7 @@
|
||||||
if (!initial) {
|
if (!initial) {
|
||||||
var first = this._getFieldValue(firstName);
|
var first = this._getFieldValue(firstName);
|
||||||
if (first && first != this._defaultFirstName) {
|
if (first && first != this._defaultFirstName) {
|
||||||
var last = this._getFieldValue(lastName);
|
let last = this._getFieldValue(lastName);
|
||||||
this._setFieldValue(lastName, first + ' ' + last);
|
this._setFieldValue(lastName, first + ' ' + last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1139,44 +1141,43 @@
|
||||||
var computedStyle = window.getComputedStyle(this, null);
|
var computedStyle = window.getComputedStyle(this, null);
|
||||||
var boxWidth = computedStyle.getPropertyValue('width');
|
var boxWidth = computedStyle.getPropertyValue('width');
|
||||||
// get field label width
|
// get field label width
|
||||||
var computedStyle = window.getComputedStyle(row.firstChild, null);
|
computedStyle = window.getComputedStyle(row.firstChild, null);
|
||||||
var leftHboxWidth = computedStyle.getPropertyValue('width');
|
var leftHboxWidth = computedStyle.getPropertyValue('width');
|
||||||
// get last name width
|
// get last name width
|
||||||
computedStyle = window.getComputedStyle(lastName, null);
|
computedStyle = window.getComputedStyle(lastName, null);
|
||||||
var lastNameWidth = computedStyle.getPropertyValue('width');
|
var lastNameWidth = computedStyle.getPropertyValue('width');
|
||||||
if(boxWidth.substr(-2) === 'px'
|
if (boxWidth.substr(-2) === 'px'
|
||||||
&& leftHboxWidth.substr(-2) === 'px'
|
&& leftHboxWidth.substr(-2) === 'px'
|
||||||
&& lastNameWidth.substr(-2) === "px") {
|
&& lastNameWidth.substr(-2) === "px") {
|
||||||
// compute a maximum width
|
// compute a maximum width
|
||||||
boxWidth = parseInt(boxWidth);
|
boxWidth = parseInt(boxWidth);
|
||||||
leftHboxWidth = parseInt(leftHboxWidth);
|
leftHboxWidth = parseInt(leftHboxWidth);
|
||||||
lastNameWidth = parseInt(lastNameWidth);
|
lastNameWidth = parseInt(lastNameWidth);
|
||||||
var maxWidth = boxWidth-leftHboxWidth-140;
|
var maxWidth = boxWidth - leftHboxWidth - 140;
|
||||||
if(lastNameWidth > maxWidth) {
|
if (lastNameWidth > maxWidth) {
|
||||||
//lastName.style.width = maxWidth+"px";
|
//lastName.style.width = maxWidth+"px";
|
||||||
//lastName.style.maxWidth = maxWidth+"px";
|
//lastName.style.maxWidth = maxWidth+"px";
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
delete lastName.style.width;
|
delete lastName.style.width;
|
||||||
delete lastName.style.maxWidth;
|
delete lastName.style.maxWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add firstname field to tabindex
|
// Add firstname field to tabindex
|
||||||
var tab = parseInt(lastName.getAttribute('ztabindex'));
|
tab = parseInt(lastName.getAttribute('ztabindex'));
|
||||||
firstName.setAttribute('ztabindex', tab + 1);
|
firstName.setAttribute('ztabindex', tab + 1);
|
||||||
if (this._tabIndexMaxCreators == tab)
|
if (this._tabIndexMaxCreators == tab) {
|
||||||
{
|
|
||||||
this._tabIndexMaxCreators++;
|
this._tabIndexMaxCreators++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!initial) {
|
if (!initial) {
|
||||||
// Move all but last word to first name field and show it
|
// Move all but last word to first name field and show it
|
||||||
var last = this._getFieldValue(lastName);
|
let last = this._getFieldValue(lastName);
|
||||||
if (last && last != this._defaultFullName) {
|
if (last && last != this._defaultFullName) {
|
||||||
var lastNameRE = /(.*?)[ ]*([^ ]+[ ]*)$/;
|
var lastNameRE = /(.*?)[ ]*([^ ]+[ ]*)$/;
|
||||||
var parts = lastNameRE.exec(last);
|
var parts = lastNameRE.exec(last);
|
||||||
if (parts[2] && parts[2] != last)
|
if (parts[2] && parts[2] != last) {
|
||||||
{
|
|
||||||
this._setFieldValue(lastName, parts[2]);
|
this._setFieldValue(lastName, parts[2]);
|
||||||
this._setFieldValue(firstName, parts[1]);
|
this._setFieldValue(firstName, parts[1]);
|
||||||
}
|
}
|
||||||
|
@ -1250,8 +1251,8 @@
|
||||||
// Add warning for shortTitle when moving from book to bookSection
|
// Add warning for shortTitle when moving from book to bookSection
|
||||||
// when title will be transferred
|
// when title will be transferred
|
||||||
if (this.item.itemTypeID == bookTypeID && itemTypeID == bookSectionTypeID) {
|
if (this.item.itemTypeID == bookTypeID && itemTypeID == bookSectionTypeID) {
|
||||||
var titleFieldID = Zotero.ItemFields.getID('title');
|
let titleFieldID = Zotero.ItemFields.getID('title');
|
||||||
var shortTitleFieldID = Zotero.ItemFields.getID('shortTitle');
|
let shortTitleFieldID = Zotero.ItemFields.getID('shortTitle');
|
||||||
if (this.item.getField(titleFieldID) && this.item.getField(shortTitleFieldID)) {
|
if (this.item.getField(titleFieldID) && this.item.getField(shortTitleFieldID)) {
|
||||||
if (!fieldsToDelete) {
|
if (!fieldsToDelete) {
|
||||||
fieldsToDelete = [];
|
fieldsToDelete = [];
|
||||||
|
@ -1266,9 +1267,9 @@
|
||||||
// if there's not also a title, since the book title is transferred
|
// if there's not also a title, since the book title is transferred
|
||||||
// to title automatically in Zotero.Item.setType()
|
// to title automatically in Zotero.Item.setType()
|
||||||
if (this.item.itemTypeID == bookSectionTypeID && itemTypeID == bookTypeID) {
|
if (this.item.itemTypeID == bookSectionTypeID && itemTypeID == bookTypeID) {
|
||||||
var titleFieldID = Zotero.ItemFields.getID('title');
|
let titleFieldID = Zotero.ItemFields.getID('title');
|
||||||
var bookTitleFieldID = Zotero.ItemFields.getID('bookTitle');
|
var bookTitleFieldID = Zotero.ItemFields.getID('bookTitle');
|
||||||
var shortTitleFieldID = Zotero.ItemFields.getID('shortTitle');
|
let shortTitleFieldID = Zotero.ItemFields.getID('shortTitle');
|
||||||
if (this.item.getField(bookTitleFieldID) && !this.item.getField(titleFieldID)) {
|
if (this.item.getField(bookTitleFieldID) && !this.item.getField(titleFieldID)) {
|
||||||
var index = fieldsToDelete.indexOf(bookTitleFieldID);
|
var index = fieldsToDelete.indexOf(bookTitleFieldID);
|
||||||
fieldsToDelete.splice(index, 1);
|
fieldsToDelete.splice(index, 1);
|
||||||
|
@ -1280,17 +1281,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var fieldNames = "";
|
var fieldNames = "";
|
||||||
for (var i=0; i<fieldsToDelete.length; i++) {
|
for (var i = 0; i < fieldsToDelete.length; i++) {
|
||||||
fieldNames += "\n - " +
|
fieldNames += "\n - "
|
||||||
Zotero.ItemFields.getLocalizedString(fieldsToDelete[i]);
|
+ Zotero.ItemFields.getLocalizedString(fieldsToDelete[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||||
.getService(Components.interfaces.nsIPromptService);
|
.getService(Components.interfaces.nsIPromptService);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fieldsToDelete || fieldsToDelete.length == 0 ||
|
if (!fieldsToDelete || fieldsToDelete.length == 0
|
||||||
promptService.confirm(null,
|
|| promptService.confirm(null,
|
||||||
Zotero.getString('pane.item.changeType.title'),
|
Zotero.getString('pane.item.changeType.title'),
|
||||||
Zotero.getString('pane.item.changeType.text') + "\n" + fieldNames)) {
|
Zotero.getString('pane.item.changeType.text') + "\n" + fieldNames)) {
|
||||||
this.item.setType(itemTypeID);
|
this.item.setType(itemTypeID);
|
||||||
|
@ -1343,7 +1344,7 @@
|
||||||
button.setAttribute('onclick', false);
|
button.setAttribute('onclick', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
_enablePlusButton(button, creatorTypeID, fieldMode) {
|
_enablePlusButton(button, creatorTypeID, _fieldMode) {
|
||||||
button.removeAttribute('disabled');
|
button.removeAttribute('disabled');
|
||||||
button.onclick = () => {
|
button.onclick = () => {
|
||||||
this.disableButton(button);
|
this.disableButton(button);
|
||||||
|
@ -1360,7 +1361,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
createValueElement(valueText, fieldName, tabindex) {
|
createValueElement(valueText, fieldName, tabindex) {
|
||||||
valueText = valueText + '';
|
valueText += '';
|
||||||
|
|
||||||
if (fieldName) {
|
if (fieldName) {
|
||||||
var fieldID = Zotero.ItemFields.getID(fieldName);
|
var fieldID = Zotero.ItemFields.getID(fieldName);
|
||||||
|
@ -1382,7 +1383,7 @@
|
||||||
if (this._fieldIsClickable(fieldName)) {
|
if (this._fieldIsClickable(fieldName)) {
|
||||||
valueElement.setAttribute('ztabindex', tabindex);
|
valueElement.setAttribute('ztabindex', tabindex);
|
||||||
valueElement.addEventListener('click', (event) => {
|
valueElement.addEventListener('click', (event) => {
|
||||||
/* Skip right-click on Windows */
|
// Skip right-click on Windows
|
||||||
if (event.button) {
|
if (event.button) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1402,9 +1403,7 @@
|
||||||
case 'dateModified':
|
case 'dateModified':
|
||||||
case 'accessDate':
|
case 'accessDate':
|
||||||
case 'date':
|
case 'date':
|
||||||
|
case 'dateSent': // TEMP - NSF
|
||||||
// TEMP - NSF
|
|
||||||
case 'dateSent':
|
|
||||||
case 'dateDue':
|
case 'dateDue':
|
||||||
case 'accepted':
|
case 'accepted':
|
||||||
if (fieldName == 'date' && this.item._objectType != 'feedItem') {
|
if (fieldName == 'date' && this.item._objectType != 'feedItem') {
|
||||||
|
@ -1441,9 +1440,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display a context menu for certain fields
|
// Display a context menu for certain fields
|
||||||
if (this.editable && (fieldName == 'seriesTitle' || fieldName == 'shortTitle' ||
|
if (this.editable && (fieldName == 'seriesTitle' || fieldName == 'shortTitle'
|
||||||
Zotero.ItemFields.isFieldOfBase(fieldID, 'title') ||
|
|| Zotero.ItemFields.isFieldOfBase(fieldID, 'title')
|
||||||
Zotero.ItemFields.isFieldOfBase(fieldID, 'publicationTitle'))) {
|
|| Zotero.ItemFields.isFieldOfBase(fieldID, 'publicationTitle'))) {
|
||||||
valueElement.setAttribute('context', 'zotero-field-transform-menu');
|
valueElement.setAttribute('context', 'zotero-field-transform-menu');
|
||||||
valueElement.oncontextmenu = (event) => {
|
valueElement.oncontextmenu = (event) => {
|
||||||
document.popupNode = valueElement;
|
document.popupNode = valueElement;
|
||||||
|
@ -1510,7 +1509,7 @@
|
||||||
|
|
||||||
// Enable the "+" button on the previous row
|
// Enable the "+" button on the previous row
|
||||||
var elems = this._infoTable.getElementsByClassName('zotero-clicky-plus');
|
var elems = this._infoTable.getElementsByClassName('zotero-clicky-plus');
|
||||||
var button = elems[elems.length-1];
|
var button = elems[elems.length - 1];
|
||||||
var creatorFields = this.getCreatorFields(button.closest('tr'));
|
var creatorFields = this.getCreatorFields(button.closest('tr'));
|
||||||
this._enablePlusButton(button, creatorFields.creatorTypeID, creatorFields.fieldMode);
|
this._enablePlusButton(button, creatorFields.creatorTypeID, creatorFields.fieldMode);
|
||||||
|
|
||||||
|
@ -1547,34 +1546,34 @@
|
||||||
var tabindex = elem.getAttribute('ztabindex');
|
var tabindex = elem.getAttribute('ztabindex');
|
||||||
|
|
||||||
var [field, creatorIndex, creatorField] = fieldName.split('-');
|
var [field, creatorIndex, creatorField] = fieldName.split('-');
|
||||||
|
let value, itemID;
|
||||||
if (field == 'creator') {
|
if (field == 'creator') {
|
||||||
var value = this.item.getCreator(creatorIndex)[creatorField];
|
value = this.item.getCreator(creatorIndex)[creatorField];
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
value = "";
|
value = "";
|
||||||
}
|
}
|
||||||
var itemID = this.item.id;
|
itemID = this.item.id;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var value = this.item.getField(fieldName);
|
value = this.item.getField(fieldName);
|
||||||
var itemID = this.item.id;
|
itemID = this.item.id;
|
||||||
|
|
||||||
// Access date needs to be converted from UTC
|
// Access date needs to be converted from UTC
|
||||||
if (value != '') {
|
if (value != '') {
|
||||||
|
let localDate;
|
||||||
switch (fieldName) {
|
switch (fieldName) {
|
||||||
case 'accessDate':
|
case 'accessDate':
|
||||||
|
case 'dateSent': // TEMP - NSF
|
||||||
// TEMP - NSF
|
|
||||||
case 'dateSent':
|
|
||||||
case 'dateDue':
|
case 'dateDue':
|
||||||
case 'accepted':
|
case 'accepted':
|
||||||
// If no time, interpret as local, not UTC
|
// If no time, interpret as local, not UTC
|
||||||
if (Zotero.Date.isSQLDate(value)) {
|
if (Zotero.Date.isSQLDate(value)) {
|
||||||
var localDate = Zotero.Date.sqlToDate(value);
|
localDate = Zotero.Date.sqlToDate(value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var localDate = Zotero.Date.sqlToDate(value, true);
|
localDate = Zotero.Date.sqlToDate(value, true);
|
||||||
}
|
}
|
||||||
var value = Zotero.Date.dateToSQL(localDate);
|
value = Zotero.Date.dateToSQL(localDate);
|
||||||
|
|
||||||
// Don't show time in editor
|
// Don't show time in editor
|
||||||
value = value.replace(' 00:00:00', '');
|
value = value.replace(' 00:00:00', '');
|
||||||
|
@ -1765,8 +1764,6 @@
|
||||||
t.addEventListener('input', updateHeight);
|
t.addEventListener('input', updateHeight);
|
||||||
updateHeight();
|
updateHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1794,14 +1791,13 @@
|
||||||
var [creatorID, numFields] = id.split('-');
|
var [creatorID, numFields] = id.split('-');
|
||||||
|
|
||||||
// If result uses two fields, save both
|
// If result uses two fields, save both
|
||||||
if (numFields==2)
|
if (numFields == 2) {
|
||||||
{
|
|
||||||
// Manually clear autocomplete controller's reference to
|
// Manually clear autocomplete controller's reference to
|
||||||
// textbox to prevent error next time around
|
// textbox to prevent error next time around
|
||||||
textbox.mController.input = null;
|
textbox.mController.input = null;
|
||||||
|
|
||||||
var [field, creatorIndex, creatorField] =
|
var [_field, creatorIndex, creatorField]
|
||||||
textbox.getAttribute('fieldname').split('-');
|
= textbox.getAttribute('fieldname').split('-');
|
||||||
|
|
||||||
if (stayFocused) {
|
if (stayFocused) {
|
||||||
this._lastTabIndex = parseInt(textbox.getAttribute('ztabindex'));
|
this._lastTabIndex = parseInt(textbox.getAttribute('ztabindex'));
|
||||||
|
@ -1817,15 +1813,16 @@
|
||||||
textbox.value = creator[creatorField];
|
textbox.value = creator[creatorField];
|
||||||
|
|
||||||
// Update the other label
|
// Update the other label
|
||||||
if (otherField=='firstName'){
|
let label;
|
||||||
var label = textbox.nextSibling.nextSibling;
|
if (otherField == 'firstName') {
|
||||||
|
label = textbox.nextSibling.nextSibling;
|
||||||
}
|
}
|
||||||
else if (otherField=='lastName'){
|
else if (otherField == 'lastName') {
|
||||||
var label = textbox.previousSibling.previousSibling;
|
label = textbox.previousSibling.previousSibling;
|
||||||
}
|
}
|
||||||
|
|
||||||
//this._setFieldValue(label, creator[otherField]);
|
//this._setFieldValue(label, creator[otherField]);
|
||||||
if (label.firstChild){
|
if (label.firstChild) {
|
||||||
label.firstChild.nodeValue = creator[otherField];
|
label.firstChild.nodeValue = creator[otherField];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1867,8 +1864,8 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (event.keyCode)
|
let tree;
|
||||||
{
|
switch (event.keyCode) {
|
||||||
case event.DOM_VK_RETURN:
|
case event.DOM_VK_RETURN:
|
||||||
var fieldname = target.getAttribute('fieldname');
|
var fieldname = target.getAttribute('fieldname');
|
||||||
// Use shift-enter as the save action for the larger fields
|
// Use shift-enter as the save action for the larger fields
|
||||||
|
@ -1910,7 +1907,7 @@
|
||||||
focused.blur();
|
focused.blur();
|
||||||
|
|
||||||
// Return focus to items pane
|
// Return focus to items pane
|
||||||
var tree = document.getElementById('zotero-items-tree');
|
tree = document.getElementById('zotero-items-tree');
|
||||||
if (tree) {
|
if (tree) {
|
||||||
tree.focus();
|
tree.focus();
|
||||||
}
|
}
|
||||||
|
@ -1924,7 +1921,7 @@
|
||||||
focused.blur();
|
focused.blur();
|
||||||
|
|
||||||
// Return focus to items pane
|
// Return focus to items pane
|
||||||
var tree = document.getElementById('zotero-items-tree');
|
tree = document.getElementById('zotero-items-tree');
|
||||||
if (tree) {
|
if (tree) {
|
||||||
tree.focus();
|
tree.focus();
|
||||||
}
|
}
|
||||||
|
@ -1999,7 +1996,8 @@
|
||||||
// Reset to '(first)'/'(last)'/'(name)'
|
// Reset to '(first)'/'(last)'/'(name)'
|
||||||
if (creatorField == 'lastName') {
|
if (creatorField == 'lastName') {
|
||||||
val = otherFields.fieldMode
|
val = otherFields.fieldMode
|
||||||
? this._defaultFullName : this._defaultLastName;
|
? this._defaultFullName
|
||||||
|
: this._defaultLastName;
|
||||||
}
|
}
|
||||||
else if (creatorField == 'firstName') {
|
else if (creatorField == 'firstName') {
|
||||||
val = this._defaultFirstName;
|
val = this._defaultFirstName;
|
||||||
|
@ -2028,15 +2026,15 @@
|
||||||
}
|
}
|
||||||
// If just date, don't convert to UTC
|
// If just date, don't convert to UTC
|
||||||
else if (Zotero.Date.isSQLDate(value)) {
|
else if (Zotero.Date.isSQLDate(value)) {
|
||||||
var localDate = Zotero.Date.sqlToDate(value);
|
let localDate = Zotero.Date.sqlToDate(value);
|
||||||
value = Zotero.Date.dateToSQL(localDate).replace(' 00:00:00', '');
|
value = Zotero.Date.dateToSQL(localDate).replace(' 00:00:00', '');
|
||||||
}
|
}
|
||||||
else if (Zotero.Date.isSQLDateTime(value)) {
|
else if (Zotero.Date.isSQLDateTime(value)) {
|
||||||
var localDate = Zotero.Date.sqlToDate(value);
|
let localDate = Zotero.Date.sqlToDate(value);
|
||||||
value = Zotero.Date.dateToSQL(localDate, true);
|
value = Zotero.Date.dateToSQL(localDate, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var d = Zotero.Date.strToDate(value);
|
let d = Zotero.Date.strToDate(value);
|
||||||
value = null;
|
value = null;
|
||||||
if (d.year && d.month != undefined && d.day) {
|
if (d.year && d.month != undefined && d.day) {
|
||||||
d = new Date(d.year, d.month, d.day);
|
d = new Date(d.year, d.month, d.day);
|
||||||
|
@ -2050,11 +2048,11 @@
|
||||||
case 'dateDue':
|
case 'dateDue':
|
||||||
case 'accepted':
|
case 'accepted':
|
||||||
if (Zotero.Date.isSQLDate(value)) {
|
if (Zotero.Date.isSQLDate(value)) {
|
||||||
var localDate = Zotero.Date.sqlToDate(value);
|
let localDate = Zotero.Date.sqlToDate(value);
|
||||||
value = Zotero.Date.dateToSQL(localDate).replace(' 00:00:00', '');
|
value = Zotero.Date.dateToSQL(localDate).replace(' 00:00:00', '');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var d = Zotero.Date.strToDate(value);
|
let d = Zotero.Date.strToDate(value);
|
||||||
value = null;
|
value = null;
|
||||||
if (d.year && d.month != undefined && d.day) {
|
if (d.year && d.month != undefined && d.day) {
|
||||||
d = new Date(d.year, d.month, d.day);
|
d = new Date(d.year, d.month, d.day);
|
||||||
|
@ -2098,14 +2096,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
_rowIsClickable(fieldName) {
|
_rowIsClickable(fieldName) {
|
||||||
return this.clickByRow &&
|
return this.clickByRow
|
||||||
(this.clickable ||
|
&& (this.clickable
|
||||||
this._clickableFields.indexOf(fieldName) != -1);
|
|| this._clickableFields.indexOf(fieldName) != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_fieldIsClickable(fieldName) {
|
_fieldIsClickable(fieldName) {
|
||||||
return !this.clickByRow &&
|
return !this.clickByRow
|
||||||
((this.clickable && !Zotero.Items.isPrimaryField(fieldName))
|
&& ((this.clickable && !Zotero.Items.isPrimaryField(fieldName))
|
||||||
|| this._clickableFields.indexOf(fieldName) != -1);
|
|| this._clickableFields.indexOf(fieldName) != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2140,8 +2138,9 @@
|
||||||
// capitalize after ?, ! and remove space(s) before those as well as colon analogous to capitalizeTitle function
|
// capitalize after ?, ! and remove space(s) before those as well as colon analogous to capitalizeTitle function
|
||||||
// also deal with initial punctuation here - open quotes and Spanish beginning punctuation marks
|
// also deal with initial punctuation here - open quotes and Spanish beginning punctuation marks
|
||||||
val = val.toLowerCase().replace(/\s*:/, ":");
|
val = val.toLowerCase().replace(/\s*:/, ":");
|
||||||
val = val.replace(/(([\?!]\s*|^)([\'\"¡¿“‘„«\s]+)?[^\s])/g, function (x) {
|
val = val.replace(/(([?!]\s*|^)(['"¡¿“‘„«\s]+)?[^\s])/g, function (x) {
|
||||||
return x.replace(/\s+/m, " ").toUpperCase();});
|
return x.replace(/\s+/m, " ").toUpperCase();
|
||||||
|
});
|
||||||
return val;
|
return val;
|
||||||
default:
|
default:
|
||||||
throw new Error("Invalid transform mode '" + mode + "' in ItemBox.textTransformString()");
|
throw new Error("Invalid transform mode '" + mode + "' in ItemBox.textTransformString()");
|
||||||
|
@ -2188,7 +2187,8 @@
|
||||||
lastName: label1.firstChild ? label1.firstChild.nodeValue : label1.value,
|
lastName: label1.firstChild ? label1.firstChild.nodeValue : label1.value,
|
||||||
firstName: label2.firstChild ? label2.firstChild.nodeValue : label2.value,
|
firstName: label2.firstChild ? label2.firstChild.nodeValue : label2.value,
|
||||||
fieldMode: label1.getAttribute('fieldMode')
|
fieldMode: label1.getAttribute('fieldMode')
|
||||||
? parseInt(label1.getAttribute('fieldMode')) : 0,
|
? parseInt(label1.getAttribute('fieldMode'))
|
||||||
|
: 0,
|
||||||
creatorTypeID: parseInt(typeID),
|
creatorTypeID: parseInt(typeID),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2206,16 +2206,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
modifyCreator(index, fields) {
|
modifyCreator(index, fields) {
|
||||||
var libraryID = this.item.libraryID;
|
|
||||||
var firstName = fields.firstName;
|
var firstName = fields.firstName;
|
||||||
var lastName = fields.lastName;
|
var lastName = fields.lastName;
|
||||||
var fieldMode = fields.fieldMode;
|
|
||||||
var creatorTypeID = fields.creatorTypeID;
|
|
||||||
|
|
||||||
var oldCreator = this.item.getCreator(index);
|
var oldCreator = this.item.getCreator(index);
|
||||||
|
|
||||||
// Don't save empty creators
|
// Don't save empty creators
|
||||||
if (!firstName && !lastName){
|
if (!firstName && !lastName) {
|
||||||
if (!oldCreator) {
|
if (!oldCreator) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2228,7 +2225,7 @@
|
||||||
/**
|
/**
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
async swapNames(event) {
|
async swapNames(_event) {
|
||||||
var row = document.popupNode.closest('tr');
|
var row = document.popupNode.closest('tr');
|
||||||
var typeBox = row.querySelector('.creator-type-label');
|
var typeBox = row.querySelector('.creator-type-label');
|
||||||
var creatorIndex = parseInt(typeBox.getAttribute('fieldname').split('-')[1]);
|
var creatorIndex = parseInt(typeBox.getAttribute('fieldname').split('-')[1]);
|
||||||
|
@ -2254,7 +2251,7 @@
|
||||||
/**
|
/**
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
async capitalizeCreatorName(event) {
|
async capitalizeCreatorName(_event) {
|
||||||
var row = document.popupNode.closest('tr');
|
var row = document.popupNode.closest('tr');
|
||||||
var typeBox = row.querySelector('.creator-type-label');
|
var typeBox = row.querySelector('.creator-type-label');
|
||||||
var creatorIndex = parseInt(typeBox.getAttribute('fieldname').split('-')[1]);
|
var creatorIndex = parseInt(typeBox.getAttribute('fieldname').split('-')[1]);
|
||||||
|
@ -2314,7 +2311,7 @@
|
||||||
this.item.setCreator(index, otherCreator);
|
this.item.setCreator(index, otherCreator);
|
||||||
}
|
}
|
||||||
if (this.saveOnEdit) {
|
if (this.saveOnEdit) {
|
||||||
return this.item.saveTx();
|
this.item.saveTx();
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
|
@ -2414,12 +2411,13 @@
|
||||||
// 1) next.parentNode is always null for some reason
|
// 1) next.parentNode is always null for some reason
|
||||||
// 2) For some reason it's necessary to scroll to the next element when
|
// 2) For some reason it's necessary to scroll to the next element when
|
||||||
// moving forward for the target element to be fully in view
|
// moving forward for the target element to be fully in view
|
||||||
|
let visElem;
|
||||||
if (!back && tabbableFields[pos + 1]) {
|
if (!back && tabbableFields[pos + 1]) {
|
||||||
Zotero.debug("Scrolling to next field");
|
Zotero.debug("Scrolling to next field");
|
||||||
var visElem = tabbableFields[pos + 1];
|
visElem = tabbableFields[pos + 1];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var visElem = next;
|
visElem = next;
|
||||||
}
|
}
|
||||||
this.ensureElementIsVisible(visElem);
|
this.ensureElementIsVisible(visElem);
|
||||||
|
|
||||||
|
@ -2586,7 +2584,7 @@
|
||||||
let hideElem = this._id('retraction-hide');
|
let hideElem = this._id('retraction-hide');
|
||||||
hideElem.firstChild.textContent = Zotero.getString('retraction.replacedItem.hide');
|
hideElem.firstChild.textContent = Zotero.getString('retraction.replacedItem.hide');
|
||||||
hideElem.hidden = !allowHiding;
|
hideElem.hidden = !allowHiding;
|
||||||
hideElem.firstChild.onclick = (event) => {
|
hideElem.firstChild.onclick = (_event) => {
|
||||||
ZoteroPane.promptToHideRetractionForReplacedItem(item);
|
ZoteroPane.promptToHideRetractionForReplacedItem(item);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue