зеркало из https://github.com/mozilla/pjs.git
Add tasks overlay for starting editor from taskbar or menus in other modules. b=122271, fix by neil@parkwaycc.co.uk, r=cmanske, sr=hewitt, a=asa
This commit is contained in:
Родитель
a003a99643
Коммит
cb9ad893c1
|
@ -38,7 +38,8 @@
|
|||
|
||||
function toNavigator()
|
||||
{
|
||||
CycleWindow('navigator:browser', getBrowserURL());
|
||||
if (!CycleWindow("navigator:browser"))
|
||||
OpenBrowserWindow();
|
||||
}
|
||||
|
||||
// Set up a lame hack to avoid opening two bookmarks.
|
||||
|
@ -147,21 +148,7 @@ function OpenBrowserWindow()
|
|||
}
|
||||
}
|
||||
|
||||
function newWindowOfType( aType )
|
||||
{
|
||||
switch (aType) {
|
||||
case "navigator:browser":
|
||||
OpenBrowserWindow();
|
||||
break;
|
||||
case "composer:html":
|
||||
NewEditorWindow();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function CycleWindow( aType, aChromeURL )
|
||||
function CycleWindow( aType )
|
||||
{
|
||||
var windowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();
|
||||
var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
|
||||
|
@ -170,29 +157,30 @@ function CycleWindow( aType, aChromeURL )
|
|||
var topWindow = windowManagerInterface.getMostRecentWindow( null );
|
||||
|
||||
if ( topWindowOfType == null )
|
||||
newWindowOfType( aType );
|
||||
else if ( topWindowOfType != topWindow )
|
||||
topWindowOfType.focus();
|
||||
else {
|
||||
var enumerator = windowManagerInterface.getEnumerator( aType );
|
||||
var firstWindow = windowManagerInterface.convertISupportsToDOMWindow ( enumerator.getNext() );
|
||||
var iWindow = firstWindow; // ;-)
|
||||
while ( iWindow != topWindow && enumerator.hasMoreElements() )
|
||||
iWindow = windowManagerInterface.convertISupportsToDOMWindow ( enumerator.getNext() );
|
||||
|
||||
var desiredWindow = firstWindow;
|
||||
if ( enumerator.hasMoreElements() )
|
||||
desiredWindow = windowManagerInterface.convertISupportsToDOMWindow ( enumerator.getNext() );
|
||||
if ( desiredWindow == topWindow ) // Only one window, open a new one
|
||||
newWindowOfType( aType );
|
||||
else
|
||||
desiredWindow.focus();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
function toEditor()
|
||||
{
|
||||
CycleWindow('composer:html', 'chrome://editor/content/editor.xul');
|
||||
if ( topWindowOfType != topWindow ) {
|
||||
topWindowOfType.focus();
|
||||
return topWindowOfType;
|
||||
}
|
||||
|
||||
var enumerator = windowManagerInterface.getEnumerator( aType );
|
||||
var firstWindow = windowManagerInterface.convertISupportsToDOMWindow(enumerator.getNext());
|
||||
var iWindow = firstWindow;
|
||||
while (iWindow != topWindow && enumerator.hasMoreElements())
|
||||
iWindow = windowManagerInterface.convertISupportsToDOMWindow(enumerator.getNext());
|
||||
|
||||
if (enumerator.hasMoreElements()) {
|
||||
iWindow = windowManagerInterface.convertISupportsToDOMWindow(enumerator.getNext());
|
||||
iWindow.focus();
|
||||
return iWindow;
|
||||
}
|
||||
|
||||
if (firstWindow == topWindow) // Only one window
|
||||
return null;
|
||||
|
||||
firstWindow.focus();
|
||||
return firstWindow;
|
||||
}
|
||||
|
||||
function ShowWindowFromResource( node )
|
||||
|
|
|
@ -17,14 +17,12 @@
|
|||
|
||||
<keyset id="tasksKeys">
|
||||
<key id="key_navigator" key="&navigatorCmd.commandkey;" command="Tasks:Navigator" modifiers="accel"/>
|
||||
<key id="key_editor" key="&editorCmd.commandkey;" command="Tasks:Editor" modifiers="accel"/>
|
||||
|
||||
<!-- Tools Menu -->
|
||||
<key id="key_gotoHistory" key="&history.commandKey;" oncommand="toHistory();" modifiers="accel"/>
|
||||
</keyset>
|
||||
<commandset id="tasksCommands">
|
||||
<command id="Tasks:Navigator" oncommand="toNavigator();"/>
|
||||
<command id="Tasks:Editor" oncommand="toEditor();"/>
|
||||
</commandset>
|
||||
|
||||
|
||||
|
@ -42,7 +40,6 @@
|
|||
|
||||
<menupopup id="taskPopup">
|
||||
<menuitem label="&navigatorCmd.label;" accesskey="&navigatorCmd.accesskey;" key="key_navigator" command="Tasks:Navigator" id="tasksMenuNavigator"/>
|
||||
<menuitem label="&editorCmd.label;" accesskey="&editorCmd.accesskey;" key="key_editor" command="Tasks:Editor" id="tasksMenuEditor"/>
|
||||
|
||||
<!-- Overlays get stuffed in here. -->
|
||||
|
||||
|
@ -58,7 +55,6 @@
|
|||
<menu label="&toolsMenu.label;" accesskey="&toolsMenu.accesskey;">
|
||||
<menupopup id="toolsPopup" onpopupshowing="javaItemEnabling();">
|
||||
<menuitem label="&historyCmd.label;" accesskey="&historyCmd.accesskey;" oncommand="toHistory()" key="key_gotoHistory"/>
|
||||
<menuitem label="&importUtilCmd.label;" accesskey="&importUtilCmd.accesskey;" oncommand="toImport()"/>
|
||||
<menuitem id="java" label="&javaConsoleCmd.label;" accesskey="&javaConsoleCmd.accesskey;" oncommand="toJavaConsole()"/>
|
||||
<menuitem label="&javaScriptConsoleCmd.label;" accesskey="&javaScriptConsoleCmd.accesskey;" oncommand="toJavaScriptConsole();"/>
|
||||
<menuitem label="&downloadManagerCmd.label;" accesskey="&downloadManagerCmd.accesskey;" oncommand="toDownloadManager();"/>
|
||||
|
@ -72,7 +68,5 @@
|
|||
<statusbarpanel id="component-bar" persist="collapsed">
|
||||
<toolbarbutton class="taskbutton" id="mini-nav" oncommand="toNavigator();"
|
||||
tooltiptext="&taskNavigator.tooltip;"/>
|
||||
<toolbarbutton class="taskbutton" id="mini-comp" oncommand="toEditor();"
|
||||
tooltiptext="&taskComposer.tooltip;"/>
|
||||
</statusbarpanel>
|
||||
</overlay>
|
||||
|
|
Загрузка…
Ссылка в новой задаче