thomascube
2011-09-21 d06e57fdf21879a4e93d6c00b939ca42094d3e86
program/js/app.js
@@ -86,7 +86,7 @@
    if (over) button_prop.over = over;
    this.buttons[command].push(button_prop);
    if (this.loaded)
      init_button(command, button_prop);
  };
@@ -155,7 +155,7 @@
    }
    // enable general commands
    this.enable_command('logout', 'mail', 'addressbook', 'settings', 'save-pref', 'undo', true);
    this.enable_command('logout', 'mail', 'addressbook', 'settings', 'save-pref', 'compose', 'undo', true);
    if (this.env.permaurl)
      this.enable_command('permaurl', true);
@@ -164,7 +164,7 @@
      case 'mail':
        // enable mail commands
        this.enable_command('list', 'checkmail', 'compose', 'add-contact', 'search', 'reset-search', 'collapse-folder', true);
        this.enable_command('list', 'checkmail', 'add-contact', 'search', 'reset-search', 'collapse-folder', true);
        if (this.gui_objects.messagelist) {
@@ -809,7 +809,7 @@
        break;
      case 'compose':
        var url = this.env.comm_path+'&_action=compose';
        var url = this.url('mail/compose');
        if (this.task == 'mail') {
          url += '&_mbox='+urlencode(this.env.mailbox);
@@ -1522,11 +1522,12 @@
  this.msglist_keypress = function(list)
  {
    if (list.modkey == CONTROL_KEY)
      return;
    if (list.key_pressed == list.ENTER_KEY)
      this.command('show');
    else if (list.key_pressed == list.DELETE_KEY)
      this.command('delete');
    else if (list.key_pressed == list.BACKSPACE_KEY)
    else if (list.key_pressed == list.DELETE_KEY || list.key_pressed == list.BACKSPACE_KEY)
      this.command('delete');
    else if (list.key_pressed == 33)
      this.command('previouspage');
@@ -1646,8 +1647,8 @@
    // merge flags over local message object
    $.extend(this.env.messages[uid], {
      deleted: flags.deleted?1:0,
      replied: flags.replied?1:0,
      unread: flags.unread?1:0,
      replied: flags.answered?1:0,
      unread: !flags.seen?1:0,
      forwarded: flags.forwarded?1:0,
      flagged: flags.flagged?1:0,
      has_children: flags.has_children?1:0,
@@ -1670,10 +1671,10 @@
      message = this.env.messages[uid],
      css_class = 'message'
        + (even ? ' even' : ' odd')
        + (flags.unread ? ' unread' : '')
        + (!flags.seen ? ' unread' : '')
        + (flags.deleted ? ' deleted' : '')
        + (flags.flagged ? ' flagged' : '')
        + (flags.unread_children && !flags.unread && !this.env.autoexpand_threads ? ' unroot' : '')
        + (flags.unread_children && flags.seen && !this.env.autoexpand_threads ? ' unroot' : '')
        + (message.selected ? ' selected' : ''),
      // for performance use DOM instead of jQuery here
      row = document.createElement('tr'),
@@ -1688,12 +1689,12 @@
      css_class += ' status';
      if (flags.deleted)
        css_class += ' deleted';
      else if (flags.unread)
      else if (!flags.seen)
        css_class += ' unread';
      else if (flags.unread_children > 0)
        css_class += ' unreadchildren';
    }
    if (flags.replied)
    if (flags.answered)
      css_class += ' replied';
    if (flags.forwarded)
      css_class += ' forwarded';
@@ -1761,7 +1762,7 @@
      else if (c == 'status') {
        if (flags.deleted)
          css_class = 'deleted';
        else if (flags.unread)
        else if (!flags.seen)
          css_class = 'unread';
        else if (flags.unread_children > 0)
          css_class = 'unreadchildren';
@@ -2055,8 +2056,7 @@
      new_row = tbody.firstChild;
    while (new_row) {
      if (new_row.nodeType == 1 && (r = this.message_list.rows[new_row.uid])
       && r.unread_children) {
      if (new_row.nodeType == 1 && (r = this.message_list.rows[new_row.uid]) && r.unread_children) {
       this.message_list.expand_all(r);
       this.set_unread_children(r.uid);
      }
@@ -2496,7 +2496,7 @@
    // if there is a trash mailbox defined and we're not currently in it
    else {
      // if shift was pressed delete it immediately
      if (list && list.shiftkey) {
      if (list && list.modkey == SHIFT_KEY) {
        if (confirm(this.get_label('deletemessagesconfirm')))
          this.permanently_remove_messages();
      }
@@ -3156,7 +3156,7 @@
        sig = this.env.signatures[sig].is_html ? this.env.signatures[sig].plain_text : this.env.signatures[sig].text;
        sig = sig.replace(/\r\n/g, '\n');
        if (!sig.match(/^--[ -]\n/))
        if (!sig.match(/^--[ -]\n/m))
          sig = sig_separator + '\n' + sig;
        p = this.env.sig_above ? message.indexOf(sig) : message.lastIndexOf(sig);
@@ -3168,7 +3168,7 @@
        sig = this.env.signatures[id]['is_html'] ? this.env.signatures[id]['plain_text'] : this.env.signatures[id]['text'];
        sig = sig.replace(/\r\n/g, '\n');
        if (!sig.match(/^--[ -]\n/))
        if (!sig.match(/^--[ -]\n/m))
          sig = sig_separator + '\n' + sig;
        if (this.env.sig_above) {
@@ -3237,12 +3237,12 @@
      if (this.env.signatures[id]) {
        if (this.env.signatures[id].is_html) {
          sig = this.env.signatures[id].text;
          if (!this.env.signatures[id].plain_text.match(/^--[ -]\r?\n/))
          if (!this.env.signatures[id].plain_text.match(/^--[ -]\r?\n/m))
            sig = sig_separator + '<br />' + sig;
        }
        else {
          sig = this.env.signatures[id].text;
          if (!sig.match(/^--[ -]\r?\n/))
          if (!sig.match(/^--[ -]\r?\n/m))
            sig = sig_separator + '\n' + sig;
          sig = '<pre>' + sig + '</pre>';
        }
@@ -3495,13 +3495,15 @@
        return rcube_event.cancel(e);
      case 9:  // tab
        if (mod == SHIFT_KEY)
          break;
      case 9:   // tab
        if (mod == SHIFT_KEY || !this.ksearch_visible()) {
          this.ksearch_hide();
          return;
        }
      case 13:  // enter
        if (this.ksearch_selected === null || !this.ksearch_value)
          break;
        if (!this.ksearch_visible())
          return false;
        // insert selected address and hide ksearch pane
        this.insert_recipient(this.ksearch_selected);
@@ -3526,6 +3528,11 @@
    return true;
  };
  this.ksearch_visible = function()
  {
    return (this.ksearch_selected !== null && this.ksearch_selected !== undefined && this.ksearch_value);
  };
  this.ksearch_select = function(node)
  {
    var current = $('#rcmksearchSelected');
@@ -3541,7 +3548,7 @@
  this.insert_recipient = function(id)
  {
    if (!this.env.contacts[id] || !this.ksearch_input)
    if (id === null || !this.env.contacts[id] || !this.ksearch_input)
      return;
    // get cursor pos
@@ -3613,19 +3620,15 @@
      return;
    if (q.length && q.length < min) {
      if (!this.env.acinfo) {
        this.env.acinfo = this.display_message(
      if (!this.ksearch_info) {
        this.ksearch_info = this.display_message(
          this.get_label('autocompletechars').replace('$min', min));
      }
      return;
    }
    else if (this.env.acinfo) {
      this.hide_message(this.env.acinfo);
    }
    var old_value = this.ksearch_value;
    this.ksearch_value = q;
    this.ksearch_destroy();
    // ...string is empty
@@ -3723,16 +3726,20 @@
      this.env.contacts = this.env.contacts.concat(results);
    // run next parallel search
    if (maxlen > 0 && this.ksearch_data.id == reqid && this.ksearch_data.sources.length) {
      var lock, xhr, props = this.ksearch_data, source = props.sources.shift();
      if (source) {
        lock = this.display_message(this.get_label('searching'), 'loading');
        xhr = this.http_post(props.action, '_search='+urlencode(s_val)+'&_id='+reqid
          +'&_source='+urlencode(source), lock);
    if (this.ksearch_data.id == reqid) {
      if (maxlen > 0 && this.ksearch_data.sources.length) {
        var lock, xhr, props = this.ksearch_data, source = props.sources.shift();
        if (source) {
          lock = this.display_message(this.get_label('searching'), 'loading');
          xhr = this.http_post(props.action, '_search='+urlencode(s_val)+'&_id='+reqid
            +'&_source='+urlencode(source), lock);
        this.ksearch_data.locks.push(lock);
        this.ksearch_data.requests.push(xhr);
          this.ksearch_data.locks.push(lock);
          this.ksearch_data.requests.push(xhr);
        }
      }
      else if (!maxlen && !this.ksearch_msg)
        this.ksearch_msg = this.display_message(this.get_label('autocompletemore'));
    }
  };
@@ -3776,7 +3783,15 @@
    for (i=0, len=ac.locks.length; i<len; i++)
      this.abort_request({request: ac.requests[i], lock: ac.locks[i]});
    if (this.ksearch_info)
      this.hide_message(this.ksearch_info);
    if (this.ksearch_msg)
      this.hide_message(this.ksearch_msg);
    this.ksearch_data = null;
    this.ksearch_info = null;
    this.ksearch_msg = null;
  }
  /*********************************************************/
@@ -3979,7 +3994,8 @@
  {
    // exit if no mailbox specified or if selection is empty
    var selection = this.contact_list.get_selection();
    if (!(selection.length || this.env.cid) || !confirm(this.get_label('deletecontactconfirm')))
    var undelete = this.env.address_sources[this.env.source].undelete;
    if (!(selection.length || this.env.cid) || (!undelete && !confirm(this.get_label('deletecontactconfirm'))))
      return;
    var id, n, a_cids = [], qs = '';
@@ -5686,7 +5702,7 @@
    var base = this.env.comm_path;
    // overwrite task name
    if (query._action.match(/([a-z]+)\/([a-z-_.]+)/)) {
    if (query._action.match(/([a-z]+)\/([a-z0-9-_.]+)/)) {
      query._action = RegExp.$2;
      base = base.replace(/\_task=[a-z]+/, '_task='+RegExp.$1);
    }
@@ -6120,7 +6136,7 @@
{
  if (!elem.title) {
    var $elem = $(elem),
      txt = $elem.text(),
      txt = $.trim($elem.text()),
      tmp = $('<span>').text(txt)
        .css({'position': 'absolute', 'float': 'left', 'visibility': 'hidden',
          'font-size': $elem.css('font-size'), 'font-weight': $elem.css('font-weight')})