- add Frank's citation re-ordering patch, with a few changes
- fix error when canceling citation add after editing
This commit is contained in:
parent
41f39aa4e8
commit
75374af5af
|
@ -50,6 +50,8 @@ var Zotero_Citation_Dialog = new function () {
|
|||
this.toggleEditor = toggleEditor;
|
||||
this.treeItemSelected = treeItemSelected;
|
||||
this.listItemSelected = listItemSelected;
|
||||
this.up = up;
|
||||
this.down = down;
|
||||
this.add = add;
|
||||
this.remove = remove;
|
||||
this.sortCitation = sortCitation;
|
||||
|
@ -215,19 +217,63 @@ var Zotero_Citation_Dialog = new function () {
|
|||
_updateAccept();
|
||||
_updatePreview();
|
||||
}
|
||||
_configListPosition(document.getElementById("citation-list"), true);
|
||||
}
|
||||
|
||||
/*
|
||||
* called when an item in the selected items list is clicked
|
||||
*/
|
||||
function listItemSelected() {
|
||||
var selectedListItem = document.getElementById("citation-list").getSelectedItem(0);
|
||||
var itemList = document.getElementById("citation-list");
|
||||
var selectedListItem = itemList.getSelectedItem(0);
|
||||
var itemID = (selectedListItem ? selectedListItem.value : false);
|
||||
_itemSelected(itemID);
|
||||
_configListPosition(itemList, !itemID);
|
||||
|
||||
document.getElementById("remove").disabled = !itemID;
|
||||
}
|
||||
|
||||
function _configListPosition(itemList,flag) {
|
||||
var selectedIndex = itemList.selectedIndex;
|
||||
if (selectedIndex > 0) {
|
||||
document.getElementById("up").disabled = flag;
|
||||
} else {
|
||||
document.getElementById("up").disabled = true;
|
||||
}
|
||||
if (selectedIndex < (itemList.getRowCount() - 1)) {
|
||||
document.getElementById("down").disabled = flag;
|
||||
} else {
|
||||
document.getElementById("down").disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
function _move(direction) {
|
||||
var insertBeforeItem;
|
||||
var itemList = document.getElementById("citation-list");
|
||||
var selectedListItem = itemList.getSelectedItem(0);
|
||||
var itemID = selectedListItem.value;
|
||||
var selectedListIndex = itemList.selectedIndex;
|
||||
if (direction === -1) {
|
||||
insertBeforeItem = selectedListItem.previousSibling;
|
||||
} else {
|
||||
insertBeforeItem = selectedListItem.nextSibling.nextSibling;
|
||||
}
|
||||
var listItem = itemList.removeChild(selectedListItem);
|
||||
itemList.insertBefore(listItem, insertBeforeItem);
|
||||
itemList.selectedIndex = (selectedListIndex + direction);
|
||||
_itemSelected(itemID);
|
||||
_updatePreview();
|
||||
_configListPosition(itemList, false);
|
||||
}
|
||||
|
||||
function up() {
|
||||
_move(-1);
|
||||
}
|
||||
|
||||
function down() {
|
||||
_move(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a citation to the multipleSources list
|
||||
*/
|
||||
|
@ -514,11 +560,15 @@ var Zotero_Citation_Dialog = new function () {
|
|||
*/
|
||||
function _addItem(item) {
|
||||
var itemNode = document.createElement("listitem");
|
||||
var itemList = document.getElementById("citation-list");
|
||||
itemNode.setAttribute("value", item.getID());
|
||||
itemNode.setAttribute("label", item.getField("title"));
|
||||
itemNode.setAttribute("class", "listitem-iconic");
|
||||
itemNode.setAttribute("image", item.getImageSrc());
|
||||
document.getElementById("citation-list").appendChild(itemNode);
|
||||
itemList.appendChild(itemNode);
|
||||
itemList.focus();
|
||||
itemList.selectedIndex = itemList.childNodes.length-1;
|
||||
_configListPosition(itemList, false);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -159,15 +159,17 @@
|
|||
</hbox>
|
||||
</vbox>
|
||||
|
||||
<hbox hidden="true" id="multiple-sources">
|
||||
<vbox align="center" pack="center">
|
||||
<hbox hidden="true" id="multiple-sources" align="stretch">
|
||||
<vbox align="center" pack="center" id="citation-buttons">
|
||||
<toolbarbutton id="up" oncommand="Zotero_Citation_Dialog.up()" disabled="true"/>
|
||||
<toolbarbutton id="add" oncommand="Zotero_Citation_Dialog.add()" disabled="true"/>
|
||||
<toolbarbutton id="remove" oncommand="Zotero_Citation_Dialog.remove()" disabled="true"/>
|
||||
<toolbarbutton id="down" oncommand="Zotero_Citation_Dialog.down()" disabled="true"/>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<vbox align="left">
|
||||
<checkbox id="keepSorted" hidden="true" checked="false" oncommand="Zotero_Citation_Dialog.sortCitation()" label="&zotero.citation.keepSorted.label;"/>
|
||||
<listbox id="citation-list" flex="1" align="stretch" seltype="single"
|
||||
onselect="Zotero_Citation_Dialog.listItemSelected();"></listbox>
|
||||
onselect="Zotero_Citation_Dialog.listItemSelected();"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
</hbox>
|
||||
|
|
|
@ -616,10 +616,11 @@ Zotero.Integration.Document.prototype._updateSession = function(newField, editFi
|
|||
Zotero.Integration.Document.prototype._updateDocument = function(forceCitations, forceBibliography) {
|
||||
// update citations
|
||||
this._session.updateUpdateIndices(forceCitations);
|
||||
this._deleteFields = this._deleteFields.concat(this._session.updateCitations());
|
||||
for(var i in this._session.citationText) {
|
||||
var deleteCitations = this._session.updateCitations();
|
||||
this._deleteFields = this._deleteFields.concat([i for(i in deleteCitations)]);
|
||||
for(var i in this._session.updateIndices) {
|
||||
citation = this._session.citationsByIndex[i];
|
||||
if(!citation) continue;
|
||||
if(!citation || deleteCitations[i]) continue;
|
||||
|
||||
var fieldCode = this._session.getCitationField(citation);
|
||||
if(fieldCode != citation.properties.field) {
|
||||
|
@ -1370,14 +1371,14 @@ Zotero.Integration.Session.prototype.updateCitations = function() {
|
|||
Zotero.debug("Zotero.Integration: indices of updated citations");
|
||||
Zotero.debug([key for(key in this.updateIndices)]);
|
||||
|
||||
var deleteCitations = [];
|
||||
var deleteCitations = {};
|
||||
for each(var indexList in [this.newIndices, this.updateIndices]) {
|
||||
for(var index in indexList) {
|
||||
index = parseInt(index);
|
||||
|
||||
var citation = this.citationsByIndex[index];
|
||||
if(citation.properties.delete) {
|
||||
if(deleteCitations.indexOf(index) == -1) deleteCitations.push(index);
|
||||
deleteCitations[index] = true;
|
||||
continue;
|
||||
}
|
||||
if(this.formatCitation(index, citation)) {
|
||||
|
|
BIN
chrome/skin/default/zotero/citation-down-gray.png
Normal file
BIN
chrome/skin/default/zotero/citation-down-gray.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1010 B |
BIN
chrome/skin/default/zotero/citation-down.png
Normal file
BIN
chrome/skin/default/zotero/citation-down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 397 B |
BIN
chrome/skin/default/zotero/citation-up-gray.png
Normal file
BIN
chrome/skin/default/zotero/citation-up-gray.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1009 B |
BIN
chrome/skin/default/zotero/citation-up.png
Normal file
BIN
chrome/skin/default/zotero/citation-up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 407 B |
|
@ -1,3 +1,20 @@
|
|||
#up {
|
||||
list-style-image: url('chrome://zotero/skin/citation-up.png');
|
||||
}
|
||||
|
||||
#up[disabled="true"] {
|
||||
list-style-image: url('chrome://zotero/skin/citation-up-gray.png');
|
||||
}
|
||||
|
||||
#down {
|
||||
list-style-image: url('chrome://zotero/skin/citation-down.png');
|
||||
}
|
||||
|
||||
#down[disabled="true"] {
|
||||
list-style-image: url('chrome://zotero/skin/citation-down-gray.png');
|
||||
}
|
||||
|
||||
|
||||
#add {
|
||||
list-style-image: url('chrome://zotero/skin/citation-add.png');
|
||||
}
|
||||
|
@ -14,13 +31,18 @@
|
|||
list-style-image: url('chrome://zotero/skin/citation-delete-gray.png');
|
||||
}
|
||||
|
||||
#add .toolbarbutton-text, #remove .toolbarbutton-text
|
||||
#citation-buttons > toolbarbutton
|
||||
{
|
||||
margin: 2px 0 2px 4px !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
#citation-buttons > toolbarbutton > .toolbarbutton-text
|
||||
{
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
|
||||
#prefix, #suffix {
|
||||
width: 200px;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user