Bug 953619 - Improve topic notification bar. r=morian
authorBenedikt Pfeifer <benediktp@ymail.com>
Tue, 11 Aug 2009 03:59:40 +0200 (2009-08-11)
changeset 14041 8541b2932cfb52ed0b41bb56c576be9ebd49341b
parent 14040 08fe2d6ade6c1e0d8971024756ee5ec23bed1086
child 14042 c6a0fe30dc89521e95f3512b634f240690ab7467
push id9778
push userflorian@queze.net
push dateSun, 12 Jan 2014 18:25:45 +0000 (2014-01-12)
treeherdercomm-central@f81a23bfefcd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmorian
bugs953619
Bug 953619 - Improve topic notification bar. r=morian
im/base/content/instantbird/instantbird.css
im/base/content/instantbird/topicNotification.xml
im/base/content/jar.mn
im/locales/en-US/chrome/instantbird/instantbird.dtd
--- a/im/base/content/instantbird/instantbird.css
+++ b/im/base/content/instantbird/instantbird.css
@@ -52,8 +52,17 @@ conversation:not([selected="true"]) brow
 
 convtab {
   -moz-binding: url("chrome://instantbird/content/conversation.xml#convtab");
 }
 
 convtab[selected="true"] {
   -moz-user-focus: normal;
 }
+
+notification[value="topic"] {
+  -moz-binding: url("chrome://instantbird/content/topicNotification.xml#topicnotification");
+}
+
+notification[value="topic"] deck[selectedIndex="0"] > :nth-child(2) *,
+notification[value="topic"] deck[selectedIndex="1"] > :nth-child(1) * {
+  display: none;
+}
new file mode 100644
--- /dev/null
+++ b/im/base/content/instantbird/topicNotification.xml
@@ -0,0 +1,141 @@
+<?xml version="1.0"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+   - Version: MPL 1.1/GPL 2.0/LGPL 2.1
+   -
+   - The contents of this file are subject to the Mozilla Public License Version
+   - 1.1 (the "License"); you may not use this file except in compliance with
+   - the License. You may obtain a copy of the License at
+   - http://www.mozilla.org/MPL/
+   -
+   - Software distributed under the License is distributed on an "AS IS" basis,
+   - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+   - for the specific language governing rights and limitations under the
+   - License.
+   -
+   - The Original Code is the Instantbird messenging client, released
+   - 2009.
+   -
+   - The Initial Developer of the Original Code is
+   -     Benedikt P. <leeraccount@yahoo.de>.
+   - Portions created by the Initial Developer are Copyright (C) 2009
+   - the Initial Developer. All Rights Reserved.
+   -
+   - Contributor(s):
+   -
+   - Alternatively, the contents of this file may be used under the terms of
+   - either the GNU General Public License Version 2 or later (the "GPL"), or
+   - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+   - in which case the provisions of the GPL or the LGPL are applicable instead
+   - of those above. If you wish to allow use of your version of this file only
+   - under the terms of either the GPL or the LGPL, and not to allow others to
+   - use your version of this file under the terms of the MPL, indicate your
+   - decision by deleting the provisions above and replace them with the notice
+   - and other provisions required by the GPL or the LGPL. If you do not delete
+   - the provisions above, a recipient may use your version of this file under
+   - the terms of any one of the MPL, the GPL or the LGPL.
+   -
+   - ***** END LICENSE BLOCK ***** -->
+
+
+<!DOCTYPE bindings [
+  <!ENTITY % instantbirdDTD SYSTEM "chrome://instantbird/locale/instantbird.dtd">
+  %instantbirdDTD;
+]>
+
+<bindings id="notificationBindings"
+          xmlns="http://www.mozilla.org/xbl"
+          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+          xmlns:xbl="http://www.mozilla.org/xbl">
+  <binding id="topicnotification"
+           extends="chrome://global/content/bindings/notification.xml#notification">
+    <content>
+      <xul:hbox class="notification-inner outset" flex="1" xbl:inherits="type">
+        <xul:hbox anonid="details" align="center" flex="1">
+          <xul:deck anonid="notificationdeck" selectedIndex="0" flex="1">
+            <xul:hbox flex="1" align="center" ondblclick="editTopic();">
+              <xul:image anonid="messageImage" 
+                         class="messageImage"
+                         xbl:inherits="src=image"/>
+              <xul:description anonid="messageText"
+                               class="messageText"
+                               flex="1"
+                               xbl:inherits="xbl:text=label"
+                               tooltiptext="&topicBar.tooltip;"/>
+              <children/>
+            </xul:hbox>
+            <xul:hbox flex="1" align="center">
+              <xul:image anonid="messageImage"
+                         class="messageImage"
+                         xbl:inherits="src=image"/>
+              <xul:textbox anonid="newtopictextbox" flex="1" spellcheck="true"/>
+              <xul:button label="&topicBar.button.label;" oncommand="setTopic();"
+                          accesskey="&topicBar.button.accesskey;"/>
+            </xul:hbox>
+          </xul:deck>
+        </xul:hbox>
+        <xul:toolbarbutton anonid="topicBarCloseButton"
+                           ondblclick="event.stopPropagation();"
+                           class="messageCloseButton tabbable"
+                           xbl:inherits="hidden=hideclose"
+                           oncommand="closeBar();"/>
+      </xul:hbox>
+    </content>
+    <implementation>
+      <method name="editTopic">
+        <body>
+          <![CDATA[
+            document.getAnonymousElementByAttribute(this, "anonid", "notificationdeck")
+                    .selectedIndex = 1;
+            let textboxElt =
+              document.getAnonymousElementByAttribute(this, "anonid", "newtopictextbox");
+            textboxElt.value = this.label;
+            textboxElt.focus();
+          ]]>
+        </body>
+      </method>
+
+      <method name="setTopic">
+        <body>
+          <![CDATA[
+            var changeCmdString = "/topic " +
+              document.getAnonymousElementByAttribute(this, "anonid", "newtopictextbox")
+                      .value;
+            document.getBindingParent(this).sendMsg(changeCmdString);
+            this.stopEdit();
+          ]]>
+        </body>
+      </method>
+
+      <method name="stopEdit">
+        <body>
+          <![CDATA[
+            document.getAnonymousElementByAttribute (this, "anonid", "notificationdeck")
+                    .selectedIndex = 0;
+            document.getBindingParent(this).focus();
+          ]]>
+        </body>
+      </method>
+
+      <method name="closeBar">
+        <body>
+          <![CDATA[ 
+            // Actions on the close button:
+            //  if in edit mode, change back to the topic display
+            //  otherwise close the bar as usual
+            if (document.getAnonymousElementByAttribute(this, "anonid", "notificationdeck")
+                        .selectedIndex == 1)
+              this.stopEdit();
+            else
+              this.close();
+          ]]>
+        </body>
+      </method>
+    </implementation>
+
+    <handlers>
+     <handler event="keypress" keycode="VK_RETURN" action="this.setTopic();"/>
+     <handler event="keypress" keycode="VK_ENTER" action="this.setTopic();"/>
+     <handler event="keypress" keycode="VK_ESCAPE" action="this.stopEdit();"/>
+    </handlers>
+  </binding>
+</bindings>
--- a/im/base/content/jar.mn
+++ b/im/base/content/jar.mn
@@ -13,16 +13,17 @@ instantbird.jar:
 	content/instantbird/addbuddy.js		(instantbird/addbuddy.js)
 	content/instantbird/addbuddy.xul	(instantbird/addbuddy.xul)
 	content/instantbird/anim.xml		(instantbird/anim.xml)
 	content/instantbird/blist.css		(instantbird/blist.css)
 	content/instantbird/blist.js		(instantbird/blist.js)
 *	content/instantbird/blist.xul		(instantbird/blist.xul)
 *	content/instantbird/buddy.xml		(instantbird/buddy.xml)
 	content/instantbird/core.js		(instantbird/core.js)
