commit b6980b6c760786cfc76275d1d3baa6f6f37bfcb7
parent daf313ad87fcb68aa99ff9187b8679380a9df7bc
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 13 Oct 2009 08:56:04 +0000
- Restore Notes tab
- "Add" button in Notes tab now uses inline notes editor by default instead of new window -- Shift toggles
- Fix overflow of tab panels in right column
- Fix error clicking on parent item title in unsaved new note window
Diffstat:
6 files changed, 112 insertions(+), 9 deletions(-)
diff --git a/chrome/content/zotero/bindings/noteeditor.xml b/chrome/content/zotero/bindings/noteeditor.xml
@@ -294,7 +294,7 @@
<method name="selectParent">
<body>
<![CDATA[
- if (!this.item.id) {
+ if (!this.item || !this.item.id) {
return;
}
diff --git a/chrome/content/zotero/itemPane.js b/chrome/content/zotero/itemPane.js
@@ -38,6 +38,9 @@ var ZoteroItemPane = new function() {
}
_itemBox = document.getElementById('zotero-editpane-item-box');
+ _notesLabel = document.getElementById('zotero-editpane-notes-label');
+ _notesButton = document.getElementById('zotero-editpane-notes-add');
+ _notesList = document.getElementById('zotero-editpane-dynamic-notes');
_tagsBox = document.getElementById('zotero-editpane-tags');
_relatedBox = document.getElementById('zotero-editpane-related');
}
@@ -57,12 +60,12 @@ var ZoteroItemPane = new function() {
case 0:
var box = _itemBox;
break;
-
- case 1:
+
+ case 2:
var box = _tagsBox;
break;
- case 2:
+ case 3:
var box = _relatedBox;
break;
}
@@ -72,7 +75,7 @@ var ZoteroItemPane = new function() {
if (_lastItem && _lastItem != item) {
switch (index) {
case 0:
- case 1:
+ case 2:
box.blurOpenField();
// DEBUG: Currently broken
//box.scrollToTop();
@@ -82,6 +85,54 @@ var ZoteroItemPane = new function() {
_lastItem = item;
+ if (index == 1) {
+ var editable = ZoteroPane.canEdit();
+ _notesButton.hidden = !editable;
+
+ while(_notesList.hasChildNodes()) {
+ _notesList.removeChild(_notesList.firstChild);
+ }
+
+ var notes = Zotero.Items.get(item.getNotes());
+ if (notes.length) {
+ for(var i = 0; i < notes.length; i++) {
+ var icon = document.createElement('image');
+ icon.setAttribute('src','chrome://zotero/skin/treeitem-note.png');
+
+ var label = document.createElement('label');
+ var title = Zotero.Notes.noteToTitle(notes[i].getNote());
+ title = title ? title : Zotero.getString('pane.item.notes.untitled');
+ label.setAttribute('value', title);
+ label.setAttribute('flex','1'); //so that the long names will flex smaller
+ label.setAttribute('crop','end');
+
+ var box = document.createElement('box');
+ box.setAttribute('onclick',"ZoteroPane.selectItem(" + notes[i].id + ");");
+ box.setAttribute('class','zotero-clicky');
+ box.appendChild(icon);
+ box.appendChild(label);
+
+ if (editable) {
+ var removeButton = document.createElement('label');
+ removeButton.setAttribute("value","-");
+ removeButton.setAttribute("class","zotero-clicky");
+ removeButton.setAttribute("onclick","ZoteroItemPane.removeNote(" + notes[i].id + ")");
+ }
+
+ var row = document.createElement('row');
+ row.appendChild(box);
+ if (editable) {
+ row.appendChild(removeButton);
+ }
+
+ _notesList.appendChild(row);
+ }
+ }
+
+ _updateNoteCount();
+ return;
+ }
+
if (mode) {
box.mode = mode;
}
@@ -90,6 +141,41 @@ var ZoteroItemPane = new function() {
}
box.item = item;
}
-}
+
+
+ this.addNote = function (popup) {
+ ZoteroPane.newNote(popup, _lastItem.id);
+ }
+
+
+ this.removeNote = function (id) {
+ var note = Zotero.Items.get(id);
+ var pr = Components.classes["@mozilla.org/network/default-prompt;1"]
+ .createInstance(Components.interfaces.nsIPrompt);
+ if (note && pr.confirm('', Zotero.getString('pane.item.notes.delete.confirm'))) {
+ note.erase();
+ }
+ }
+
+
+ function _updateNoteCount() {
+ var c = _notesList.childNodes.length;
+
+ var str = 'pane.item.notes.count.';
+ switch (c){
+ case 0:
+ str += 'zero';
+ break;
+ case 1:
+ str += 'singular';
+ break;
+ default:
+ str += 'plural';
+ break;
+ }
+
+ _notesLabel.value = Zotero.getString(str, [c]);
+ }
+}
addEventListener("load", function(e) { ZoteroItemPane.onLoad(e); }, false);
diff --git a/chrome/content/zotero/itemPane.xul b/chrome/content/zotero/itemPane.xul
@@ -36,6 +36,22 @@
<zoteroitembox id="zotero-editpane-item-box" flex="1"/>
</tabpanel>
+ <tabpanel flex="1" orient="vertical">
+ <vbox flex="1">
+ <hbox align="center">
+ <label id="zotero-editpane-notes-label"/>
+ <button id="zotero-editpane-notes-add" label="&zotero.item.add;" oncommand="ZoteroItemPane.addNote(event.shiftKey);"/>
+ </hbox>
+ <grid flex="1">
+ <columns>
+ <column flex="1"/>
+ <column/>
+ </columns>
+ <rows id="zotero-editpane-dynamic-notes" flex="1"/>
+ </grid>
+ </vbox>
+ </tabpanel>
+
<tabpanel>
<tagsbox id="zotero-editpane-tags" flex="1"/>
</tabpanel>
diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js
@@ -2394,10 +2394,10 @@ var ZoteroPane = new function()
// TODO: _text_
var c = this.getSelectedCollection();
if (c) {
- this.openNoteWindow(null, c.id);
+ this.openNoteWindow(null, c.id, parent);
}
else {
- this.openNoteWindow();
+ this.openNoteWindow(null, null, parent);
}
}
}
diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul
@@ -414,6 +414,7 @@
<tabbox id="zotero-view-tabbox" flex="1" onselect="if (!ZoteroPane.collectionsView.selection || event.originalTarget.localName != 'tabpanels') { return; }; ZoteroItemPane.viewItem(ZoteroPane.getSelectedItems()[0], ZoteroPane.collectionsView.editable ? 'edit' : 'view', this.selectedIndex)">
<tabs>
<tab label="&zotero.tabs.info.label;"/>
+ <tab label="&zotero.tabs.notes.label;"/>
<tab label="&zotero.tabs.tags.label;"/>
<tab label="&zotero.tabs.related.label;"/>
</tabs>
diff --git a/chrome/skin/default/zotero/itemPane.css b/chrome/skin/default/zotero/itemPane.css
@@ -1,4 +1,4 @@
-zoteroitembox
+#zotero-view-item > tabpanel > *
{
overflow: auto;
}