зеркало из https://github.com/mozilla/pjs.git
Progress on Command Updating and Dispatching (15127). r=scottip
This commit is contained in:
Родитель
6c48babf84
Коммит
af0cf70bfc
|
@ -9,6 +9,7 @@ var ResultsPaneController =
|
|||
{
|
||||
case "cmd_selectAll":
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -24,11 +25,19 @@ var ResultsPaneController =
|
|||
return true;
|
||||
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
var resultsTree = document.getElementById('resultsTree');
|
||||
var numSelected = 0;
|
||||
if ( resultsTree && resultsTree.selectedItems )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
numSelected = resultsTree.selectedItems.length;
|
||||
if ( command == "cmd_delete" )
|
||||
{
|
||||
if ( numSelected < 2 )
|
||||
goSetMenuValue(command, 'valueCard');
|
||||
else
|
||||
goSetMenuValue(command, 'valueCards');
|
||||
}
|
||||
return ( numSelected > 0 );
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
@ -50,6 +59,7 @@ var ResultsPaneController =
|
|||
break;
|
||||
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
if ( resultsTree )
|
||||
{
|
||||
var cardList = resultsTree.selectedItems;
|
||||
|
@ -70,6 +80,7 @@ var DirPaneController =
|
|||
{
|
||||
case "cmd_selectAll":
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -84,6 +95,9 @@ var DirPaneController =
|
|||
case "cmd_selectAll":
|
||||
return true;
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
if ( command == "cmd_delete" )
|
||||
goSetMenuValue(command, 'valueAddressBook');
|
||||
var dirTree = document.getElementById('dirTree');
|
||||
if ( dirTree && dirTree.selectedItems )
|
||||
return true;
|
||||
|
@ -110,6 +124,7 @@ var DirPaneController =
|
|||
break;
|
||||
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
if ( dirTree )
|
||||
top.addressbook.DeleteAddressBooks(dirTree.database, dirTree, dirTree.selectedItems);
|
||||
break;
|
||||
|
|
|
@ -1,40 +1,6 @@
|
|||
var addressbook = 0;
|
||||
var editCardCallback = 0;
|
||||
|
||||
// Default Controller object for window
|
||||
var DefaultController =
|
||||
{
|
||||
supportsCommand: function(command)
|
||||
{
|
||||
switch ( command )
|
||||
{
|
||||
case "cmd_delete":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
isCommandEnabled: function(command)
|
||||
{
|
||||
dump('DefaultController::isCommandEnabled(' + command + ')\n');
|
||||
switch ( command )
|
||||
{
|
||||
case "cmd_delete":
|
||||
// set the menu to the default text
|
||||
goSetMenuValue(command, 'valueDefault');
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
doCommand: function(command)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
function OnLoadAddressBook()
|
||||
{
|
||||
// FIX ME - later we will be able to use onload from the overlay
|
||||
|
@ -60,6 +26,8 @@ function CommandUpdate_AddressBook()
|
|||
{
|
||||
dump("CommandUpdate_AddressBook\n");
|
||||
|
||||
goUpdateCommand('button_delete');
|
||||
|
||||
// get selection info from dir pane
|
||||
var tree = document.getElementById('dirTree');
|
||||
var oneAddressBookSelected = false;
|
||||
|
@ -78,53 +46,6 @@ function CommandUpdate_AddressBook()
|
|||
goSetCommandEnabled('cmd_SortByName', oneAddressBookSelected);
|
||||
goSetCommandEnabled('cmd_SortByEmail', oneAddressBookSelected);
|
||||
goSetCommandEnabled('cmd_SortByPhone', oneAddressBookSelected);
|
||||
|
||||
AbUpdateCommandDelete();
|
||||
}
|
||||
|
||||
|
||||
// This function updates the text of the delete menu item and sets the state of the delete button
|
||||
function AbUpdateCommandDelete()
|
||||
{
|
||||
var command = "cmd_delete";
|
||||
var focusedElement = document.commandDispatcher.focusedNode;
|
||||
|
||||
var id = 0;
|
||||
if ( focusedElement )
|
||||
id = focusedElement.getAttribute('id');
|
||||
|
||||
dump("focusedOn = " + id + "\n");
|
||||
|
||||
switch ( id )
|
||||
{
|
||||
case "dirTree":
|
||||
// menu text
|
||||
goSetMenuValue(command, 'valueAddressBook');
|
||||
// delete button
|
||||
var dirTree = document.getElementById('dirTree');
|
||||
var numSelected = 0;
|
||||
if ( dirTree && dirTree.selectedItems )
|
||||
numSelected = dirTree.selectedItems.length;
|
||||
goSetCommandEnabled('button_delete', (numSelected>0));
|
||||
break;
|
||||
case "resultsTree":
|
||||
// menu text
|
||||
var resultsTree = document.getElementById('resultsTree');
|
||||
var numSelected = 0;
|
||||
if ( resultsTree && resultsTree.selectedItems )
|
||||
numSelected = resultsTree.selectedItems.length;
|
||||
if ( numSelected < 2 )
|
||||
goSetMenuValue(command, 'valueCard');
|
||||
else
|
||||
goSetMenuValue(command, 'valueCards');
|
||||
// delete button
|
||||
goSetCommandEnabled('button_delete', (numSelected>0));
|
||||
break;
|
||||
default:
|
||||
goSetMenuValue(command, 'valueDefault');
|
||||
goSetCommandEnabled('button_delete', false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ Rights Reserved.
|
|||
<toolbarseparator/>
|
||||
<titledbutton id="button_editcard" class="other28" align="top" value="&editButton.label;" onclick="AbEditCard()"/>
|
||||
<titledbutton id="button_newmessage" class="other28" align="top" value="&newmsgButton.label;" onclick="AbNewMessage()"/>
|
||||
<titledbutton id="button_delete" class="other28" disabled="true" align="top" value="&deleteButton.label;" onclick="AbDelete()"/>
|
||||
<titledbutton id="button_delete" class="other28" disabled="true" align="top" value="&deleteButton.label;" onclick="goDoCommand('button_delete')"/>
|
||||
|
||||
<box align="vertical" flex="100%">
|
||||
<spring flex="1"/>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
rdf:datasources="rdf:null"
|
||||
id="folderTree" class="mail-folders"
|
||||
rdf:ignore="http://home.netscape.com/NC-rdf#MessageChild"
|
||||
onselect="top.FolderPaneSelectionChange()">
|
||||
onselect="top.FolderPaneSelectionChange(); document.commandDispatcher.updateCommands('tree-select');">
|
||||
|
||||
<template>
|
||||
<rule>
|
||||
|
|
|
@ -52,6 +52,11 @@ Rights Reserved.
|
|||
<html:script src="chrome://navigator/content/contentframe.js" />
|
||||
|
||||
<commands id="commands">
|
||||
<commandset id="CommandUpdate_Mail"
|
||||
commandupdater="true"
|
||||
events="focus,blur,tree-select"
|
||||
oncommandupdate="goUpdateCommand('button_delete')"/>
|
||||
|
||||
<commandset id="globalEditMenuItems"/>
|
||||
</commands>
|
||||
|
||||
|
@ -172,9 +177,6 @@ Rights Reserved.
|
|||
<menuseparator/>
|
||||
<menuitem id="menu_delete"/>
|
||||
<menuseparator/>
|
||||
<menuitem value="&deleteMsgCmd.label;" oncommand="MsgDeleteMessage(false);"/>
|
||||
<menuitem value="&deleteFolderCmd.label;" oncommand="MsgDeleteFolder();"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="menu_selectAll"/>
|
||||
<menuitem value="&selectThreadCmd.label;" oncommand="MsgSelectThread();"/>
|
||||
<menuitem value="&selectFlaggedCmd.label;" oncommand="MsgSelectFlaggedMsg();"/>
|
||||
|
@ -495,7 +497,7 @@ Rights Reserved.
|
|||
<titledbutton id="button_forward" class="button28" align="top" value="&forwardButton.label;" onclick="MsgForwardMessage(event)"/>
|
||||
<toolbarseparator/>
|
||||
<titledbutton id="button_next" class="other28" align="top" value="&nextButton.label;" onclick="MsgNextUnreadMessage()"/>
|
||||
<titledbutton id="button_delete" class="other28" align="top" value="&deleteButton.label;" onclick="MsgDeleteMessage(true)"/>
|
||||
<titledbutton id="button_delete" class="other28" disabled="true" align="top" value="&deleteButton.label;" onclick="goDoCommand('button_delete')"/>
|
||||
<titledbutton id="button_print" class="other28" align="top" value="&printButton.label;" onclick="Print()"/>
|
||||
<titledbutton id="button_stop" class="other28" align="top" value="&stopButton.label;" onclick="MsgStop();"/>
|
||||
<spring flex="100%"/>
|
||||
|
|
|
@ -109,8 +109,6 @@ function OnLoadMessenger()
|
|||
loadStartFolder();
|
||||
|
||||
AddToSession();
|
||||
|
||||
goSetDefaultController(DefaultController);
|
||||
}
|
||||
|
||||
function OnUnloadMessenger()
|
||||
|
@ -282,6 +280,9 @@ function InitPanes()
|
|||
var folderTree = GetFolderTree();
|
||||
if(folderTree)
|
||||
OnLoadFolderPane(folderTree);
|
||||
|
||||
top.controllers.appendController(DefaultController);
|
||||
SetupCommandUpdateHandlers();
|
||||
}
|
||||
|
||||
function OnLoadFolderPane(folderTree)
|
||||
|
|
|
@ -30,7 +30,7 @@ Rights Reserved.
|
|||
>
|
||||
|
||||
<tree datasources="rdf:null" id="threadTree" style="width: 100%; height: 100%"
|
||||
onselect="top.ThreadPaneSelectionChange(event.target)"
|
||||
onselect="top.ThreadPaneSelectionChange(event.target); document.commandDispatcher.updateCommands('tree-select');"
|
||||
containment="http://home.netscape.com/NC-rdf#MessageChild">
|
||||
|
||||
<template>
|
||||
|
|
|
@ -32,8 +32,6 @@ var DefaultController =
|
|||
switch ( command )
|
||||
{
|
||||
case "cmd_undo":
|
||||
return true;
|
||||
|
||||
case "cmd_redo":
|
||||
return true;
|
||||
|
||||
|
@ -47,8 +45,6 @@ var DefaultController =
|
|||
switch ( command )
|
||||
{
|
||||
case "cmd_undo":
|
||||
return true;
|
||||
|
||||
case "cmd_redo":
|
||||
return true;
|
||||
|
||||
|
@ -82,6 +78,7 @@ var FolderPaneController =
|
|||
{
|
||||
case "cmd_selectAll":
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -98,8 +95,14 @@ var FolderPaneController =
|
|||
return true;
|
||||
|
||||
case "cmd_delete":
|
||||
goSetMenuValue(command, 'valueFolder');
|
||||
return true;
|
||||
case "button_delete":
|
||||
if ( command == "cmd_delete" )
|
||||
goSetMenuValue(command, 'valueFolder');
|
||||
var folderTree = GetFolderTree();
|
||||
if ( folderTree && folderTree.selectedItems )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
@ -120,7 +123,9 @@ var FolderPaneController =
|
|||
break;
|
||||
|
||||
case "cmd_delete":
|
||||
MsgDeleteFolder();
|
||||
case "button_delete":
|
||||
// add this back in when folder delete has warning
|
||||
//MsgDeleteFolder();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +141,7 @@ var ThreadPaneController =
|
|||
{
|
||||
case "cmd_selectAll":
|
||||
case "cmd_delete":
|
||||
case "button_delete":
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -152,8 +158,20 @@ var ThreadPaneController =
|
|||
return true;
|
||||
|
||||
case "cmd_delete":
|
||||
goSetMenuValue(command, 'valueMessage');
|
||||
return true;
|
||||
case "button_delete":
|
||||
var threadTree = GetThreadTree();
|
||||
dump("threadTree = " + threadTree + "\n");
|
||||
var numSelected = 0;
|
||||
if ( threadTree && threadTree.selectedItems )
|
||||
numSelected = threadTree.selectedItems.length;
|
||||
if ( command == "cmd_delete" )
|
||||
{
|
||||
if ( numSelected < 2 )
|
||||
goSetMenuValue(command, 'valueMessage');
|
||||
else
|
||||
goSetMenuValue(command, 'valueMessages');
|
||||
}
|
||||
return ( numSelected > 0 );
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
@ -176,6 +194,10 @@ var ThreadPaneController =
|
|||
case "cmd_delete":
|
||||
MsgDeleteMessage(false);
|
||||
break;
|
||||
|
||||
case "button_delete":
|
||||
MsgDeleteMessage(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -140,11 +140,6 @@ function goDoCommand(command)
|
|||
}
|
||||
|
||||
|
||||
function goSetDefaultController(controller)
|
||||
{
|
||||
top.controllers.appendController(controller);
|
||||
}
|
||||
|
||||
function goSetCommandEnabled(id, enabled)
|
||||
{
|
||||
var node = top.document.getElementById(id);
|
||||
|
|
Загрузка…
Ссылка в новой задаче