mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 783687 - Use custom event in the chat box to update the titlebar. r=jaws
This commit is contained in:
parent
340d010c82
commit
a8a6c5265f
@ -7,7 +7,7 @@
|
||||
|
||||
<binding id="chatbox">
|
||||
<content orient="vertical" mousethrough="never">
|
||||
<xul:hbox class="chat-titlebar" xbl:inherits="minimized,selected"
|
||||
<xul:hbox class="chat-titlebar" xbl:inherits="minimized,selected,activity"
|
||||
onclick="document.getBindingParent(this).toggle();" align="baseline">
|
||||
<xul:image class="chat-status-icon" xbl:inherits="src=image"/>
|
||||
<xul:label class="chat-title" flex="1" xbl:inherits="value=label,crop"/>
|
||||
@ -78,11 +78,25 @@
|
||||
<handler event="focus" phase="capturing">
|
||||
this.parentNode.selectedChat = this;
|
||||
</handler>
|
||||
<handler event="load"><![CDATA[
|
||||
<handler event="DOMContentLoaded"><![CDATA[
|
||||
this.isActive = !this.minimized;
|
||||
if (this._callback) this._callback(this.iframe.contentWindow);
|
||||
let chatbox = this;
|
||||
function chatActivity() {
|
||||
chatbox.setAttribute("activity", true);
|
||||
chatbox.parentNode.updateTitlebar(chatbox);
|
||||
};
|
||||
let iframeWindow = this.iframe.contentWindow;
|
||||
iframeWindow.addEventListener("socialChatActivity", chatActivity);
|
||||
iframeWindow.addEventListener("unload", function unload() {
|
||||
iframeWindow.removeEventListener("unload", unload);
|
||||
iframeWindow.removeEventListener("socialChatActivity", chatActivity);
|
||||
});
|
||||
]]></handler>
|
||||
<handler event="DOMTitleChanged"><![CDATA[
|
||||
this.setAttribute('label', this.iframe.contentDocument.title);
|
||||
this.parentNode.updateTitlebar(this);
|
||||
]]></handler>
|
||||
<handler event="DOMTitleChanged" action="this.setAttribute('label', this.iframe.contentDocument.title);"/>
|
||||
<handler event="DOMLinkAdded"><![CDATA[
|
||||
// much of this logic is from DOMLinkHandler in browser.js
|
||||
// this sets the presence icon for a chat user, we simply use favicon style updating
|
||||
@ -99,6 +113,7 @@
|
||||
|
||||
// we made it this far, use it
|
||||
this.setAttribute('image', uri.spec);
|
||||
this.parentNode.updateTitlebar(this);
|
||||
]]></handler>
|
||||
</handlers>
|
||||
</binding>
|
||||
@ -124,6 +139,10 @@
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "nubMenu");
|
||||
</field>
|
||||
|
||||
<field name="nub" readonly="true">
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "nub");
|
||||
</field>
|
||||
|
||||
<property name="emptyWidth">
|
||||
<getter>
|
||||
return document.getAnonymousElementByAttribute(this, "anonid", "spacer").boxObject.width;
|
||||
@ -140,6 +159,7 @@
|
||||
this._selectedChat = val;
|
||||
if (val) {
|
||||
this._selectedChat.setAttribute("selected", "true");
|
||||
this._selectedChat.removeAttribute("activity");
|
||||
}
|
||||
]]></setter>
|
||||
</property>
|
||||
@ -196,6 +216,21 @@
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="updateTitlebar">
|
||||
<parameter name="aChatbox"/>
|
||||
<body><![CDATA[
|
||||
if (aChatbox.collapsed) {
|
||||
let menuitem = this.menuitemMap.get(aChatbox);
|
||||
if (aChatbox.getAttribute("activity")) {
|
||||
menuitem.setAttribute("activity", true);
|
||||
this.nub.setAttribute("activity", true);
|
||||
}
|
||||
menuitem.setAttribute("label", aChatbox.getAttribute("label"));
|
||||
menuitem.setAttribute("image", aChatbox.getAttribute("image"));
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="handleEvent">
|
||||
<parameter name="aEvent"/>
|
||||
<body><![CDATA[
|
||||
@ -225,7 +260,9 @@
|
||||
aChatbox.collapsed = true;
|
||||
aChatbox.isActive = false;
|
||||
let menu = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem");
|
||||
menu.setAttribute("class", "menuitem-iconic");
|
||||
menu.setAttribute("label", aChatbox.iframe.contentDocument.title);
|
||||
menu.setAttribute("image", aChatbox.getAttribute("image"));
|
||||
menu.chat = aChatbox;
|
||||
this.menuitemMap.set(aChatbox, menu);
|
||||
this.menupopup.appendChild(menu);
|
||||
@ -296,6 +333,9 @@
|
||||
|
||||
</implementation>
|
||||
<handlers>
|
||||
<handler event="popupshown"><![CDATA[
|
||||
this.nub.removeAttribute("activity");
|
||||
]]></handler>
|
||||
<handler event="overflow"><![CDATA[
|
||||
// make sure we're not getting an overflow from content
|
||||
if (event.originalTarget != this.innerbox)
|
||||
|
@ -2780,6 +2780,10 @@ html|*#gcli-output-frame {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.chat-titlebar[activity] {
|
||||
background-color: #ceeaff;
|
||||
}
|
||||
|
||||
.chat-frame {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
@ -2809,6 +2813,14 @@ html|*#gcli-output-frame {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.chatbar-button[activity] {
|
||||
background-color: #ceeaff;
|
||||
}
|
||||
|
||||
.chatbar-button > menupopup > menuitem[activity] {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.chatbar-innerbox {
|
||||
background: transparent;
|
||||
margin: -285px -1px 0 -1px;
|
||||
|
@ -3462,6 +3462,10 @@ html|*#gcli-output-frame {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.chat-titlebar[activity] {
|
||||
background-color: #ceeaff;
|
||||
}
|
||||
|
||||
.chat-titlebar[selected] {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
@ -3495,6 +3499,14 @@ html|*#gcli-output-frame {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.chatbar-button[activity] {
|
||||
background-color: #ceeaff;
|
||||
}
|
||||
|
||||
.chatbar-button > menupopup > menuitem[activity] {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.chatbar-innerbox {
|
||||
background: transparent;
|
||||
margin: -285px -1px 0 -1px;
|
||||
|
@ -3484,6 +3484,10 @@ html|*#gcli-output-frame {
|
||||
background-color: #dae3f0;
|
||||
}
|
||||
|
||||
.chat-titlebar[activity] {
|
||||
background-color: #ceeaff;
|
||||
}
|
||||
|
||||
.chat-frame {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
@ -3522,6 +3526,14 @@ html|*#gcli-output-frame {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.chatbar-button[activity] {
|
||||
background-color: #ceeaff;
|
||||
}
|
||||
|
||||
.chatbar-button > menupopup > menuitem[activity] {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.chatbar-innerbox {
|
||||
background: transparent;
|
||||
margin: -285px -1px 0 -1px;
|
||||
|
Loading…
Reference in New Issue
Block a user