alecpl
2010-05-28 f07d238b1b4d75b34639be873dcc1b1627404ae7
program/js/app.js
@@ -199,17 +199,17 @@
        if (this.env.trash_mailbox && this.env.mailbox != this.env.trash_mailbox)
          this.set_alttext('delete', 'movemessagetotrash');
        this.env.message_commands = ['show', 'reply', 'reply-all', 'forward', 'moveto', 'copy', 'delete',
          'open', 'mark', 'edit', 'viewsource', 'download', 'print', 'load-attachment', 'load-headers'];
        if (this.env.action=='show' || this.env.action=='preview') {
          this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'copy', 'delete',
            'open', 'mark', 'edit', 'viewsource', 'download', 'print', 'load-attachment', 'load-headers', true);
          this.enable_command(this.env.message_commands, true);
          if (this.env.next_uid) {
            this.enable_command('nextmessage', true);
            this.enable_command('lastmessage', true);
            this.enable_command('nextmessage', 'lastmessage', true);
          }
          if (this.env.prev_uid) {
            this.enable_command('previousmessage', true);
            this.enable_command('firstmessage', true);
            this.enable_command('previousmessage', 'firstmessage', true);
          }
          if (this.env.blockedobjects) {
@@ -326,8 +326,7 @@
        else if (this.env.action=='folders')
          this.enable_command('subscribe', 'unsubscribe', 'create-folder', 'rename-folder', 'delete-folder', 'enable-threading', 'disable-threading', true);
        if (this.gui_objects.identitieslist)
          {
        if (this.gui_objects.identitieslist) {
          this.identity_list = new rcube_list_widget(this.gui_objects.identitieslist, {multiselect:false, draggable:false, keyboard:false});
          this.identity_list.addEventListener('select', function(o){ p.identity_select(o); });
          this.identity_list.init();
@@ -335,9 +334,8 @@
          if (this.env.iid)
            this.identity_list.highlight_row(this.env.iid);
          }
        else if (this.gui_objects.sectionslist)
          {
        }
        else if (this.gui_objects.sectionslist) {
          this.sections_list = new rcube_list_widget(this.gui_objects.sectionslist, {multiselect:false, draggable:false, keyboard:false});
          this.sections_list.addEventListener('select', function(o){ p.section_select(o); });
          this.sections_list.init();
@@ -1051,21 +1049,25 @@
    return obj ? false : true;
  };
  // set command enabled or disabled
  // set command(s) enabled or disabled
  this.enable_command = function()
  {
    var args = arguments, len = args.length;
    if (!len)
      return -1;
    var args = Array.prototype.slice.call(arguments),
      enable = args.pop(), cmd;
    var command, enable = args[len-1];
    for (var n=0, len=len-1; n<len; n++) {
      command = args[n];
      this.commands[command] = enable;
      this.set_button(command, (enable ? 'act' : 'pas'));
    for (var n=0; n<args.length; n++) {
      cmd = args[n];
      // argument of type array
      if (typeof cmd === 'string') {
        this.commands[cmd] = enable;
        this.set_button(cmd, (enable ? 'act' : 'pas'));
      }
      // push array elements into commands array
      else {
        for (var i in cmd)
          args.push(cmd[i]);
      }
    }
    return true;
  };
  // lock/unlock interface
@@ -1073,7 +1075,7 @@
  {
    if (a && message) {
      var msg = this.get_label(message);
      if (msg == message)
      if (msg == message)
        msg = 'Loading...';
      this.display_message(msg, 'loading', true);
@@ -1402,9 +1404,12 @@
    var selected = list.get_single_selection() != null;
    this.enable_command(this.env.message_commands, selected);
    // Hide certain command buttons when Drafts folder is selected
    this.enable_command('reply', 'reply-all', 'forward', this.env.mailbox == this.env.drafts_mailbox ? false : selected);
    this.enable_command('show', 'print', 'open', 'edit', 'download', 'viewsource', selected);
    if (selected && this.env.mailbox == this.env.drafts_mailbox) {
      this.enable_command('reply', 'reply-all', 'forward', false);
    }
    // Multi-message commands
    this.enable_command('delete', 'moveto', 'copy', 'mark', (list.selection.length > 0 ? true : false));
    // reset all-pages-selection
@@ -2028,7 +2033,7 @@
        this.set_tree_icons(uid[i], tmp[i]);
      }
    }
  };
  };
  // adds tree icons to specified message row
  this.set_tree_icons = function(uid, tree)
@@ -2048,14 +2053,14 @@
      else
        divs.push({'class': null, width: 15});
    }
    for (i=divs.length-1; i>=0; i--) {
      if (divs[i]['class'])
        html += '<div class="tree '+divs[i]['class']+'" />';
      else
        html += '<div style="width:'+divs[i].width+'px" />';
    }
    if (html)
      $('#rcmtab'+uid).html(html);
  };
