Changeset da5cadc in github


Ignore:
Timestamp:
Apr 22, 2012 1:15:39 PM (14 months ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo
Children:
390959b
Parents:
55dce68
Message:
  • Fix issue where draft auto-save wasn't executed after some inactivity time
  • Code improvement - unified (set|clear)Timeout() usage
File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/js/app.js

    r5a79416 rda5cadc  
    273273        else if (this.env.action == 'print' && this.env.uid) 
    274274          if (bw.safari) 
    275             window.setTimeout('window.print()', 10); 
     275            setTimeout('window.print()', 10); 
    276276          else 
    277277            window.print(); 
     
    772772        if (this.env.uid && this.env.sender) { 
    773773          this.add_contact(urlencode(this.env.sender)); 
    774           window.setTimeout(function(){ ref.command('load-images'); }, 300); 
     774          setTimeout(function(){ ref.command('load-images'); }, 300); 
    775775          break; 
    776776        } 
     
    790790          this.attachment_win = window.open(this.env.comm_path+'&_action=get&'+qstring+'&_frame=1', 'rcubemailattachment'); 
    791791          if (this.attachment_win) { 
    792             window.setTimeout(function(){ ref.attachment_win.focus(); }, 10); 
     792            setTimeout(function(){ ref.attachment_win.focus(); }, 10); 
    793793            break; 
    794794          } 
     
    913913 
    914914      case 'savedraft': 
     915        var form = this.gui_objects.messageform, msgid; 
     916 
    915917        // Reset the auto-save timer 
    916         self.clearTimeout(this.save_timer); 
    917  
    918         if (!this.gui_objects.messageform) 
     918        clearTimeout(this.save_timer); 
     919 
     920        // saving Drafts is disabled 
     921        if (!form) 
    919922          break; 
    920923 
    921         // if saving Drafts is disabled in main.inc.php 
    922         // or if compose form did not change 
    923         if (!this.env.drafts_mailbox || this.cmp_hash == this.compose_field_hash()) 
     924        // compose form did not change 
     925        if (this.cmp_hash == this.compose_field_hash()) { 
     926          this.auto_save_start(); 
    924927          break; 
    925  
    926         var form = this.gui_objects.messageform, 
    927           msgid = this.set_busy(true, 'savingmessage'); 
     928        } 
     929 
     930        // re-set keep-alive timeout 
     931        this.start_keepalive(); 
     932 
     933        msgid = this.set_busy(true, 'savingmessage'); 
    928934 
    929935        form.target = "savetarget"; 
     
    941947 
    942948        // Reset the auto-save timer 
    943         self.clearTimeout(this.save_timer); 
     949        clearTimeout(this.save_timer); 
    944950 
    945951        // all checks passed, send message 
     
    960966      case 'send-attachment': 
    961967        // Reset the auto-save timer 
    962         self.clearTimeout(this.save_timer); 
     968        clearTimeout(this.save_timer); 
    963969 
    964970        this.upload_file(props || this.gui_objects.uploadform); 
     
    10071013          ref.printwin = window.open(this.env.comm_path+'&_action=print&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)+(this.env.safemode ? '&_safe=1' : '')); 
    10081014          if (this.printwin) { 
    1009             window.setTimeout(function(){ ref.printwin.focus(); }, 20); 
     1015            setTimeout(function(){ ref.printwin.focus(); }, 20); 
    10101016            if (this.env.action != 'show') 
    10111017              this.mark_message('read', uid); 
     
    10181024          ref.sourcewin = window.open(this.env.comm_path+'&_action=viewsource&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)); 
    10191025          if (this.sourcewin) 
    1020             window.setTimeout(function(){ ref.sourcewin.focus(); }, 20); 
     1026            setTimeout(function(){ ref.sourcewin.focus(); }, 20); 
    10211027          } 
    10221028        break; 
     
    11631169    // set timer for requests 
    11641170    if (a && this.env.request_timeout) 
    1165       this.request_timer = window.setTimeout(function(){ ref.request_timed_out(); }, this.env.request_timeout * 1000); 
     1171      this.request_timer = setTimeout(function(){ ref.request_timed_out(); }, this.env.request_timeout * 1000); 
    11661172 
    11671173    return id; 
     
    12151221      parent.rcmail.reload(delay); 
    12161222    else if (delay) 
    1217       window.setTimeout(function(){ rcmail.reload(); }, delay); 
     1223      setTimeout(function(){ rcmail.reload(); }, delay); 
    12181224    else if (window.location) 
    12191225      location.href = this.env.comm_path + (this.env.action ? '&_action='+this.env.action : ''); 
     
    13481354 
    13491355    if (this.folder_auto_timer) { 
    1350       window.clearTimeout(this.folder_auto_timer); 
     1356      clearTimeout(this.folder_auto_timer); 
    13511357      this.folder_auto_timer = null; 
    13521358      this.folder_auto_expand = null; 
     
    14011407            if (div.hasClass('collapsed')) { 
    14021408              if (this.folder_auto_timer) 
    1403                 window.clearTimeout(this.folder_auto_timer); 
     1409                clearTimeout(this.folder_auto_timer); 
    14041410 
    14051411              this.folder_auto_expand = this.env.mailboxes[k].id; 
    1406               this.folder_auto_timer = window.setTimeout(function() { 
     1412              this.folder_auto_timer = setTimeout(function() { 
    14071413                rcmail.command('collapse-folder', rcmail.folder_auto_expand); 
    14081414                rcmail.drag_start(null); 
    14091415              }, 1000); 
    14101416            } else if (this.folder_auto_timer) { 
    1411               window.clearTimeout(this.folder_auto_timer); 
     1417              clearTimeout(this.folder_auto_timer); 
    14121418              this.folder_auto_timer = null; 
    14131419              this.folder_auto_expand = null; 
     
    15611567    // start timer for message preview (wait for double click) 
    15621568    if (selected && this.env.contentframe && !list.multi_selecting && !this.dummy_select) 
    1563       this.preview_timer = window.setTimeout(function(){ ref.msglist_get_preview(); }, 200); 
     1569      this.preview_timer = setTimeout(function(){ ref.msglist_get_preview(); }, 200); 
    15641570    else if (this.env.contentframe) 
    15651571      this.show_contentframe(false); 
     
    15781584        if (this.preview_read_timer) 
    15791585          clearTimeout(this.preview_read_timer); 
    1580         this.preview_timer = window.setTimeout(function(){ ref.msglist_get_preview(); }, 200); 
     1586        this.preview_timer = setTimeout(function(){ ref.msglist_get_preview(); }, 200); 
    15811587      } 
    15821588    } 
     
    19641970      // mark as read and change mbox unread counter 
    19651971      if (action == 'preview' && this.message_list && this.message_list.rows[id] && this.message_list.rows[id].unread && this.env.preview_pane_mark_read >= 0) { 
    1966         this.preview_read_timer = window.setTimeout(function() { 
     1972        this.preview_read_timer = setTimeout(function() { 
    19671973          ref.set_message(id, 'unread', false); 
    19681974          ref.update_thread_root(id, 'read'); 
     
    31533159 
    31543160      if (this.env.default_font) 
    3155         window.setTimeout(function() { 
     3161        setTimeout(function() { 
    31563162          $(tinyMCE.get(props.id).getBody()).css('font-family', rcmail.env.default_font); 
    31573163        }, 500); 
     
    32523258  { 
    32533259    if (this.env.draft_autosave) 
    3254       this.save_timer = self.setTimeout(function(){ ref.command("savedraft"); }, this.env.draft_autosave * 1000); 
     3260      this.save_timer = setTimeout(function(){ ref.command("savedraft"); }, this.env.draft_autosave * 1000); 
    32553261 
    32563262    // Unlock interface now that saving is complete 
     
    35373543  this.upload_progress_start = function(action, name) 
    35383544  { 
    3539     window.setTimeout(function() { rcmail.http_request(action, {_progress: name}); }, 
     3545    setTimeout(function() { rcmail.http_request(action, {_progress: name}); }, 
    35403546      this.env.upload_progress_time * 1000); 
    35413547  }; 
     
    36423648    this.display_message(msg, type); 
    36433649    // before redirect we need to wait some time for Chrome (#1486177) 
    3644     window.setTimeout(function(){ ref.list_mailbox(); }, 500); 
     3650    setTimeout(function(){ ref.list_mailbox(); }, 500); 
    36453651  }; 
    36463652 
     
    37003706      case 39:  // right 
    37013707        if (mod != SHIFT_KEY) 
    3702               return; 
     3708          return; 
    37033709    } 
    37043710 
    37053711    // start timer 
    3706     this.ksearch_timer = window.setTimeout(function(){ ref.ksearch_get_results(props); }, 200); 
     3712    this.ksearch_timer = setTimeout(function(){ ref.ksearch_get_results(props); }, 200); 
    37073713    this.ksearch_input = obj; 
    37083714 
     
    40124018 
    40134019    if (id = list.get_single_selection()) 
    4014       this.preview_timer = window.setTimeout(function(){ ref.load_contact(id, 'show'); }, 200); 
     4020      this.preview_timer = setTimeout(function(){ ref.load_contact(id, 'show'); }, 200); 
    40154021    else if (this.env.contentframe) 
    40164022      this.show_contentframe(false); 
     
    55545560      // add element and set timeout 
    55555561      this.messages[key].elements.push(id); 
    5556       window.setTimeout(function() { ref.hide_message(id, type == 'loading'); }, timeout); 
     5562      setTimeout(function() { ref.hide_message(id, type == 'loading'); }, timeout); 
    55575563      return id; 
    55585564    } 
     
    55745580 
    55755581    if (timeout > 0) 
    5576       window.setTimeout(function() { ref.hide_message(id, type == 'loading'); }, timeout); 
     5582      setTimeout(function() { ref.hide_message(id, type == 'loading'); }, timeout); 
    55775583    return id; 
    55785584  }; 
Note: See TracChangeset for help on using the changeset viewer.