Changeset 2461 in subversion


Ignore:
Timestamp:
May 9, 2009 3:52:29 AM (4 years ago)
Author:
alec
Message:
  • Correct caret position in message form with signature (#1485833)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/js/app.js

    r2446 r2461  
    473473      input_subject.focus(); 
    474474    else if (input_message) 
    475       this.set_caret2start(input_message); 
     475      input_message.focus(); 
    476476 
    477477    // get summary of all field values 
     
    21892189    var message = input_message.val(); 
    21902190    var is_html = ($("input[name='_is_html']").val() == '1'); 
    2191     var sig, p; 
     2191    var sig, p, len; 
    21922192 
    21932193    if (!this.env.identity) 
     
    22132213 
    22142214      message = message.replace(/[\r\n]+$/, ''); 
    2215        
     2215      len = message.length; 
     2216 
    22162217      // add the new signature string 
    22172218      if (this.env.signatures && this.env.signatures[id]) 
     
    22252226          sig = '-- \n'+sig; 
    22262227        message += '\n\n'+sig; 
     2228        if (len) len += 1; 
    22272229        } 
    22282230      } 
     
    22702272 
    22712273    input_message.val(message); 
     2274 
     2275    // move cursor before the signature 
     2276    if (!is_html) 
     2277      this.set_caret_pos(input_message.get(0), len); 
    22722278 
    22732279    this.env.identity = id; 
     
    40124018    }; 
    40134019 
    4014   this.set_caret2start = function(obj) 
    4015     { 
    4016     if (obj.createTextRange) 
     4020  this.set_caret_pos = function(obj, pos) 
     4021    { 
     4022    if (obj.setSelectionRange) 
     4023      obj.setSelectionRange(pos, pos); 
     4024    else if (obj.createTextRange) 
    40174025      { 
    40184026      var range = obj.createTextRange(); 
    40194027      range.collapse(true); 
     4028      range.moveEnd('character', pos); 
     4029      range.moveStart('character', pos); 
    40204030      range.select(); 
    40214031      } 
    4022     else if (obj.setSelectionRange) 
    4023       obj.setSelectionRange(0,0); 
    4024  
    4025     obj.focus(); 
    4026     }; 
     4032    } 
    40274033 
    40284034  // set all fields of a form disabled 
Note: See TracChangeset for help on using the changeset viewer.