+	content/instantbird/topicNotification.xml	(instantbird/topicNotification.xml)
 *	content/instantbird/conversation.xml	(instantbird/conversation.xml)
 	content/instantbird/convbrowser.xml	(instantbird/convbrowser.xml)
 	content/instantbird/conv.html		(instantbird/conv.html)
 *	content/instantbird/credits.xhtml	(instantbird/credits.xhtml)
 *	content/instantbird/engineManager.js	(instantbird/engineManager.js)
 *	content/instantbird/engineManager.xul	(instantbird/engineManager.xul)
 	content/instantbird/group.xml		(instantbird/group.xml)
 *	content/instantbird/instantbird.css	(instantbird/instantbird.css)
--- a/im/locales/en-US/chrome/instantbird/instantbird.dtd
+++ b/im/locales/en-US/chrome/instantbird/instantbird.dtd
@@ -24,16 +24,19 @@
 <!ENTITY messageStyle       "Message Styles…">
 <!ENTITY smileys            "Smileys…">
 <!ENTITY checkForUpdates    "Check for Updates">
 <!ENTITY help.menu          "?">
 <!ENTITY about.menu         "About &brandShortName;">
 <!ENTITY about.accesskey    "A">
 <!ENTITY conversation.contextMenu.close "Close Tab">
 <!ENTITY chat.participants  "Participants:">
+<!ENTITY topicBar.tooltip   "Double click to change topic">
+<!ENTITY topicBar.button.label        "Change">
+<!ENTITY topicBar.button.accesskey    "C">
 
 <!ENTITY errorConsoleCmd.label        "Error Console">
 <!ENTITY errorConsoleCmd.accesskey    "C">
 <!ENTITY errorConsoleCmd.commandkey   "j">
 
 <!ENTITY textEnlarge.commandkey   "+">
 <!ENTITY textEnlarge.commandkey2  "=">
 <!ENTITY textEnlarge.commandkey3  "">