thomascube
2006-09-24 3381d45ef674884897efddb1c87a0aa2b777214f
program/js/app.js
@@ -51,7 +51,7 @@
  // default environment vars
  this.env.keep_alive = 60;        // seconds
  this.env.request_timeout = 180;  // seconds
  this.env.draft_autosave = 300;   // seconds
  this.env.draft_autosave = 0;     // seconds
  // set environment variable
@@ -142,17 +142,20 @@
          if (this.gui_objects.remoteobjectsmsg)
            this.gui_objects.remoteobjectsmsg.style.display = 'block';
          this.enable_command('load-images', true);
          }
          }
        if (this.env.action=='compose')
          {
          this.enable_command('add-attachment', 'send-attachment', 'remove-attachment', 'send', true);
          if (this.env.spellcheck)
            this.enable_command('spellcheck', true);
            {
            this.env.spellcheck.spelling_state_observer = function(s){ rcube_webmail_client.set_spellcheck_state(s); };
            this.set_spellcheck_state('ready');
            }
          if (this.env.drafts_mailbox)
            this.enable_command('savedraft', true);
          }
        if (this.env.messagecount)
          this.enable_command('select-all', 'select-none', 'sort', 'expunge', true);
@@ -171,7 +174,7 @@
        // show printing dialog
        if (this.env.action=='print')
          window.print();
        // get unread count for each mailbox
        if (this.gui_objects.mailboxlist)
          this.http_request('getunread', '');
@@ -434,7 +437,7 @@
    var input_replyto = rcube_find_object('_replyto');
    var input_subject = rcube_find_object('_subject');
    var input_message = rcube_find_object('_message');
    // init live search events
    if (input_to)
      this.init_address_input_events(input_to);
@@ -453,7 +456,7 @@
      input_subject.focus();
    else if (input_message)
      this.set_caret2start(input_message); // input_message.focus();
    // get summary of all field values
    this.cmp_hash = this.compose_field_hash();
 
@@ -930,8 +933,11 @@
        break;
        
      case 'spellcheck':
        if (this.env.spellcheck && this.env.spellcheck.spellCheck)
        if (this.env.spellcheck && this.env.spellcheck.spellCheck && this.spellcheck_ready)
          {
          this.env.spellcheck.spellCheck(this.env.spellcheck.check_link);
          this.set_spellcheck_state('checking');
          }
        break;
      case 'savedraft':
@@ -942,7 +948,8 @@
          break;
        // if saving Drafts is disabled in main.inc.php
        if (!this.env.drafts_mailbox)
        // or if compose form did not change
        if (!this.env.drafts_mailbox || this.cmp_hash == this.compose_field_hash())
          break;
        this.set_busy(true, 'savingmessage');
