зеркало из https://github.com/mozilla/pjs.git
Added real commandUpdater code to globalOverlay and addressbook. So far the Select All menu item enables/disables with this code. Stay tuned for more...
This commit is contained in:
Родитель
fb5fcc3775
Коммит
48dfa1f639
|
@ -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;
|
||||
|
|
|
@ -40,7 +40,7 @@ Rights Reserved.
|
|||
<html:label for="abPopup">&chooseAddressBook.label;</html:label>
|
||||
<html:select id="abPopup" ref="abdirectory://" datasources="rdf:addressdirectory">
|
||||
<template>
|
||||
<html:option uri="..." value="...">
|
||||
<html:option uri="..." value="rdf:http://home.netscape.com/NC-rdf#DirUri">
|
||||
<text value="rdf:http://home.netscape.com/NC-rdf#DirName"/>
|
||||
</html:option>
|
||||
</template>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,10 +43,13 @@ Rights Reserved.
|
|||
<html:script language="JavaScript" src="chrome://addressbook/content/abCommon.js"/>
|
||||
<!--html:script language="JavaScript" src="resource:/res/samples/DumpDOM.js"/-->
|
||||
|
||||
<commands id="commands">
|
||||
<commandset id="CommandUpdate_AddressBook" onchange="CommandUpdate_AddressBook()"/>
|
||||
</commands>
|
||||
|
||||
<broadcasterset id="broadcasterset">
|
||||
//<broadcaster id="CommandUpdate_AddressBook" onchange="CommandUpdate_AddressBook()"/>
|
||||
<!-- File Menu -->
|
||||
<broadcaster id="cmd_PrintCard" oncommand="AbPrintCard()"/>
|
||||
<broadcaster id="cmd_PrintCard" oncommand="AbPrintCard()" disabled="true"/>
|
||||
<broadcaster id="cmd_close" oncommand="AbClose()"/>
|
||||
<broadcaster id="cmd_quit"/>
|
||||
<!-- Edit Menu -->
|
||||
|
@ -56,12 +59,12 @@ Rights Reserved.
|
|||
<broadcaster id="cmd_copy" oncommand="AbEditCopy()"/>
|
||||
<broadcaster id="cmd_paste" oncommand="AbEditPaste()"/>
|
||||
<broadcaster id="cmd_delete" oncommand="AbDelete()"/>
|
||||
<broadcaster id="cmd_selectAll" oncommand="AbSelectAll()"/>
|
||||
<broadcaster id='cmd_selectAll' oncommand="goDoCommand('cmd_selectAll')" onchange="goUpdateCommand('cmd_selectAll')"/>
|
||||
</broadcasterset>
|
||||
|
||||
<keyset id="keyset">
|
||||
<!-- File Menu -->
|
||||
<key id="key_PrintCard" disabled="true" command="true" key="P" observes="cmd_PrintCard" />
|
||||
<key id="key_PrintCard" command="true" key="P" observes="cmd_PrintCard" />
|
||||
<key id="key_close"/>
|
||||
<key id="key_quit"/>
|
||||
<!-- Edit Menu -->
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче