From c345b90b9a798793bbb1d12126637613daa347ea Mon Sep 17 00:00:00 2001 From: David Norton Date: Mon, 19 Jun 2006 15:00:13 +0000 Subject: [PATCH] Contextual menus - Collections, Items. Moved close button to a more sensible place. On Item Add: Clear search text, and select Info tab. Minor function renames. --- chrome/chromeFiles/content/scholar/overlay.js | 51 ++++- .../chromeFiles/content/scholar/overlay.xul | 208 ++++++++++-------- .../locale/en-US/scholar/scholar.properties | 8 +- 3 files changed, 164 insertions(+), 103 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js index d59556f869..cd99dcb202 100644 --- a/chrome/chromeFiles/content/scholar/overlay.js +++ b/chrome/chromeFiles/content/scholar/overlay.js @@ -15,12 +15,14 @@ var ScholarPane = new function() this.newCollection = newCollection; this.onCollectionSelected = onCollectionSelected; this.itemSelected = itemSelected; - this.deleteItemSelection = deleteItemSelection; - this.deleteCollectionSelection = deleteCollectionSelection; + this.deleteSelectedItem = deleteSelectedItem; + this.deleteSelectedCollection = deleteSelectedCollection; this.renameSelectedCollection = renameSelectedCollection; this.search = search; this.getCollectionsView = getCollectionsView; this.getItemsView = getItemsView; + this.buildCollectionContextMenu = buildCollectionContextMenu; + this.buildItemContextMenu = buildItemContextMenu; /* * Called when the window is open @@ -72,10 +74,18 @@ var ScholarPane = new function() */ function newItem(typeID) { + if(document.getElementById('tb-search').value != "") + { + document.getElementById('tb-search').value = ""; + document.getElementById('tb-search').doCommand(); + } + var item = new Scholar.Item(typeID); item.save(); if(itemsView && itemsView._itemGroup.isCollection()) itemsView._itemGroup.ref.addItem(item.getID()); + + document.getElementById('scholar-view-item').selectedIndex = 1; } function newCollection() @@ -123,18 +133,18 @@ var ScholarPane = new function() document.getElementById('scholar-view-item').hidden = true; var label = document.getElementById('scholar-view-selected-label'); label.hidden = false; - label.value = itemsView.selection.count + " items selected."; + label.value = itemsView.selection.count + " items selected"; } } - function deleteItemSelection() + function deleteSelectedItem() { if(itemsView && itemsView.selection.count > 0 && confirm(Scholar.getString('pane.items.delete'))) itemsView.deleteSelection(); } - function deleteCollectionSelection() + function deleteSelectedCollection() { if(collectionsView.selection.count > 0 && confirm(Scholar.getString('pane.collections.delete'))) collectionsView.deleteSelection(); @@ -167,6 +177,37 @@ var ScholarPane = new function() { return itemsView; } + + function buildCollectionContextMenu() + { + var menu = document.getElementById('scholar-collectionmenu'); + + if(collectionsView.selection.count == 1 && !collectionsView._getItemAtRow(collectionsView.selection.currentIndex).isLibrary()) + { + menu.childNodes[2].removeAttribute('disabled'); + menu.childNodes[3].removeAttribute('disabled'); + } + else + { + menu.childNodes[2].setAttribute('disabled', true); + menu.childNodes[3].setAttribute('disabled', true); + } + } + + function buildItemContextMenu() + { + var menu = document.getElementById('scholar-itemmenu'); + + if(itemsView && itemsView.selection.count > 0) + menu.childNodes[2].removeAttribute('disabled'); + else + menu.childNodes[2].setAttribute('disabled', true); + + if(itemsView && itemsView.selection.count > 1) + menu.childNodes[2].setAttribute('label', 'Remove Selected Items...'); + else + menu.childNodes[2].setAttribute('label', 'Remove Selected Item...'); + } } window.addEventListener("load", function(e) { ScholarPane.onLoad(e); }, false); diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul index 436a62ddaa..cdf8ba17a5 100644 --- a/chrome/chromeFiles/content/scholar/overlay.xul +++ b/chrome/chromeFiles/content/scholar/overlay.xul @@ -20,100 +20,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/chrome/chromeFiles/locale/en-US/scholar/scholar.properties b/chrome/chromeFiles/locale/en-US/scholar/scholar.properties index 8c6071ef0f..9bf83e4639 100644 --- a/chrome/chromeFiles/locale/en-US/scholar/scholar.properties +++ b/chrome/chromeFiles/locale/en-US/scholar/scholar.properties @@ -1,11 +1,11 @@ pane.items.delete = Are you sure you want to delete the selected item? pane.items.delete.multiple = Are you sure you want to delete the selected items? -pane.collections.delete = Are you sure you want to delete the selected collection? -pane.collections.delete.multiple = Are you sure you want to delete the selected collections? -pane.collections.rename = Rename collection: +pane.collections.delete = Are you sure you want to delete the selected project? +pane.collections.delete.multiple = Are you sure you want to delete the selected projects? +pane.collections.rename = Rename Project: pane.collections.library = Library -pane.collections.untitled = Untitled Collection +pane.collections.untitled = Untitled Project metadata.savechanges = Do you want to save changes to '%1'?