A very quick little addition to please the masses
Add options to browser context menu, "Add Selection to Zotero Note" and "Create Zotero Note from Selection" "Add Note" context menu option on items
This commit is contained in:
parent
0b1002c8ce
commit
65ef6a6926
|
@ -51,8 +51,10 @@ var ZoteroPane = new function()
|
||||||
this.buildCollectionContextMenu = buildCollectionContextMenu;
|
this.buildCollectionContextMenu = buildCollectionContextMenu;
|
||||||
this.buildItemContextMenu = buildItemContextMenu;
|
this.buildItemContextMenu = buildItemContextMenu;
|
||||||
this.onDoubleClick = onDoubleClick;
|
this.onDoubleClick = onDoubleClick;
|
||||||
|
this.contextPopupShowing = contextPopupShowing;
|
||||||
this.openNoteWindow = openNoteWindow;
|
this.openNoteWindow = openNoteWindow;
|
||||||
this.newNote = newNote;
|
this.newNote = newNote;
|
||||||
|
this.addTextToNote = addTextToNote;
|
||||||
this.addItemFromPage = addItemFromPage;
|
this.addItemFromPage = addItemFromPage;
|
||||||
this.addAttachmentFromDialog = addAttachmentFromDialog;
|
this.addAttachmentFromDialog = addAttachmentFromDialog;
|
||||||
this.addAttachmentFromPage = addAttachmentFromPage;
|
this.addAttachmentFromPage = addAttachmentFromPage;
|
||||||
|
@ -121,6 +123,9 @@ var ZoteroPane = new function()
|
||||||
menuitem.setAttribute("oncommand","ZoteroPane.newItem("+itemTypes[i]['id']+")");
|
menuitem.setAttribute("oncommand","ZoteroPane.newItem("+itemTypes[i]['id']+")");
|
||||||
moreMenu.appendChild(menuitem);
|
moreMenu.appendChild(menuitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var menu = document.getElementById("contentAreaContextMenu");
|
||||||
|
menu.addEventListener("popupshowing", ZoteroPane.contextPopupShowing, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -240,13 +245,11 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
itemsView = new Zotero.ItemTreeView(itemgroup);
|
itemsView = new Zotero.ItemTreeView(itemgroup);
|
||||||
document.getElementById('zotero-items-tree').view = itemsView;
|
document.getElementById('zotero-items-tree').view = itemsView;
|
||||||
document.getElementById('zotero-tb-collection-rename').disabled = itemgroup.isLibrary();
|
|
||||||
itemsView.selection.clearSelection();
|
itemsView.selection.clearSelection();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
document.getElementById('zotero-items-tree').view = itemsView = null;
|
document.getElementById('zotero-items-tree').view = itemsView = null;
|
||||||
document.getElementById('zotero-tb-collection-rename').disabled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,7 +639,7 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
if(itemsView && itemsView.selection.count > 0)
|
if(itemsView && itemsView.selection.count > 0)
|
||||||
{
|
{
|
||||||
enable.push(3,4,5,7);
|
enable.push(4,5,6,8);
|
||||||
|
|
||||||
// Multiple items selected
|
// Multiple items selected
|
||||||
if (itemsView.selection.count > 1)
|
if (itemsView.selection.count > 1)
|
||||||
|
@ -652,34 +655,34 @@ var ZoteroPane = new function()
|
||||||
var itemID = item.ref.getID();
|
var itemID = item.ref.getID();
|
||||||
menu.setAttribute('itemID', itemID);
|
menu.setAttribute('itemID', itemID);
|
||||||
|
|
||||||
show.push(0,1,2);
|
show.push(0,1,2,3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hide.push(0,1,2);
|
hide.push(0,1,2,3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disable.push(3,4,6,7);
|
disable.push(4,5,7,8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove from collection
|
// Remove from collection
|
||||||
if (itemsView._itemGroup.isCollection())
|
if (itemsView._itemGroup.isCollection())
|
||||||
{
|
{
|
||||||
menu.childNodes[3].setAttribute('label', Zotero.getString('pane.items.menu.remove' + multiple));
|
menu.childNodes[4].setAttribute('label', Zotero.getString('pane.items.menu.remove' + multiple));
|
||||||
show.push(3);
|
show.push(4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hide.push(3);
|
hide.push(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plural if necessary
|
// Plural if necessary
|
||||||
menu.childNodes[4].setAttribute('label', Zotero.getString('pane.items.menu.erase' + multiple));
|
menu.childNodes[5].setAttribute('label', Zotero.getString('pane.items.menu.erase' + multiple));
|
||||||
menu.childNodes[6].setAttribute('label', Zotero.getString('pane.items.menu.export' + multiple));
|
menu.childNodes[7].setAttribute('label', Zotero.getString('pane.items.menu.export' + multiple));
|
||||||
menu.childNodes[7].setAttribute('label', Zotero.getString('pane.items.menu.createBib' + multiple));
|
menu.childNodes[8].setAttribute('label', Zotero.getString('pane.items.menu.createBib' + multiple));
|
||||||
|
|
||||||
for (var i in disable)
|
for (var i in disable)
|
||||||
{
|
{
|
||||||
|
@ -726,15 +729,72 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function newNote(popup)
|
|
||||||
|
// Updates browser context menu options
|
||||||
|
function contextPopupShowing()
|
||||||
|
{
|
||||||
|
var menuitem = document.getElementById("zotero-context-add-to-current-note");
|
||||||
|
var showing = false;
|
||||||
|
if (menuitem){
|
||||||
|
var items = getSelectedItems();
|
||||||
|
if (itemsView.selection.count==1 && items[0] && items[0].isNote()
|
||||||
|
&& window.gContextMenu.isTextSelected)
|
||||||
|
{
|
||||||
|
menuitem.hidden = false;
|
||||||
|
showing = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menuitem.hidden = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var menuitem = document.getElementById("zotero-context-add-to-new-note");
|
||||||
|
if (menuitem){
|
||||||
|
if (window.gContextMenu.isTextSelected)
|
||||||
|
{
|
||||||
|
menuitem.hidden = false;
|
||||||
|
showing = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menuitem.hidden = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var separator = document.getElementById("zotero-context-separator");
|
||||||
|
separator.hidden = !showing;
|
||||||
|
}
|
||||||
|
|
||||||
|
function newNote(popup, parent, text)
|
||||||
{
|
{
|
||||||
if (!popup)
|
if (!popup)
|
||||||
{
|
{
|
||||||
var item = this.newItem(Zotero.ItemTypes.getID('note'));
|
var item = this.newItem(Zotero.ItemTypes.getID('note'));
|
||||||
document.getElementById('zotero-note-editor').focus();
|
var note = document.getElementById('zotero-note-editor');
|
||||||
|
try {
|
||||||
|
// trim
|
||||||
|
text = text.replace(/^[\xA0\r\n\s]*(.*)[\xA0\r\n\s]*$/m, "$1");
|
||||||
|
}
|
||||||
|
catch (e){}
|
||||||
|
if (text)
|
||||||
|
{
|
||||||
|
note.value = '"' + text + '"';
|
||||||
|
}
|
||||||
|
note.save();
|
||||||
|
note.focus();
|
||||||
|
|
||||||
|
if (parent)
|
||||||
|
{
|
||||||
|
Zotero.debug(parent);
|
||||||
|
Zotero.debug(item.getID());
|
||||||
|
item.setSource(parent);
|
||||||
|
selectItem(item.getID());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// TODO: _text_
|
||||||
var c = getSelectedCollection();
|
var c = getSelectedCollection();
|
||||||
if (c)
|
if (c)
|
||||||
{
|
{
|
||||||
|
@ -747,6 +807,36 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addTextToNote(text)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// trim
|
||||||
|
text = text.replace(/^[\xA0\r\n\s]*(.*)[\xA0\r\n\s]*$/m, "$1");
|
||||||
|
}
|
||||||
|
catch (e){}
|
||||||
|
|
||||||
|
if (!text || !text.length)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var items = getSelectedItems();
|
||||||
|
if (itemsView.selection.count == 1 && items[0] && items[0].isNote())
|
||||||
|
{
|
||||||
|
var note = items[0].getNote()
|
||||||
|
items[0].updateNote(note + "\n\n" + '"' + text + '"');
|
||||||
|
var noteElem = document.getElementById('zotero-note-editor')
|
||||||
|
noteElem.focus();
|
||||||
|
noteElem.id('noteField').inputField.editor.
|
||||||
|
selectionController.scrollSelectionIntoView(1,
|
||||||
|
1,
|
||||||
|
true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function openNoteWindow(id, parent)
|
function openNoteWindow(id, parent)
|
||||||
{
|
{
|
||||||
window.open('chrome://zotero/content/note.xul?v=1'+(id ? '&id='+id : '')+(parent ? '&coll='+parent : ''),'','chrome,resizable,centerscreen');
|
window.open('chrome://zotero/content/note.xul?v=1'+(id ? '&id='+id : '')+(parent ? '&coll='+parent : ''),'','chrome,resizable,centerscreen');
|
||||||
|
|
|
@ -44,6 +44,17 @@
|
||||||
label="&zotero.name;"
|
label="&zotero.name;"
|
||||||
oncommand="ZoteroPane.toggleDisplay();"/>
|
oncommand="ZoteroPane.toggleDisplay();"/>
|
||||||
</toolbarpalette>
|
</toolbarpalette>
|
||||||
|
|
||||||
|
<popup id="contentAreaContextMenu">
|
||||||
|
<menuseparator id="zotero-context-separator"/>
|
||||||
|
<menuitem id="zotero-context-add-to-current-note" class="menu-iconic"
|
||||||
|
label="&zotero.contextMenu.addTextToCurrentNote;"
|
||||||
|
oncommand="ZoteroPane.addTextToNote(window.content.getSelection().toString())"/>
|
||||||
|
<menuitem id="zotero-context-add-to-new-note" class="menu-iconic"
|
||||||
|
label="&zotero.contextMenu.addTextToNewNote;"
|
||||||
|
oncommand="ZoteroPane.newNote(false, false, window.content.getSelection().toString())"/>
|
||||||
|
</popup>
|
||||||
|
|
||||||
<vbox id="appcontent">
|
<vbox id="appcontent">
|
||||||
<!-- Changes to attributes of zotero-splitter and zotero-pane must be mirrored on overlay.js's onLoad() function -->
|
<!-- Changes to attributes of zotero-splitter and zotero-pane must be mirrored on overlay.js's onLoad() function -->
|
||||||
<splitter id="zotero-splitter" resizebefore="closest" resizeafter="closest" collapsed="true"/>
|
<splitter id="zotero-splitter" resizebefore="closest" resizeafter="closest" collapsed="true"/>
|
||||||
|
@ -65,6 +76,7 @@
|
||||||
<menuitem label="&zotero.toolbar.export.label;" oncommand="Zotero_File_Interface.exportFile()"/>
|
<menuitem label="&zotero.toolbar.export.label;" oncommand="Zotero_File_Interface.exportFile()"/>
|
||||||
</popup>
|
</popup>
|
||||||
<popup id="zotero-itemmenu" onpopupshowing="ZoteroPane.buildItemContextMenu();">
|
<popup id="zotero-itemmenu" onpopupshowing="ZoteroPane.buildItemContextMenu();">
|
||||||
|
<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, this.parentNode.getAttribute('itemID'));"/>
|
<menuitem label="&zotero.items.menu.attach.snapshot;" oncommand="ZoteroPane.addAttachmentFromPage(false, this.parentNode.getAttribute('itemID'));"/>
|
||||||
<menuitem label="&zotero.items.menu.attach.link;" oncommand="ZoteroPane.addAttachmentFromPage(true, this.parentNode.getAttribute('itemID'));"/>
|
<menuitem label="&zotero.items.menu.attach.link;" oncommand="ZoteroPane.addAttachmentFromPage(true, this.parentNode.getAttribute('itemID'));"/>
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
|
@ -79,7 +91,6 @@
|
||||||
<toolbar>
|
<toolbar>
|
||||||
<toolbarbutton id="zotero-tb-collection-add" tooltiptext="&zotero.toolbar.newCollection.label;" command="cmd_zotero_newCollection"/>
|
<toolbarbutton id="zotero-tb-collection-add" tooltiptext="&zotero.toolbar.newCollection.label;" command="cmd_zotero_newCollection"/>
|
||||||
<toolbarbutton id="zotero-tb-collection-addsearch" tooltiptext="&zotero.toolbar.newSavedSearch.label;" oncommand="ZoteroPane.newSearch();"/>
|
<toolbarbutton id="zotero-tb-collection-addsearch" tooltiptext="&zotero.toolbar.newSavedSearch.label;" oncommand="ZoteroPane.newSearch();"/>
|
||||||
<toolbarbutton id="zotero-tb-collection-rename" tooltiptext="&zotero.toolbar.renameCollection.label;" oncommand="ZoteroPane.editSelectedCollection();" disabled="true"/>
|
|
||||||
<spacer flex="1"/>
|
<spacer flex="1"/>
|
||||||
<toolbarbutton id="zotero-tb-actions-menu" tooltiptext="&zotero.toolbar.actions.label;" type="menu">
|
<toolbarbutton id="zotero-tb-actions-menu" tooltiptext="&zotero.toolbar.actions.label;" type="menu">
|
||||||
<menupopup>
|
<menupopup>
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<!ENTITY zotero.name "Zotero">
|
<!ENTITY zotero.name "Zotero">
|
||||||
|
|
||||||
|
<!ENTITY zotero.contextMenu.addTextToCurrentNote "Add Selection to Zotero Note">
|
||||||
|
<!ENTITY zotero.contextMenu.addTextToNewNote "Create Zotero Note from Selection">
|
||||||
|
|
||||||
<!ENTITY zotero.tabs.info.label "Info">
|
<!ENTITY zotero.tabs.info.label "Info">
|
||||||
<!ENTITY zotero.tabs.notes.label "Notes">
|
<!ENTITY zotero.tabs.notes.label "Notes">
|
||||||
<!ENTITY zotero.tabs.attachments.label "Attachments">
|
<!ENTITY zotero.tabs.attachments.label "Attachments">
|
||||||
|
@ -16,6 +19,7 @@
|
||||||
<!ENTITY zotero.items.dateAdded_column "Date Added">
|
<!ENTITY zotero.items.dateAdded_column "Date Added">
|
||||||
<!ENTITY zotero.items.dateModified_column "Date Modified">
|
<!ENTITY zotero.items.dateModified_column "Date Modified">
|
||||||
|
|
||||||
|
<!ENTITY zotero.items.menu.attach.note "Add Note">
|
||||||
<!ENTITY zotero.items.menu.attach.snapshot "Attach Snapshot of Current Page">
|
<!ENTITY zotero.items.menu.attach.snapshot "Attach Snapshot of Current Page">
|
||||||
<!ENTITY zotero.items.menu.attach.link "Attach Link to Current Page">
|
<!ENTITY zotero.items.menu.attach.link "Attach Link to Current Page">
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user