@@ -2329,7 +2334,7 @@
      this.show_contentframe(false);
    // Hide message command buttons until a message is selected
    this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', 'open', 'edit', 'viewsource', 'download', false);
    this.enable_command(this.env.message_commands, false);
    this._with_selected_messages('moveto', lock, add_url);
  };
@@ -2690,8 +2695,8 @@
  // test if purge command is allowed
  this.purge_mailbox_test = function()
  {
    return (this.env.messagecount && (this.env.mailbox == this.env.trash_mailbox || this.env.mailbox == this.env.junk_mailbox
      || this.env.mailbox.match('^' + RegExp.escape(this.env.trash_mailbox) + RegExp.escape(this.env.delimiter))
    return (this.env.messagecount && (this.env.mailbox == this.env.trash_mailbox || this.env.mailbox == this.env.junk_mailbox
      || this.env.mailbox.match('^' + RegExp.escape(this.env.trash_mailbox) + RegExp.escape(this.env.delimiter))
      || this.env.mailbox.match('^' + RegExp.escape(this.env.junk_mailbox) + RegExp.escape(this.env.delimiter))));
  };
@@ -3819,10 +3824,10 @@
      }
      this.name_input.remove();
      if (this.name_input_li)
        this.name_input_li.remove();
      this.name_input = this.name_input_li = null;
    }
@@ -3841,9 +3846,10 @@
    var link = $('<a>').attr('href', '#')
      .bind('click', function() { return rcmail.command('listgroup', prop, this);})
      .html(prop.name);
    var li = $('<li>').attr('id', 'rcmli'+key).addClass('contactgroup').append(link);
    var pli = this.get_folder_li(prop.source)
    $(li).insertAfter(pli);
    var li = $('<li>').attr('id', 'rcmli'+key)
      .addClass('contactgroup')
      .append(link)
      .insertAfter(this.get_folder_li(prop.source));
    this.triggerEvent('insertgroup', { id:prop.id, source:prop.source, name:prop.name, li:li[0] });
  };
@@ -4310,10 +4316,8 @@
  // enable/disable buttons for page shifting
  this.set_page_buttons = function()
  {
    this.enable_command('nextpage', (this.env.pagecount > this.env.current_page));
    this.enable_command('lastpage', (this.env.pagecount > this.env.current_page));
    this.enable_command('previouspage', (this.env.current_page > 1));
    this.enable_command('firstpage', (this.env.current_page > 1));
    this.enable_command('nextpage', 'lastpage', (this.env.pagecount > this.env.current_page));
    this.enable_command('previouspage', 'firstpage', (this.env.current_page > 1));
  };
  // set event handlers on registered buttons
@@ -4931,6 +4935,12 @@
      eval(response.exec);
    }
    // execute callback functions of plugins
    if (response.callbacks && response.callbacks.length) {
      for (var i=0; i < response.callbacks.length; i++)
        this.triggerEvent(response.callbacks[i][0], response.callbacks[i][1]);
    }
    // process the response data according to the sent action
    switch (response.action) {
      case 'delete':
@@ -4944,21 +4954,24 @@
      case 'moveto':
        if (this.env.action == 'show') {
          // re-enable commands on move/delete error
          this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', 'open', 'edit', 'viewsource', 'download', true);
          this.enable_command(this.env.message_commands, true);
        }
        break;
        else if (this.task == 'addressbook') {
          this.triggerEvent('listupdate', { folder:this.env.source, rowcount:this.contact_list.rowcount });
        }
      case 'purge':
      case 'expunge':
        if (!this.env.messagecount && this.task == 'mail') {
          // clear preview pane content
          if (this.env.contentframe)
            this.show_contentframe(false);
          // disable commands useless when mailbox is empty
          this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'copy', 'delete',
            'mark', 'viewsource', 'open', 'edit', 'download', 'print', 'load-attachment',
            'purge', 'expunge', 'select-all', 'select-none', 'sort',
            'expand-all', 'expand-unread', 'collapse-all', false);
        if (this.task == 'mail') {
          if (!this.env.messagecount) {
            // clear preview pane content
            if (this.env.contentframe)
              this.show_contentframe(false);
            // disable commands useless when mailbox is empty
            this.enable_command(this.env.message_commands, 'purge', 'expunge',
              'select-all', 'select-none', 'sort', 'expand-all', 'expand-unread', 'collapse-all', false);
          }
          this.triggerEvent('listupdate', { folder:this.env.mailbox, rowcount:this.message_list.rowcount });
        }
        break;