Changeset 1848 in subversion


Ignore:
Timestamp:
Sep 19, 2008 12:14:10 PM (5 years ago)
Author:
alec
Message:
  • added set_message, set_message_icon and set_message_status functions
  • icon setting more unified + some small fixes/typos
  • get rid of *_from_preview() functions (Thomas, don't be mad, it was truly tested ;))
Location:
trunk/roundcubemail/program
Files:
3 edited

Legend:

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

    r1822 r1848  
    759759          { 
    760760          uid = props._row.uid; 
    761           this.message_list.dont_select = true; 
    762761          // toggle flagged/unflagged 
    763762          if (this.message_list.rows[uid].flagged) 
     
    13461345  /*********************************************************/ 
    13471346 
    1348  
    13491347  // when user doble-clicks on a row 
    13501348  this.show_message = function(id, safe, preview) 
     
    15411539  }; 
    15421540 
     1541  // set message icon 
     1542  this.set_message_icon = function(uid) 
     1543  { 
     1544    var icn_src; 
     1545    var rows = this.message_list.rows; 
     1546 
     1547    if (!rows[uid]) 
     1548      return false; 
     1549 
     1550    if (rows[uid].deleted && this.env.deletedicon) 
     1551      icn_src = this.env.deletedicon; 
     1552    else if (rows[uid].replied && this.env.repliedicon) 
     1553      { 
     1554      if (rows[uid].forwarded && this.env.forwardedrepliedicon) 
     1555        icn_src = this.env.forwardedrepliedicon; 
     1556      else 
     1557        icn_src = this.env.repliedicon; 
     1558      } 
     1559    else if (rows[uid].forwarded && this.env.forwardedicon) 
     1560      icn_src = this.env.forwardedicon; 
     1561    else if (rows[uid].unread && this.env.unreadicon) 
     1562      icn_src = this.env.unreadicon; 
     1563    else if (this.env.messageicon) 
     1564      icn_src = this.env.messageicon; 
     1565       
     1566    if (icn_src && rows[uid].icon) 
     1567      rows[uid].icon.src = icn_src; 
     1568 
     1569    icn_src = ''; 
     1570     
     1571    if (rows[uid].flagged && this.env.flaggedicon) 
     1572      icn_src = this.env.flaggedicon; 
     1573    else if (this.env.unflaggedicon) 
     1574      icn_src = this.env.unflaggedicon; 
     1575 
     1576    if (rows[uid].flagged_icon && icn_src) 
     1577      rows[uid].flagged_icon.src = icn_src; 
     1578  } 
     1579 
     1580  // set message status 
     1581  this.set_message_status = function(uid, flag, status) 
     1582    { 
     1583    var rows = this.message_list.rows; 
     1584 
     1585    if (!rows[uid]) return false; 
     1586 
     1587    if (flag == 'unread') 
     1588      rows[uid].unread = status; 
     1589    else if(flag == 'deleted') 
     1590      rows[uid].deleted = status; 
     1591    else if (flag == 'replied') 
     1592      rows[uid].replied = status; 
     1593    else if (flag == 'forwarded') 
     1594      rows[uid].forwarded = status; 
     1595    else if (flag == 'flagged') 
     1596      rows[uid].flagged = status; 
     1597    } 
     1598 
     1599  // set message row status, class and icon 
     1600  this.set_message = function(uid, flag, status) 
     1601    { 
     1602    var rows = this.message_list.rows; 
     1603 
     1604    if (!rows[uid]) return false; 
     1605     
     1606    if (flag) 
     1607      this.set_message_status(uid, flag, status); 
     1608     
     1609    if (rows[uid].unread && rows[uid].classname.indexOf('unread')<0) 
     1610      { 
     1611      rows[uid].classname += ' unread'; 
     1612      this.set_classname(rows[uid].obj, 'unread', true); 
     1613      } 
     1614    else if (!rows[uid].unread && rows[uid].classname.indexOf('unread')>=0) 
     1615      { 
     1616      rows[uid].classname = rows[uid].classname.replace(/\s*unread/, ''); 
     1617      this.set_classname(rows[uid].obj, 'unread', false); 
     1618      } 
     1619     
     1620    if (rows[uid].deleted && rows[uid].classname.indexOf('deleted')<0) 
     1621      { 
     1622      rows[uid].classname += ' deleted'; 
     1623      this.set_classname(rows[uid].obj, 'deleted', true); 
     1624      } 
     1625    else if (!rows[uid].deleted && rows[uid].classname.indexOf('deleted')>=0) 
     1626      { 
     1627      rows[uid].classname = rows[uid].classname.replace(/\s*deleted/, ''); 
     1628      this.set_classname(rows[uid].obj, 'deleted', false); 
     1629      } 
     1630 
     1631    this.set_message_icon(uid); 
     1632    } 
    15431633 
    15441634  // move selected messages to the specified mailbox 
     
    16401730        { 
    16411731          rows[id].deleted = true; 
    1642          
    1643           if (rows[id].classname.indexOf('deleted')<0) 
    1644           { 
    1645             rows[id].classname += ' deleted'; 
    1646             this.set_classname(rows[id].obj, 'deleted', true); 
    1647           } 
    16481732          if (this.env.read_when_deleted) 
    1649           { 
    1650             rows[id].classname = rows[id].classname.replace(/\s*unread/, ''); 
    1651             this.set_classname(rows[id].obj, 'unread', false); 
    1652           } 
    1653          
    1654           if (rows[id].icon && this.env.deletedicon) 
    1655             rows[id].icon.src = this.env.deletedicon; 
     1733            rows[id].unread = false; 
     1734          this.set_message(id); 
    16561735        } 
    16571736      } 
     
    17281807  { 
    17291808    // mark all message rows as read/unread 
    1730     var icn_src; 
    1731     var rows = this.message_list.rows; 
    17321809    for (var i=0; i<a_uids.length; i++) 
    1733       { 
    1734       uid = a_uids[i]; 
    1735       if (rows[uid]) 
    1736         { 
    1737         rows[uid].unread = (flag=='unread' ? true : false); 
    1738          
    1739         if (rows[uid].classname.indexOf('unread')<0 && rows[uid].unread) 
    1740           { 
    1741           rows[uid].classname += ' unread'; 
    1742           this.set_classname(rows[uid].obj, 'unread', true); 
    1743  
    1744           if (this.env.unreadicon) 
    1745             icn_src = this.env.unreadicon; 
    1746           } 
    1747         else if (!rows[uid].unread) 
    1748           { 
    1749           rows[uid].classname = rows[uid].classname.replace(/\s*unread/, ''); 
    1750           this.set_classname(rows[uid].obj, 'unread', false); 
    1751  
    1752           if (this.env.messageicon) 
    1753             icn_src = this.env.messageicon; 
    1754           } 
    1755  
    1756         if (rows[uid].icon && icn_src  
    1757             && !(rows[uid].replied && this.env.repliedicon) 
    1758             && !(rows[uid].forwarded && this.env.forwardedicon) 
    1759             && !(rows[uid].deleted && this.env.deletedicon)) 
    1760           rows[uid].icon.src = icn_src; 
    1761         } 
    1762       } 
     1810      this.set_message(a_uids[i], 'unread', (flag=='unread' ? true : false)); 
    17631811 
    17641812    this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag='+flag); 
    17651813  }; 
    17661814 
    1767   // set class to read/unread 
    1768   this.mark_as_read_from_preview = function(uid) 
    1769   { 
    1770     var icn_src; 
    1771     var rows = parent.rcmail.message_list.rows; 
    1772     if(rows[uid].unread) 
    1773       { 
    1774         rows[uid].unread = false; 
    1775         rows[uid].classname = rows[uid].classname.replace(/\s*unread/, ''); 
    1776         parent.rcmail.set_classname(rows[uid].obj, 'unread', false); 
    1777  
    1778         if (rows[uid].deleted && parent.rcmail.env.deletedicon) 
    1779           icn_src = parent.rcmail.env.deletedicon; 
    1780         else if (rows[uid].replied && parent.rcmail.env.repliedicon) 
    1781           { 
    1782           if (rows[uid].forwarded && parent.rcmail.env.forwardedrepliedicon) 
    1783             icn_src = parent.rcmail.env.forwardedrepliedicon; 
    1784           else 
    1785             icn_src = parent.rcmail.env.repliedicon; 
    1786           } 
    1787         else if (rows[uid].forwarded && parent.rcmail.env.forwardedicon) 
    1788           icn_src = parent.rcmail.env.forwardedicon; 
    1789         else if (parent.rcmail.env.messageicon) 
    1790           icn_src = parent.rcmail.env.messageicon; 
    1791        
    1792         if (rows[uid].icon && icn_src) 
    1793           rows[uid].icon.src = icn_src; 
    1794       } 
    1795   } 
    1796    
    1797    
    17981815  // set image to flagged or unflagged 
    17991816  this.toggle_flagged_status = function(flag, a_uids) 
    18001817  { 
    18011818    // mark all message rows as flagged/unflagged 
    1802     var icn_src; 
    1803     var rows = this.message_list.rows; 
    18041819    for (var i=0; i<a_uids.length; i++) 
    1805       { 
    1806       uid = a_uids[i]; 
    1807       if (rows[uid]) 
    1808         { 
    1809         rows[uid].flagged = (flag=='flagged' ? true : false); 
    1810  
    1811         if (rows[uid].flagged && this.env.flaggedicon) 
    1812           icn_src = this.env.flaggedicon; 
    1813         else if (this.env.unflaggedicon) 
    1814           icn_src = this.env.unflaggedicon; 
    1815  
    1816         if (rows[uid].flagged_icon && icn_src) 
    1817           rows[uid].flagged_icon.src = icn_src; 
    1818         } 
    1819       } 
     1820      this.set_message(a_uids[i], 'flagged', (flag=='flagged' ? true : false)); 
    18201821 
    18211822    this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag='+flag); 
     
    18291830    if (a_uids.length==1) 
    18301831    { 
    1831       if (!rows.length || (rows[a_uids[0]] && rows[a_uids[0]].classname.indexOf('deleted') < 0)) 
     1832      if (!rows.length || (rows[a_uids[0]] && !rows[a_uids[0]].deleted)) 
    18321833        this.flag_as_deleted(a_uids); 
    18331834      else 
     
    18421843      uid = a_uids[i]; 
    18431844      if (rows[uid]) { 
    1844         if (rows[uid].classname.indexOf('deleted')<0) 
     1845        if (!rows[uid].deleted) 
    18451846        { 
    18461847          all_deleted = false; 
     
    18611862  this.flag_as_undeleted = function(a_uids) 
    18621863  { 
    1863     var icn_src; 
    1864     var rows = this.message_list ? this.message_list.rows : new Array(); 
    1865        
    18661864    for (var i=0; i<a_uids.length; i++) 
    1867     { 
    1868       uid = a_uids[i]; 
    1869       if (rows[uid]) { 
    1870         rows[uid].deleted = false; 
    1871          
    1872         if (rows[uid].classname.indexOf('deleted') > 0) 
    1873         { 
    1874           rows[uid].classname = rows[uid].classname.replace(/\s*deleted/, ''); 
    1875           this.set_classname(rows[uid].obj, 'deleted', false); 
    1876         } 
    1877  
    1878         if (rows[uid].unread && this.env.unreadicon) 
    1879           icn_src = this.env.unreadicon; 
    1880         else if (rows[uid].replied && this.env.repliedicon) 
    1881           { 
    1882           if (rows[uid].forwarded && this.env.forwardedrepliedicon) 
    1883             icn_src = this.env.forwardedrepliedicon; 
    1884           else 
    1885             icn_src = this.env.repliedicon; 
    1886           } 
    1887         else if (rows[uid].forwarded && this.env.forwardedicon) 
    1888           icn_src = this.env.forwardedicon; 
    1889         else if (this.env.messageicon) 
    1890           icn_src = this.env.messageicon; 
    1891  
    1892         if (rows[uid].icon && icn_src) 
    1893           rows[uid].icon.src = icn_src; 
    1894       } 
    1895     } 
     1865      this.set_message(a_uids[i], 'deleted', false); 
    18961866 
    18971867    this.http_post('mark', '_uid='+a_uids.join(',')+'&_flag=undelete'); 
     
    19111881      if (rows[uid]) 
    19121882        { 
    1913         rows[uid].deleted = true; 
    1914          
    1915         if (rows[uid].classname.indexOf('deleted')<0) 
    1916           { 
    1917           rows[uid].classname += ' deleted'; 
    1918           this.set_classname(rows[uid].obj, 'deleted', true); 
    1919           } 
    1920         if (this.env.read_when_deleted) 
    1921         { 
    1922           rows[uid].classname = rows[uid].classname.replace(/\s*unread/, ''); 
    1923           this.set_classname(rows[uid].obj, 'unread', false); 
    1924         } 
    1925            
    1926         if (rows[uid].icon && this.env.deletedicon) 
    1927           rows[uid].icon.src = this.env.deletedicon; 
    1928  
     1883        this.set_message(uid, 'deleted', true); 
    19291884        if (rows[uid].unread) 
    19301885          r_uids[r_uids.length] = uid; 
     
    19581913        rows[uid].unread = false; 
    19591914        rows[uid].read = true; 
    1960          
    1961         rows[uid].classname = rows[uid].classname.replace(/\s*unread/, ''); 
    1962         this.set_classname(rows[uid].obj, 'unread', false); 
    1963  
    1964         if (rows[uid].icon) 
    1965           rows[uid].icon.src = this.env.deletedicon; 
     1915        this.set_message(uid); 
    19661916        } 
    19671917      } 
     
    23602310  /*********     keyboard live-search methods      *********/ 
    23612311  /*********************************************************/ 
    2362  
    23632312 
    23642313  // handler for keyboard events on address-fields 
     
    25822531  /*********************************************************/ 
    25832532 
    2584  
    25852533  this.contactlist_keypress = function(list) 
    25862534    { 
     
    35113459    if (flags.deleted && this.env.deletedicon) 
    35123460      icon = this.env.deletedicon; 
    3513     else if(flags.unread && this.env.unreadicon) 
    3514       icon = this.env.unreadicon; 
    35153461    else if (flags.replied && this.env.repliedicon) 
    35163462      { 
     
    35223468    else if (flags.forwarded && this.env.forwardedicon) 
    35233469      icon = this.env.forwardedicon; 
     3470    else if(flags.unread && this.env.unreadicon) 
     3471      icon = this.env.unreadicon; 
    35243472     
    35253473    var col = document.createElement('TD'); 
     
    36573605    }; 
    36583606 
    3659   // update parent's mailboxlist (from preview) 
    3660   this.set_unread_count_from_preview = function(mbox, count, set_title) 
    3661   { 
    3662     parent.rcmail.set_unread_count(mbox, count, set_title); 
    3663   } 
    3664    
    36653607  // add row to contacts list 
    36663608  this.add_contact_row = function(cid, cols, select) 
     
    42344176                      bw.win ? 500 : 200); 
    42354177  } 
    4236  
  • trunk/roundcubemail/program/js/list.js

    r1834 r1848  
    174174 
    175175/** 
    176  * Set focur to the list 
     176 * Set focus to the list 
    177177 */ 
    178178focus: function(e) 
  • trunk/roundcubemail/program/steps/mail/show.inc

    r1767 r1848  
    7272    if($RCMAIL->action == 'preview' && $marked != -1) 
    7373    { 
    74       $OUTPUT->command('set_unread_count_from_preview', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX')); 
    75       $OUTPUT->command('mark_as_read_from_preview', $MESSAGE->uid); 
     74      $OUTPUT->command('parent.set_unread_count', $mbox_name, $IMAP->messagecount($mbox_name, 'UNSEEN'), ($mbox_name == 'INBOX')); 
     75      $OUTPUT->command('parent.set_message', $MESSAGE->uid, 'unread', false); 
    7676    } 
    7777  } 
Note: See TracChangeset for help on using the changeset viewer.