www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 7f13072ef4b49df30007e039b777be6760e7e05d
parent 51108446e3517a7a63e80e4f5c2e2c244333fef6
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue, 15 Aug 2006 19:59:17 +0000

Added Scholar.Notifier.enable() and disable() to turn on and off trigger() notifications  (enabled at startup)

Changed 'smartcollection' notifier type to 'search' and reduced hash length to 2


Diffstat:
Mchrome/chromeFiles/content/scholar/xpcom/notifier.js | 27++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/xpcom/notifier.js b/chrome/chromeFiles/content/scholar/xpcom/notifier.js @@ -1,5 +1,6 @@ Scholar.Notifier = new function(){ var _observers = new Array(); + var _disabled = false; _observers['columnTree'] = new Scholar.Hash(); _observers['itemTree'] = new Scholar.Hash(); @@ -8,6 +9,8 @@ Scholar.Notifier = new function(){ this.unregisterColumnTree = unregisterColumnTree; this.unregisterItemTree = unregisterItemTree; this.trigger = trigger; + this.disable = disable; + this.enable = enable; function registerColumnTree(ref){ return _register('columnTree', ref); @@ -27,16 +30,20 @@ Scholar.Notifier = new function(){ /** * event - 'add', 'remove', 'modify' - * type - 'collection', 'smartcollection', 'item' + * type - 'collection', 'search', 'item' * ids - single id or array of ids **/ function trigger(event, type, ids){ + if (_disabled){ + return false; + } + switch (type){ case 'item': var treeType = 'itemTree'; break; case 'collection': - case 'smartcollection': + case 'search': var treeType = 'columnTree'; break; default: @@ -53,11 +60,25 @@ Scholar.Notifier = new function(){ + i + "'", 4); _observers[treeType].get(i).notify(event, type, ids); } + + return true; + } + + + function disable(){ + Scholar.debug('Disabling Notifier notifications'); + _disabled = true; + } + + + function enable(){ + Scholar.debug('Enabling Notifier notifications'); + _disabled = false; } function _register(type, ref){ - var len = 6; + var len = 2; var tries = 10; do { // Increase the hash length if we can't find a unique key