Thomas Bruederli
2014-08-18 3ebac0167bf20104fb7a2a55934765117760264c
program/js/app.js
@@ -236,8 +236,6 @@
            return ref.command('sort', $(this).attr('rel'), this);
          });
          this.gui_objects.messagelist.parentNode.onclick = function(e){ return ref.click_on_list(e || window.event); };
          this.enable_command('toggle_status', 'toggle_flag', 'sort', true);
          this.enable_command('set-listmode', this.env.threads && !this.is_multifolder_listing());
@@ -405,8 +403,6 @@
            .addEventListener('dragmove', function(e) { ref.drag_move(e); })
            .addEventListener('dragend', function(e) { ref.drag_end(e); })
            .init();
          this.gui_objects.contactslist.parentNode.onmousedown = function(e){ return ref.click_on_list(e); };
          $(this.gui_objects.qsearchbox).focusin(function() { ref.contact_list.blur(); });
@@ -1056,7 +1052,7 @@
        if (this.task == 'mail') {
          url._mbox = this.env.mailbox;
          if (props)
             url._to = props;
            url._to = props;
          // also send search request so we can go back to search result after message is sent
          if (this.env.search_request)
            url._search = this.env.search_request;
@@ -1084,8 +1080,12 @@
            break;
          }
        }
        else if (props)
        else if (props && typeof props == 'string') {
          url._to = props;
        }
        else if (props && typeof props == 'object') {
          $.extend(url, props);
        }
        this.open_compose_step(url);
        break;
@@ -1451,7 +1451,7 @@
  this.is_framed = function()
  {
    return (this.env.framed && parent.rcmail && parent.rcmail != this && parent.rcmail.command);
    return this.env.framed && parent.rcmail && parent.rcmail != this && typeof parent.rcmail.command == 'function';
  };
  this.save_pref = function(prop)
@@ -1713,19 +1713,6 @@
    return true;
  }
  this.click_on_list = function(e)
  {
    if (this.gui_objects.qsearchbox)
      this.gui_objects.qsearchbox.blur();
    if (this.message_list)
      this.message_list.focus(e);
    else if (this.contact_list)
      this.contact_list.focus(e);
    return true;
  };
  this.msglist_select = function(list)
  {
@@ -4752,6 +4739,7 @@
  this.list_contacts = function(src, group, page)
  {
    var win, folder, url = {},
      refresh = src === undefined && group === undefined && page === undefined,
      target = window;
    if (!src)
@@ -4764,7 +4752,7 @@
      page = this.env.current_page = 1;
      this.reset_qsearch();
    }
    else if (group != this.env.group)
    else if (!refresh && group != this.env.group)
      page = this.env.current_page = 1;
    if (this.env.search_id)
@@ -4902,6 +4890,9 @@
    if (action && (cid || action == 'add') && !this.drag_active) {
      if (this.env.group)
        url._gid = this.env.group;
      if (this.env.search_request)
        url._search = this.env.search_request;
      url._action = action;
      url._source = this.env.source;
@@ -5754,15 +5745,18 @@
    this.subscription_list = new rcube_treelist_widget(this.gui_objects.subscriptionlist, {
        selectable: true,
        tabexit: false,
        id_prefix: 'rcmli',
        id_encode: this.html_identifier_encode,
        id_decode: this.html_identifier_decode
        id_decode: this.html_identifier_decode,
        searchbox: '#foldersearch'
    });
    this.subscription_list
      .addEventListener('select', function(node) { ref.subscription_select(node.id); })
      .addEventListener('collapse', function(node) { ref.folder_collapsed(node) })
      .addEventListener('expand', function(node) { ref.folder_collapsed(node) })
      .addEventListener('search', function(p) { if (p.query) ref.subscription_select(); })
      .draggable({cancel: 'li.mailbox.root'})
      .droppable({
        // @todo: find better way, accept callback is executed for every folder
@@ -5845,6 +5839,12 @@
    if (!this.gui_objects.subscriptionlist)
      return false;
    // reset searching
    if (this.subscription_list.is_search()) {
      this.subscription_select();
      this.subscription_list.reset_search();
    }
    // disable drag-n-drop temporarily
    this.subscription_list.draggable('destroy').droppable('destroy');
@@ -5863,8 +5863,9 @@
    row.attr({id: 'rcmli' + this.html_identifier_encode(id), 'class': class_name});
    if (!refrow || !refrow.length) {
      // remove old subfolders and toggle
      // remove old data, subfolders and toggle
      $('ul,div.treetoggle', row).remove();
      row.removeData('filtered');
    }
    // set folder name
@@ -5991,7 +5992,7 @@
      this.subscription_list.expand(this.folder_id2name(parent.id));
    }
    row = row.get(0);
    row = row.show().get(0);
    if (row.scrollIntoView)
      row.scrollIntoView();
@@ -6002,10 +6003,18 @@
  this.replace_folder_row = function(oldid, id, name, display_name, is_protected, class_name)
  {
    if (!this.gui_objects.subscriptionlist) {
      if (this.is_framed)
        return parent.rcmail.replace_folder_row(oldid, id, name, display_name, is_protected, class_name);
      if (this.is_framed()) {
        // @FIXME: for some reason this 'parent' variable need to be prefixed with 'window.'
        return window.parent.rcmail.replace_folder_row(oldid, id, name, display_name, is_protected, class_name);
      }
      return false;
    }
    // reset searching
    if (this.subscription_list.is_search()) {
      this.subscription_select();
      this.subscription_list.reset_search();
    }
    var subfolders = {},
@@ -6053,6 +6062,12 @@
  // remove the table row of a specific mailbox from the table
  this.remove_folder_row = function(folder)
  {
    // reset searching
    if (this.subscription_list.is_search()) {
      this.subscription_select();
      this.subscription_list.reset_search();
    }
    var list = [], row = this.subscription_list.get_item(folder, true);
    // get subfolders if any
@@ -6121,6 +6136,37 @@
    $('#folder-size').replaceWith(size);
  };
  // filter folders by namespace
  this.folder_filter = function(prefix)
  {
    this.subscription_list.reset_search();
    this.subscription_list.container.children('li').each(function() {
      var i, folder = ref.folder_id2name(this.id);
      // show all folders
      if (prefix == '---') {
      }
      // got namespace prefix
      else if (prefix) {
        if (folder !== prefix) {
          $(this).data('filtered', true).hide();
          return
        }
      }
      // no namespace prefix, filter out all other namespaces
      else {
        // first get all namespace roots
        for (i in ref.env.ns_roots) {
          if (folder === ref.env.ns_roots[i]) {
            $(this).data('filtered', true).hide();
            return;
          }
        }
      }
      $(this).removeData('filtered').show();
    });
  };
  /*********************************************************/
  /*********           GUI functionality           *********/
@@ -6436,7 +6482,7 @@
    if (typeof content == 'object')
      popup.append(content);
    else
      popup.html(html);
      popup.html(content);
    popup.dialog($.extend({
        title: title,