- Add ability to collapse left column of Zotero via grippy

- Use grippy for collapsing tag selector and remove toolbar icon
- Remove redundant Attachments and Notes tabs in metadata pane
- Add all four child attachment options to submenu of item context menu
This commit is contained in:
Dan Stillman 2009-07-24 06:03:51 +00:00
parent 110800f154
commit 43e47b30a3
6 changed files with 49 additions and 266 deletions

View File

@ -23,10 +23,6 @@
var ZoteroItemPane = new function() {
var _itemBeingEdited;
var _notesList;
var _linksBox;
var _notesLabel;
var _lastPane;
var _loaded;
@ -37,11 +33,6 @@ var ZoteroItemPane = new function() {
this.onLoad = onLoad;
this.viewItem = viewItem;
this.loadPane = loadPane;
this.removeNote = removeNote;
this.addNote = addNote;
this.removeAttachment = removeAttachment;
this.addAttachmentFromDialog = addAttachmentFromDialog;
this.addAttachmentFromPage = addAttachmentFromPage;
function onLoad()
@ -57,10 +48,6 @@ var ZoteroItemPane = new function() {
_deck = document.getElementById('zotero-view-item');
_itemBox = document.getElementById('zotero-editpane-item-box');
_notesList = document.getElementById('zotero-editpane-dynamic-notes');
_notesLabel = document.getElementById('zotero-editpane-notes-label');
_attachmentsList = document.getElementById('zotero-editpane-dynamic-attachments');
_attachmentsLabel = document.getElementById('zotero-editpane-attachments-label');
_tagsBox = document.getElementById('zotero-editpane-tags');
_relatedBox = document.getElementById('zotero-editpane-related');
}
@ -129,112 +116,9 @@ var ZoteroItemPane = new function() {
_itemBox.item = _itemBeingEdited;
}
// Notes pane
else if(index == 1)
{
while(_notesList.hasChildNodes())
_notesList.removeChild(_notesList.firstChild);
var notes = Zotero.Items.get(_itemBeingEdited.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);
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);
row.appendChild(removeButton);
_notesList.appendChild(row);
}
}
_updateNoteCount();
}
// Attachments pane
else if(index == 2)
{
while(_attachmentsList.hasChildNodes())
_attachmentsList.removeChild(_attachmentsList.firstChild);
var attachments = Zotero.Items.get(_itemBeingEdited.getAttachments());
if(attachments.length)
{
for(var i = 0; i < attachments.length; i++)
{
var icon = document.createElement('image');
var linkMode = attachments[i].getAttachmentLinkMode();
var itemType = '';
if(linkMode == Zotero.Attachments.LINK_MODE_IMPORTED_FILE)
{
itemType = "-file";
}
else if(linkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE)
{
itemType = "-link";
}
else if(linkMode == Zotero.Attachments.LINK_MODE_IMPORTED_URL)
{
itemType = "-snapshot";
}
else if(linkMode == Zotero.Attachments.LINK_MODE_LINKED_URL)
{
itemType = "-web-link";
}
icon.setAttribute('src','chrome://zotero/skin/treeitem-file'+itemType+'.png');
var label = document.createElement('label');
label.setAttribute('value',attachments[i].getField('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('" + attachments[i].id + "')");
box.setAttribute('class','zotero-clicky');
box.appendChild(icon);
box.appendChild(label);
var removeButton = document.createElement('label');
removeButton.setAttribute("value","-");
removeButton.setAttribute("class","zotero-clicky");
removeButton.setAttribute("onclick","ZoteroItemPane.removeAttachment(" + attachments[i].id + ")");
var row = document.createElement('row');
row.appendChild(box);
row.appendChild(removeButton);
_attachmentsList.appendChild(row);
}
}
_updateAttachmentCount();
}
// Tags pane
else if(index == 3)
{
else if (index == 1) {
if (mode) {
_tagsBox.mode = mode;
}
@ -248,83 +132,10 @@ var ZoteroItemPane = new function() {
}
// Related pane
else if(index == 4)
{
else if (index == 2) {
_relatedBox.item = _itemBeingEdited;
}
}
function removeNote(id)
{
var note = Zotero.Items.get(id);
if(note)
if(confirm(Zotero.getString('pane.item.notes.delete.confirm')))
note.erase();
}
function addNote()
{
ZoteroPane.openNoteWindow(null, null, _itemBeingEdited.id);
}
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]);
}
function _updateAttachmentCount()
{
var c = _attachmentsList.childNodes.length;
var str = 'pane.item.attachments.count.';
switch (c){
case 0:
str += 'zero';
break;
case 1:
str += 'singular';
break;
default:
str += 'plural';
break;
}
_attachmentsLabel.value = Zotero.getString(str, [c]);
}
function removeAttachment(id)
{
var attachment = Zotero.Items.get(id);
if(attachment)
if(confirm(Zotero.getString('pane.item.attachments.delete.confirm')))
attachment.erase();
}
function addAttachmentFromDialog(link)
{
ZoteroPane.addAttachmentFromDialog(link, _itemBeingEdited.id);
}
function addAttachmentFromPage(link)
{
ZoteroPane.addAttachmentFromPage(link, _itemBeingEdited.id);
}
}
addEventListener("load", function(e) { ZoteroItemPane.onLoad(e); }, false);

