Fix for 102060, enable New Tab in the UI and implement tabbrowser context menus for closing and creating tabs, add CTRL+f4 for closing tabs. r=bryner, sr=brendan

This commit is contained in:
hyatt%netscape.com 2001-09-28 00:10:48 +00:00
Родитель 6253da57b9
Коммит bd56dc670f
4 изменённых файлов: 90 добавлений и 14 удалений

Просмотреть файл

@ -173,8 +173,8 @@
<menupopup id="menu_NewPopup">
<!-- From globalOverlay.xul -->
<menuitem id="menu_newNavigator" command="cmd_newNavigator"/>
<!-- <menuitem id="menu_newNavigatorTab" position="1" command="cmd_newNavigatorTab" key="key_newNavigatorTab"
label="&tabCmd.label;" accesskey="&tabCmd.accesskey;"/> -->
<menuitem id="menu_newNavigatorTab" command="cmd_newNavigatorTab" key="key_newNavigatorTab"
label="&tabCmd.label;" accesskey="&tabCmd.accesskey;"/>
<menuitem id="menu_newEditor" command="cmd_newEditor"/>
</menupopup>
</menu>

Просмотреть файл

@ -81,6 +81,7 @@ en-US.jar:
locale/en-US/global/textcontext.dtd (resources/locale/en-US/textcontext.dtd)
locale/en-US/global/brand.properties (resources/locale/en-US/brand.properties)
locale/en-US/global/brand.dtd (resources/locale/en-US/brand.dtd)
locale/en-US/global/tabbrowser.dtd (resources/locale/en-US/tabbrowser.dtd)
locale/en-US/global/wizardManager.properties (resources/locale/en-US/wizardManager.properties)
locale/en-US/global/wizardOverlay.dtd (resources/locale/en-US/wizardOverlay.dtd)
locale/en-US/global/keys.properties (resources/locale/en-US/keys.properties)

Просмотреть файл

@ -34,6 +34,11 @@
- GPL.
-->
<!DOCTYPE bindings [
<!ENTITY % tabBrowserDTD SYSTEM "chrome://global/locale/tabbrowser.dtd" >
%tabBrowserDTD;
]>
<bindings id="tabBrowserBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
@ -45,10 +50,16 @@
<content>
<xul:tabbox onselect="if (event.target.localName != 'tabpanels') return; this.parentNode.updateCurrentBrowser();">
<xul:stack collapsed="true" tooltip="_child">
<xul:stack collapsed="true" tooltip="_child" context="_child">
<xul:tooltip onpopupshowing="event.preventBubble(); if (document.tooltipNode.getAttribute('label')) { this.childNodes[0].value = document.tooltipNode.getAttribute('label'); return true; } return false;">
<xul:label style="margin:0px; padding:0px;" value="Dummy"/>
</xul:tooltip>
<xul:menupopup>
<xul:menuitem label="&newTab.label;" accesskey="&newTab.accesskey;" oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode; tabbrowser.selectedTab = tabbrowser.addTab('about:blank');"/>
<xul:menuseparator/>
<xul:menuitem label="&closeTab.label;" accesskey="&closeTab.accesskey;" oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode; tabbrowser.removeTab(document.popupNode);"/>
<xul:menuitem label="&closeOtherTabs.label;" accesskey="&closeOtherTabs.accesskey;" oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode; tabbrowser.removeAllTabsBut(document.popupNode);"/>
</xul:menupopup>
<xul:tabs style="padding-left:1px; padding-top: 1px;" flex="1">
<xul:tab flex="1" maxwidth="150" class="tabbrowser-tab" label="(Untitled)" crop="center"/>
</xul:tabs>
@ -71,7 +82,7 @@
this.mTabBox.firstChild
</field>
<field name="mTabContainer">
this.mStrip.childNodes[1]
this.mStrip.childNodes[2]
</field>
<field name="mPanelContainer">
this.mTabBox.childNodes[1]
@ -372,9 +383,44 @@
</body>
</method>
<method name="removeAllTabsBut">
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName == 'tabs')
aTab = this.mCurrentTab;
var l = this.mTabContainer.childNodes.length;
if (l == 1)
return;
for (var i = 0; i < l; i++) {
var tab = this.mTabContainer.childNodes[i];
if (tab != aTab) {
this.removeTab(tab);
i--;
l--;
}
}
]]>
</body>
</method>
<method name="removeCurrentTab">
<body>
<![CDATA[
return this.removeTab(this.mCurrentTab);
]]>
</body>
</method>
<method name="removeTab">
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName == 'tabs')
aTab = this.mCurrentTab;
var l = this.mTabContainer.childNodes.length;
if (l == 1)
return; // Don't allow the last tab to close.
@ -382,30 +428,48 @@
if (l == 2)
this.mStrip.collapsed = true; // Go ahead and collapse, since we're going back to 1 tab.
var index = this.mPanelContainer.index;
var index = -1;
if (this.mCurrentTab == aTab)
index = this.mPanelContainer.index;
else {
// Find and locate the tab in our list.
for (var i = 0; i < l; i++)
if (this.mTabContainer.childNodes[i] == aTab)
index = i;
}
// Remove our progress listener.
this.webProgress.removeProgressListener(this.mTabListeners[index]);
// Remove the tab's progress listener.
var oldBrowser = this.mPanelContainer.childNodes[index];
oldBrowser.webProgress.removeProgressListener(this.mTabListeners[index]);
this.mTabListeners.splice(index, 1);
// Remove our title change listener
this.mCurrentBrowser.removeEventListener("DOMTitleChanged", this.onTitleChanged, false);
oldBrowser.removeEventListener("DOMTitleChanged", this.onTitleChanged, false);
// We are no longer the primary content area.
this.mCurrentBrowser.setAttribute("type", "content");
oldBrowser.setAttribute("type", "content");
// Now select the new tab before nuking the old one.
var newIndex = (index > 0) ? index-1 : index;
var currentIndex = this.mPanelContainer.index;
var oldTab = this.mCurrentTab;
var oldBrowser = this.mCurrentBrowser;
var newIndex = -1;
if (currentIndex > index)
newIndex = currentIndex-1;
else if (currentIndex < index)
newIndex = currentIndex;
else if (index > 0)
newIndex = index-1;
else
newIndex = index;
var oldTab = aTab;
this.mTabContainer.removeChild(oldTab);
this.mPanelContainer.removeChild(oldBrowser);
this.selectedTab = this.mTabContainer.childNodes[newIndex];
if (newIndex == 0) {
if (newIndex == index) {
// No select event is going to fire. We need to just call updateCurrentBrowser()
// by hand.
this.updateCurrentBrowser();
@ -630,6 +694,10 @@
]]>
</destructor>
</implementation>
<handlers>
<handler event="keypress" modifiers="control" keycode="vk_f4" action="this.removeCurrentTab();"/>
</handlers>
</binding>
</bindings>

Просмотреть файл

@ -0,0 +1,7 @@
<!ENTITY newTab.label "New Tab">
<!ENTITY newTab.accesskey "n">
<!ENTITY closeTab.label "Close Tab">
<!ENTITY closeTab.accesskey "c">
<!ENTITY closeOtherTabs.label "Close Other Tabs">
<!ENTITY closeOtherTabs.accesskey "o">