From 43e47b30a34bbb3544f1f961caa1d5f111fa7ec7 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 24 Jul 2009 06:03:51 +0000 Subject: [PATCH] - 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 --- chrome/content/zotero/itemPane.js | 193 +----------------- chrome/content/zotero/itemPane.xul | 35 ---- chrome/content/zotero/overlay.js | 44 ++-- chrome/content/zotero/overlay.xul | 28 +-- .../default/zotero/bindings/tagselector.css | 2 +- chrome/skin/default/zotero/overlay.css | 13 +- 6 files changed, 49 insertions(+), 266 deletions(-) diff --git a/chrome/content/zotero/itemPane.js b/chrome/content/zotero/itemPane.js index 628abf3a5..ca0cf32de 100644 --- a/chrome/content/zotero/itemPane.js +++ b/chrome/content/zotero/itemPane.js @@ -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); diff --git a/chrome/content/zotero/itemPane.xul b/chrome/content/zotero/itemPane.xul index cea560aad..d91572ee9 100644 --- a/chrome/content/zotero/itemPane.xul +++ b/chrome/content/zotero/itemPane.xul @@ -36,41 +36,6 @@ - - - - - - - - - - - - diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 125713339..d313d1f95 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -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()) { diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul index 2e151ead9..8f6e29ebe 100644 --- a/chrome/content/zotero/overlay.xul +++ b/chrome/content/zotero/overlay.xul @@ -96,9 +96,17 @@ + - - + + + + + + + + + @@ -123,7 +131,6 @@ - @@ -173,12 +180,16 @@ - + + + - + + + @@ -196,11 +207,6 @@ - @@ -378,8 +384,6 @@ - - diff --git a/chrome/skin/default/zotero/bindings/tagselector.css b/chrome/skin/default/zotero/bindings/tagselector.css index afa688f3a..92ae399f3 100644 --- a/chrome/skin/default/zotero/bindings/tagselector.css +++ b/chrome/skin/default/zotero/bindings/tagselector.css @@ -1,7 +1,7 @@ groupbox { overflow: hidden; - min-height: 132px; + min-height: 142px; margin: 0; padding: 1px 1px 0; } diff --git a/chrome/skin/default/zotero/overlay.css b/chrome/skin/default/zotero/overlay.css index b6bbaeb40..dce77063f 100644 --- a/chrome/skin/default/zotero/overlay.css +++ b/chrome/skin/default/zotero/overlay.css @@ -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'); }