View File

@ -36,41 +36,6 @@
<zoteroitembox id="zotero-editpane-item-box" flex="1"/>
</tabpanel>
<tabpanel flex="1" orient="vertical">
<hbox align="center">
<label id="zotero-editpane-notes-label"/>
<button label="&zotero.item.add;" oncommand="ZoteroItemPane.addNote();"/>
</hbox>
<grid flex="1">
<columns>
<column flex="1"/>
<column/>
</columns>
<rows id="zotero-editpane-dynamic-notes" flex="1"/>
</grid>
</tabpanel>
<tabpanel flex="1" orient="vertical">
<hbox align="center">
<label id="zotero-editpane-attachments-label"/>
<button id="zotero-tb-item-attachments-add" type="menu" label="&zotero.item.add;">
<menupopup>
<menuitem class="menuitem-iconic" id="zotero-tb-item-attachments-link" label="&zotero.toolbar.attachment.linked;" oncommand="ZoteroItemPane.addAttachmentFromDialog(true);"/>
<menuitem class="menuitem-iconic" id="zotero-tb-item-attachments-file" label="&zotero.toolbar.attachment.add;" oncommand="ZoteroItemPane.addAttachmentFromDialog();"/>
<menuitem class="menuitem-iconic" id="zotero-tb-item-attachments-web-link" label="&zotero.toolbar.attachment.weblink;" oncommand="ZoteroItemPane.addAttachmentFromPage(true);"/>
<menuitem class="menuitem-iconic" id="zotero-tb-item-attachments-snapshot" label="&zotero.toolbar.attachment.snapshot;" oncommand="ZoteroItemPane.addAttachmentFromPage();"/>
</menupopup>
</button>
</hbox>
<grid flex="1">
<columns>
<column flex="1"/>
<column/>
</columns>
<rows id="zotero-editpane-dynamic-attachments" flex="1"/>
</grid>
</tabpanel>
<tabpanel>
<tagsbox id="zotero-editpane-tags" flex="1"/>
</tabpanel>

View File

