From 953b1f9d209c8fcefc9a60adf165b46b2146ce90 Mon Sep 17 00:00:00 2001 From: David Norton Date: Sat, 17 Jun 2006 00:57:50 +0000 Subject: [PATCH] Lots of little things: - Fix item modify notify() on 1st row. - Ensure that new items are visible when added. - New functionality for creating new items (prevents a lot of problems). - Number-based fields display properly. - Fixed bug when creating and saving the first notes on an item. - New notes won't save empty. --- chrome/chromeFiles/content/scholar/itemPane.js | 15 +++++++++------ .../chromeFiles/content/scholar/itemTreeView.js | 7 ++++++- chrome/chromeFiles/content/scholar/overlay.js | 9 +++++---- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js index df3ae65996..0191211b66 100644 --- a/chrome/chromeFiles/content/scholar/itemPane.js +++ b/chrome/chromeFiles/content/scholar/itemPane.js @@ -174,8 +174,11 @@ ScholarItemPane = new function() valueElement.setAttribute('onclick', 'ScholarItemPane.showEditor(this);'); valueElement.className = 'clicky'; } - - var firstSpace = valueText.indexOf(" "); + + var firstSpace; + if(typeof valueText == 'string') + firstSpace = valueText.indexOf(" "); + if((firstSpace == -1 && valueText.length > 29 ) || firstSpace > 29) { valueElement.setAttribute('crop', 'end'); @@ -284,15 +287,15 @@ ScholarItemPane = new function() { _itemBeingEdited.updateNote(id,_notesField.value); } - else //new note + else if(_notesField.value)//new note { id = _itemBeingEdited.addNote(_notesField.value); - _notesMenu.selectedItem.value = id; + _notesMenu.selectedItem.setAttribute('value',id); } var label = _noteToTitle(_notesField.value); - _notesMenu.selectedItem.label = label; - _notesMenu.setAttribute('label', label); + _notesMenu.selectedItem.label = label; //sets the individual item label + _notesMenu.setAttribute('label', label); //sets the 'overall' label of the menu... not usually updated unless the item is reselected } function removeSelectedNote() diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js index d649ce552d..8ce7e8569c 100644 --- a/chrome/chromeFiles/content/scholar/itemTreeView.js +++ b/chrome/chromeFiles/content/scholar/itemTreeView.js @@ -94,7 +94,7 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids) } else if(action == 'modify') //must check for null because it could legitimately be 0 { - if(this._itemRowMap[ids]) + if(this._itemRowMap[ids] != null) { this._treebox.invalidateRow(row); madeChanges = true; @@ -126,9 +126,14 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids) } if(action == 'add') + { this.selection.select(this._itemRowMap[item.getID()]); + this._treebox.ensureRowIsVisible(this._itemRowMap[item.getID()]); + } else + { this.rememberSelection(); + } } this.selection.selectEventsSuppressed = false; } diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js index 0f94f724e9..d59556f869 100644 --- a/chrome/chromeFiles/content/scholar/overlay.js +++ b/chrome/chromeFiles/content/scholar/overlay.js @@ -68,13 +68,14 @@ var ScholarPane = new function() } /* - * Called when the window closes + * Create a new item */ function newItem(typeID) { - ScholarItemPane.viewItem(new Scholar.Item(typeID)); - document.getElementById('scholar-view-item').hidden = false; - document.getElementById('scholar-view-selected-label').hidden = true; + var item = new Scholar.Item(typeID); + item.save(); + if(itemsView && itemsView._itemGroup.isCollection()) + itemsView._itemGroup.ref.addItem(item.getID()); } function newCollection()