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
|
||||
);
|
||||
|
||||
var label = document.createElement("label");
|
||||
label.setAttribute('fieldname', fieldName);
|
||||
|
||||
var prefix = '';
|
||||
// Add '(...)' before 'Abstract:' for collapsed abstracts
|
||||
if (fieldName == 'abstractNote') {
|
||||
if (val && !Zotero.Prefs.get('lastAbstractExpand')) {
|
||||
prefix = '(...) ';
|
||||
prefix = '(\u2026) ';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@
|
|||
|
||||
// TEMP - NSF (homepage)
|
||||
if ((fieldName == 'url' || fieldName == 'homepage') && val) {
|
||||
label.setAttribute("isButton", true);
|
||||
label.classList.add("pointer");
|
||||
// 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("tooltiptext", Zotero.getString('locate.online.tooltip'));
|
||||
|
@ -428,7 +428,7 @@
|
|||
var doi = Zotero.Utilities.cleanDOI(val);
|
||||
if (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("tooltiptext", Zotero.getString('locate.online.tooltip'));
|
||||
valueElement.setAttribute('contextmenu', 'zotero-doi-menu');
|
||||
|
@ -441,9 +441,19 @@
|
|||
}
|
||||
}
|
||||
else if (fieldName == 'abstractNote') {
|
||||
label.setAttribute("onclick",
|
||||
"if (this.nextSibling.inputField) { this.nextSibling.inputField.blur(); } "
|
||||
+ "else { document.getBindingParent(this).toggleAbstractExpand(this); }");
|
||||
if (val.length) {
|
||||
label.classList.add("pointer");
|
||||
}
|
||||
label.addEventListener('click', function () {
|
||||
if (this.nextSibling.inputField) {
|
||||
this.nextSibling.inputField.blur();
|
||||
}
|
||||
else {
|
||||
document.getBindingParent(this).toggleAbstractExpand(
|
||||
this, this.nextSibling
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
label.setAttribute("onclick",
|
||||
|
@ -1161,25 +1171,25 @@
|
|||
|
||||
<method name="toggleAbstractExpand">
|
||||
<parameter name="label"/>
|
||||
<parameter name="valueElement"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var cur = Zotero.Prefs.get('lastAbstractExpand');
|
||||
Zotero.Prefs.set('lastAbstractExpand', !cur);
|
||||
|
||||
var ab = label.nextSibling;
|
||||
var valueText = this.item.getField('abstractNote');
|
||||
var tabindex = ab.getAttribute('ztabindex');
|
||||
var elem = this.createValueElement(
|
||||
var tabindex = valueElement.getAttribute('ztabindex');
|
||||
var newValueElement = this.createValueElement(
|
||||
valueText,
|
||||
'abstractNote',
|
||||
tabindex
|
||||
);
|
||||
ab.parentNode.replaceChild(elem, ab);
|
||||
valueElement.parentNode.replaceChild(newValueElement, valueElement);
|
||||
|
||||
var text = Zotero.ItemFields.getLocalizedString(this.item.itemTypeID, 'abstractNote') + ':';
|
||||
// Add '(...)' before "Abstract:" for collapsed abstracts
|
||||
if (valueText && cur) {
|
||||
text = '(...) ' + text;
|
||||
text = '(\u2026) ' + text;
|
||||
}
|
||||
label.setAttribute('value', text);
|
||||
]]>
|
||||
|
@ -1357,6 +1367,14 @@
|
|||
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;
|
||||
]]>
|
||||
</body>
|
||||
|
|
|
@ -40,16 +40,15 @@ row > label
|
|||
border: 1px solid transparent;
|
||||
}
|
||||
|
||||
row label:first-child[isButton=true]:hover
|
||||
{
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
row label
|
||||
{
|
||||
-moz-user-focus: ignore;
|
||||
}
|
||||
|
||||
row .pointer:hover {
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
/* creator type menu */
|
||||
|
||||
.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.lastCreatorFieldMode",0);
|
||||
pref("extensions.zotero.lastAbstractExpand",0);
|
||||
pref("extensions.zotero.lastAbstractExpand", true);
|
||||
pref("extensions.zotero.lastRenameAssociatedFile", false);
|
||||
pref("extensions.zotero.lastLongTagMode", 0);
|
||||
pref("extensions.zotero.lastLongTagDelimiter", ";");
|
||||
|
|
Loading…
Reference in a new issue