document.getAnonymousElementByAttribute(this, "anonid", "notification-icon")); if (!this.chatbar) { document.getAnonymousElementByAttribute(this, "anonid", "minimize").hidden = true; document.getAnonymousElementByAttribute(this, "anonid", "close").hidden = true; } let contentWindow = this.contentWindow; // process this._callbacks, then set to null so the chatbox creator // knows to make new callbacks immediately. if (this._callbacks) { for (let callback of this._callbacks) { callback(this); } this._callbacks = null; } this.addEventListener("DOMContentLoaded", function DOMContentLoaded(event) { if (event.target != this.contentDocument) return; this.removeEventListener("DOMContentLoaded", DOMContentLoaded, true); this.isActive = !this.minimized; this._deferredChatLoaded.resolve(this); }, true); if (this.src) this.setAttribute("src", this.src); ]]> Promise.defer(); return this._deferredChatLoaded.promise; document.getAnonymousElementByAttribute(this, "anonid", "content"); return this.content.contentWindow; return this.content.contentDocument; return this.getAttribute("minimized") == "true"; if (this.parentNode.nodeName == "chatbar") return this.parentNode; return null; return this.content.docShell.isActive; this.content.docShell.isActive = !!val; // let the chat frame know if it is being shown or hidden let evt = this.contentDocument.createEvent("CustomEvent"); evt.initCustomEvent(val ? "socialFrameShow" : "socialFrameHide", true, true, {}); this.contentDocument.documentElement.dispatchEvent(evt); { chatbox.contentWindow.document.title = title; deferred.resolve(chatbox); } ); } else { // attach this chatbox to the topmost browser window let Chat = Cu.import("resource:///modules/Chat.jsm").Chat; let win = Chat.findChromeWindowForChats(); let chatbar = win.document.getElementById("pinnedchats"); let origin = this.content.getAttribute("origin"); let cb = chatbar.openChat(origin, title, "about:blank"); cb.promiseChatLoaded.then( () => { this.swapDocShells(cb); // chatboxForURL is a map of URL -> chatbox used to avoid opening // duplicate chat windows. Ensure reattached chat windows aren't // registered with about:blank as their URL, otherwise reattaching // more than one chat window isn't possible. chatbar.chatboxForURL.delete("about:blank"); chatbar.chatboxForURL.set(this.src, Cu.getWeakReference(cb)); chatbar.focus(); this.close(); deferred.resolve(cb); } ); } return deferred.promise; ]]> if (this.chatbar) this.chatbar.selectedChat = this; if (this.isActive == this.minimized) this.isActive = !this.minimized; // to avoid reflows we cache the width of the nub. this.cachedWidthNub = 0; this._selectedChat = null; document.getAnonymousElementByAttribute(this, "anonid", "innerbox"); document.getAnonymousElementByAttribute(this, "anonid", "nubMenu"); document.getAnonymousElementByAttribute(this, "anonid", "nub"); new WeakMap() new Map(); as it // must exist before the (possibly delayed) bindings are created. cb._callbacks.push(aCallback); } // src also a javascript property; the src attribute is set in the ctor. cb.src = aURL; if (aMode == "minimized") cb.setAttribute("minimized", "true"); cb.setAttribute("origin", aOrigin); cb.setAttribute("label", aTitle); this.insertBefore(cb, this.firstChild); this.selectedChat = cb; this.chatboxForURL.set(aURL, Cu.getWeakReference(cb)); this.resize(); return cb; ]]> availWidth) { // we need to collapse some. let toCollapse = []; for (let child of this.collapsibleChildren) { if (currentWidth <= availWidth) break; toCollapse.push(child); currentWidth -= this.getTotalChildWidth(child); } if (toCollapse.length) { for (let child of toCollapse) this.collapseChat(child); } } else if (currentWidth < availWidth) { // we *might* be able to expand some - see how many. // XXX - if this was clever, it could know when removing the nub // leaves enough space to show all collapsed let toShow = []; for (let child of this.collapsedChildren) { currentWidth += this.getTotalChildWidth(child); if (currentWidth > availWidth) break; toShow.push(child); } for (let child of toShow) this._showChat(child); // If none remain collapsed remove the nub. if (!this.hasCollapsedChildren) { this.nub.collapsed = true; } } // else: achievement unlocked - we are pixel-perfect! ]]> { chatbox.contentWindow.document.title = title; } ); event.stopPropagation(); ]]>