@@ -2012,7 +2019,7 @@
      }
    // check for empty body
    if (input_message.value=='')
    if ((input_message.value=='')&&(tinyMCE.getContent()==''))
      {
      if (!confirm(this.get_label('nobodywarning')))
        {
@@ -2023,6 +2030,13 @@
    return true;
    };
  this.set_spellcheck_state = function(s)
    {
   this.spellcheck_ready = (s=='check_spelling' || s=='ready');
    this.enable_command('spellcheck', this.spellcheck_ready);
   };
  this.auto_save_start = function()
@@ -2065,35 +2079,67 @@
    var id = obj.options[obj.selectedIndex].value;
    var input_message = rcube_find_object('_message');
    var message = input_message ? input_message.value : '';
    var is_html = (rcube_find_object('_is_html').value == '1');
    var sig, p;
    if (!this.env.identity)
      this.env.identity = id
    // remove the 'old' signature
    if (this.env.identity && this.env.signatures && this.env.signatures[this.env.identity])
    if (!is_html)
      {
      sig = this.env.signatures[this.env.identity];
      if (sig.indexOf('--')!=0)
        sig = '--\n'+sig;
      p = message.lastIndexOf(sig);
      if (p>=0)
        message = message.substring(0, p-1) + message.substring(p+sig.length, message.length);
      // remove the 'old' signature
      if (this.env.identity && this.env.signatures && this.env.signatures[this.env.identity])
        {
        sig = this.env.signatures[this.env.identity]['text'];
        if (sig.indexOf('--')!=0)
          sig = '--\n'+sig;
        p = message.lastIndexOf(sig);
        if (p>=0)
          message = message.substring(0, p-1) + message.substring(p+sig.length, message.length);
        }
      // add the new signature string
      if (this.env.signatures && this.env.signatures[id])
        {
        sig = this.env.signatures[id]['text'];
        if (sig.indexOf('--')!=0)
          sig = '--\n'+sig;
        message += '\n'+sig;
        }
      }
    // add the new signature string
    if (this.env.signatures && this.env.signatures[id])
    else
      {
      sig = this.env.signatures[id];
      if (sig.indexOf('--')!=0)
        sig = '--\n'+sig;
      message += '\n'+sig;
        var eid = tinyMCE.getEditorId('_message');
        // editor is a TinyMCE_Control object
        var editor = tinyMCE.getInstanceById(eid);
        var msgDoc = editor.getDoc();
        var msgBody = msgDoc.body;
        if (this.env.signatures && this.env.signatures[id])
          {
          // Append the signature as a span within the body
          var sigElem = msgDoc.getElementById("_rc_sig");
          if (!sigElem)
            {
            sigElem = msgDoc.createElement("span");
            sigElem.setAttribute("id", "_rc_sig");
            msgBody.appendChild(sigElem);
            }
          if (this.env.signatures[id]['is_html'])
            {
            sigElem.innerHTML = this.env.signatures[id]['text'];
            }
          else
            {
            sigElem.innerHTML = '<pre>' + this.env.signatures[id]['text'] + '</pre>';
            }
          }
      }
    if (input_message)
      input_message.value = message;
    this.env.identity = id;
    return true;
    };
@@ -2783,7 +2829,7 @@
  this.reset_folder_rename = function()
    {
    var cell = this.name_input ? this.name_input.parentNode : null;
    if (cell && this.edit_folder)
    if (cell && this.edit_folder && this.env.subscriptionrows[this.edit_folder])
      cell.innerHTML = this.env.subscriptionrows[this.edit_folder][1];
      
    this.edit_folder = null;
@@ -3417,6 +3463,18 @@
    };
  this.toggle_editor = function(checkbox, textElementName)
    {
    var ischecked = checkbox.checked;
    if (ischecked)
      {
        tinyMCE.execCommand('mceAddControl', true, textElementName);
      }
    else
      {
        tinyMCE.execCommand('mceRemoveControl', true, textElementName);
      }
    }
  /********************************************************/
  /*********          drag & drop methods         *********/
@@ -3568,7 +3626,7 @@
      case 'expunge':
        this.enable_command('select-all', 'select-none', 'expunge', this.env.messagecount ? true : false);
        break;
        break;
      }
    request_obj.reset();
@@ -3806,7 +3864,7 @@
      }
    }
  // sedn GET request
  // send GET request
  this.GET = function(url)
    {
    this.build();
@@ -3827,9 +3885,28 @@
    };
  this.POST = function(url, a_param)
  this.POST = function(url, body, contentType)
    {
    // not implemented yet
    // default value for contentType if not provided
    contentType = typeof(contentType) != 'undefined' ?
       contentType : 'application/x-www-form-urlencoded';
    this.build();
    if (!this.xmlhttp)
    {
       this.onerror(this);
       return false;
    }
    var ref=this;
    this.url = url;
    this.busy = true;
    this.xmlhttp.onreadystatechange = function() { ref.xmlhttp_onreadystatechange(); };
    this.xmlhttp.open('POST', url, true);
    this.xmlhttp.setRequestHeader('Content-Type', contentType);
    this.xmlhttp.send(body);
    };
@@ -3886,6 +3963,12 @@
  }  // end class rcube_http_request
// helper function to call the init method with a delay
function call_init(o)
  {
  if (window[o] && window[o].init)
    setTimeout(o+'.init()', 200);
  }
function console(str)
  {
@@ -3893,10 +3976,3 @@
    document.debugform.console.value += str+'\n--------------------------------------\n';
  }
// set onload handler
window.onload = function(e)
  {
  if (window.rcube_webmail_client)
    rcube_webmail_client.init();
  };