mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-15 11:13:29 +00:00
Bug 808235 - give chatbox focus when restored. r=jaws
--HG-- extra : rebase_source : 6c224570314d77c83405b3345ee9b858f0df2fac
This commit is contained in:
parent
fe1ca13ca3
commit
c4107853a9
@ -254,10 +254,7 @@ let SocialChatBar = {
|
||||
}
|
||||
},
|
||||
focus: function SocialChatBar_focus() {
|
||||
if (!this.chatbar.selectedChat)
|
||||
return;
|
||||
let commandDispatcher = gBrowser.ownerDocument.commandDispatcher;
|
||||
commandDispatcher.advanceFocusIntoSubtree(this.chatbar.selectedChat);
|
||||
this.chatbar.focus();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,13 +27,20 @@
|
||||
<getter>
|
||||
return this.getAttribute("minimized") == "true";
|
||||
</getter>
|
||||
<setter>
|
||||
<setter><![CDATA[
|
||||
this.isActive = !val;
|
||||
if (val)
|
||||
let parent = this.parentNode;
|
||||
if (val) {
|
||||
this.setAttribute("minimized", "true");
|
||||
else
|
||||
// If this chat is the selected one a new one needs to be selected.
|
||||
if (parent.selectedChat == this)
|
||||
parent._selectAnotherChat();
|
||||
} else {
|
||||
this.removeAttribute("minimized");
|
||||
</setter>
|
||||
// this chat gets selected.
|
||||
parent.selectedChat = this;
|
||||
}
|
||||
]]></setter>
|
||||
</property>
|
||||
|
||||
<property name="isActive">
|
||||
@ -123,6 +130,15 @@
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "nub");
|
||||
</field>
|
||||
|
||||
<method name="focus">
|
||||
<body><![CDATA[
|
||||
if (!this.selectedChat)
|
||||
return;
|
||||
let commandDispatcher = gBrowser.ownerDocument.commandDispatcher;
|
||||
commandDispatcher.advanceFocusIntoSubtree(this.selectedChat);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<property name="selectedChat">
|
||||
<getter><![CDATA[
|
||||
return this._selectedChat;
|
||||
@ -141,6 +157,7 @@
|
||||
this._selectedChat = val;
|
||||
if (val) {
|
||||
this._selectedChat.setAttribute("selected", "true");
|
||||
this.focus();
|
||||
}
|
||||
}
|
||||
if (val) {
|
||||
@ -194,6 +211,26 @@
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<method name="_selectAnotherChat">
|
||||
<body><![CDATA[
|
||||
// Select a different chat (as the currently selected one is no
|
||||
// longer suitable as the selection - maybe it is being minimized or
|
||||
// closed.) We only select non-minimized and non-collapsed chats,
|
||||
// and if none are found, set the selectedChat to null.
|
||||
// It's possible in the future we will track most-recently-selected
|
||||
// chats or similar to find the "best" candidate - for now though
|
||||
// the choice is somewhat arbitrary.
|
||||
for (let other of this.children) {
|
||||
if (other != this.selectedChat && !other.minimized && !other.collapsed) {
|
||||
this.selectedChat = other;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// can't find another - so set no chat as selected.
|
||||
this.selectedChat = null;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="updateTitlebar">
|
||||
<parameter name="aChatbox"/>
|
||||
<body><![CDATA[
|
||||
@ -306,7 +343,7 @@
|
||||
<parameter name="aChatbox"/>
|
||||
<body><![CDATA[
|
||||
if (this.selectedChat == aChatbox) {
|
||||
this.selectedChat = aChatbox.previousSibling ? aChatbox.previousSibling : aChatbox.nextSibling
|
||||
this._selectAnotherChat();
|
||||
}
|
||||
this.removeChild(aChatbox);
|
||||
// child might have been collapsed.
|
||||
@ -321,6 +358,7 @@
|
||||
|
||||
<method name="removeAll">
|
||||
<body><![CDATA[
|
||||
this.selectedChat = null;
|
||||
while (this.firstChild) {
|
||||
this._remove(this.firstChild);
|
||||
}
|
||||
@ -396,8 +434,8 @@
|
||||
cb = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "chatbox");
|
||||
if (aMode == "minimized")
|
||||
cb.setAttribute("minimized", "true");
|
||||
this.selectedChat = cb;
|
||||
this.insertBefore(cb, this.firstChild);
|
||||
this.selectedChat = cb;
|
||||
this.initChatBox(cb, aProvider, aURL, aCallback);
|
||||
this.chatboxForURL.set(aURL, Cu.getWeakReference(cb));
|
||||
this.resize();
|
||||
|
@ -589,7 +589,5 @@ function getPopupWidth() {
|
||||
|
||||
function closeAllChats() {
|
||||
let chatbar = window.SocialChatBar.chatbar;
|
||||
while (chatbar.selectedChat) {
|
||||
chatbar.selectedChat.close();
|
||||
}
|
||||
chatbar.removeAll();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user