From d686b57c72c574bca7349a7ddfe0425f50a0122a Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Fri, 12 Feb 2016 03:34:59 -0500
Subject: [PATCH] Fix bug where contacts widget in compose could be incorrectly initialized with treelist widget (T998) Fix typo in command name (list-adresses -> list-addresses)

---
 program/steps/mail/compose.inc |    2 +-
 program/js/app.js              |   13 +++++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index 9a9a1d6..3199ee4 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -295,7 +295,7 @@
         else if (this.env.action == 'compose') {
           this.env.address_group_stack = [];
           this.env.compose_commands = ['send-attachment', 'remove-attachment', 'send', 'cancel',
-            'toggle-editor', 'list-adresses', 'pushgroup', 'search', 'reset-search', 'extwin',
+            'toggle-editor', 'list-addresses', 'pushgroup', 'search', 'reset-search', 'extwin',
             'insert-response', 'save-response', 'menu-open', 'menu-close'];
 
           if (this.env.drafts_mailbox)
@@ -381,7 +381,7 @@
 
         if (this.gui_objects.addressbookslist) {
           this.gui_objects.folderlist = this.gui_objects.addressbookslist;
-          this.enable_command('list-adresses', true);
+          this.enable_command('list-addresses', true);
         }
 
         // ask user to send MDN
@@ -581,7 +581,12 @@
       this.display_message.apply(this, this.pending_message);
 
     // init treelist widget
-    if (this.gui_objects.folderlist && window.rcube_treelist_widget) {
+    if (this.gui_objects.folderlist && window.rcube_treelist_widget
+      // some plugins may load rcube_treelist_widget and there's one case
+      // when this will cause problems - addressbook widget in compose,
+      // which already has been initialized using rcube_list_widget
+      && this.gui_objects.folderlist != this.gui_objects.addressbookslist
+    ) {
       this.treelist = new rcube_treelist_widget(this.gui_objects.folderlist, {
           selectable: true,
           id_prefix: 'rcmli',
@@ -1161,7 +1166,7 @@
         this.change_identity($("[name='_from']")[0], true);
         break;
 
-      case 'list-adresses':
+      case 'list-addresses':
         this.list_contacts(props);
         this.enable_command('add-recipient', false);
         break;
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index bbb29d0..48aef76 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -1850,7 +1850,7 @@
         'id' => 'rcmli%s', 'class' => '%s'),
         html::a(array('href' => '#list',
             'rel' => '%s',
-            'onclick' => "return ".rcmail_output::JS_OBJECT_NAME.".command('list-adresses','%s',this)"), '%s'));
+            'onclick' => "return ".rcmail_output::JS_OBJECT_NAME.".command('list-addresses','%s',this)"), '%s'));
 
     foreach ($RCMAIL->get_address_sources(false, true) as $j => $source) {
         $id = strval(strlen($source['id']) ? $source['id'] : $j);

--
Gitblit v1.9.1