alecpl
2010-10-05 c288f9969e113cb7dbd38bf05167cc8e94e007ff
program/js/app.js
@@ -1,9 +1,9 @@
/*
 +-----------------------------------------------------------------------+
 | RoundCube Webmail Client Script                                       |
 | Roundcube Webmail Client Script                                       |
 |                                                                       |
 | This file is part of the RoundCube Webmail client                     |
 | Copyright (C) 2005-2010, RoundCube Dev, - Switzerland                 |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2005-2010, Roundcube Dev, - Switzerland                 |
 | Licensed under the GNU GPL                                            |
 |                                                                       |
 +-----------------------------------------------------------------------+
@@ -56,7 +56,7 @@
  $.ajaxSetup({
    cache:false,
    error:function(request, status, err){ ref.http_error(request, status, err); },
    beforeSend:function(xmlhttp){ xmlhttp.setRequestHeader('X-RoundCube-Request', ref.env.request_token); }
    beforeSend:function(xmlhttp){ xmlhttp.setRequestHeader('X-Roundcube-Request', ref.env.request_token); }
  });
  // set environment variable(s)
@@ -199,11 +199,13 @@
        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'];
        this.env.message_commands = ['show', 'reply', 'reply-all', 'reply-list', '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(this.env.message_commands, this.env.uid);
          this.enable_command('reply-list', this.env.list_post);
          if (this.env.next_uid) {
            this.enable_command('nextmessage', 'lastmessage', true);
@@ -225,17 +227,20 @@
          }
        }
        else if (this.env.action == 'compose') {
          this.enable_command('send-attachment', 'remove-attachment', 'send', 'toggle-editor', true);
          this.env.compose_commands = ['send-attachment', 'remove-attachment', 'send', 'toggle-editor'];
          if (this.env.drafts_mailbox)
            this.env.compose_commands.push('savedraft')
          this.enable_command(this.env.compose_commands, 'identities', true);
          if (this.env.spellcheck) {
            this.env.spellcheck.spelling_state_observer = function(s){ ref.set_spellcheck_state(s); };
            this.env.compose_commands.push('spellcheck')
            this.set_spellcheck_state('ready');
            if ($("input[name='_is_html']").val() == '1')
              this.display_spellcheck_controls(false);
          }
          if (this.env.drafts_mailbox)
            this.enable_command('savedraft', true);
          document.onmouseup = function(e){ return p.doc_mouse_up(e); };
@@ -301,10 +306,14 @@
        if (this.env.cid)
          this.enable_command('show', 'edit', true);
        if ((this.env.action=='add' || this.env.action=='edit') && this.gui_objects.editform)
        if ((this.env.action=='add' || this.env.action=='edit') && this.gui_objects.editform) {
          this.enable_command('save', true);
        else
          $("input[type='text']").first().select();
        }
        else if (this.gui_objects.qsearchbox) {
          this.enable_command('search', 'reset-search', 'moveto', true);
          $(this.gui_objects.qsearchbox).select();
        }
        if (this.contact_list && this.contact_list.rowcount > 0)
          this.enable_command('export', true);
@@ -421,8 +430,7 @@
    }
    // check input before leaving compose step
    if (this.task=='mail' && this.env.action=='compose'
        && (command == 'list' || command == 'mail' || command == 'addressbook' || command == 'settings')) {
    if (this.task=='mail' && this.env.action=='compose' && $.inArray(command, this.env.compose_commands)<0) {
      if (this.cmp_hash != this.compose_field_hash() && !confirm(this.get_label('notsentwarning')))
        return false;
    }
@@ -876,10 +884,19 @@
        break;
      case 'reply-all':
      case 'reply-list':
      case 'reply':
        var uid;
        if (uid = this.get_single_uid())
          this.goto_url('compose', '_reply_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)+(command=='reply-all' ? '&_all=1' : ''), true);
        if (uid = this.get_single_uid()) {
          var url = '_reply_uid='+uid+'&_mbox='+urlencode(this.env.mailbox);
          if (command == 'reply-all')
            // do reply-list, when list is detected and popup menu wasn't used
            url += '&_all=' + (!props && this.commands['reply-list'] ? 'list' : 'all');
          else if (command == 'reply-list')
            url += '&_all=list';
          this.goto_url('compose', url, true);
        }
        break;
      case 'forward':
@@ -970,11 +987,11 @@
        break;
      case 'identities':
        this.goto_url('identities');
        this.goto_url('settings/identities');
        break;
      case 'folders':
        this.goto_url('folders');
        this.goto_url('settings/folders');
        break;
      // unified command call (command name == function name)
@@ -1288,7 +1305,7 @@
      }
    }
    this.http_post('utils/save-pref', '_name=collapsed_folders&_value='+urlencode(this.env.collapsed_folders));
    this.http_post('save-pref', '_name=collapsed_folders&_value='+urlencode(this.env.collapsed_folders));
    this.set_unread_count_display(id, false);
  };
@@ -1360,9 +1377,16 @@
    var selected = list.get_single_selection() != null;
    this.enable_command(this.env.message_commands, selected);
    // Hide certain command buttons when Drafts folder is selected
    if (selected && this.env.mailbox == this.env.drafts_mailbox) {
      this.enable_command('reply', 'reply-all', 'forward', false);
    if (selected) {
      // Hide certain command buttons when Drafts folder is selected
      if (this.env.mailbox == this.env.drafts_mailbox)
        this.enable_command('reply', 'reply-all', 'reply-list', 'forward', false);
      // Disable reply-list when List-Post header is not set
      else {
        var msg = this.env.messages[list.get_single_selection()];
        if (!msg.ml)
          this.enable_command('reply-list', false);
      }
    }
    // Multi-message commands
    this.enable_command('delete', 'moveto', 'copy', 'mark', (list.selection.length > 0 ? true : false));
@@ -1459,7 +1483,7 @@
    if ((found = $.inArray('subject', this.env.coltypes)) >= 0)
      this.set_env('subject_col', found);
    this.http_post('utils/save-pref', { '_name':'list_cols', '_value':this.env.coltypes, '_session':'list_attrib/columns' });
    this.http_post('save-pref', { '_name':'list_cols', '_value':this.env.coltypes, '_session':'list_attrib/columns' });
  };
  this.check_droptarget = function(id)
@@ -1540,6 +1564,7 @@
      unread_children: flags.unread_children?flags.unread_children:0,
      parent_uid: flags.parent_uid?flags.parent_uid:0,
      selected: this.select_all_mode || this.message_list.in_selection(uid),
      ml: flags.ml?1:0,
      // flags from plugins
      flags: flags.extra_flags
    });
@@ -2743,9 +2768,8 @@
  this.init_address_input_events = function(obj)
  {
    var handler = function(e){ return ref.ksearch_keypress(e,this); };
    obj.bind((bw.safari || bw.ie ? 'keydown' : 'keypress'), handler);
    obj.attr('autocomplete', 'off');
    obj[bw.ie || bw.safari || bw.chrome ? 'keydown' : 'keypress'](function(e){ return ref.ksearch_keydown(e, this); })
      .attr('autocomplete', 'off');
  };
  // checks the input fields before sending a message
@@ -2938,8 +2962,10 @@
      sig_separator = this.env.sig_above && (this.env.compose_mode == 'reply' || this.env.compose_mode == 'forward') ? '---' : '-- ';
    // enable manual signature insert
    if (this.env.signatures && this.env.signatures[id])
    if (this.env.signatures && this.env.signatures[id]) {
      this.enable_command('insert-sig', true);
      this.env.compose_commands.push('insert-sig');
    }
    else
      this.enable_command('insert-sig', false);
@@ -3240,8 +3266,9 @@
  this.sent_successfully = function(type, msg)
  {
    this.list_mailbox();
    this.display_message(msg, type, true);
    // before redirect we need to wait some time for Chrome (#1486177)
    window.setTimeout(function(){ ref.list_mailbox(); }, 500);
  };
@@ -3250,7 +3277,7 @@
  /*********************************************************/
  // handler for keyboard events on address-fields
  this.ksearch_keypress = function(e, obj)
  this.ksearch_keydown = function(e, obj)
  {
    if (this.ksearch_timer)
      clearTimeout(this.ksearch_timer);
@@ -3627,7 +3654,6 @@
    }
  };
  this.delete_contacts = function()
  {
    // exit if no mailbox specified or if selection is empty
@@ -3717,7 +3743,6 @@
    this.enable_command('export', (this.contact_list.rowcount > 0));
  };
  this.group_create = function()
  {
@@ -3852,7 +3877,7 @@
    if (li && (link = li.firstChild) && link.tagName.toLowerCase() == 'a')
      link.innerHTML = prop.name;
    this.env.contactfolders[key].name = this.env.contactgroups[key].name = name;
    this.env.contactfolders[key].name = this.env.contactgroups[key].name = prop.name;
    this.triggerEvent('group_update', { id:prop.id, source:prop.source, name:prop.name, li:li[0] });
  };
@@ -5009,6 +5034,8 @@
        if (this.env.action == 'show') {
          // re-enable commands on move/delete error
          this.enable_command(this.env.message_commands, true);
          if (!this.env.list_post)
            this.enable_command('reply-list', false);
        }
        else if (this.task == 'addressbook') {
          this.triggerEvent('listupdate', { folder:this.env.source, rowcount:this.contact_list.rowcount });