Bug 1112525 - UITour: Change the loop-selectedRoomButtons target to anchor from the chatbox's browser so info panels behave when the buttons disappear. r=dolske
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Mon, 22 Dec 2014 14:24:35 -0500
changeset 220919 f2b28a37a4c00e2754ed2689c7c8f3ba296c6cda
parent 220918 5c5ae97511dbd5fee333fb3412735a8a44568457
child 220920 8998763a34f503b471c38253944dce20b9163dcf
push id28003
push userryanvm@gmail.com
push dateMon, 22 Dec 2014 22:44:16 +0000
treeherdermozilla-central@d5167dc0ded3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs1112525
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1112525 - UITour: Change the loop-selectedRoomButtons target to anchor from the chatbox's browser so info panels behave when the buttons disappear. r=dolske The copy/email buttons can disappear when the feedback form appears or when someone else joins a room.
browser/modules/UITour.jsm
--- a/browser/modules/UITour.jsm
+++ b/browser/modules/UITour.jsm
@@ -138,37 +138,46 @@ this.UITour = {
         let loopBrowser = aDocument.querySelector("#loop-notification-panel > #loop");
         if (!loopBrowser) {
           return null;
         }
         return loopBrowser.contentDocument.querySelector(".room-list");
       },
     }],
     ["loop-selectedRoomButtons", {
-      infoPanelPosition: "leftcenter bottomright",
+      infoPanelOffsetY: -20,
+      infoPanelPosition: "start_after",
       query: (aDocument) => {
         let chatbox = aDocument.querySelector("chatbox[src^='about\:loopconversation'][selected]");
-        if (!chatbox || !chatbox.contentDocument) {
+
+        // Check that the real target actually exists
+        if (!chatbox || !chatbox.contentDocument ||
+            !chatbox.contentDocument.querySelector(".call-action-group")) {
           return null;
         }
-        return chatbox.contentDocument.querySelector(".call-action-group");
+
+        // But anchor on the <browser> in the chatbox so the panel doesn't jump to undefined
+        // positions when the copy/email buttons disappear e.g. when the feedback form opens or
+        // somebody else joins the room.
+        return chatbox.content;
       },
     }],
     ["loop-signInUpLink", {
       query: (aDocument) => {
         let loopBrowser = aDocument.querySelector("#loop-notification-panel > #loop");
         if (!loopBrowser) {
           return null;
         }
         return loopBrowser.contentDocument.querySelector(".signin-link");
       },
     }],
     ["privateWindow",  {query: "#privatebrowsing-button"}],
     ["quit",        {query: "#PanelUI-quit"}],
     ["search",      {
+      infoPanelOffsetX: 18,
       infoPanelPosition: "after_start",
       query: "#searchbar",
       widgetName: "search-container",
     }],
     ["searchProvider", {
       query: (aDocument) => {
         let searchbar = aDocument.getElementById("searchbar");
         if (searchbar.hasAttribute("oneoffui")) {
@@ -897,16 +906,18 @@ this.UITour = {
           node = null;
         }
       } else {
         node = aWindow.document.querySelector(targetQuery);
       }
 
       deferred.resolve({
         addTargetListener: targetObject.addTargetListener,
+        infoPanelOffsetX: targetObject.infoPanelOffsetX,
+        infoPanelOffsetY: targetObject.infoPanelOffsetY,
         infoPanelPosition: targetObject.infoPanelPosition,
         node: node,
         removeTargetListener: targetObject.removeTargetListener,
         targetName: aTargetName,
         widgetName: targetObject.widgetName,
         allowAdd: targetObject.allowAdd,
       });
     }).catch(log.error);
@@ -1236,22 +1247,20 @@ this.UITour = {
 
       tooltip.setAttribute("targetName", aAnchor.targetName);
       tooltip.hidden = false;
       let alignment = "bottomcenter topright";
       if (aAnchor.infoPanelPosition) {
         alignment = aAnchor.infoPanelPosition;
       }
 
-      let xOffset = 0, yOffset = 0;
-      if (aAnchor.targetName == "search") {
-        xOffset = 18;
-      }
+      let { infoPanelOffsetX: xOffset, infoPanelOffsetY: yOffset } = aAnchor;
+
       this._addAnnotationPanelMutationObserver(tooltip);
-      tooltip.openPopup(aAnchorEl, alignment, xOffset, yOffset);
+      tooltip.openPopup(aAnchorEl, alignment, xOffset || 0, yOffset || 0);
       if (tooltip.state == "closed") {
         document.defaultView.addEventListener("endmodalstate", function endModalStateHandler() {
           document.defaultView.removeEventListener("endmodalstate", endModalStateHandler);
           tooltip.openPopup(aAnchorEl, alignment);
         }, false);
       }
     }