Bug 1508233 - remove broadcasters from im and chat. r=florian
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Mon, 19 Nov 2018 13:00:12 +0200
changeset 33741 237d8227bd3fbbcbbf2ff62f376f255a8666c5f2
parent 33740 e975eec95a7e884346424bc9eace9ac511d1b01e
child 33742 0a1e5f9bc3135ad07009ca682ae8b43f82992d58
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersflorian
bugs1508233
Bug 1508233 - remove broadcasters from im and chat. r=florian
mail/components/im/content/imAccounts.js
mail/components/im/content/imAccounts.xul
mail/components/preferences/chat.inc.xul
mail/components/preferences/chat.js
--- a/mail/components/im/content/imAccounts.js
+++ b/mail/components/im/content/imAccounts.js
@@ -355,17 +355,19 @@ var gAccountManager = {
         elt.setAttribute("disabled", "true");
       else
         elt.removeAttribute("disabled");
     }
   },
   onContextMenuShowing: function am_onContextMenuShowing() {
     let targetElt = document.popupNode;
     let isAccount = targetElt instanceof Ci.nsIDOMXULSelectControlItemElement;
-    document.getElementById("contextAccountsItems").hidden = !isAccount;
+    document.querySelector(".im-context-account-item").forEach(e => {
+      e.hidden = !isAccount;
+    });
     if (isAccount) {
       let account = targetElt.account;
       let hiddenItems = {
         connect: !account.disconnected,
         disconnect: account.disconnected || account.disconnecting,
         cancelReconnection: !targetElt.hasAttribute("reconnectPending"),
         accountsItemsSeparator: account.disconnecting,
       };
--- a/mail/components/im/content/imAccounts.xul
+++ b/mail/components/im/content/imAccounts.xul
@@ -71,41 +71,37 @@
 
  <keyset id="accountsKeys">
    <key id="key_close1" key="w" modifiers="accel" command="cmd_close"/>
    <key id="key_close2" keycode="VK_ESCAPE" command="cmd_close"/>
    <key id="key_close3" command="cmd_close"
         key="&accountManager.close.commandkey;" modifiers="accel,shift"/>
  </keyset>
 
- <broadcasterset>
-   <broadcaster id="contextAccountsItems"/>
- </broadcasterset>
-
  <menupopup id="accountsContextMenu"
             onpopupshowing="gAccountManager.onContextMenuShowing()">
    <menuitem id="context_connect"
              command="cmd_connect"
-             observes="contextAccountsItems"/>
+             class="im-context-account-item"/>
    <menuitem id="context_disconnect"
              command="cmd_disconnect"
-             observes="contextAccountsItems"/>
+             class="im-context-account-item"/>
    <menuitem id="context_cancelReconnection"
              command="cmd_cancelReconnection"
-             observes="contextAccountsItems"/>
+             class="im-context-account-item"/>
    <menuitem id="context_copyDebugLog"
              command="cmd_copyDebugLog"/>
    <menuseparator id="context_accountsItemsSeparator"
-                  observes="contextAccountsItems"/>
+                  class="im-context-account-item"/>
    <menuitem command="cmd_new"/>
-   <menuseparator observes="contextAccountsItems"/>
-   <menuitem command="cmd_moveup" observes="contextAccountsItems"/>
-   <menuitem command="cmd_movedown" observes="contextAccountsItems"/>
-   <menuseparator observes="contextAccountsItems"/>
-   <menuitem command="cmd_edit" observes="contextAccountsItems"/>
+   <menuseparator class="im-context-account-item"/>
+   <menuitem command="cmd_moveup" class="im-context-account-item"/>
+   <menuitem command="cmd_movedown" class="im-context-account-item"/>
+   <menuseparator class="im-context-account-item"/>
+   <menuitem command="cmd_edit" class="im-context-account-item"/>
  </menupopup>
 
  <toolbox id="mainToolbox">
    <toolbar id="statusArea">
      <stack id="statusImageStack">
        <image id="userIcon" onclick="statusSelector.userIconClick();"/>
        <button type="menu" id="statusTypeIcon" status="available">
          <menupopup id="setStatusTypeMenupopup"
--- a/mail/components/preferences/chat.inc.xul
+++ b/mail/components/preferences/chat.inc.xul
@@ -24,18 +24,16 @@
       <preference id="mail.chat.play_sound.type" name="mail.chat.play_sound.type" type="int"/>
       <preference id="mail.chat.play_sound.url" name="mail.chat.play_sound.url" type="string"/>
       <preference id="messenger.options.getAttentionOnNewMessages" name="messenger.options.getAttentionOnNewMessages" type="bool"/>
       <preference id="messenger.options.messagesStyle.theme"      name="messenger.options.messagesStyle.theme"      type="string"/>
       <preference id="messenger.options.messagesStyle.variant"    name="messenger.options.messagesStyle.variant"    type="string"/>
       <preference id="messenger.options.messagesStyle.showHeader" name="messenger.options.messagesStyle.showHeader" type="bool"/>
     </preferences>
 
-    <broadcaster id="idleReportingEnabled"/>
-
     <stringbundle id="themesBundle"
                   src="chrome://messenger/locale/preferences/messagestyle.properties"/>
 
     <tabbox id="chatPrefs" flex="1">
       <tabs id="chatPrefsTabs">
         <tab id="chatGeneralTab"       label="&generalTab.label;"/>
         <tab id="chatMessageStylesTab" label="&messageStyleTab.title;"/>
       </tabs>
@@ -58,34 +56,34 @@
           <separator/>
 
           <!-- Status -->
           <hbox align="center">
             <checkbox id="reportIdle" label="&reportIdleAfter.label;"
                       accesskey="&reportIdleAfter.accesskey;"
                       preference="messenger.status.reportIdle"/>
             <textbox id="timeBeforeAway" type="number" min="1" max="720"
-                     observes="idleReportingEnabled"
+                     class="idle-reporting-enabled"
                      preference="messenger.status.timeBeforeIdle"
                      onsyncfrompreference="var elt = document.getElementById(this.getAttribute('preference'));
                                            return (elt.instantApply ? elt.valueFromPreferences : elt.value) / 60;"
                      onsynctopreference="return this.value * 60;"/>
             <label value="&idleTime;" control="timeBeforeAway"/>
           </hbox>
           <vbox class="indent">
             <hbox>
               <checkbox id="autoAway"
                         label="&andSetStatusToAway.label;"
-                        observes="idleReportingEnabled"
+                        class="idle-reporting-enabled"
                         accesskey="&andSetStatusToAway.accesskey;"
                         preference="messenger.status.awayWhenIdle"/>
               <spacer flex="1"/>
             </hbox>
-            <textbox id="defaultIdleAwayMessage" class="indent"
-                     observes="idleReportingEnabled"
+            <textbox id="defaultIdleAwayMessage"
+                     class="idle-reporting-enabled indent"
                      preference="messenger.status.defaultIdleAwayMessage"/>
           </vbox>
           <separator/>
           <hbox>
             <checkbox id="sendTyping"
                       label="&sendTyping.label;"
                       accesskey="&sendTyping.accesskey;"
                       preference="purple.conversations.im.send_typing"/>
--- a/mail/components/preferences/chat.js
+++ b/mail/components/preferences/chat.js
@@ -8,23 +8,20 @@
 var gChatPane = {
   init() {
     previewObserver.load();
     this.updateDisabledState();
     this.updatePlaySound();
   },
 
   updateDisabledState() {
-    let broadcaster = document.getElementById("idleReportingEnabled");
-    if (document.getElementById("messenger.status.reportIdle").value) {
-      broadcaster.removeAttribute("disabled");
-      this.updateMessageDisabledState();
-    } else {
-      broadcaster.setAttribute("disabled", "true");
-    }
+    let checked = document.getElementById("messenger.status.reportIdle").value;
+    document.querySelectorAll(".idle-reporting-enabled").forEach(e => {
+      e.disabled = !checked;
+    });
   },
 
   updateMessageDisabledState() {
     let textbox = document.getElementById("defaultIdleAwayMessage");
     if (document.getElementById("messenger.status.awayWhenIdle").value)
       textbox.removeAttribute("disabled");
     else
       textbox.setAttribute("disabled", "true");