Abstract field tweaks
- Allow clicking on non-editable abstract field to expand/collapse it - Change cursor when hovering over abstract to show it can be toggled - Default abstracts to expanded
This commit is contained in:
parent
0f5b277c91
commit
df1cdb9754
3 changed files with 38 additions and 21 deletions
|
@ -396,18 +396,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var valueElement = this.createValueElement(
|
let label = document.createElement("label");
|
||||||
|
label.setAttribute('fieldname', fieldName);
|
||||||
|
|
||||||
|
let valueElement = this.createValueElement(
|
||||||
val, fieldName, tabindex
|
val, fieldName, tabindex
|
||||||
);
|
);
|
||||||
|
|
||||||
var label = document.createElement("label");
|
|
||||||
label.setAttribute('fieldname', fieldName);
|
|
||||||
|
|
||||||
var prefix = '';
|
var prefix = '';
|
||||||
// Add '(...)' before 'Abstract:' for collapsed abstracts
|
// Add '(...)' before 'Abstract:' for collapsed abstracts
|
||||||
if (fieldName == 'abstractNote') {
|
if (fieldName == 'abstractNote') {
|
||||||
if (val && !Zotero.Prefs.get('lastAbstractExpand')) {
|
if (val && !Zotero.Prefs.get('lastAbstractExpand')) {
|
||||||
prefix = '(...) ';
|
prefix = '(\u2026) ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +418,7 @@
|
||||||
|
|
||||||
// TEMP - NSF (homepage)
|
// TEMP - NSF (homepage)
|
||||||
if ((fieldName == 'url' || fieldName == 'homepage') && val) {
|
if ((fieldName == 'url' || fieldName == 'homepage') && val) {
|
||||||
label.setAttribute("isButton", true);
|
label.classList.add("pointer");
|
||||||
// TODO: make getFieldValue non-private and use below instead
|
// TODO: make getFieldValue non-private and use below instead
|
||||||
label.setAttribute("onclick", "ZoteroPane_Local.loadURI(this.nextSibling.firstChild ? this.nextSibling.firstChild.nodeValue : this.nextSibling.value, event)");
|
label.setAttribute("onclick", "ZoteroPane_Local.loadURI(this.nextSibling.firstChild ? this.nextSibling.firstChild.nodeValue : this.nextSibling.value, event)");
|
||||||
label.setAttribute("tooltiptext", Zotero.getString('locate.online.tooltip'));
|
label.setAttribute("tooltiptext", Zotero.getString('locate.online.tooltip'));
|
||||||
|
@ -428,7 +428,7 @@
|
||||||
var doi = Zotero.Utilities.cleanDOI(val);
|
var doi = Zotero.Utilities.cleanDOI(val);
|
||||||
if (doi) {
|
if (doi) {
|
||||||
doi = "http://dx.doi.org/" + encodeURIComponent(doi);
|
doi = "http://dx.doi.org/" + encodeURIComponent(doi);
|
||||||
label.setAttribute("isButton", true);
|
label.classList.add("pointer");
|
||||||
label.setAttribute("onclick", "ZoteroPane_Local.loadURI('" + doi + "', event)");
|
label.setAttribute("onclick", "ZoteroPane_Local.loadURI('" + doi + "', event)");
|
||||||
label.setAttribute("tooltiptext", Zotero.getString('locate.online.tooltip'));
|
label.setAttribute("tooltiptext", Zotero.getString('locate.online.tooltip'));
|
||||||
valueElement.setAttribute('contextmenu', 'zotero-doi-menu');
|
valueElement.setAttribute('contextmenu', 'zotero-doi-menu');
|
||||||
|
@ -441,9 +441,19 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (fieldName == 'abstractNote') {
|
else if (fieldName == 'abstractNote') {
|
||||||
label.setAttribute("onclick",
|
if (val.length) {
|
||||||
"if (this.nextSibling.inputField) { this.nextSibling.inputField.blur(); } "
|
label.classList.add("pointer");
|
||||||
+ "else { document.getBindingParent(this).toggleAbstractExpand(this); }");
|
}
|
||||||
|
label.addEventListener('click', function () {
|
||||||
|
if (this.nextSibling.inputField) {
|
||||||
|
this.nextSibling.inputField.blur();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
document.getBindingParent(this).toggleAbstractExpand(
|
||||||
|
this, this.nextSibling
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
label.setAttribute("onclick",
|
label.setAttribute("onclick",
|
||||||
|
@ -1161,25 +1171,25 @@
|
||||||
|
|
||||||
<method name="toggleAbstractExpand">
|
<method name="toggleAbstractExpand">
|
||||||
<parameter name="label"/>
|
<parameter name="label"/>
|
||||||
|
<parameter name="valueElement"/>
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
var cur = Zotero.Prefs.get('lastAbstractExpand');
|
var cur = Zotero.Prefs.get('lastAbstractExpand');
|
||||||
Zotero.Prefs.set('lastAbstractExpand', !cur);
|
Zotero.Prefs.set('lastAbstractExpand', !cur);
|
||||||
|
|
||||||
var ab = label.nextSibling;
|
|
||||||
var valueText = this.item.getField('abstractNote');
|
var valueText = this.item.getField('abstractNote');
|
||||||
var tabindex = ab.getAttribute('ztabindex');
|
var tabindex = valueElement.getAttribute('ztabindex');
|
||||||
var elem = this.createValueElement(
|
var newValueElement = this.createValueElement(
|
||||||
valueText,
|
valueText,
|
||||||
'abstractNote',
|
'abstractNote',
|
||||||
tabindex
|
tabindex
|
||||||
);
|
);
|
||||||
ab.parentNode.replaceChild(elem, ab);
|
valueElement.parentNode.replaceChild(newValueElement, valueElement);
|
||||||
|
|
||||||
var text = Zotero.ItemFields.getLocalizedString(this.item.itemTypeID, 'abstractNote') + ':';
|
var text = Zotero.ItemFields.getLocalizedString(this.item.itemTypeID, 'abstractNote') + ':';
|
||||||
// Add '(...)' before "Abstract:" for collapsed abstracts
|
// Add '(...)' before "Abstract:" for collapsed abstracts
|
||||||
if (valueText && cur) {
|
if (valueText && cur) {
|
||||||
text = '(...) ' + text;
|
text = '(\u2026) ' + text;
|
||||||
}
|
}
|
||||||
label.setAttribute('value', text);
|
label.setAttribute('value', text);
|
||||||
]]>
|
]]>
|
||||||
|
@ -1357,6 +1367,14 @@
|
||||||
valueElement.appendChild(document.createTextNode(valueText));
|
valueElement.appendChild(document.createTextNode(valueText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow toggling non-editable Abstract open and closed with click
|
||||||
|
if (fieldName == 'abstractNote' && !this.editable) {
|
||||||
|
valueElement.classList.add("pointer");
|
||||||
|
valueElement.addEventListener('click', function () {
|
||||||
|
this.toggleAbstractExpand(valueElement.previousSibling, valueElement);
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
return valueElement;
|
return valueElement;
|
||||||
]]>
|
]]>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -40,16 +40,15 @@ row > label
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
row label:first-child[isButton=true]:hover
|
|
||||||
{
|
|
||||||
cursor: pointer !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
row label
|
row label
|
||||||
{
|
{
|
||||||
-moz-user-focus: ignore;
|
-moz-user-focus: ignore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
row .pointer:hover {
|
||||||
|
cursor: pointer !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* creator type menu */
|
/* creator type menu */
|
||||||
|
|
||||||
.creator-type-label, .creator-type-value {
|
.creator-type-label, .creator-type-value {
|
||||||
|
|
|
@ -60,7 +60,7 @@ pref("extensions.zotero.backup.numBackups", 2);
|
||||||
pref("extensions.zotero.backup.interval", 1440);
|
pref("extensions.zotero.backup.interval", 1440);
|
||||||
|
|
||||||
pref("extensions.zotero.lastCreatorFieldMode",0);
|
pref("extensions.zotero.lastCreatorFieldMode",0);
|
||||||
pref("extensions.zotero.lastAbstractExpand",0);
|
pref("extensions.zotero.lastAbstractExpand", true);
|
||||||
pref("extensions.zotero.lastRenameAssociatedFile", false);
|
pref("extensions.zotero.lastRenameAssociatedFile", false);
|
||||||
pref("extensions.zotero.lastLongTagMode", 0);
|
pref("extensions.zotero.lastLongTagMode", 0);
|
||||||
pref("extensions.zotero.lastLongTagDelimiter", ";");
|
pref("extensions.zotero.lastLongTagDelimiter", ";");
|
||||||
|
|
Loading…
Reference in a new issue