alecpl
2009-05-10 4769ead5e8fa2cbee61ac6675d499cb16d7ffb7c
program/js/app.js
@@ -472,7 +472,7 @@
    else if (input_subject.val() == '')
      input_subject.focus();
    else if (input_message)
      this.set_caret2start(input_message);
      input_message.focus();
    // get summary of all field values
    this.compose_field_hash(true);
@@ -596,23 +596,13 @@
      case 'sort':
        // get the type of sorting
        var a_sort = props.split('_');
        var sort_col = a_sort[0];
        var sort_order = a_sort[1] ? a_sort[1].toUpperCase() : null;
        var sort_order, sort_col = props;
        // no sort order specified: toggle
        if (sort_order==null)
          {
          if (this.env.sort_col==sort_col)
            sort_order = this.env.sort_order=='ASC' ? 'DESC' : 'ASC';
          else
            sort_order = this.env.sort_order;
          }
        if (this.env.sort_col==sort_col && this.env.sort_order==sort_order)
          break;
        if (this.env.sort_col==sort_col)
          sort_order = this.env.sort_order=='ASC' ? 'DESC' : 'ASC';
        else
     sort_order = 'ASC';
        // set table header class
        $('#rcm'+this.env.sort_col).removeClass('sorted'+(this.env.sort_order.toUpperCase()));
        $('#rcm'+sort_col).addClass('sorted'+sort_order);
@@ -912,7 +902,7 @@
          tinyMCE.execCommand('mceSpellCheck', true);
        }
        else if (this.env.spellcheck && this.env.spellcheck.spellCheck && this.spellcheck_ready) {
          this.env.spellcheck.spellCheck(this.env.spellcheck.check_link);
          this.env.spellcheck.spellCheck();
          this.set_spellcheck_state('checking');
        }
        break;
@@ -2123,7 +2113,7 @@
  this.stop_spellchecking = function()
    {
    if (this.env.spellcheck && !this.spellcheck_ready) {
      exec_event(this.env.spellcheck.check_link, 'click');
      $(this.env.spellcheck.spell_span).trigger('click');
      this.set_spellcheck_state('ready');
      }
    };
@@ -2134,15 +2124,14 @@
      // stop spellchecking process
      if (!vis)
   this.stop_spellchecking();
      this.env.spellcheck.check_link.style.visibility = vis ? 'visible' : 'hidden';
      this.env.spellcheck.switch_lan_pic.style.visibility = vis ? 'visible' : 'hidden';
      $(this.env.spellcheck.spell_container).css('visibility', vis ? 'visible' : 'hidden');
      }
    };
  this.set_spellcheck_state = function(s)
    {
    this.spellcheck_ready = (s=='check_spelling' || s=='ready');
    this.spellcheck_ready = (s == 'ready' || s == 'no_error_found');
    this.enable_command('spellcheck', this.spellcheck_ready);
    };
@@ -2199,7 +2188,7 @@
    var input_message = $("[name='_message']");
    var message = input_message.val();
    var is_html = ($("input[name='_is_html']").val() == '1');
    var sig, p;
    var sig, p, len;
    if (!this.env.identity)
      this.env.identity = id
@@ -2223,7 +2212,8 @@
        }
      message = message.replace(/[\r\n]+$/, '');
      len = message.length;
      // add the new signature string
      if (this.env.signatures && this.env.signatures[id])
        {
@@ -2235,6 +2225,7 @@
        if (sig.indexOf('-- ')!=0)
          sig = '-- \n'+sig;
        message += '\n\n'+sig;
   if (len) len += 1;
        }
      }
    else
@@ -2280,6 +2271,10 @@
      }
    input_message.val(message);
    // move cursor before the signature
    if (!is_html)
      this.set_caret_pos(input_message.get(0), len);
    this.env.identity = id;
    return true;
@@ -2403,19 +2398,26 @@
    };
  // send remote request to search mail or contacts
  this.qsearch = function(value, addurl)
  this.qsearch = function(value)
    {
    if (value != '')
      {
      if (this.message_list)
      var addurl = '';
      if (this.message_list) {
        this.message_list.clear();
      else if (this.contact_list) {
   if (this.env.search_mods) {
          var head_arr = new Array();
          for (var n in this.env.search_mods)
       head_arr.push(n);
     addurl += '&_headers='+head_arr.join(',');
          }
        } else if (this.contact_list) {
        this.contact_list.clear(true);
        this.show_contentframe(false);
        }
      if (this.gui_objects.search_filter)
      addurl = '&_filter=' + this.gui_objects.search_filter.value;
        addurl += '&_filter=' + this.gui_objects.search_filter.value;
      // reset vars
      this.env.current_page = 1;
@@ -3459,6 +3461,9 @@
      if ((target_li = this.get_folder_li(name))) {
        $(target_li).removeClass('unfocused').addClass('selected');
      }
      // trigger event hook
      this.triggerEvent('selectfolder', { folder:name, old:old });
    }
  };
@@ -3531,7 +3536,7 @@
        + (flags.unread ? ' unread' : '')
        + (flags.deleted ? ' deleted' : '')
        + (flags.flagged ? ' flagged' : '')
   + (this.message_list.in_selection(uid) ? ' selected' : '');
        + (this.message_list.in_selection(uid) ? ' selected' : '');
    // for performance use DOM instead of jQuery here
    var row = document.createElement('TR');
@@ -3580,6 +3585,7 @@
      }
    this.message_list.insert_row(row, attop);
    this.triggerEvent('insertrow', { uid:uid, row:row });
    // remove 'old' row
    if (attop && this.env.pagesize && this.message_list.rowcount > this.env.pagesize) {
@@ -3722,6 +3728,8 @@
    }
    
    this.contact_list.insert_row(row);
    this.triggerEvent('insertrow', { cid:cid, row:row });
    this.enable_command('export', (this.contact_list.rowcount > 0));
    };
@@ -3912,9 +3920,16 @@
            this.msglist_select(this.message_list);
          this.enable_command('show', 'expunge', 'select-all', 'select-none', 'sort', (this.env.messagecount > 0));
          this.enable_command('purge', this.purge_mailbox_test());
          if (response.action == 'list')
            this.triggerEvent('listupdate', { folder:this.env.mailbox, rowcount:this.message_list.rowcount });
        }
        else if (this.task == 'addressbook')
        else if (this.task == 'addressbook') {
          this.enable_command('export', (this.contact_list && this.contact_list.rowcount > 0));
          if (response.action == 'list')
            this.triggerEvent('listupdate', { folder:this.env.source, rowcount:this.contact_list.rowcount });
        }
        break;
    }
  };
@@ -4002,19 +4017,19 @@
      return obj.value.length;
    };
  this.set_caret2start = function(obj)
  this.set_caret_pos = function(obj, pos)
    {
    if (obj.createTextRange)
    if (obj.setSelectionRange)
      obj.setSelectionRange(pos, pos);
    else if (obj.createTextRange)
      {
      var range = obj.createTextRange();
      range.collapse(true);
      range.moveEnd('character', pos);
      range.moveStart('character', pos);
      range.select();
      }
    else if (obj.setSelectionRange)
      obj.setSelectionRange(0,0);
    obj.focus();
    };
    }
  // set all fields of a form disabled
  this.lock_form = function(form, lock)