@ -779,12 +779,10 @@ var ZoteroPane = new function()
function toggleTagSelector(){
var zoteroPane = document.getElementById('zotero-pane');
var splitter = document.getElementById('zotero-tags-splitter');
var tagSelector = document.getElementById('zotero-tag-selector');
var showing = tagSelector.getAttribute('collapsed') == 'true';
tagSelector.setAttribute('collapsed', !showing);
splitter.setAttribute('collapsed', !showing);
this.updateTagSelectorSize();
// If showing, set scope to items in current view
@ -1669,21 +1667,20 @@ var ZoteroPane = new function()
showInLibrary: 0,
sep1: 1,
addNote: 2,
attachSnapshot: 3,
attachLink: 4,
sep2: 5,
duplicateItem: 6,
deleteItem: 7,
deleteFromLibrary: 8,
sep3: 9,
exportItems: 10,
createBib: 11,
loadReport: 12,
sep4: 13,
createParent: 14,
recognizePDF: 15,
renameAttachments: 16,
reindexItem: 17
addAttachments: 3,
sep2: 4,
duplicateItem: 5,
deleteItem: 6,
deleteFromLibrary: 7,
sep3: 8,
exportItems: 9,
createBib: 10,
loadReport: 11,
sep4: 12,
createParent: 13,
recognizePDF: 14,
renameAttachments: 15,
reindexItem: 16
};
var menu = document.getElementById('zotero-itemmenu');
@ -1698,15 +1695,15 @@ var ZoteroPane = new function()
}
else if (this.itemsView && this.itemsView.selection.count > 0) {
enable.push(m.showInLibrary, m.addNote, m.attachSnapshot, m.attachLink,
enable.push(m.showInLibrary, m.addNote, m.addAttachments,
m.sep2, m.duplicateItem, m.deleteItem, m.deleteFromLibrary,
m.exportItems, m.createBib, m.loadReport);
// Multiple items selected
if (this.itemsView.selection.count > 1) {
var multiple = '.multiple';
hide.push(m.showInLibrary, m.sep1, m.addNote, m.attachSnapshot,
m.attachLink, m.sep2, m.duplicateItem);
hide.push(m.showInLibrary, m.sep1, m.addNote, m.addAttachments,
m.sep2, m.duplicateItem);
// If all items can be reindexed, or all items can be recognized, show option
var items = this.getSelectedItems();
@ -1797,11 +1794,11 @@ var ZoteroPane = new function()
if (item.isRegularItem())
{
show.push(m.addNote, m.attachSnapshot, m.attachLink, m.sep2);
show.push(m.addNote, m.addAttachments, m.sep2);
}
else
{
hide.push(m.addNote, m.attachSnapshot, m.attachLink, m.sep2);
hide.push(m.addNote, m.addAttachments, m.sep2);
}
if (item.isAttachment()) {
@ -1878,7 +1875,7 @@ var ZoteroPane = new function()
disable.push(m.showInLibrary, m.duplicateItem, m.deleteItem,
m.deleteFromLibrary, m.exportItems, m.createBib, m.loadReport);
hide.push(m.addNote, m.attachSnapshot, m.attachLink, m.sep2, m.sep4, m.reindexItem,
hide.push(m.addNote, m.addAttachments, m.sep2, m.sep4, m.reindexItem,
m.createParent, m.recognizePDF, m.renameAttachments);
}
@ -2274,6 +2271,7 @@ var ZoteroPane = new function()
}
}
function addTextToNote(text)
{
if (!this.canEdit()) {

View File

@ -96,9 +96,17 @@
<popup id="zotero-itemmenu" onpopupshowing="ZoteroPane.buildItemContextMenu();">
<menuitem label="&zotero.items.menu.showInLibrary;" oncommand="ZoteroPane.selectItem(this.parentNode.getAttribute('itemID'), true)"/>
<menuseparator/>
<!-- with icon: <menuitem class="menuitem-iconic" id="zotero-menuitem-note" label="&zotero.items.menu.attach.note;" oncommand="ZoteroPane.newNote(false, this.parentNode.getAttribute('itemID'))"/>-->
<menuitem label="&zotero.items.menu.attach.note;" oncommand="ZoteroPane.newNote(false, this.parentNode.getAttribute('itemID'))"/>
<menuitem label="&zotero.items.menu.attach.snapshot;" oncommand="ZoteroPane.addAttachmentFromPage(false, parseInt(this.parentNode.getAttribute('itemID')))"/>
<menuitem label="&zotero.items.menu.attach.link;" oncommand="ZoteroPane.addAttachmentFromPage(true, parseInt(this.parentNode.getAttribute('itemID')))"/>
<!-- TODO: localize -->
<menu label="Add Attachment">
<menupopup>
<menuitem class="menuitem-iconic" id="zotero-menuitem-attachments-snapshot" label="&zotero.items.menu.attach.snapshot;" oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane.addAttachmentFromPage(false, itemID)"/>
<menuitem class="menuitem-iconic" id="zotero-menuitem-attachments-web-link" label="&zotero.items.menu.attach.link;" oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane.addAttachmentFromPage(true, itemID)"/>
<menuitem class="menuitem-iconic" id="zotero-menuitem-attachments-link" label="Attach Link to File..." oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane.addAttachmentFromDialog(true, itemID);"/>
<menuitem class="menuitem-iconic" id="zotero-menuitem-attachments-file" label="Attach Stored Copy of File..." oncommand="var itemID = parseInt(this.parentNode.parentNode.parentNode.getAttribute('itemID')); ZoteroPane.addAttachmentFromDialog(false, itemID);"/>
</menupopup>
</menu>
<menuseparator/>
<menuitem label="&zotero.items.menu.duplicateItem;" oncommand="ZoteroPane.duplicateSelectedItem();"/>
<menuitem oncommand="ZoteroPane.deleteSelectedItems();"/>
@ -123,7 +131,6 @@
<toolbarbutton id="zotero-tb-collection-add" tooltiptext="&zotero.toolbar.newCollection.label;" oncommand="ZoteroPane.newCollection()"/>
<toolbarbutton id="zotero-tb-group-add" tooltiptext="&zotero.toolbar.newGroup;" oncommand="ZoteroPane.newGroup()"/>
<spacer flex="1"/>
<toolbarbutton id="zotero-tb-tag-selector" tooltiptext="&zotero.toolbar.tagSelector.label;" oncommand="ZoteroPane.toggleTagSelector()"/>
<toolbarbutton id="zotero-tb-actions-menu" tooltiptext="&zotero.toolbar.actions.label;" type="menu">
<menupopup id="zotero-tb-actions-popup" onpopupshowing="document.getElementById('cmd_zotero_reportErrors').setAttribute('disabled', Zotero.getErrors().length == 0)">
<menuitem id="zotero-tb-actions-import" label="&zotero.toolbar.import.label;" oncommand="Zotero_File_Interface.importFile();"/>
@ -173,12 +180,16 @@
<treechildren/>
</tree>
</vbox>
<splitter id="zotero-tags-splitter" persist="collapsed" onmouseup="ZoteroPane.updateTagSelectorSize()"/>
<splitter id="zotero-tags-splitter" onmouseup="ZoteroPane.updateTagSelectorSize()" collapse="after">
<grippy oncommand="ZoteroPane.toggleTagSelector()"/>
</splitter>
<zoterotagselector id="zotero-tag-selector" persist="height,collapsed,showAutomatic,filterToScope"
oncommand="ZoteroPane.updateTagFilter()"/>
</vbox>
<splitter id="zotero-tree-splitter" resizebefore="closest" resizeafter="closest"/>
<splitter id="zotero-tree-splitter" resizebefore="closest" resizeafter="closest" collapse="before">
<grippy/>
</splitter>
<vbox id="zotero-items-pane" persist="width" flex="1">
<hbox class="toolbar" align="center">
@ -196,11 +207,6 @@
</toolbarbutton>
<toolbarbutton id="zotero-tb-item-from-page" tooltiptext="&zotero.toolbar.newItemFromPage.label;" oncommand="ZoteroPane.addItemFromPage('temporaryPDFHack', event.shiftKey ? !Zotero.Prefs.get('automaticSnapshots') : null)"/>
<toolbarbutton id="zotero-tb-lookup" tooltiptext="&zotero.toolbar.lookup.label;" oncommand="ZoteroPane.openLookupWindow()"/>
<!--
<toolbarseparator/>
<toolbarbutton id="zotero-tb-link-page" tooltiptext="&zotero.toolbar.attachment.weblink;" oncommand="ZoteroPane.addAttachmentFromPage(true)"/>
<toolbarbutton id="zotero-tb-snapshot-page" tooltiptext="&zotero.toolbar.attachment.snapshot;" oncommand="ZoteroPane.addAttachmentFromPage()"/>
-->
<toolbarbutton id="zotero-tb-note-add" tooltiptext="&zotero.toolbar.note.standalone;" oncommand="ZoteroPane.newNote(event.shiftKey);"/>
<toolbarseparator/>
<toolbarbutton id="zotero-tb-advanced-search" tooltiptext="&zotero.toolbar.advancedSearch;" oncommand="ZoteroPane.openAdvancedSearchWindow()"/>
@ -378,8 +384,6 @@
<tabbox id="zotero-view-tabbox" flex="1" oncommand="if (this.selectedIndex !== '') { ZoteroItemPane.loadPane(this.selectedIndex); }">
<tabs>
<tab label="&zotero.tabs.info.label;"/>
<tab label="&zotero.tabs.notes.label;"/>
<tab label="&zotero.tabs.attachments.label;"/>
<tab label="&zotero.tabs.tags.label;"/>
<tab label="&zotero.tabs.related.label;"/>
</tabs>

View File

@ -1,7 +1,7 @@
groupbox
{
overflow: hidden;
min-height: 132px;
min-height: 142px;
margin: 0;
padding: 1px 1px 0;
}

View File

@ -182,22 +182,27 @@ window[active="true"] #zotero-pane[fullscreenmode="true"][platform="mac"]
list-style-image: url('chrome://zotero/skin/toolbar-note-add.png');
}
#zotero-tb-item-attachments-file
#zotero-menuitem-note
{
list-style-image: url('chrome://zotero/skin/treeitem-note.png');
}
#zotero-menuitem-attachments-file
{
list-style-image: url('chrome://zotero/skin/treeitem-attachment-file.png');
}
#zotero-tb-item-attachments-link
#zotero-menuitem-attachments-link
{
list-style-image: url('chrome://zotero/skin/treeitem-attachment-link.png');
}
#zotero-tb-item-attachments-snapshot
#zotero-menuitem-attachments-snapshot
{
list-style-image: url('chrome://zotero/skin/treeitem-attachment-snapshot.png');
}
#zotero-tb-item-attachments-web-link
#zotero-menuitem-attachments-web-link
{
list-style-image: url('chrome://zotero/skin/treeitem-attachment-web-link.png');
}