From 4187b3e26ff00b607d05cb9b588e83db18c3cab7 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Thu, 12 Dec 2013 02:59:41 -0500
Subject: [PATCH] Merge branch 'master' of github.com:roundcube/roundcubemail

---
 program/js/app.js |   64 +++++++++++++++----------------
 1 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index bd52298..cbe61ab 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -34,7 +34,7 @@
 
   // webmail client settings
   this.dblclick_time = 500;
-  this.message_time = 4000;
+  this.message_time = 5000;
   this.identifier_expr = new RegExp('[^0-9a-z\-_]', 'gi');
 
   // environment defaults
@@ -186,8 +186,6 @@
 
     if (this.env.permaurl)
       this.enable_command('permaurl', 'extwin', true);
-
-    this.local_storage_prefix = 'roundcube.' + (this.env.user_id || 'anonymous') + '.';
 
     switch (this.task) {
 
@@ -1728,6 +1726,9 @@
       extwin.document.write('<html><body>' + this.get_label('loading') + '</body></html>');
     }
 
+    // allow plugins to grab the window reference (#1489413)
+    this.triggerEvent('openwindow', { url:url, handle:extwin });
+
     // focus window, delayed to bring to front
     window.setTimeout(function() { extwin && extwin.focus(); }, 10);
 
@@ -2661,20 +2662,7 @@
   // delete selected messages from the current mailbox
   this.delete_messages = function(event)
   {
-    var uid, i, len, trash = this.env.trash_mailbox,
-      list = this.message_list,
-      selection = list ? list.get_selection() : [];
-
-    // exit if no mailbox specified or if selection is empty
-    if (!this.env.uid && !selection.length)
-      return;
-
-    // also select childs of collapsed rows
-    for (i=0, len=selection.length; i<len; i++) {
-      uid = selection[i];
-      if (list.rows[uid].has_children && !list.rows[uid].expanded)
-        list.select_children(uid);
-    }
+    var list = this.message_list, trash = this.env.trash_mailbox;
 
     // if config is set to flag for deletion
     if (this.env.flag_for_deletion) {
@@ -2714,7 +2702,7 @@
     this._with_selected_messages('delete', post_data);
   };
 
-  // Send a specifc move/delete request with UIDs of all selected messages
+  // Send a specific move/delete request with UIDs of all selected messages
   // @private
   this._with_selected_messages = function(action, post_data, lock)
   {
@@ -3199,7 +3187,7 @@
   {
     this.env.recipients_delimiter = this.env.recipients_separator + ' ';
 
-    obj[bw.ie || bw.safari || bw.chrome ? 'keydown' : 'keypress'](function(e) { return ref.ksearch_keydown(e, this, props); })
+    obj.keydown(function(e) { return ref.ksearch_keydown(e, this, props); })
       .attr('autocomplete', 'off');
   };
 
@@ -3688,7 +3676,7 @@
           if (elem.type == 'button' || elem.type == 'submit' || (elem.type == 'hidden' && elem.name != '_is_html')) {
             break;
           }
-          formdata[elem.name] = elem.type != 'checkbox' || elem.checked ? elem.value : '';
+          formdata[elem.name] = elem.type != 'checkbox' || elem.checked ? $(elem).val() : '';
 
           if (formdata[elem.name] != '' && elem.type != 'hidden')
             empty = false;
@@ -5544,9 +5532,8 @@
       target = win;
     }
 
-    if (action && (id || action == 'add-identity')) {
-      this.set_busy(true);
-      this.location_href(url, target);
+    if (id || action == 'add-identity') {
+      this.location_href(url, target, true);
     }
 
     return true;
@@ -5757,19 +5744,23 @@
       .prop({checked: subscribed ? true : false, disabled: is_protected ? true : false});
 
     // add to folder/row-ID map
-    this.env.subscriptionrows[id] = [name, display_name, 0];
+    this.env.subscriptionrows[id] = [name, display_name, false];
 
     // sort folders (to find a place where to insert the row)
     // replace delimiter with \0 character to fix sorting
     // issue where 'Abc Abc' would be placed before 'Abc/def'
     var replace_from = RegExp(RegExp.escape(this.env.delimiter), 'g'),
       replace_to = String.fromCharCode(0);
+
     $.each(this.env.subscriptionrows, function(k,v) {
-      var n = v[0];
-      n = n.replace(replace_from, replace_to);
-      v.push(n);
+      if (v.length < 4) {
+        var n = v[0];
+        n = n.replace(replace_from, replace_to);
+        v.push(n);
+      }
       folders.push(v);
     });
+
     folders.sort(function(a, b) {
       var len = a.length - 1; n1 = a[len], n2 = b[len];
       return n1 < n2 ? -1 : 1;
@@ -6209,7 +6200,7 @@
     this.triggerEvent('message', { message:msg, type:type, timeout:timeout, object:obj });
 
     if (timeout > 0)
-      setTimeout(function() { ref.hide_message(id, type == 'loading'); }, timeout);
+      setTimeout(function() { ref.hide_message(id, type != 'loading'); }, timeout);
     return id;
   };
 
@@ -6843,7 +6834,6 @@
 
           if ((response.action == 'list' || response.action == 'search') && this.message_list) {
             this.msglist_select(this.message_list);
-            this.message_list.resize();
             this.triggerEvent('listupdate', { folder:this.env.mailbox, rowcount:this.message_list.rowcount });
           }
         }
@@ -6854,7 +6844,6 @@
             this.enable_command('search-create', this.env.source == '');
             this.enable_command('search-delete', this.env.search_id);
             this.update_group_commands();
-            this.contact_list.resize();
             this.triggerEvent('listupdate', { folder:this.env.source, rowcount:this.contact_list.rowcount });
           }
         }
@@ -7445,11 +7434,20 @@
     setCookie(name, value, expires, this.env.cookie_path, this.env.cookie_domain, this.env.cookie_secure);
   };
 
+  this.get_local_storage_prefix = function()
+  {
+    if (!this.local_storage_prefix)
+      this.local_storage_prefix = 'roundcube.' + (this.env.user_id || 'anonymous') + '.';
+
+    return this.local_storage_prefix;
+  };
+
   // wrapper for localStorage.getItem(key)
   this.local_storage_get_item = function(key, deflt, encrypted)
   {
+
     // TODO: add encryption
-    var item = localStorage.getItem(this.local_storage_prefix + key);
+    var item = localStorage.getItem(this.get_local_storage_prefix() + key);
     return item !== null ? JSON.parse(item) : (deflt || null);
   };
 
@@ -7457,13 +7455,13 @@
   this.local_storage_set_item = function(key, data, encrypted)
   {
     // TODO: add encryption
-    return localStorage.setItem(this.local_storage_prefix + key, JSON.stringify(data));
+    return localStorage.setItem(this.get_local_storage_prefix() + key, JSON.stringify(data));
   };
 
   // wrapper for localStorage.removeItem(key)
   this.local_storage_remove_item = function(key)
   {
-    return localStorage.removeItem(this.local_storage_prefix + key);
+    return localStorage.removeItem(this.get_local_storage_prefix() + key);
   };
 
 }  // end object rcube_webmail

--
Gitblit v1.9.1