From ad5ce20c82eb56046efda679ce36d7294d95a53a Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 8 Sep 2006 06:01:29 +0000 Subject: [PATCH] Fixes #286, if a quick search is entered in the item pane, and a new item is added to the library, the item appears regardless New logic in itemTreeView notify() target: - Items are only selected on add in the active window -- this fixes a fairly major flaw in the previous system that would cause new items to be selected in all open windows - If a quicksearch is open in the active window and a new item is added, clear the search - If quicksearch and active window and item modify, rerun search - If quicksearch and not active window, rerun search - If not quicksearch and not active window, update list but retain previous selection --- chrome/chromeFiles/content/scholar/overlay.js | 6 - .../content/scholar/xpcom/itemTreeView.js | 125 +++++++++++------- 2 files changed, 80 insertions(+), 51 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js index 8a5166a383..ef6c6ec745 100644 --- a/chrome/chromeFiles/content/scholar/overlay.js +++ b/chrome/chromeFiles/content/scholar/overlay.js @@ -139,12 +139,6 @@ 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()) diff --git a/chrome/chromeFiles/content/scholar/xpcom/itemTreeView.js b/chrome/chromeFiles/content/scholar/xpcom/itemTreeView.js index ddb0654a25..59af52df0e 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/itemTreeView.js +++ b/chrome/chromeFiles/content/scholar/xpcom/itemTreeView.js @@ -74,12 +74,21 @@ Scholar.ItemTreeView.prototype.refresh = function() Scholar.ItemTreeView.prototype.notify = function(action, type, ids) { var madeChanges = false; - this.selection.selectEventsSuppressed = true; var savedSelection = this.saveSelection(); ids = Scholar.flattenArguments(ids); + // See if we're in the active window + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + if (wm.getMostRecentWindow("navigator:browser") == + this._treebox.treeBody.ownerDocument.defaultView){ + var activeWindow = true; + } + + var quicksearch = this._treebox.treeBody.ownerDocument.getElementById('tb-search'); + if((action == 'remove' && !this._itemGroup.isLibrary()) || (action == 'delete' && this._itemGroup.isLibrary())) { //Since a remove involves shifting of rows, we have to do it in order @@ -110,55 +119,82 @@ Scholar.ItemTreeView.prototype.notify = function(action, type, ids) } else if(action == 'modify') //must check for null because it could legitimately be 0 { - for(var i=0, len=ids.length; i