From 75374af5afc4c01dce49c8a39038d2808014020f Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 6 Jun 2010 00:01:11 +0000 Subject: [PATCH] - add Frank's citation re-ordering patch, with a few changes - fix error when canceling citation add after editing --- .../zotero/integration/addCitationDialog.js | 54 +++++++++++++++++- .../zotero/integration/addCitationDialog.xul | 10 ++-- chrome/content/zotero/xpcom/integration.js | 11 ++-- .../default/zotero/citation-down-gray.png | Bin 0 -> 1010 bytes chrome/skin/default/zotero/citation-down.png | Bin 0 -> 397 bytes .../skin/default/zotero/citation-up-gray.png | Bin 0 -> 1009 bytes chrome/skin/default/zotero/citation-up.png | Bin 0 -> 407 bytes chrome/skin/default/zotero/integration.css | 26 ++++++++- 8 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 chrome/skin/default/zotero/citation-down-gray.png create mode 100644 chrome/skin/default/zotero/citation-down.png create mode 100644 chrome/skin/default/zotero/citation-up-gray.png create mode 100644 chrome/skin/default/zotero/citation-up.png diff --git a/chrome/content/zotero/integration/addCitationDialog.js b/chrome/content/zotero/integration/addCitationDialog.js index ac7ccf460..0beca4849 100644 --- a/chrome/content/zotero/integration/addCitationDialog.js +++ b/chrome/content/zotero/integration/addCitationDialog.js @@ -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); } /* diff --git a/chrome/content/zotero/integration/addCitationDialog.xul b/chrome/content/zotero/integration/addCitationDialog.xul index 025aa7258..11c59d962 100644 --- a/chrome/content/zotero/integration/addCitationDialog.xul +++ b/chrome/content/zotero/integration/addCitationDialog.xul @@ -159,15 +159,17 @@ - diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 22cb32531..d3925a7aa 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -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)) { diff --git a/chrome/skin/default/zotero/citation-down-gray.png b/chrome/skin/default/zotero/citation-down-gray.png new file mode 100644 index 0000000000000000000000000000000000000000..d10dc7327bdbf3c8a727878b5819a6de8514fca0 GIT binary patch literal 1010 zcmXAoMQkHR6ow~VrQK{5wNiVi+8$PwdTTFXhrvng#IYU6iQ_Ocqr=S14l^?|Gdax6 z%*=h&9%e=}(v05wzJEf?09cry}HQfDmH_q24xxxDMdD!w%*zeuO?DGJz`H$njla zVPRceT|+~Ixw*Nzy1J5*QdU-0X=$mRo}RtEy^M^EgoH#zMTMWAUutS^2F7E8?Y;JCDX=zDFNXX30%*n}db#;Avd*kBb;^yY&;o;%s z<>lk!s%FoJ@DLPA2q!ou*BsHmuzn3%Y@IFu(TDJdl-g~ei}rKO=@Sy@>e z4u{9%<>ch#<>jFyD2zxXl1L;nnXIU&NTE=mO)8bDtgNh}qC%t5R8>{!bh?_F8W7OX z(9qP>)Y8(@*4Eb1(b3h_1r+-F`UVCDhK7blMn=ZQ#wI2vrlzK5W@Z4*!otGR($dPx z%G%o6#>U3h*4EC>4$wI`I5;{wIypHxJ3BKN3>Oy{=+4c}&E4JI!^6YV(-UZTdwcu% z`1tzz0$zWAf8ZGy7#I{36dW8J5)u*`8VYQ~!^0yYA|fLrqoSgsqoZSDVt{{KTwHv7 zJa9`)OiW5jVltVa2AG2*5Rsmq4$J{5s0981Ha9mH$mi$hg9tGGjeki=35W(qpbQj) zwW_Krum(13Yil7D_4V}-3~=4l)b!01xC8I)?d=^M9iXqPtE;=ayQin8x3{;iudlzq ze_&u>aBy&FXlQtNcw}T`baZrVY;1gdoW){IOiWBpPEJitO;1nH%*@Qr&d$xv&Cky- zEG#T8E-o!CEiW&xtgNiAuCA@Et*@_dY-~W-wzjsmx3_n8c6N7n_xASo_xBGD4h|0w zkB*LxkB?7IPEJox&(6-y&(AL|E-o)Gudc4Hudi=zZf)Z)j+3y#Si{H^ivc^u%9vKuSBz1iM1F*jpkN^Mx literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/citation-down.png b/chrome/skin/default/zotero/citation-down.png new file mode 100644 index 0000000000000000000000000000000000000000..70e4a290df44ed7910d830f60a22f9e970f21dbe GIT binary patch literal 397 zcmV;80doF{P)qo(*OX&yZ`_)=Kug4bmKW9 zHvj+u6G=otRCwBik+DhxK@f(&-McdvwXl^`78YV*?6k5nD1yN!u=k040t?ex2)1dg z1fM|E6gGl6-MgK=-L;U5N)818;7=9IFe-1sQcYO-V0718+w5oEgvsRfz8LLp r0T5%Hb!Y!_oF81>{@khm;{F@}hPjl%FItq)00000NkvXXu0mjfnvI*- literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/citation-up-gray.png b/chrome/skin/default/zotero/citation-up-gray.png new file mode 100644 index 0000000000000000000000000000000000000000..fa9814437c8cddcf3f7372d72dbb55ece37c02b6 GIT binary patch literal 1009 zcmWlYWlS?h9ET6c62?OICVR8IdAB9YKJD{{yR@`L3Y6mR?#12R-Q6ipad#_HpirFR z?k@Z9!`+0(E^z^K(taNvGmz0zY4i0*Idp9&R zbar;;3SReSQ7X($e1EUUPHv%*;$5A0I_UMSp*PFE6jc z!orr8mWqlB4-b!yjt);x&$qWXQ&ZEry1Lrh+Un|RUtiyvni>}um-6!R_V#u@K0bba zegOdiK|w(wAt7O5VG$7#QBhGbF)?v*aR~_tNl8g5DJf}bX&D(ASy@>O27|?7<>cgW zI2<02ClCno^70A_3h)3WB_$$}sI084qN1Xzs!Ae})YR0-WU{)tx`u{^rlzKrmX@}* zwvLVtNm6-f3oL2BCnGrKP2nm6f%%wT+DpptG~H19}b) z4vvnF0KwVW86p5f3Weh4=H~A14tXIg5CC)l1Y-L6`2mxFfPlcjz@VU@;NW1O9U2-M z78VvB9v%@95g8d76%`d79SufeV`Jmu;^O1u6A}^<6BCn?lE6z!N=j;KYFb)adU|?B zMh2h;aoO3~ASE|9H!m*_41yG3UQ|>BioqRtDJv@jwxFQ0va+hG3YY_MfKR1T!9sm~ zJ(z85Yy^+Z&CMXIwY3%Gwzai^4p0WtySlod2~Y`8+}GFF-`_tlFaWI>8X6iN9v&GP z866!R8yg!RAD@_*n4FxPnwpxPo}QVRq0{NJv$Jz^bMy1_3kwSj24it?acOC3d3l-1 zWJ1AKS65jq*4oVF6=GNBM_V)J9&d%=cE}PBX+uPgU-#<7wI6OQ&IyyQ& zK0Y})IXyi+J3Bi+Kfk!RxV*f)y1Kf)zP`D+xxKx;ySux;zkhgmczk?(dU|?(eul2T zzP>{1-rwIpK0ZD_KY6iv-{IeIP)I~IBz3T20UHAXMw;x&Ql$UODa(QS=N{u&H0tXX zRW`$dFnWdi`u@hl7N+MgXum1H{91BPdD8mh%SDI+Z_{BHXFAj8=dWyC?qq3Eu6<`F qr}ev9pzkt4YOXfD&uZ^@YtRGrl>A^VYUvLD79j$bh^dn?3jPl_O&Tx& literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/citation-up.png b/chrome/skin/default/zotero/citation-up.png new file mode 100644 index 0000000000000000000000000000000000000000..1c542455497ce2241954f564d0f58e437523c146 GIT binary patch literal 407 zcmV;I0cie-P)qo(*OX&yZ`_)=Kug4bmKW9 zHvj+u9Z5t%RCwBakv&TTK@f(Y-MyW?TN48oeh@zzu~V=TE2{|pfHeLC{c9E>LK+(z z(TGhf0%8-3m{KfG61?QrDlu@;x0~VNnHfff5cn^8zDUkmkMZf%-F#0?4dwd7bG5p1 zkPRoi_qv_YP5lr+tzYyc`yO?7R{ieLUWs(9xPR)?@4dW6A>G$jT+2$lSy`G8IZZ6E zwU(fa-yW;d^=!n( z$bE$IQap26Lu_+Q1Xki1@N4jv$U-?EW5pE>P7GE8#wet0iw2*7(*YbTYgGi|C?~OF zatz`Z?2yifo$mjq7002ovPDHLkV1j1x BovQ!< literal 0 HcmV?d00001 diff --git a/chrome/skin/default/zotero/integration.css b/chrome/skin/default/zotero/integration.css index 096b01461..ccb809d04 100644 --- a/chrome/skin/default/zotero/integration.css +++ b/chrome/skin/default/zotero/integration.css @@ -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; }