Improve standalone menus

This commit is contained in:
Simon Kornblith 2011-07-02 03:09:13 +00:00
parent 8feb3f93ff
commit fa7ca7e2d7
5 changed files with 93 additions and 10 deletions

View file

@ -30,6 +30,9 @@ Components.utils.import("resource://gre/modules/Services.jsm");
*/
var ZoteroStandalone = new function()
{
/**
* Run when standalone window first opens
*/
this.onLoad = function() {
if(!Zotero || !Zotero.initialized) {
ZoteroPane.displayStartupError();
@ -53,6 +56,52 @@ var ZoteroStandalone = new function()
}
/**
* Builds new item menu
*/
this.buildNewItemMenu = function() {
var addMenu = document.getElementById('menu_NewItemPopup');
// Remove all nodes so we can regenerate
while(addMenu.hasChildNodes()) addMenu.removeChild(addMenu.firstChild);
var typeSets = [Zotero.ItemTypes.getPrimaryTypes(), Zotero.ItemTypes.getSecondaryTypes()];
for(var i in typeSets) {
var t = typeSets[i];
// Sort by localized name
var itemTypes = [];
for (var i=0; i<t.length; i++) {
itemTypes.push({
id: t[i].id,
name: t[i].name,
localized: Zotero.ItemTypes.getLocalizedString(t[i].id)
});
}
var collation = Zotero.getLocaleCollation();
itemTypes.sort(function(a, b) {
return collation.compareString(1, a.localized, b.localized);
});
for (var i = 0; i<itemTypes.length; i++) {
var menuitem = document.createElement("menuitem");
menuitem.setAttribute("label", itemTypes[i].localized);
menuitem.setAttribute("oncommand","ZoteroPane_Local.newItem("+itemTypes[i]['id']+")");
menuitem.setAttribute("tooltiptext", "");
menuitem.className = "zotero-tb-add";
addMenu.appendChild(menuitem);
}
// add separator between sets
if(i !== typeSets.length-1) {
addMenu.appendChild(document.createElement("menuseparator"));
}
}
}
/**
* Handles help menu requests
*/
this.openHelp = function(type) {
if(type === "troubleshooting") {
ZoteroPane.loadURI("http://www.zotero.org/support/getting_help");
@ -63,6 +112,9 @@ var ZoteroStandalone = new function()
}
}
/**
* Called before standalone window is closed
*/
this.onUnload = function() {
ZoteroPane.destroy();
}

View file

@ -109,6 +109,15 @@
style="border:0px;padding:0px;margin:0px;-moz-appearance:none">
<menu id="fileMenu" label="&fileMenu.label;" accesskey="&fileMenu.accesskey;">
<menupopup id="menu_FilePopup">
<menu id="menu_newItem" label="&zotero.toolbar.newItem.label;">
<menupopup id="menu_NewItemPopup"
onpopupshowing="ZoteroStandalone.buildNewItemMenu()"/>
</menu>
<menuitem id="menu_newNote" label="&zotero.toolbar.newNote;"
command="cmd_zotero_newStandaloneNote"/>
<menuitem id="menu_newCollection" label="&zotero.toolbar.newCollection.label;"
command="cmd_zotero_newCollection"/>
<menuseparator/>
<menuitem id="menu_close" label="&closeCmd.label;" key="key_close"
accesskey="&closeCmd.accesskey;" command="cmd_close"/>
<menuseparator/>
@ -131,9 +140,9 @@
key="key_copy" accesskey="&copyCmd.accesskey;"
command="cmd_copy"/>
<menuitem id="menu_copyCitation" label="&copyCitationCmd.label;"
oncommand="ZoteroPane_Local.copySelectedItemsToClipboard(true);"/>
command="cmd_zotero_copyCitation"/>
<menuitem id="menu_copyBibliography" label="&copyBibliographyCmd.label;"
oncommand="ZoteroPane_Local.copySelectedItemsToClipboard();"/>
command="cmd_zotero_copyBibliography"/>
<menuitem id="menu_paste"/>
<menuitem id="menu_delete"/>
<menuseparator/>
@ -153,6 +162,15 @@
</menupopup>
</menu>
<menu id="toolsMenu" label="&toolsMenu.label;" accesskey="&toolsMenu.accesskey;">
<menupopup id="menu_ToolsPopup">
<menuitem id="menu_createTimeline" label="&zotero.toolbar.timeline.label;"
command="cmd_zotero_createTimeline"/>
<menuitem id="menu_rtfScan" label="&zotero.toolbar.rtfScan.label;"
command="cmd_zotero_rtfScan"/>
</menupopup>
</menu>
<menu id="windowMenu" />
<menu id="helpMenu"

View file

@ -51,6 +51,13 @@
<command id="cmd_zotero_importFromClipboard" oncommand="Zotero_File_Interface.importFromClipboard();"/>
<command id="cmd_zotero_exportLibrary" oncommand="Zotero_File_Interface.exportFile();"/>
<command id="cmd_zotero_advancedSearch" oncommand="ZoteroPane_Local.openAdvancedSearchWindow();"/>
<command id="cmd_zotero_copyCitation" oncommand="ZoteroPane_Local.copySelectedItemsToClipboard(true);"/>
<command id="cmd_zotero_copyBibliography" oncommand="ZoteroPane_Local.copySelectedItemsToClipboard();"/>
<command id="cmd_zotero_createTimeline" oncommand="Zotero_Timeline_Interface.loadTimeline();"/>
<command id="cmd_zotero_rtfScan" oncommand="window.openDialog('chrome://zotero/content/rtfScan.xul', 'rtfScan', 'chrome,centerscreen')"/>
<command id="cmd_zotero_newCollection" oncommand="ZoteroPane_Local.newCollection()"/>
<command id="cmd_zotero_newSavedSearch" oncommand="ZoteroPane_Local.newSearch()"/>
<command id="cmd_zotero_newStandaloneNote" oncommand="ZoteroPane_Local.newNote(event.shiftKey);"/>
</commandset>
<popup id="contentAreaContextMenu">
@ -86,7 +93,7 @@
<hbox id="zotero-toolbar" class="toolbar">
<hbox id="zotero-collections-toolbar">
<toolbarbutton id="zotero-tb-collection-add" class="zotero-tb-button" tooltiptext="&zotero.toolbar.newCollection.label;" oncommand="ZoteroPane_Local.newCollection()"/>
<toolbarbutton id="zotero-tb-collection-add" class="zotero-tb-button" tooltiptext="&zotero.toolbar.newCollection.label;" command="cmd_zotero_newCollection"/>
<toolbarbutton id="zotero-tb-group-add" class="zotero-tb-button" tooltiptext="&zotero.toolbar.newGroup;" oncommand="ZoteroPane_Local.newGroup()"/>
<spacer flex="1"/>
<toolbarbutton id="zotero-tb-actions-menu" class="zotero-tb-button" tooltiptext="&zotero.toolbar.actions.label;" type="menu">
@ -94,11 +101,11 @@
<menuitem id="zotero-tb-actions-import" label="&zotero.toolbar.import.label;" command="cmd_zotero_import"/>
<menuitem id="zotero-tb-actions-import-clipboard" label="&zotero.toolbar.importFromClipboard;" command="cmd_zotero_importFromClipboard"/>
<menuitem id="zotero-tb-actions-export" label="&zotero.toolbar.export.label;" command="cmd_zotero_exportLibrary"/>
<menuitem id="zotero-tb-actions-rtfScan" label="&zotero.toolbar.rtfScan.label;" oncommand="window.openDialog('chrome://zotero/content/rtfScan.xul', 'rtfScan', 'chrome,centerscreen')"/>
<menuitem id="zotero-tb-actions-rtfScan" label="&zotero.toolbar.rtfScan.label;" command="cmd_zotero_rtfScan"/>
<menuitem hidden="true" id="zotero-tb-actions-zeroconf-update"
label="Search for Shared Libraries" oncommand="Zotero.Zeroconf.findInstances()"/>
<menuseparator id="zotero-tb-actions-plugins-separator"/>
<menuitem id="zotero-tb-actions-timeline" label="&zotero.toolbar.timeline.label;" oncommand="Zotero_Timeline_Interface.loadTimeline()"/>
<menuitem id="zotero-tb-actions-timeline" label="&zotero.toolbar.timeline.label;" command="cmd_zotero_createTimeline"/>
<!-- TODO: localize <menuitem id="zotero-tb-actions-duplicate" label="&zotero.toolbar.duplicate.label;" oncommand="ZoteroPane_Local.showDuplicates()"/>-->
<menuitem id="zotero-tb-actions-showDuplicates" label="Show Duplicates" oncommand="ZoteroPane_Local.showDuplicates()" hidden="true"/>
<menuseparator hidden="true" id="zotero-tb-actions-sync-separator"/>
@ -131,10 +138,10 @@
<toolbarbutton id="zotero-tb-item-from-page" class="zotero-tb-button" tooltiptext="&zotero.toolbar.newItemFromPage.label;" oncommand="ZoteroPane_Local.addItemFromPage('temporaryPDFHack', event.shiftKey ? !Zotero.Prefs.get('automaticSnapshots') : null)"/>
<toolbarbutton id="zotero-tb-lookup" class="zotero-tb-button" tooltiptext="&zotero.toolbar.lookup.label;" oncommand="ZoteroPane_Local.openLookupWindow()"/>
<!--<toolbarbutton id="zotero-tb-note-add" class="zotero-tb-button" tooltiptext="&zotero.toolbar.note.standalone;" oncommand="ZoteroPane_Local.newNote(event.shiftKey);"/>-->
<toolbarbutton id="zotero-tb-note-add" class="zotero-tb-button" tooltiptext="New Note" type="menu">
<toolbarbutton id="zotero-tb-note-add" class="zotero-tb-button" tooltiptext="&zotero.toolbar.newNote;" type="menu">
<menupopup onpopupshowing="ZoteroPane_Local.updateNoteButtonMenu()">
<menuitem label="Add Standalone Note" oncommand="ZoteroPane_Local.newNote(event.shiftKey);"/>
<menuitem id="zotero-tb-add-child-note" label="Add Child Note" oncommand="var selected = ZoteroPane_Local.getSelectedItems()[0]; var parent = selected.getSource(); parent = parent ? parent : selected.id; ZoteroPane_Local.newNote(event.shiftKey, parent);"/>
<menuitem label="&zotero.toolbar.note.standalone;" command="cmd_zotero_newStandaloneNote"/>
<menuitem id="zotero-tb-add-child-note" label="&zotero.toolbar.note.child;" oncommand="var selected = ZoteroPane_Local.getSelectedItems()[0]; var parent = selected.getSource(); parent = parent ? parent : selected.id; ZoteroPane_Local.newNote(event.shiftKey, parent);"/>
</menupopup>
</toolbarbutton>
<toolbarbutton id="zotero-tb-attachment-add" class="zotero-tb-button" tooltiptext="New Child Attachment" type="menu">
@ -216,8 +223,8 @@
<popupset>
<menupopup id="zotero-collectionmenu" onpopupshowing="ZoteroPane_Local.buildCollectionContextMenu();">
<menuitem label="&zotero.toolbar.newCollection.label;" oncommand="ZoteroPane_Local.newCollection()"/>
<menuitem label="&zotero.toolbar.newSavedSearch.label;" oncommand="ZoteroPane_Local.newSearch()"/>
<menuitem label="&zotero.toolbar.newCollection.label;" command="cmd_zotero_newCollection"/>
<menuitem label="&zotero.toolbar.newSavedSearch.label;" command="cmd_zotero_newSavedSearch"/>
<menuitem label="&zotero.toolbar.newSubcollection.label;" oncommand="ZoteroPane_Local.newCollection(ZoteroPane_Local.getSelectedCollection().id)"/>
<menuseparator/>
<menuitem label="&zotero.collections.showUnfiledItems;" oncommand="ZoteroPane_Local.setUnfiled(ZoteroPane_Local.getSelectedLibraryID(), true)"/>

View file

@ -60,6 +60,10 @@
<!ENTITY bidiSwitchTextDirectionItem.accesskey "w">
<!ENTITY bidiSwitchTextDirectionItem.commandkey "X">
<!--TOOLS MENU-->
<!ENTITY toolsMenu.label "Tools">
<!ENTITY toolsMenu.accesskey "T">
<!--WINDOW MENU-->
<!ENTITY minimizeWindow.key "m">
<!ENTITY minimizeWindow.label "Minimize">

View file

@ -100,7 +100,9 @@
<!ENTITY zotero.item.textTransform.lowercase "lower case">
<!ENTITY zotero.item.textTransform.titlecase "Title Case">
<!ENTITY zotero.toolbar.newNote "New Note">
<!ENTITY zotero.toolbar.note.standalone "New Standalone Note">
<!ENTITY zotero.toolbar.note.child "Add Child Note">
<!ENTITY zotero.toolbar.lookup "Lookup by Identifier...">
<!ENTITY zotero.toolbar.attachment.linked "Link to File...">
<!ENTITY zotero.toolbar.attachment.add "Store Copy of File...">