From 3a66af9238328fcd907ea31492915e615e329e16 Mon Sep 17 00:00:00 2001 From: "hangas%netscape.com" Date: Thu, 16 Sep 1999 01:46:30 +0000 Subject: [PATCH] Added real commandUpdater code to globalOverlay and addressbook. So far the Select All menu item enables/disables with this code. Stay tuned for more... git-svn-id: svn://10.0.0.236/trunk@47715 18797224-902f-48f8-a5cc-f745e15eee43 --- .../addrbook/resources/content/abCommon.js | 79 +++++++++++++++++++ .../resources/content/abNewCardDialog.xul | 2 +- .../addrbook/resources/content/addressbook.js | 25 ++---- .../resources/content/addressbook.xul | 11 ++- .../global/resources/content/globalOverlay.js | 37 +++++++++ 5 files changed, 131 insertions(+), 23 deletions(-) diff --git a/mozilla/mailnews/addrbook/resources/content/abCommon.js b/mozilla/mailnews/addrbook/resources/content/abCommon.js index 9a9004c9fea..22ea1bb3e99 100644 --- a/mozilla/mailnews/addrbook/resources/content/abCommon.js +++ b/mozilla/mailnews/addrbook/resources/content/abCommon.js @@ -1,5 +1,84 @@ // functions needed from abMainWindow and abSelectAddresses +// Controller object for Results Pane +var ResultsPaneController = +{ + IsCommandEnabled: function(command) + { + dump("IsCommandEnabled" + "\n"); + switch ( command ) + { + case "cmd_selectAll": + return true; + default: + return false; + } + }, + + DoCommand: function(command) + { + switch ( command ) + { + case "cmd_selectAll": + var resultsTree = document.getElementById('resultsTree'); + if ( resultsTree ) + { + dump("select all now!!!!!!" + "\n"); + resultsTree.selectAll(); + } + break; + } + } +}; + + +// Controller object for Dir Pane +var DirPaneController = +{ + IsCommandEnabled: function(command) + { + dump("IsCommandEnabled" + "\n"); + switch ( command ) + { + case "cmd_selectAll": + return true; + default: + return false; + } + }, + + DoCommand: function(command) + { + switch ( command ) + { + case "cmd_selectAll": + var dirTree = document.getElementById('dirTree'); + if ( dirTree ) + { + dump("select all now!!!!!!" + "\n"); + dirTree.selectAll(); + } + break; + } + } +}; + +function SetupCommandUpdateHandlers() +{ + var widget; + + // dir pane + widget = document.getElementById('dirTree'); + if ( widget ) + widget.controller = DirPaneController; + + // results pane + widget = document.getElementById('resultsTree'); + if ( widget ) + widget.controller = ResultsPaneController; +} + + function AbNewCard() { var selectedAB = 0; diff --git a/mozilla/mailnews/addrbook/resources/content/abNewCardDialog.xul b/mozilla/mailnews/addrbook/resources/content/abNewCardDialog.xul index 21c68a2c840..daf23960e14 100644 --- a/mozilla/mailnews/addrbook/resources/content/abNewCardDialog.xul +++ b/mozilla/mailnews/addrbook/resources/content/abNewCardDialog.xul @@ -40,7 +40,7 @@ Rights Reserved. &chooseAddressBook.label; diff --git a/mozilla/mailnews/addrbook/resources/content/addressbook.js b/mozilla/mailnews/addrbook/resources/content/addressbook.js index 8c40077bbe3..8078217209e 100644 --- a/mozilla/mailnews/addrbook/resources/content/addressbook.js +++ b/mozilla/mailnews/addrbook/resources/content/addressbook.js @@ -18,8 +18,10 @@ function OnLoadAddressBook() dump("failed to set webshell window\n"); } - document.commandDispatcher.addCommand(document.getElementById('CommandUpdate_AddressBook')); + //document.commandDispatcher.addCommand(document.getElementById('CommandUpdate_AddressBook')); + document.commandDispatcher.addCommand(document.getElementById('cmd_selectAll')); + SetupCommandUpdateHandlers(); SelectFirstAddressBook(); } @@ -42,23 +44,10 @@ function CommandUpdate_AddressBook() oneOrMoreAddressesSelected = true; // set commands to enabled / disabled - SetCommandEnabled('cmd_PrintCard', oneOrMoreAddressesSelected); - SetCommandEnabled('cmd_SortByName', oneAddressBookSelected); - SetCommandEnabled('cmd_SortByEmail', oneAddressBookSelected); - SetCommandEnabled('cmd_SortByPhone', oneAddressBookSelected); -} - -function SetCommandEnabled(id, enabled) -{ - var node = document.getElementById(id); - - if ( node ) - { - if ( enabled ) - node.removeAttribute("disabled"); - else - node.setAttribute('disabled', 'true'); - } + goSetCommandEnabled('cmd_PrintCard', oneOrMoreAddressesSelected); + goSetCommandEnabled('cmd_SortByName', oneAddressBookSelected); + goSetCommandEnabled('cmd_SortByEmail', oneAddressBookSelected); + goSetCommandEnabled('cmd_SortByPhone', oneAddressBookSelected); } diff --git a/mozilla/mailnews/addrbook/resources/content/addressbook.xul b/mozilla/mailnews/addrbook/resources/content/addressbook.xul index 249f2eb4ef4..44a261953e4 100644 --- a/mozilla/mailnews/addrbook/resources/content/addressbook.xul +++ b/mozilla/mailnews/addrbook/resources/content/addressbook.xul @@ -43,10 +43,13 @@ Rights Reserved. + + + + - // - + @@ -56,12 +59,12 @@ Rights Reserved. - + - + diff --git a/mozilla/xpfe/global/resources/content/globalOverlay.js b/mozilla/xpfe/global/resources/content/globalOverlay.js index 18061c35394..99009afd46d 100644 --- a/mozilla/xpfe/global/resources/content/globalOverlay.js +++ b/mozilla/xpfe/global/resources/content/globalOverlay.js @@ -97,3 +97,40 @@ function toggleToolbar( id ) document.persist(id, 'hidden') } } + + +function goUpdateCommand(command) +{ + var controller = document.commandDispatcher.getController(); + + var enabled = false; + + if ( controller ) + enabled = controller.IsCommandEnabled(command); + + goSetCommandEnabled(command, enabled); +} + +function goDoCommand(command) +{ + var controller = document.commandDispatcher.getController(); + + if ( controller ) + controller.DoCommand(command); +} + + +function goSetCommandEnabled(id, enabled) +{ + var node = document.getElementById(id); + + if ( node ) + { + if ( enabled ) + node.removeAttribute("disabled"); + else + node.setAttribute('disabled', 'true'); + } +} + +