зеркало из https://github.com/mozilla/pjs.git
Bug 454667: Ability to close tabs, r=gavin
This commit is contained in:
Родитель
1b42de5061
Коммит
3e87a9415b
|
@ -733,6 +733,11 @@ var BrowserUI = {
|
|||
this.show(UIMODE_URLEDIT);
|
||||
},
|
||||
|
||||
closeTab : function(aTab) {
|
||||
Browser.content.removeTab(aTab);
|
||||
this.show(UIMODE_NONE);
|
||||
},
|
||||
|
||||
selectTab : function(aTab) {
|
||||
Browser.content.selectTab(aTab);
|
||||
this.show(UIMODE_NONE);
|
||||
|
|
|
@ -296,7 +296,7 @@
|
|||
</hbox>
|
||||
|
||||
<vbox id="tab-list-container" style="-moz-stack-sizing: ignore;" top="60" left="0">
|
||||
<richlistbox id="tab-list" onselect="BrowserUI.selectTab(this.selectedItem);"/>
|
||||
<richlistbox id="tab-list" onselect="BrowserUI.selectTab(this.selectedItem);" onclosetab="BrowserUI.closeTab(this);"/>
|
||||
<hbox>
|
||||
<toolbarbutton id="newtab-button" command="cmd_newTab"/>
|
||||
<toolbarbutton id="retrievetab-button" command=""/>
|
||||
|
|
|
@ -305,11 +305,24 @@
|
|||
if (!tab)
|
||||
return;
|
||||
|
||||
var nextTab = this.tabList.selectedItem;
|
||||
if (tab == this.tabList.selectedItem) {
|
||||
nextTab = tab.nextSibling;
|
||||
if (!nextTab)
|
||||
nextTab = tab.previousSibling;
|
||||
if (!nextTab)
|
||||
return;
|
||||
}
|
||||
|
||||
var display = this.getDisplayForTab(tab);
|
||||
if (display)
|
||||
display.removeChild(display);
|
||||
display.parentNode.removeChild(display);
|
||||
tab.parentNode.removeChild(tab);
|
||||
|
||||
this.tabList.selectedItem = nextTab;
|
||||
this.displayList.selectedPanel = this.getDisplayForTab(nextTab);
|
||||
this.selectTab(nextTab);
|
||||
|
||||
var evt = document.createEvent("Events");
|
||||
evt.initEvent("TabClose", true, false);
|
||||
tab.dispatchEvent(evt);
|
||||
|
@ -343,8 +356,11 @@
|
|||
nextDisplay = this.getDisplayForTab(nextTab);
|
||||
}
|
||||
|
||||
var uniqueId = Date.now() + displayList.childNodes.length;
|
||||
|
||||
if (!display) {
|
||||
display = document.createElementNS(XUL_NS, "deck");
|
||||
display.setAttribute("id", "display-" + uniqueId)
|
||||
displayList.insertBefore(display, nextDisplay);
|
||||
}
|
||||
display.appendChild(browser);
|
||||
|
@ -358,6 +374,7 @@
|
|||
|
||||
if (!tab) {
|
||||
tab = document.createElementNS(XUL_NS, "richlistitem");
|
||||
tab.setAttribute("id", "tab-" + uniqueId)
|
||||
tab.setAttribute("type", "documenttab");
|
||||
this.tabList.appendChild(tab);
|
||||
}
|
||||
|
@ -1221,6 +1238,13 @@
|
|||
</xul:stack>
|
||||
</content>
|
||||
<implementation>
|
||||
<constructor><![CDATA[
|
||||
let close = document.getAnonymousElementByAttribute(this, "anonid", "close");
|
||||
let closefn = new Function("event", parentNode.getAttribute("onclosetab"));
|
||||
var self = this;
|
||||
close.addEventListener("mousedown", function(event) { closefn.call(self, event); event.stopPropagation(); }, true);
|
||||
]]></constructor>
|
||||
|
||||
<method name="updateTab">
|
||||
<parameter name="browser"/>
|
||||
<body>
|
||||
|
@ -1242,6 +1266,7 @@
|
|||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="markInvalid">
|
||||
<parameter name="browser"/>
|
||||
<body>
|
||||
|
|
|
@ -29,6 +29,7 @@ classic.jar:
|
|||
notification.css (skin/notification.css)
|
||||
images/close.png (skin/images/close.png)
|
||||
images/close-small.png (skin/images/close-small.png)
|
||||
images/tab_close.png (skin/images/tab_close.png)
|
||||
images/default-favicon.png (skin/images/default-favicon.png)
|
||||
images/identity.png (skin/images/identity.png)
|
||||
images/starred48.png (skin/images/starred48.png)
|
||||
|
|
|
@ -338,6 +338,16 @@ richlistitem[type="documenttab"][selected="true"] {
|
|||
border: 1px solid white !important;
|
||||
}
|
||||
|
||||
.documenttab-close {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
list-style-image: url(chrome://browser/skin/images/tab_close.png);
|
||||
}
|
||||
|
||||
richlistitem[type="documenttab"]:only-child .documenttab-close {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#newtab-button {
|
||||
list-style-image: url("images/left_buttons.png");
|
||||
-moz-image-region: rect(0px 48px 48px 0px);
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 972 B |
Загрузка…
Ссылка в новой задаче