Changeset 8fa9229 in github


Ignore:
Timestamp:
Apr 16, 2010 9:46:54 AM (3 years ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
c287f34
Parents:
186537b
Message:
  • code formatting, cleanup and small improvements
Location:
program/js
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • program/js/app.js

    r186537b r8fa9229  
    2121function rcube_webmail() 
    2222{ 
    23   this.env = new Object(); 
    24   this.labels = new Object(); 
    25   this.buttons = new Object(); 
    26   this.buttons_sel = new Object(); 
    27   this.gui_objects = new Object(); 
    28   this.gui_containers = new Object(); 
    29   this.commands = new Object(); 
    30   this.command_handlers = new Object(); 
    31   this.onloads = new Array(); 
     23  this.env = {}; 
     24  this.labels = {}; 
     25  this.buttons = {}; 
     26  this.buttons_sel = {}; 
     27  this.gui_objects = {}; 
     28  this.gui_containers = {}; 
     29  this.commands = {}; 
     30  this.command_handlers = {}; 
     31  this.onloads = []; 
    3232 
    3333  // create protected reference to myself 
    3434  this.ref = 'rcmail'; 
    3535  var ref = this; 
    36   
     36 
    3737  // webmail client settings 
    3838  this.dblclick_time = 500; 
    3939  this.message_time = 3000; 
    40    
     40 
    4141  this.identifier_expr = new RegExp('[^0-9a-z\-_]', 'gi'); 
    42    
     42 
    4343  // mimetypes supported by the browser (default settings) 
    4444  this.mimetypes = new Array('text/plain', 'text/html', 'text/xml', 
    45                              'image/jpeg', 'image/gif', 'image/png', 
    46                              'application/x-javascript', 'application/pdf', 
    47                              'application/x-shockwave-flash'); 
     45    'image/jpeg', 'image/gif', 'image/png', 
     46    'application/x-javascript', 'application/pdf', 'application/x-shockwave-flash'); 
    4847 
    4948  // default environment vars 
     
    5655 
    5756  // set jQuery ajax options 
    58   jQuery.ajaxSetup({ 
     57  $.ajaxSetup({ 
    5958    cache:false, 
    6059    error:function(request, status, err){ ref.http_error(request, status, err); }, 
     
    6463  // set environment variable(s) 
    6564  this.set_env = function(p, value) 
    66     { 
     65  { 
    6766    if (p != null && typeof(p) == 'object' && !value) 
    6867      for (var n in p) 
     
    7069    else 
    7170      this.env[p] = value; 
    72     }; 
     71  }; 
    7372 
    7473  // add a localized label to the client environment 
    7574  this.add_label = function(key, value) 
    76     { 
     75  { 
    7776    this.labels[key] = value; 
    78     }; 
     77  }; 
    7978 
    8079  // add a button to the button list 
    8180  this.register_button = function(command, id, type, act, sel, over) 
    82     { 
     81  { 
    8382    if (!this.buttons[command]) 
    84       this.buttons[command] = new Array(); 
    85        
     83      this.buttons[command] = []; 
     84 
    8685    var button_prop = {id:id, type:type}; 
    8786    if (act) button_prop.act = act; 
     
    9089 
    9190    this.buttons[command][this.buttons[command].length] = button_prop;     
    92     }; 
     91  }; 
    9392 
    9493  // register a specific gui object 
    9594  this.gui_object = function(name, id) 
    96     { 
     95  { 
    9796    this.gui_objects[name] = id; 
    98     }; 
    99    
     97  }; 
     98 
    10099  // register a container object 
    101100  this.gui_container = function(name, id) 
     
    103102    this.gui_containers[name] = id; 
    104103  }; 
    105    
     104 
    106105  // add a GUI element (html node) to a specified container 
    107106  this.add_element = function(elm, container) 
     
    115114  { 
    116115    this.command_handlers[command] = callback; 
    117      
     116 
    118117    if (enable) 
    119118      this.enable_command(command, true); 
    120119  }; 
    121    
     120 
    122121  // execute the given script on load 
    123122  this.add_onload = function(f) 
     
    128127  // initialize webmail client 
    129128  this.init = function() 
    130     { 
     129  { 
    131130    var p = this; 
    132131    this.task = this.env.task; 
    133      
     132 
    134133    // check browser 
    135134    if (!bw.dom || !bw.xmlhttp_test()) { 
    136135      this.goto_url('error', '_code=0x199'); 
    137136      return; 
    138       } 
     137    } 
    139138 
    140139    // find all registered gui containers 
     
    145144    for (var n in this.gui_objects) 
    146145      this.gui_objects[n] = rcube_find_object(this.gui_objects[n]); 
    147        
     146 
    148147    // init registered buttons 
    149148    this.init_buttons(); 
     
    155154    // enable general commands 
    156155    this.enable_command('logout', 'mail', 'addressbook', 'settings', true); 
    157      
     156 
    158157    if (this.env.permaurl) 
    159158      this.enable_command('permaurl', true); 
    160159 
    161     switch (this.task) 
    162       { 
     160    switch (this.task) { 
     161 
    163162      case 'mail': 
    164163        // enable mail commands 
    165164        this.enable_command('list', 'checkmail', 'compose', 'add-contact', 'search', 'reset-search', 'collapse-folder', true); 
    166        
    167         if (this.gui_objects.messagelist) 
    168           { 
     165 
     166        if (this.gui_objects.messagelist) { 
     167 
    169168          this.message_list = new rcube_list_widget(this.gui_objects.messagelist, 
    170169            {multiselect:true, multiexpand:true, draggable:true, keyboard:true, dblclick_time:this.dblclick_time}); 
     
    185184          this.message_list.init(); 
    186185          this.enable_command('toggle_status', 'toggle_flag', 'menu-open', 'menu-save', true); 
    187            
     186 
    188187          // load messages 
    189188          if (this.env.messagecount) 
    190189            this.command('list'); 
    191           } 
     190        } 
    192191 
    193192        if (this.gui_objects.qsearchbox) { 
    194193          if (this.env.search_text != null) { 
    195194            this.gui_objects.qsearchbox.value = this.env.search_text; 
    196             } 
     195          } 
    197196          $(this.gui_objects.qsearchbox).focusin(function() { rcmail.message_list.blur(); }); 
    198           } 
     197        } 
    199198 
    200199        if (this.env.trash_mailbox && this.env.mailbox != this.env.trash_mailbox) 
     
    208207            this.enable_command('nextmessage', true); 
    209208            this.enable_command('lastmessage', true); 
    210             } 
     209          } 
    211210          if (this.env.prev_uid) { 
    212211            this.enable_command('previousmessage', true); 
    213212            this.enable_command('firstmessage', true); 
    214             } 
    215          
     213          } 
     214 
    216215          if (this.env.blockedobjects) { 
    217216            if (this.gui_objects.remoteobjectsmsg) 
    218217              this.gui_objects.remoteobjectsmsg.style.display = 'block'; 
    219218            this.enable_command('load-images', 'always-load', true); 
    220             } 
     219          } 
    221220 
    222221          // make preview/message frame visible 
     
    224223            this.enable_command('compose', 'add-contact', false); 
    225224            parent.rcmail.show_contentframe(true); 
    226             } 
    227225          } 
     226        } 
    228227        else if (this.env.action == 'compose') { 
    229228          this.enable_command('add-attachment', 'send-attachment', 'remove-attachment', 'send', true); 
     
    234233            if ($("input[name='_is_html']").val() == '1') 
    235234              this.display_spellcheck_controls(false); 
    236             } 
     235          } 
    237236 
    238237          if (this.env.drafts_mailbox) 
    239238            this.enable_command('savedraft', true); 
    240              
     239 
    241240          document.onmouseup = function(e){ return p.doc_mouse_up(e); }; 
    242241 
    243242          // init message compose form 
    244243          this.init_messageform(); 
    245           } 
     244        } 
    246245        // show printing dialog 
    247246        else if (this.env.action == 'print') 
     
    251250          this.enable_command('select-all', 'select-none', 'expunge', true); 
    252251          this.enable_command('expand-all', 'expand-unread', 'collapse-all', this.env.threading); 
    253           } 
     252        } 
    254253 
    255254        if (this.purge_mailbox_test()) 
     
    263262          this.gui_objects.folderlist = this.gui_objects.mailboxlist; 
    264263          this.http_request('getunread', ''); 
    265           } 
    266          
     264        } 
     265 
    267266        // ask user to send MDN 
    268267        if (this.env.mdn_request && this.env.uid) { 
     
    272271          else 
    273272            this.http_post('mark', mdnurl+'&_flag=mdnsent'); 
    274           } 
     273        } 
    275274 
    276275        break; 
     
    280279        if (this.gui_objects.folderlist) 
    281280          this.env.contactfolders = $.extend($.extend({}, this.env.address_sources), this.env.contactgroups); 
    282          
    283         if (this.gui_objects.contactslist) 
    284           { 
     281 
     282        if (this.gui_objects.contactslist) { 
     283 
    285284          this.contact_list = new rcube_list_widget(this.gui_objects.contactslist, 
    286285            {multiselect:true, draggable:this.gui_objects.folderlist?true:false, keyboard:true}); 
     
    300299          if (this.gui_objects.qsearchbox) { 
    301300            $(this.gui_objects.qsearchbox).focusin(function() { rcmail.contact_list.blur(); }); 
    302             } 
    303301          } 
     302        } 
    304303 
    305304        this.set_page_buttons(); 
    306          
     305 
    307306        if (this.env.address_sources && this.env.address_sources[this.env.source] && !this.env.address_sources[this.env.source].readonly) { 
    308307          this.enable_command('add', 'import', true); 
    309308          this.enable_command('group-create', this.env.address_sources[this.env.source].groups); 
    310309        } 
    311          
     310 
    312311        if (this.env.cid) 
    313312          this.enable_command('show', 'edit', true); 
     
    317316        else 
    318317          this.enable_command('search', 'reset-search', 'moveto', true); 
    319            
     318 
    320319        if (this.contact_list && this.contact_list.rowcount > 0) 
    321320          this.enable_command('export', true); 
     
    327326      case 'settings': 
    328327        this.enable_command('preferences', 'identities', 'save', 'folders', true); 
    329          
     328 
    330329        if (this.env.action=='identities') { 
    331330          this.enable_command('add', this.env.identities_level < 2); 
     
    363362        var input_user = $('#rcmloginuser'); 
    364363        input_user.bind('keyup', function(e){ return rcmail.login_user_keyup(e); }); 
    365          
     364 
    366365        if (input_user.val() == '') 
    367366          input_user.focus(); 
     
    374373        this.enable_command('login', true); 
    375374        break; 
    376        
     375 
    377376      default: 
    378377        break; 
     
    385384    if (this.pending_message) 
    386385      this.display_message(this.pending_message[0], this.pending_message[1]); 
    387        
     386 
    388387    // map implicit containers 
    389388    if (this.gui_objects.folderlist) 
     
    392391    // trigger init event hook 
    393392    this.triggerEvent('init', { task:this.task, action:this.env.action }); 
    394      
     393 
    395394    // execute all foreign onload scripts 
    396395    // @deprecated 
     
    413412  // execute a specific command on the web client 
    414413  this.command = function(command, props, obj) 
    415     { 
     414  { 
    416415    if (obj && obj.blur) 
    417416      obj.blur(); 
     
    421420 
    422421    // command not supported or allowed 
    423     if (!this.commands[command]) 
    424       { 
     422    if (!this.commands[command]) { 
    425423      // pass command to parent window 
    426424      if (this.env.framed && parent.rcmail && parent.rcmail.command) 
     
    428426 
    429427      return false; 
    430       } 
    431        
    432    // check input before leaving compose step 
    433    if (this.task=='mail' && this.env.action=='compose' && (command=='list' || command=='mail' || command=='addressbook' || command=='settings')) 
    434      { 
    435      if (this.cmp_hash != this.compose_field_hash() && !confirm(this.get_label('notsentwarning'))) 
     428    } 
     429 
     430    // check input before leaving compose step 
     431    if (this.task=='mail' && this.env.action=='compose' 
     432        && (command == 'list' || command == 'mail' || command == 'addressbook' || command == 'settings')) { 
     433      if (this.cmp_hash != this.compose_field_hash() && !confirm(this.get_label('notsentwarning'))) 
    436434        return false; 
    437      } 
     435    } 
    438436 
    439437    // process external commands 
    440     if (typeof this.command_handlers[command] == 'function') 
    441     { 
     438    if (typeof this.command_handlers[command] == 'function') { 
    442439      var ret = this.command_handlers[command](props, obj); 
    443440      return ret !== null ? ret : (obj ? false : true); 
    444441    } 
    445     else if (typeof this.command_handlers[command] == 'string') 
    446     { 
     442    else if (typeof this.command_handlers[command] == 'string') { 
    447443      var ret = window[this.command_handlers[command]](props, obj); 
    448444      return ret !== null ? ret : (obj ? false : true); 
    449445    } 
    450      
     446 
    451447    // trigger plugin hook 
    452448    var event_ret = this.triggerEvent('before'+command, props); 
     
    460456 
    461457    // process internal command 
    462     switch (command) 
    463       { 
     458    switch (command) { 
     459 
    464460      case 'login': 
    465461        if (this.gui_objects.loginform) 
     
    610606      case 'save-identity': 
    611607      case 'save': 
    612         if (this.gui_objects.editform) 
    613           { 
     608        if (this.gui_objects.editform) { 
    614609          var input_pagesize = $("input[name='_pagesize']"); 
    615610          var input_name  = $("input[name='_name']"); 
     
    617612 
    618613          // user prefs 
    619           if (input_pagesize.length && isNaN(parseInt(input_pagesize.val()))) 
    620             { 
     614          if (input_pagesize.length && isNaN(parseInt(input_pagesize.val()))) { 
    621615            alert(this.get_label('nopagesizewarning')); 
    622616            input_pagesize.focus(); 
    623617            break; 
    624             } 
     618          } 
    625619          // contacts/identities 
    626           else 
    627             { 
    628             if (input_name.length && input_name.val() == '') 
    629               { 
     620          else { 
     621            if (input_name.length && input_name.val() == '') { 
    630622              alert(this.get_label('nonamewarning')); 
    631623              input_name.focus(); 
    632624              break; 
    633               } 
    634             else if (input_email.length && !rcube_check_email(input_email.val())) 
    635               { 
     625            } 
     626            else if (input_email.length && !rcube_check_email(input_email.val())) { 
    636627              alert(this.get_label('noemailwarning')); 
    637628              input_email.focus(); 
    638629              break; 
    639               } 
    640630            } 
     631          } 
    641632 
    642633          this.gui_objects.editform.submit(); 
    643           } 
     634        } 
    644635        break; 
    645636 
     
    674665          this.mark_message(props); 
    675666        break; 
    676        
     667 
    677668      case 'toggle_status': 
    678669        if (props && !props._row) 
    679670          break; 
    680          
    681         var uid; 
    682         var flag = 'read'; 
    683          
     671 
     672        var uid, flag = 'read'; 
     673 
    684674        if (props._row.uid) { 
    685675          uid = props._row.uid; 
    686            
     676 
    687677          // toggle read/unread 
    688678          if (this.message_list.rows[uid].deleted) { 
     
    692682            flag = 'unread'; 
    693683        } 
    694            
     684 
    695685        this.mark_message(flag, uid); 
    696686        break; 
    697          
     687 
    698688      case 'toggle_flag': 
    699689        if (props && !props._row) 
    700690          break; 
    701691 
    702         var uid; 
    703         var flag = 'flagged'; 
     692        var uid, flag = 'flagged'; 
    704693 
    705694        if (props._row.uid) { 
     
    718707          break; 
    719708        } 
    720          
     709 
    721710      case 'load-images': 
    722711        if (this.env.uid) 
     
    726715      case 'load-attachment': 
    727716        var qstring = '_mbox='+urlencode(this.env.mailbox)+'&_uid='+this.env.uid+'&_part='+props.part; 
    728          
     717 
    729718        // open attachment in frame if it's of a supported mimetype 
    730         if (this.env.uid && props.mimetype && jQuery.inArray(props.mimetype, this.mimetypes)>=0) { 
     719        if (this.env.uid && props.mimetype && $.inArray(props.mimetype, this.mimetypes)>=0) { 
    731720          if (props.mimetype == 'text/html') 
    732721            qstring += '&_safe=1'; 
     
    740729        this.goto_url('get', qstring+'&_download=1', false); 
    741730        break; 
    742          
     731 
    743732      case 'select-all': 
    744733        this.select_all_mode = props ? false : true; 
     
    788777          this.show_message(this.env.first_uid); 
    789778        break; 
    790        
     779 
    791780      case 'checkmail': 
    792781        this.check_for_recent(true); 
    793782        break; 
    794        
     783 
    795784      case 'compose': 
    796785        var url = this.env.comm_path+'&_action=compose'; 
    797         
     786 
    798787        if (this.task=='mail') { 
    799788          url += '&_mbox='+urlencode(this.env.mailbox); 
    800            
     789 
    801790          if (this.env.mailbox==this.env.drafts_mailbox) { 
    802791            var uid; 
     
    815804            break; 
    816805          } 
    817            
     806 
    818807          // use contact_id passed as command parameter 
    819           var a_cids = new Array(); 
     808          var a_cids = []; 
    820809          if (props) 
    821810            a_cids[a_cids.length] = props; 
     
    826815              a_cids[a_cids.length] = selection[n]; 
    827816          } 
    828              
     817 
    829818          if (a_cids.length) 
    830819            this.http_request('mailto', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source), true); 
     
    838827        this.redirect(url); 
    839828        break; 
    840          
     829 
    841830      case 'spellcheck': 
    842831        if (window.tinyMCE && tinyMCE.get(this.env.composebody)) { 
     
    884873        form._draft.value = ''; 
    885874        form.submit(); 
    886          
     875 
    887876        // clear timeout (sending could take longer) 
    888877        clearTimeout(this.request_timer); 
     
    891880      case 'add-attachment': 
    892881        this.show_attachment_form(true); 
    893          
     882 
    894883      case 'send-attachment': 
    895884        // Reset the auto-save timer 
     
    898887        this.upload_file(props)       
    899888        break; 
    900        
     889 
    901890      case 'remove-attachment': 
    902891        this.remove_attachment(props); 
     
    919908          this.goto_url('compose', '_forward_uid='+uid+'&_mbox='+urlencode(this.env.mailbox), true); 
    920909        break; 
    921          
     910 
    922911      case 'print': 
    923912        var uid; 
    924         if (uid = this.get_single_uid()) 
    925         { 
     913        if (uid = this.get_single_uid()) { 
    926914          ref.printwin = window.open(this.env.comm_path+'&_action=print&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)+(this.env.safemode ? '&_safe=1' : '')); 
    927           if (this.printwin) 
    928           { 
     915          if (this.printwin) { 
    929916            window.setTimeout(function(){ ref.printwin.focus(); }, 20); 
    930917            if (this.env.action != 'show') 
     
    936923      case 'viewsource': 
    937924        var uid; 
    938         if (uid = this.get_single_uid()) 
    939           { 
     925        if (uid = this.get_single_uid()) { 
    940926          ref.sourcewin = window.open(this.env.comm_path+'&_action=viewsource&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)); 
    941927          if (this.sourcewin) 
     
    958944        if (!props && this.gui_objects.qsearchbox) 
    959945          props = this.gui_objects.qsearchbox.value; 
    960         if (props) 
    961         { 
     946        if (props) { 
    962947          this.qsearch(props); 
    963948          break; 
     
    968953        var s = this.env.search_request; 
    969954        this.reset_qsearch(); 
    970          
     955 
    971956        if (s && this.env.mailbox) 
    972957          this.list_mailbox(this.env.mailbox); 
     
    978963        this.add_contact_group(props) 
    979964        break; 
    980          
     965 
    981966      case 'group-rename': 
    982967        this.rename_contact_group(); 
    983968        break; 
    984          
     969 
    985970      case 'group-delete': 
    986971        this.delete_contact_group(); 
     
    1001986          this.goto_url('import', (this.env.source ? '_target='+urlencode(this.env.source)+'&' : '')); 
    1002987        break; 
    1003          
     988 
    1004989      case 'export': 
    1005990        if (this.contact_list.rowcount > 0) { 
     
    1007992          if (this.env.search_request) 
    1008993            add_url += '_search='+this.env.search_request; 
    1009          
     994 
    1010995          this.goto_url('export', add_url); 
    1011996        } 
     
    10261011        this.goto_url('identities'); 
    10271012        break; 
    1028            
     1013 
    10291014      case 'delete-identity': 
    10301015        this.delete_identity(); 
    1031          
     1016 
    10321017      case 'folders': 
    10331018        this.goto_url('folders'); 
     
    10621047        break; 
    10631048 
    1064       } 
    1065        
     1049    } 
     1050 
    10661051    this.triggerEvent('after'+command, props); 
    10671052 
    10681053    return obj ? false : true; 
    1069     }; 
     1054  }; 
    10701055 
    10711056  // set command enabled or disabled 
    10721057  this.enable_command = function() 
    1073     { 
     1058  { 
    10741059    var args = arguments; 
    1075     if(!args.length) return -1; 
    1076  
    1077     var command; 
    1078     var enable = args[args.length-1]; 
    1079      
    1080     for(var n=0; n<args.length-1; n++) 
    1081       { 
     1060    if (!args.length) 
     1061      return -1; 
     1062 
     1063    var command, enable = args[args.length-1]; 
     1064 
     1065    for (var n=0; n<args.length-1; n++) { 
    10821066      command = args[n]; 
    10831067      this.commands[command] = enable; 
    10841068      this.set_button(command, (enable ? 'act' : 'pas')); 
    1085       } 
    1086       return true; 
    1087     }; 
     1069    } 
     1070    return true; 
     1071  }; 
    10881072 
    10891073  // lock/unlock interface 
    10901074  this.set_busy = function(a, message) 
    1091     { 
    1092     if (a && message) 
    1093       { 
     1075  { 
     1076    if (a && message) { 
    10941077      var msg = this.get_label(message); 
    10951078      if (msg==message)         
     
    10971080 
    10981081      this.display_message(msg, 'loading', true); 
    1099       } 
     1082    } 
    11001083    else if (!a) 
    11011084      this.hide_message(); 
     
    11031086    this.busy = a; 
    11041087    //document.body.style.cursor = a ? 'wait' : 'default'; 
    1105      
     1088 
    11061089    if (this.gui_objects.editform) 
    11071090      this.lock_form(this.gui_objects.editform, a); 
    1108        
     1091 
    11091092    // clear pending timer 
    11101093    if (this.request_timer) 
     
    11141097    if (a && this.env.request_timeout) 
    11151098      this.request_timer = window.setTimeout(function(){ ref.request_timed_out(); }, this.env.request_timeout * 1000); 
    1116     }; 
     1099  }; 
    11171100 
    11181101  // return a localized string 
    11191102  this.get_label = function(name, domain) 
    1120     { 
     1103  { 
    11211104    if (domain && this.labels[domain+'.'+name]) 
    11221105      return this.labels[domain+'.'+name]; 
     
    11251108    else 
    11261109      return name; 
    1127     }; 
    1128    
     1110  }; 
     1111 
    11291112  // alias for convenience reasons 
    11301113  this.gettext = this.get_label; 
     
    11321115  // switch to another application task 
    11331116  this.switch_task = function(task) 
    1134     { 
     1117  { 
    11351118    if (this.task===task && task!='mail') 
    11361119      return; 
     
    11411124 
    11421125    this.redirect(url); 
    1143     }; 
     1126  }; 
    11441127 
    11451128  this.get_task_url = function(task, url) 
    1146     { 
     1129  { 
    11471130    if (!url) 
    11481131      url = this.env.comm_path; 
    11491132 
    11501133    return url.replace(/_task=[a-z]+/, '_task='+task); 
    1151     }; 
    1152      
     1134  }; 
     1135 
    11531136  // called when a request timed out 
    11541137  this.request_timed_out = function() 
    1155     { 
     1138  { 
    11561139    this.set_busy(false); 
    11571140    this.display_message('Request timed out!', 'error'); 
    1158     }; 
    1159    
     1141  }; 
     1142 
    11601143  this.reload = function(delay) 
    11611144  { 
     
    11751158  this.drag_menu = function(e, target) 
    11761159  { 
    1177     var modkey = rcube_event.get_modifier(e); 
    1178     var menu = $('#'+this.gui_objects.message_dragmenu); 
     1160    var modkey = rcube_event.get_modifier(e), 
     1161      menu = $('#'+this.gui_objects.message_dragmenu); 
    11791162 
    11801163    if (menu && modkey == SHIFT_KEY && this.commands['copy']) { 
     
    11841167      return true; 
    11851168    } 
    1186      
     1169 
    11871170    return false; 
    11881171  }; 
     
    12051188    if (this.preview_timer) 
    12061189      clearTimeout(this.preview_timer); 
    1207      
     1190 
    12081191    if (this.preview_read_timer) 
    12091192      clearTimeout(this.preview_read_timer); 
     
    12201203      this.env.folderlist_coords = { x1:pos.left, y1:pos.top, x2:pos.left + list.width(), y2:pos.top + list.height() }; 
    12211204 
    1222       this.env.folder_coords = new Array(); 
     1205      this.env.folder_coords = []; 
    12231206      for (var k in model) { 
    12241207        if (li = this.get_folder_li(k)) { 
     
    12381221    this.drag_active = false; 
    12391222    this.env.last_folder_target = null; 
    1240      
     1223 
    12411224    if (this.folder_auto_timer) { 
    12421225      window.clearTimeout(this.folder_auto_timer); 
     
    12531236    } 
    12541237  }; 
    1255    
     1238 
    12561239  this.drag_move = function(e) 
    12571240  { 
     
    12611244      var moffset = this.initialListScrollTop-this.gui_objects.folderlist.parentNode.scrollTop; 
    12621245      var toffset = -moffset-boffset; 
    1263  
    12641246      var li, div, pos, mouse; 
     1247 
    12651248      mouse = rcube_event.get_mouse_pos(e); 
    12661249      pos = this.env.folderlist_coords; 
     
    12761259        return; 
    12771260      } 
    1278      
     1261 
    12791262      // over the folders 
    12801263      for (var k in this.env.folder_coords) { 
     
    12901273            if (this.folder_auto_timer) 
    12911274              window.clearTimeout(this.folder_auto_timer); 
    1292              
     1275 
    12931276            this.folder_auto_expand = k; 
    12941277            this.folder_auto_timer = window.setTimeout(function() { 
     
    13011284            this.folder_auto_expand = null; 
    13021285          } 
    1303            
     1286 
    13041287          $(li).addClass('droptarget'); 
    13051288          this.env.last_folder_target = k; 
     
    13161299  this.collapse_folder = function(id) 
    13171300  { 
    1318     var li = this.get_folder_li(id); 
    1319     var div = $(li.getElementsByTagName('div')[0]); 
    1320      
     1301    var li = this.get_folder_li(id), 
     1302      div = $(li.getElementsByTagName('div')[0]); 
     1303 
    13211304    if (!div || (!div.hasClass('collapsed') && !div.hasClass('expanded'))) 
    13221305      return; 
    1323      
     1306 
    13241307    var ul = $(li.getElementsByTagName('ul')[0]); 
     1308 
    13251309    if (div.hasClass('collapsed')) { 
    13261310      ul.show(); 
     
    13791363    if (this.drag_active && model && this.env.last_folder_target) { 
    13801364      var target = model[this.env.last_folder_target]; 
    1381        
     1365 
    13821366      $(this.get_folder_li(this.env.last_folder_target)).removeClass('droptarget'); 
    13831367      this.env.last_folder_target = null; 
     
    14901474      this.show_contentframe(false); 
    14911475  }; 
    1492    
     1476 
    14931477  this.msglist_expand = function(row) 
    14941478  { 
     
    14961480      this.env.messages[row.uid].expanded = row.expanded; 
    14971481  }; 
    1498    
     1482 
    14991483  this.check_droptarget = function(id) 
    15001484  { 
     
    15161500  this.init_message_row = function(row) 
    15171501  { 
    1518     var self = this; 
    1519     var uid = row.uid; 
    1520      
     1502    var self = this, uid = row.uid; 
     1503 
    15211504    if (uid && this.env.messages[uid]) 
    15221505      $.extend(row, this.env.messages[uid]); 
     
    15521535    else 
    15531536      var tbody = this.gui_objects.messagelist.tBodies[0]; 
    1554  
    1555     var rows = this.message_list.rows; 
    1556     var rowcount = tbody.rows.length; 
    1557     var even = rowcount%2; 
    15581537 
    15591538    if (!this.env.messages[uid]) 
     
    15731552    }); 
    15741553 
    1575     var message = this.env.messages[uid]; 
    1576  
    1577     var css_class = 'message' 
     1554    var tree = expando = '', 
     1555      rows = this.message_list.rows, 
     1556      rowcount = tbody.rows.length, 
     1557      even = rowcount%2, 
     1558      message = this.env.messages[uid], 
     1559      css_class = 'message' 
    15781560        + (even ? ' even' : ' odd') 
    15791561        + (flags.unread ? ' unread' : '') 
     
    15811563        + (flags.flagged ? ' flagged' : '') 
    15821564        + (flags.unread_children && !flags.unread && !this.env.autoexpand_threads ? ' unroot' : '') 
    1583         + (this.message_list.in_selection(uid) ? ' selected' : ''); 
    1584  
    1585     // for performance use DOM instead of jQuery here 
    1586     var row = document.createElement('tr'); 
     1565        + (this.message_list.in_selection(uid) ? ' selected' : ''), 
     1566      // for performance use DOM instead of jQuery here 
     1567      row = document.createElement('tr'), 
     1568      col = document.createElement('td'); 
     1569 
    15871570    row.id = 'rcmrow'+uid; 
    15881571    row.className = css_class; 
    15891572 
     1573    // message status icon 
    15901574    var icon = this.env.messageicon; 
    15911575    if (!flags.unread && flags.unread_children > 0 && this.env.unreadchildrenicon) 
     
    16041588      icon = this.env.unreadicon; 
    16051589 
    1606     var tree = expando = ''; 
    1607  
     1590    // threads 
    16081591    if (this.env.threading) { 
    16091592      // This assumes that div width is hardcoded to 15px, 
     
    16321615 
    16331616    tree += icon ? '<img id="msgicn'+uid+'" src="'+icon+'" alt="" class="msgicon" />' : ''; 
    1634      
     1617 
    16351618    // first col is always there 
    1636     var col = document.createElement('td'); 
    16371619    col.className = 'threads'; 
    16381620    col.innerHTML = expando; 
    16391621    row.appendChild(col); 
    1640      
     1622 
    16411623    // build subject link  
    16421624    if (!bw.ie && cols.subject) { 
     
    16951677    if (sort_col) 
    16961678      $('#rcm'+sort_col).addClass('sorted'+sort_order); 
    1697      
     1679 
    16981680    this.env.sort_col = sort_col; 
    16991681    this.env.sort_order = sort_order; 
     
    17081690      this.set_list_sorting(sort_col, sort_order); 
    17091691    } 
    1710      
     1692 
    17111693    if (this.env.threading != threads) { 
    17121694      update = 1; 
     
    17971779    if (page > 0 && page <= this.env.pagecount) { 
    17981780      this.env.current_page = page; 
    1799        
     1781 
    18001782      if (this.task=='mail') 
    18011783        this.list_mailbox(this.env.mailbox, page); 
     
    18661848      return; 
    18671849    } 
    1868      
     1850 
    18691851    if (this.env.contentframe && window.frames && window.frames[this.env.contentframe]) { 
    18701852      target = window.frames[this.env.contentframe]; 
     
    18971879    var new_row = tbody.firstChild; 
    18981880    var r; 
    1899      
     1881 
    19001882    while (new_row) { 
    19011883      if (new_row.nodeType == 1 && (r = this.message_list.rows[new_row.uid]) 
     
    19361918    } 
    19371919    //  this.message_list.expand(null); 
    1938   } 
     1920  }; 
    19391921 
    19401922  // update parent in a thread 
     
    19451927 
    19461928    var root = this.message_list.find_root(uid); 
    1947      
     1929 
    19481930    if (uid == root) 
    19491931      return; 
     
    19751957    var depth = rows[uid].depth; 
    19761958    var r, parent, count = 0; 
    1977     var roots = new Array(); 
     1959    var roots = []; 
    19781960 
    19791961    if (!row.depth) // root message: decrease roots count 
     
    20242006          row = row.nextSibling; 
    20252007    } 
    2026      
     2008 
    20272009    // update unread_children for roots 
    20282010    for (var i=0; i<roots.length; i++) 
     
    20382020    var row = tbody.firstChild; 
    20392021    var cnt = this.env.pagesize + 1; 
    2040      
     2022 
    20412023    while (row) { 
    20422024      if (row.nodeType == 1 && (r = rows[row.uid])) { 
     
    20762058    else if (this.env.messageicon) 
    20772059      icn_src = this.env.messageicon; 
    2078        
     2060 
    20792061    if (icn_src && rows[uid].icon) 
    20802062      rows[uid].icon.src = icn_src; 
    20812063 
    20822064    icn_src = ''; 
    2083      
     2065 
    20842066    if (rows[uid].flagged && this.env.flaggedicon) 
    20852067      icn_src = this.env.flaggedicon; 
     
    21172099 
    21182100    if (!rows[uid]) return false; 
    2119      
     2101 
    21202102    if (flag) 
    21212103      this.set_message_status(uid, flag, status); 
     
    21272109    else if (!rows[uid].unread && rowobj.hasClass('unread')) 
    21282110      rowobj.removeClass('unread'); 
    2129      
     2111 
    21302112    if (rows[uid].deleted && !rowobj.hasClass('deleted')) 
    21312113      rowobj.addClass('deleted'); 
     
    21642146 
    21652147    var add_url = '&_target_mbox='+urlencode(mbox)+'&_from='+(this.env.action ? this.env.action : ''); 
    2166     var a_uids = new Array(); 
     2148    var a_uids = []; 
    21672149 
    21682150    if (this.env.uid) 
     
    21862168    if (mbox && typeof mbox == 'object') 
    21872169      mbox = mbox.id; 
    2188        
     2170 
    21892171    // exit if current or no mailbox specified or if selection is empty 
    21902172    if (!mbox || mbox == this.env.mailbox || (!this.env.uid && (!this.message_list || !this.message_list.get_selection().length))) 
     
    22112193  this.delete_messages = function() 
    22122194  { 
    2213     var selection = this.message_list ? $.merge([], this.message_list.get_selection()) : new Array(); 
     2195    var selection = this.message_list ? $.merge([], this.message_list.get_selection()) : []; 
    22142196 
    22152197    // exit if no mailbox specified or if selection is empty 
    22162198    if (!this.env.uid && !selection.length) 
    22172199      return; 
    2218        
     2200 
    22192201    // also select childs of collapsed rows 
    22202202    for (var uid, i=0; i < selection.length; i++) { 
     
    22232205        this.message_list.select_childs(uid); 
    22242206    } 
    2225      
     2207 
    22262208    // if config is set to flag for deletion 
    22272209    if (this.env.flag_for_deletion) { 
     
    22522234    if (!this.env.uid && (!this.message_list || !this.message_list.get_selection().length)) 
    22532235      return; 
    2254        
     2236 
    22552237    this.show_contentframe(false); 
    22562238    this._with_selected_messages('delete', false, '&_from='+(this.env.action ? this.env.action : '')); 
     
    22612243  this._with_selected_messages = function(action, lock, add_url) 
    22622244  { 
    2263     var a_uids = new Array(), 
    2264       count = 0; 
     2245    var a_uids = [], count = 0; 
    22652246 
    22662247    if (this.env.uid) 
     
    23022283  this.mark_message = function(flag, uid) 
    23032284  { 
    2304     var a_uids = new Array(), 
    2305       r_uids = new Array(), 
    2306       selection = this.message_list ? this.message_list.get_selection() : new Array(); 
     2285    var a_uids = [], r_uids = [], 
     2286      selection = this.message_list ? this.message_list.get_selection() : []; 
    23072287 
    23082288    if (uid) 
     
    23742354    this.http_post('mark', '_uid='+this.uids_to_list(a_uids)+'&_flag='+flag); 
    23752355  }; 
    2376    
     2356 
    23772357  // mark all message rows as deleted/undeleted 
    23782358  this.toggle_delete_status = function(a_uids) 
    23792359  { 
    2380     var rows = this.message_list ? this.message_list.rows : new Array(); 
    2381      
    2382     if (a_uids.length==1) 
    2383     { 
     2360    var rows = this.message_list ? this.message_list.rows : []; 
     2361 
     2362    if (a_uids.length==1) { 
    23842363      if (!rows.length || (rows[a_uids[0]] && !rows[a_uids[0]].deleted)) 
    23852364        this.flag_as_deleted(a_uids); 
     
    23892368      return true; 
    23902369    } 
    2391      
     2370 
    23922371    var all_deleted = true; 
    2393     for (var uid, i=0; i<a_uids.length; i++) 
    2394     { 
     2372    for (var uid, i=0; i<a_uids.length; i++) { 
    23952373      uid = a_uids[i]; 
    23962374      if (rows[uid] && !rows[uid].deleted) { 
     
    23992377      } 
    24002378    } 
    2401      
     2379 
    24022380    if (all_deleted) 
    24032381      this.flag_as_undeleted(a_uids); 
    24042382    else 
    24052383      this.flag_as_deleted(a_uids); 
    2406      
     2384 
    24072385    return true; 
    24082386  }; 
     
    24202398  { 
    24212399    var add_url = '', 
    2422       r_uids = new Array(), 
    2423       rows = this.message_list ? this.message_list.rows : new Array(), 
     2400      r_uids = [], 
     2401      rows = this.message_list ? this.message_list.rows : [], 
    24242402      count = 0; 
    24252403 
     
    24512429 
    24522430    add_url = '&_from='+(this.env.action ? this.env.action : ''); 
    2453      
     2431 
    24542432    // ?? 
    24552433    if (r_uids.length) 
     
    24632441        add_url += '&_next_uid='+this.env.next_uid; 
    24642442    } 
    2465      
     2443 
    24662444    this.http_post('mark', '_uid='+this.uids_to_list(a_uids)+'&_flag=delete'+add_url); 
    24672445    return true;   
     
    24732451  { 
    24742452    var icn_src, uid, 
    2475       rows = this.message_list ? this.message_list.rows : new Array(), 
     2453      rows = this.message_list ? this.message_list.rows : [], 
    24762454      str = String(uids), 
    24772455      a_uids = str.split(','); 
     
    24812459      if (rows[uid]) 
    24822460        this.set_message(uid, 'unread', false); 
    2483       } 
     2461    } 
    24842462  }; 
    24852463 
     
    24902468    return this.select_all_mode ? '*' : uids.join(','); 
    24912469  }; 
    2492    
     2470 
    24932471 
    24942472  /*********************************************************/ 
     
    24972475 
    24982476  this.expunge_mailbox = function(mbox) 
    2499     { 
     2477  { 
    25002478    var lock = false; 
    25012479    var add_url = ''; 
    2502      
     2480 
    25032481    // lock interface if it's the active mailbox 
    2504     if (mbox == this.env.mailbox) 
    2505        { 
     2482    if (mbox == this.env.mailbox) { 
    25062483       lock = true; 
    25072484       this.set_busy(true, 'loading'); 
    25082485       add_url = '&_reload=1'; 
    2509        } 
     2486     } 
    25102487 
    25112488    // send request to server 
    25122489    var url = '_mbox='+urlencode(mbox); 
    25132490    this.http_post('expunge', url+add_url, lock); 
    2514     }; 
     2491  }; 
    25152492 
    25162493  this.purge_mailbox = function(mbox) 
    2517     { 
     2494  { 
    25182495    var lock = false; 
    25192496    var add_url = ''; 
    2520      
     2497 
    25212498    if (!confirm(this.get_label('purgefolderconfirm'))) 
    25222499      return false; 
    2523      
     2500 
    25242501    // lock interface if it's the active mailbox 
    2525     if (mbox == this.env.mailbox) 
    2526        { 
     2502    if (mbox == this.env.mailbox) { 
    25272503       lock = true; 
    25282504       this.set_busy(true, 'loading'); 
    25292505       add_url = '&_reload=1'; 
    2530        } 
     2506     } 
    25312507 
    25322508    // send request to server 
     
    25342510    this.http_post('purge', url+add_url, lock); 
    25352511    return true; 
    2536     }; 
     2512  }; 
    25372513 
    25382514  // test if purge command is allowed 
     
    25442520  }; 
    25452521 
    2546    
     2522 
    25472523  /*********************************************************/ 
    25482524  /*********           login form methods          *********/ 
     
    25602536      return rcube_event.cancel(e); 
    25612537    } 
    2562      
     2538 
    25632539    return true; 
    25642540  }; 
     
    25682544  /*********        message compose methods        *********/ 
    25692545  /*********************************************************/ 
    2570    
     2546 
    25712547  // init message compose form: set focus and eventhandlers 
    25722548  this.init_messageform = function() 
     
    25742550    if (!this.gui_objects.messageform) 
    25752551      return false; 
    2576      
     2552 
    25772553    //this.messageform = this.gui_objects.messageform; 
    25782554    var input_from = $("[name='_from']"); 
     
    25862562    this.init_address_input_events($("[name='_cc']")); 
    25872563    this.init_address_input_events($("[name='_bcc']")); 
    2588      
     2564 
    25892565    if (!html_mode) { 
    25902566      // add signature according to selected identity 
     
    26052581    // get summary of all field values 
    26062582    this.compose_field_hash(true); 
    2607   
     2583 
    26082584    // start the auto-save timer 
    26092585    this.auto_save_start(); 
     
    26502626      } 
    26512627    } 
    2652      
     2628 
    26532629    // display localized warning for missing subject 
    26542630    if (input_subject.val() == '') { 
     
    27342710    var value_subject = $("[name='_subject']").val(); 
    27352711    var str = ''; 
    2736      
     2712 
    27372713    if (value_to) 
    27382714      str += value_to+':'; 
     
    27432719    if (value_subject) 
    27442720      str += value_subject+':'; 
    2745      
     2721 
    27462722    var editor = tinyMCE.get(this.env.composebody); 
    27472723    if (editor) 
     
    27592735    return str; 
    27602736  }; 
    2761      
     2737 
    27622738  this.change_identity = function(obj, show_sig) 
    27632739  { 
     
    27772753    if (!this.env.identity) 
    27782754      this.env.identity = id 
    2779    
     2755 
    27802756    // enable manual signature insert 
    27812757    if (this.env.signatures && this.env.signatures[id]) 
     
    29042880      $(elm).toggle(); 
    29052881    } 
    2906        
     2882 
    29072883    // clear upload form 
    29082884    try { 
     
    29112887    } 
    29122888    catch(e){}  // ignore errors 
    2913      
     2889 
    29142890    return true; 
    29152891  }; 
     
    29202896    if (!form) 
    29212897      return false; 
    2922        
     2898 
    29232899    // get file input fields 
    29242900    var send = false; 
     
    29282904        break; 
    29292905      } 
    2930      
     2906 
    29312907    // create hidden iframe and post upload form 
    29322908    if (send) { 
     
    29762952      form.setAttribute('enctype', 'multipart/form-data'); 
    29772953      form.submit(); 
    2978        
     2954 
    29792955      // hide upload form 
    29802956      this.show_attachment_form(false); 
     
    29872963      this.add2attachment_list(ts, { name:'', html:content, complete:false }); 
    29882964    } 
    2989      
     2965 
    29902966    // set reference to the form object 
    29912967    this.gui_objects.attachmentform = form; 
     
    29992975    if (!this.gui_objects.attachmentlist) 
    30002976      return false; 
    3001      
     2977 
    30022978    var li = $('<li>').attr('id', name).html(att.html); 
    30032979    var indicator; 
    3004      
     2980 
    30052981    // replace indicator's li 
    30062982    if (upload_id && (indicator = document.getElementById(upload_id))) { 
     
    30102986      li.appendTo(this.gui_objects.attachmentlist); 
    30112987    } 
    3012      
     2988 
    30132989    if (upload_id && this.env.attachments[upload_id]) 
    30142990      delete this.env.attachments[upload_id]; 
    3015      
     2991 
    30162992    this.env.attachments[name] = att; 
    3017      
     2993 
    30182994    return true; 
    30192995  }; 
     
    30232999    if (this.env.attachments[name]) 
    30243000      delete this.env.attachments[name]; 
    3025      
     3001 
    30263002    if (!this.gui_objects.attachmentlist) 
    30273003      return false; 
     
    30563032    if (value) 
    30573033      this.http_post('addcontact', '_address='+value); 
    3058      
     3034 
    30593035    return true; 
    30603036  }; 
     
    30703046          var mods = this.env.search_mods[this.env.mailbox] ? this.env.search_mods[this.env.mailbox] : this.env.search_mods['*']; 
    30713047          if (mods) { 
    3072             var head_arr = new Array(); 
     3048            var head_arr = []; 
    30733049            for (var n in mods) 
    30743050              head_arr.push(n); 
     
    31013077    if (this.gui_objects.qsearchbox) 
    31023078      this.gui_objects.qsearchbox.value = ''; 
    3103        
     3079 
    31043080    this.env.search_request = null; 
    31053081    return true; 
     
    31273103    var mod = rcube_event.get_modifier(e); 
    31283104 
    3129     switch (key) 
    3130       { 
     3105    switch (key) { 
    31313106      case 38:  // key up 
    31323107      case 40:  // key down 
    31333108        if (!this.ksearch_pane) 
    31343109          break; 
    3135            
     3110 
    31363111        var dir = key==38 ? 1 : 0; 
    3137          
     3112 
    31383113        highlight = document.getElementById('rcmksearchSelected'); 
    31393114        if (!highlight) 
    31403115          highlight = this.ksearch_pane.__ul.firstChild; 
    3141          
     3116 
    31423117        if (highlight) 
    31433118          this.ksearch_select(dir ? highlight.previousSibling : highlight.nextSibling); 
     
    31623137        this.ksearch_hide(); 
    31633138        break; 
    3164        
     3139 
    31653140      case 37:  // left 
    31663141      case 39:  // right 
    31673142        if (mod != SHIFT_KEY) 
    3168           return; 
    3169       } 
     3143              return; 
     3144    } 
    31703145 
    31713146    // start timer 
    31723147    this.ksearch_timer = window.setTimeout(function(){ ref.ksearch_get_results(); }, 200); 
    31733148    this.ksearch_input = obj; 
    3174      
     3149 
    31753150    return true; 
    31763151  }; 
    3177    
     3152 
    31783153  this.ksearch_select = function(node) 
    31793154  { 
     
    31933168    if (!this.env.contacts[id] || !this.ksearch_input) 
    31943169      return; 
    3195      
     3170 
    31963171    // get cursor pos 
    31973172    var inp_value = this.ksearch_input.value; 
     
    32033178    var end = this.ksearch_input.value.substring(p+this.ksearch_value.length, this.ksearch_input.value.length); 
    32043179    var insert = ''; 
    3205      
     3180 
    32063181    // insert all members of a group 
    32073182    if (typeof this.env.contacts[id] == 'object' && this.env.contacts[id].id) { 
     
    32213196      this.ksearch_input.setSelectionRange(cpos, cpos); 
    32223197  }; 
    3223    
     3198 
    32243199  this.replace_group_recipients = function(id, recipients) 
    32253200  { 
     
    32363211    if (inp_value === null) 
    32373212      return; 
    3238        
     3213 
    32393214    if (this.ksearch_pane && this.ksearch_pane.is(":visible")) 
    32403215      this.ksearch_pane.hide(); 
     
    32513226    if (q == this.ksearch_value) 
    32523227      return; 
    3253      
     3228 
    32543229    var old_value = this.ksearch_value; 
    32553230    this.ksearch_value = q; 
    3256      
     3231 
    32573232    // ...string is empty 
    32583233    if (!q.length) 
     
    32623237    if (old_value && old_value.length && this.env.contacts && !this.env.contacts.length && q.indexOf(old_value) == 0) 
    32633238      return; 
    3264      
     3239 
    32653240    this.display_message(this.get_label('searching'), 'loading', false); 
    32663241    this.http_post('autocomplete', '_search='+urlencode(q)); 
     
    32723247    if (this.ksearch_value && search != this.ksearch_value) 
    32733248      return; 
    3274        
     3249 
    32753250    this.hide_message(); 
    32763251    this.env.contacts = results ? results : []; 
     
    32833258    if (a_results.length && this.ksearch_input && this.ksearch_value) { 
    32843259      var p, ul, li, text, s_val = this.ksearch_value; 
    3285        
     3260 
    32863261      // create results pane if not present 
    32873262      if (!this.ksearch_pane) { 
     
    33183293      this.ksearch_hide(); 
    33193294  }; 
    3320    
     3295 
    33213296  this.ksearch_click = function(node) 
    33223297  { 
     
    33293304 
    33303305  this.ksearch_blur = function() 
    3331     { 
     3306  { 
    33323307    if (this.ksearch_timer) 
    33333308      clearTimeout(this.ksearch_timer); 
     
    33353310    this.ksearch_value = ''; 
    33363311    this.ksearch_input = null; 
    3337      
    33383312    this.ksearch_hide(); 
    3339     }; 
     3313  }; 
    33403314 
    33413315 
    33423316  this.ksearch_hide = function() 
    3343     { 
     3317  { 
    33443318    this.ksearch_selected = null; 
    3345      
     3319 
    33463320    if (this.ksearch_pane) 
    33473321      this.ksearch_pane.hide(); 
    3348     }; 
     3322  }; 
    33493323 
    33503324 
     
    33543328 
    33553329  this.contactlist_keypress = function(list) 
    3356     { 
    3357       if (list.key_pressed == list.DELETE_KEY) 
    3358         this.command('delete'); 
    3359     }; 
     3330  { 
     3331    if (list.key_pressed == list.DELETE_KEY) 
     3332      this.command('delete'); 
     3333  }; 
    33603334 
    33613335  this.contactlist_select = function(list) 
    3362     { 
    3363       if (this.preview_timer) 
    3364         clearTimeout(this.preview_timer); 
    3365  
    3366       var id, frame, ref = this; 
    3367       if (id = list.get_single_selection()) 
    3368         this.preview_timer = window.setTimeout(function(){ ref.load_contact(id, 'show'); }, 200); 
    3369       else if (this.env.contentframe) 
    3370         this.show_contentframe(false); 
    3371  
    3372       this.enable_command('compose', list.selection.length > 0); 
    3373       this.enable_command('edit', (id && this.env.address_sources && !this.env.address_sources[this.env.source].readonly) ? true : false); 
    3374       this.enable_command('delete', list.selection.length && this.env.address_sources && !this.env.address_sources[this.env.source].readonly); 
    3375  
    3376       return false; 
    3377     }; 
     3336  { 
     3337    if (this.preview_timer) 
     3338      clearTimeout(this.preview_timer); 
     3339 
     3340    var id, frame, ref = this; 
     3341    if (id = list.get_single_selection()) 
     3342      this.preview_timer = window.setTimeout(function(){ ref.load_contact(id, 'show'); }, 200); 
     3343    else if (this.env.contentframe) 
     3344      this.show_contentframe(false); 
     3345 
     3346    this.enable_command('compose', list.selection.length > 0); 
     3347    this.enable_command('edit', (id && this.env.address_sources && !this.env.address_sources[this.env.source].readonly) ? true : false); 
     3348    this.enable_command('delete', list.selection.length && this.env.address_sources && !this.env.address_sources[this.env.source].readonly); 
     3349 
     3350    return false; 
     3351  }; 
    33783352 
    33793353  this.list_contacts = function(src, group, page) 
    3380     { 
     3354  { 
    33813355    var add_url = ''; 
    33823356    var target = window; 
    3383      
     3357 
    33843358    // currently all groups belong to the local address book 
    33853359    if (group) 
     
    33873361    else if (!src) 
    33883362      src = this.env.source; 
    3389      
     3363 
    33903364    if (page && this.current_page == page && src == this.env.source && group == this.env.group) 
    33913365      return false; 
    3392        
    3393     if (src != this.env.source) 
    3394       { 
     3366 
     3367    if (src != this.env.source) { 
    33953368      page = 1; 
    33963369      this.env.current_page = page; 
    33973370      this.reset_qsearch(); 
    3398       } 
     3371    } 
    33993372    else if (group != this.env.group) 
    34003373      page = this.env.current_page = 1; 
    34013374 
    34023375    this.select_folder((group ? 'G'+group : src), (this.env.group ? 'G'+this.env.group : this.env.source)); 
    3403      
     3376 
    34043377    this.env.source = src; 
    34053378    this.env.group = group; 
    34063379 
    34073380    // load contacts remotely 
    3408     if (this.gui_objects.contactslist) 
    3409       { 
     3381    if (this.gui_objects.contactslist) { 
    34103382      this.list_contacts_remote(src, group, page); 
    34113383      return; 
    3412       } 
    3413  
    3414     if (this.env.contentframe && window.frames && window.frames[this.env.contentframe]) 
    3415       { 
     3384    } 
     3385 
     3386    if (this.env.contentframe && window.frames && window.frames[this.env.contentframe]) { 
    34163387      target = window.frames[this.env.contentframe]; 
    34173388      add_url = '&_framed=1'; 
    3418       } 
    3419        
     3389    } 
     3390 
    34203391    if (group) 
    34213392      add_url += '&_gid='+group; 
     
    34293400    this.set_busy(true, 'loading'); 
    34303401    target.location.href = this.env.comm_path + (src ? '&_source='+urlencode(src) : '') + add_url; 
    3431     }; 
     3402  }; 
    34323403 
    34333404  // send remote request to load contacts list 
    34343405  this.list_contacts_remote = function(src, group, page) 
    3435     { 
     3406  { 
    34363407    // clear message list first 
    34373408    this.contact_list.clear(true); 
     
    34433414    this.env.source = src; 
    34443415    this.env.group = group; 
    3445      
     3416 
    34463417    if (group) 
    34473418      url += '&_gid='+group; 
    3448      
     3419 
    34493420    // also send search request to get the right messages  
    34503421    if (this.env.search_request)  
     
    34533424    this.set_busy(true, 'loading'); 
    34543425    this.http_request('list', url, true); 
    3455     }; 
     3426  }; 
    34563427 
    34573428  // load contact record 
    34583429  this.load_contact = function(cid, action, framed) 
    3459     { 
     3430  { 
    34603431    var add_url = ''; 
    34613432    var target = window; 
    3462     if (this.env.contentframe && window.frames && window.frames[this.env.contentframe]) 
    3463       { 
     3433    if (this.env.contentframe && window.frames && window.frames[this.env.contentframe]) { 
    34643434      add_url = '&_framed=1'; 
    34653435      target = window.frames[this.env.contentframe]; 
    34663436      this.show_contentframe(true); 
    3467       } 
     3437    } 
    34683438    else if (framed) 
    34693439      return false; 
    3470        
    3471     if (action && (cid || action=='add') && !this.drag_active) 
    3472       { 
     3440 
     3441    if (action && (cid || action=='add') && !this.drag_active) { 
    34733442      this.set_busy(true); 
    34743443      target.location.href = this.env.comm_path+'&_action='+action+'&_source='+urlencode(this.env.source)+'&_gid='+urlencode(this.env.group)+'&_cid='+urlencode(cid) + add_url; 
    3475       } 
     3444    } 
    34763445    return true; 
    3477     }; 
     3446  }; 
    34783447 
    34793448  // copy a contact to the specified target (group or directory) 
    34803449  this.copy_contact = function(cid, to) 
    3481     { 
     3450  { 
    34823451    if (!cid) 
    34833452      cid = this.contact_list.get_selection().join(','); 
     
    34873456    else if (to.id != this.env.source && cid && this.env.address_sources[to.id] && !this.env.address_sources[to.id].readonly) 
    34883457      this.http_post('copy', '_cid='+urlencode(cid)+'&_source='+urlencode(this.env.source)+'&_to='+urlencode(to.id)); 
    3489     }; 
     3458  }; 
    34903459 
    34913460 
    34923461  this.delete_contacts = function() 
    3493     { 
     3462  { 
    34943463    // exit if no mailbox specified or if selection is empty 
    34953464    var selection = this.contact_list.get_selection(); 
    34963465    if (!(selection.length || this.env.cid) || (!this.env.group && !confirm(this.get_label('deletecontactconfirm')))) 
    34973466      return; 
    3498        
    3499     var a_cids = new Array(); 
    3500     var qs = ''; 
     3467 
     3468    var a_cids = [], qs = ''; 
    35013469 
    35023470    if (this.env.cid) 
    35033471      a_cids[a_cids.length] = this.env.cid; 
    3504     else 
    3505       { 
     3472    else { 
    35063473      var id; 
    3507       for (var n=0; n<selection.length; n++) 
    3508         { 
     3474      for (var n=0; n<selection.length; n++) { 
    35093475        id = selection[n]; 
    35103476        a_cids[a_cids.length] = id; 
    35113477        this.contact_list.remove_row(id, (n == selection.length-1)); 
    3512         } 
     3478      } 
    35133479 
    35143480      // hide content frame if we delete the currently displayed contact 
    35153481      if (selection.length == 1) 
    35163482        this.show_contentframe(false); 
    3517       } 
     3483    } 
    35183484 
    35193485    // also send search request to get the right records from the next page 
     
    35263492    else 
    35273493      this.http_post('delete', '_cid='+urlencode(a_cids.join(','))+'&_source='+urlencode(this.env.source)+'&_from='+(this.env.action ? this.env.action : '')+qs); 
    3528        
     3494 
    35293495    return true; 
    3530     }; 
     3496  }; 
    35313497 
    35323498  // update a contact record in the list 
     
    35563522  // add row to contacts list 
    35573523  this.add_contact_row = function(cid, cols, select) 
    3558     { 
     3524  { 
    35593525    if (!this.gui_objects.contactslist || !this.gui_objects.contactslist.tBodies[0]) 
    35603526      return false; 
    3561      
    3562     var tbody = this.gui_objects.contactslist.tBodies[0]; 
    3563     var rowcount = tbody.rows.length; 
    3564     var even = rowcount%2; 
    3565      
    3566     var row = document.createElement('tr'); 
     3527 
     3528    var tbody = this.gui_objects.contactslist.tBodies[0], 
     3529      rowcount = tbody.rows.length, 
     3530      even = rowcount%2, 
     3531      row = document.createElement('tr'); 
     3532 
    35673533    row.id = 'rcmrow'+cid; 
    35683534    row.className = 'contact '+(even ? 'even' : 'odd'); 
    3569              
     3535 
    35703536    if (this.contact_list.in_selection(cid)) 
    35713537      row.className += ' selected'; 
     
    35783544      row.appendChild(col); 
    35793545    } 
    3580      
     3546 
    35813547    this.contact_list.insert_row(row); 
    3582      
     3548 
    35833549    this.enable_command('export', (this.contact_list.rowcount > 0)); 
    3584     }; 
    3585    
    3586    
     3550  }; 
     3551 
     3552 
    35873553  this.add_contact_group = function() 
    35883554  { 
    35893555    if (!this.gui_objects.folderlist || !this.env.address_sources[this.env.source].groups) 
    35903556      return; 
    3591        
     3557 
    35923558    if (!this.name_input) { 
    35933559      this.name_input = document.createElement('input'); 
    35943560      this.name_input.type = 'text'; 
    35953561      this.name_input.onkeypress = function(e){ return rcmail.add_input_keypress(e); }; 
    3596      
     3562 
    35973563      this.gui_objects.folderlist.parentNode.appendChild(this.name_input); 
    35983564    } 
    3599      
     3565 
    36003566    this.name_input.select(); 
    36013567  }; 
    3602    
     3568 
    36033569  this.rename_contact_group = function() 
    36043570  { 
    36053571    if (!this.env.group || !this.gui_objects.folderlist) 
    36063572      return; 
    3607      
     3573 
    36083574    if (!this.name_input) { 
    36093575      this.enable_command('list', 'listgroup', false); 
     
    36233589    this.name_input.select(); 
    36243590  }; 
    3625    
     3591 
    36263592  this.delete_contact_group = function() 
    36273593  { 
     
    36293595      this.http_post('group-delete', '_source='+urlencode(this.env.source)+'&_gid='+urlencode(this.env.group), true); 
    36303596  }; 
    3631    
     3597 
    36323598  // callback from server upon group-delete command 
    36333599  this.remove_group_item = function(id) 
     
    36363602    if ((li = this.get_folder_li(key))) { 
    36373603      this.triggerEvent('removegroup', { id:id, li:li }); 
    3638        
     3604 
    36393605      li.parentNode.removeChild(li); 
    36403606      delete this.env.contactfolders[key]; 
    36413607      delete this.env.contactgroups[key]; 
    36423608    } 
    3643      
     3609 
    36443610    this.list_contacts(null, 0); 
    36453611  }; 
    3646    
     3612 
    36473613  // handler for keyboard events on the input field 
    36483614  this.add_input_keypress = function(e) 
     
    36533619    if (key == 13) { 
    36543620      var newname = this.name_input.value; 
    3655        
     3621 
    36563622      if (newname) { 
    36573623        this.set_busy(true, 'loading'); 
     
    36663632    else if (key == 27) 
    36673633      this.reset_add_input(); 
    3668        
     3634 
    36693635    return true; 
    36703636  }; 
    3671    
     3637 
    36723638  this.reset_add_input = function() 
    36733639  { 
     
    36783644        this.env.group_renaming = false; 
    36793645      } 
    3680        
     3646 
    36813647      this.name_input.parentNode.removeChild(this.name_input); 
    36823648      this.name_input = null; 
     
    36853651    this.enable_command('list', 'listgroup', true); 
    36863652  }; 
    3687    
     3653 
    36883654  // callback for creating a new contact group 
    36893655  this.insert_contact_group = function(prop) 
    36903656  { 
    36913657    this.reset_add_input(); 
    3692      
     3658 
    36933659    prop.type = 'group'; 
    36943660    var key = 'G'+prop.id; 
     
    37003666    var li = $('<li>').attr('id', 'rcmli'+key).addClass('contactgroup').append(link); 
    37013667    $(this.gui_objects.folderlist).append(li); 
    3702      
     3668 
    37033669    this.triggerEvent('insertgroup', { id:prop.id, name:prop.name, li:li[0] }); 
    37043670  }; 
    3705    
     3671 
    37063672  // callback for renaming a contact group 
    37073673  this.update_contact_group = function(id, name) 
    37083674  { 
    37093675    this.reset_add_input(); 
    3710      
    3711     var key = 'G'+id; 
    3712     var link, li = this.get_folder_li(key); 
     3676 
     3677    var key = 'G'+id, link, li = this.get_folder_li(key); 
     3678 
    37133679    if (li && (link = li.firstChild) && link.tagName.toLowerCase() == 'a') 
    37143680      link.innerHTML = name; 
    3715      
     3681 
    37163682    this.env.contactfolders[key].name = this.env.contactgroups[key].name = name; 
    37173683    this.triggerEvent('updategroup', { id:id, name:name, li:li[0] }); 
     
    37243690 
    37253691  this.init_subscription_list = function() 
    3726     { 
     3692  { 
    37273693    var p = this; 
    37283694    this.subscription_list = new rcube_list_widget(this.gui_objects.subscriptionlist, {multiselect:false, draggable:true, keyboard:false, toggleselect:true}); 
     
    37303696    this.subscription_list.addEventListener('dragstart', function(o){ p.drag_active = true; }); 
    37313697    this.subscription_list.addEventListener('dragend', function(o){ p.subscription_move_folder(o); }); 
    3732     this.subscription_list.row_init = function (row) 
    3733       { 
     3698    this.subscription_list.row_init = function (row) { 
    37343699      var anchors = row.obj.getElementsByTagName('a'); 
    37353700      if (anchors[0]) 
     
    37393704      row.obj.onmouseover = function() { p.focus_subscription(row.id); }; 
    37403705      row.obj.onmouseout = function() { p.unfocus_subscription(row.id); }; 
    3741       } 
     3706    }; 
    37423707    this.subscription_list.init(); 
    3743     } 
     3708  }; 
    37443709 
    37453710  // preferences section select and load options frame 
    37463711  this.section_select = function(list) 
    3747     { 
     3712  { 
    37483713    var id = list.get_single_selection(); 
    3749      
     3714 
    37503715    if (id) { 
    3751       var add_url = ''; 
    3752       var target = window; 
     3716      var add_url = '', target = window; 
    37533717      this.set_busy(true); 
    37543718 
     
    37563720        add_url = '&_framed=1'; 
    37573721        target = window.frames[this.env.contentframe]; 
    3758         } 
     3722      } 
    37593723      target.location.href = this.env.comm_path+'&_action=edit-prefs&_section='+id+add_url; 
    3760       } 
     3724    } 
    37613725 
    37623726    return true; 
    3763     }; 
     3727  }; 
    37643728 
    37653729  this.identity_select = function(list) 
    3766     { 
     3730  { 
    37673731    var id; 
    37683732    if (id = list.get_single_selection()) 
    37693733      this.load_identity(id, 'edit-identity'); 
    3770     }; 
     3734  }; 
    37713735 
    37723736  // load identity record 
    37733737  this.load_identity = function(id, action) 
    3774     { 
     3738  { 
    37753739    if (action=='edit-identity' && (!id || id==this.env.iid)) 
    37763740      return false; 
    37773741 
    3778     var add_url = ''; 
    3779     var target = window; 
    3780     if (this.env.contentframe && window.frames && window.frames[this.env.contentframe]) 
    3781       { 
     3742    var add_url = '',  target = window; 
     3743 
     3744    if (this.env.contentframe && window.frames && window.frames[this.env.contentframe]) { 
    37823745      add_url = '&_framed=1'; 
    37833746      target = window.frames[this.env.contentframe]; 
    37843747      document.getElementById(this.env.contentframe).style.visibility = 'inherit'; 
    3785       } 
    3786  
    3787     if (action && (id || action=='add-identity')) 
    3788       { 
     3748    } 
     3749 
     3750    if (action && (id || action=='add-identity')) { 
    37893751      this.set_busy(true); 
    37903752      target.location.href = this.env.comm_path+'&_action='+action+'&_iid='+id+add_url; 
    3791       } 
     3753    } 
     3754 
    37923755    return true; 
    3793     }; 
     3756  }; 
    37943757 
    37953758  this.delete_identity = function(id) 
    3796     { 
     3759  { 
    37973760    // exit if no mailbox specified or if selection is empty 
    37983761    var selection = this.identity_list.get_selection(); 
    37993762    if (!(selection.length || this.env.iid)) 
    38003763      return; 
    3801      
     3764 
    38023765    if (!id) 
    38033766      id = this.env.iid ? this.env.iid : selection[0]; 
     
    38053768    // append token to request 
    38063769    this.goto_url('delete-identity', '_iid='+id+'&_token='+this.env.request_token, true); 
    3807      
     3770 
    38083771    return true; 
    3809     }; 
     3772  }; 
    38103773 
    38113774  this.focus_subscription = function(id) 
    3812     { 
    3813     var row, folder; 
    3814     var reg = RegExp('['+RegExp.escape(this.env.delimiter)+']?[^'+RegExp.escape(this.env.delimiter)+']+$'); 
     3775  { 
     3776    var row, folder, 
     3777      reg = RegExp('['+RegExp.escape(this.env.delimiter)+']?[^'+RegExp.escape(this.env.delimiter)+']+$'); 
    38153778 
    38163779    if (this.drag_active && this.env.folder && (row = document.getElementById(id))) 
    38173780      if (this.env.subscriptionrows[id] && 
    3818           (folder = this.env.subscriptionrows[id][0])) 
    3819         { 
     3781          (folder = this.env.subscriptionrows[id][0])) { 
    38203782        if (this.check_droptarget(folder) && 
    38213783            !this.env.subscriptionrows[this.get_folder_row_id(this.env.folder)][2] && 
    38223784            (folder != this.env.folder.replace(reg, '')) && 
    3823             (!folder.match(new RegExp('^'+RegExp.escape(this.env.folder+this.env.delimiter))))) 
    3824           { 
     3785            (!folder.match(new RegExp('^'+RegExp.escape(this.env.folder+this.env.delimiter))))) { 
    38253786          this.set_env('dstfolder', folder); 
    38263787          $(row).addClass('droptarget'); 
    3827           } 
    3828         } 
    3829       else if (this.env.folder.match(new RegExp(RegExp.escape(this.env.delimiter)))) 
    3830         { 
     3788        } 
     3789      } 
     3790      else if (this.env.folder.match(new RegExp(RegExp.escape(this.env.delimiter)))) { 
    38313791        this.set_env('dstfolder', this.env.delimiter); 
    38323792        $(this.subscription_list.frame).addClass('droptarget'); 
    3833         } 
    3834     } 
     3793      } 
     3794  }; 
    38353795 
    38363796  this.unfocus_subscription = function(id) 
    3837     { 
    3838       var row = $('#'+id); 
    3839       this.set_env('dstfolder', null); 
    3840       if (this.env.subscriptionrows[id] && row[0]) 
    3841         row.removeClass('droptarget'); 
    3842       else 
    3843         $(this.subscription_list.frame).removeClass('droptarget'); 
    3844     } 
     3797  { 
     3798    var row = $('#'+id); 
     3799 
     3800    this.set_env('dstfolder', null); 
     3801    if (this.env.subscriptionrows[id] && row[0]) 
     3802      row.removeClass('droptarget'); 
     3803    else 
     3804      $(this.subscription_list.frame).removeClass('droptarget'); 
     3805  }; 
    38453806 
    38463807  this.subscription_select = function(list) 
    3847     { 
     3808  { 
    38483809    var id, folder; 
    38493810    if ((id = list.get_single_selection()) && 
     
    38533814    else 
    38543815      this.set_env('folder', null); 
    3855        
     3816 
    38563817    if (this.gui_objects.createfolderhint) 
    38573818      $(this.gui_objects.createfolderhint).html(this.env.folder ? this.get_label('addsubfolderhint') : ''); 
    3858     }; 
     3819  }; 
    38593820 
    38603821  this.subscription_move_folder = function(list) 
    3861     { 
     3822  { 
    38623823    var reg = RegExp('['+RegExp.escape(this.env.delimiter)+']?[^'+RegExp.escape(this.env.delimiter)+']+$'); 
    38633824    if (this.env.folder && this.env.dstfolder && (this.env.dstfolder != this.env.folder) && 
    3864         (this.env.dstfolder != this.env.folder.replace(reg, ''))) 
    3865       { 
     3825        (this.env.dstfolder != this.env.folder.replace(reg, ''))) { 
    38663826      var reg = new RegExp('[^'+RegExp.escape(this.env.delimiter)+']*['+RegExp.escape(this.env.delimiter)+']', 'g'); 
    38673827      var basename = this.env.folder.replace(reg, ''); 
     
    38703830      this.set_busy(true, 'foldermoving'); 
    38713831      this.http_post('rename-folder', '_folder_oldname='+urlencode(this.env.folder)+'&_folder_newname='+urlencode(newname), true); 
    3872       } 
     3832    } 
    38733833    this.drag_active = false; 
    38743834    this.unfocus_subscription(this.get_folder_row_id(this.env.dstfolder)); 
    3875     }; 
     3835  }; 
    38763836 
    38773837  // tell server to create and subscribe a new mailbox 
    38783838  this.create_folder = function(name) 
    3879     { 
     3839  { 
    38803840    if (this.edit_folder) 
    38813841      this.reset_folder_rename(); 
    38823842 
    38833843    var form; 
    3884     if ((form = this.gui_objects.editform) && form.elements['_folder_name']) 
    3885       { 
     3844    if ((form = this.gui_objects.editform) && form.elements['_folder_name']) { 
    38863845      name = form.elements['_folder_name'].value; 
    38873846 
    3888       if (name.indexOf(this.env.delimiter)>=0) 
    3889         { 
     3847      if (name.indexOf(this.env.delimiter)>=0) { 
    38903848        alert(this.get_label('forbiddencharacter')+' ('+this.env.delimiter+')'); 
    38913849        return false; 
    3892         } 
     3850      } 
    38933851 
    38943852      if (this.env.folder && name != '') 
     
    38973855      this.set_busy(true, 'foldercreating'); 
    38983856      this.http_post('create-folder', '_name='+urlencode(name), true); 
    3899       } 
     3857    } 
    39003858    else if (form.elements['_folder_name']) 
    39013859      form.elements['_folder_name'].focus(); 
    3902     }; 
     3860  }; 
    39033861 
    39043862  // start renaming the mailbox name. 
    39053863  // this will replace the name string with an input field 
    39063864  this.rename_folder = function(id) 
    3907     { 
     3865  { 
    39083866    var temp, row, form; 
    39093867 
    39103868    // reset current renaming 
    3911     if (temp = this.edit_folder) 
    3912       { 
     3869    if (temp = this.edit_folder) { 
    39133870      this.reset_folder_rename(); 
    39143871      if (temp == id) 
    39153872        return; 
    3916       } 
    3917  
    3918     if (id && this.env.subscriptionrows[id] && (row = document.getElementById(id))) 
    3919       { 
     3873    } 
     3874 
     3875    if (id && this.env.subscriptionrows[id] && (row = document.getElementById(id))) { 
    39203876      var reg = new RegExp('.*['+RegExp.escape(this.env.delimiter)+']'); 
    39213877      this.name_input = document.createElement('input'); 
     
    39263882      this.name_input.__parent = this.env.subscriptionrows[id][0].replace(reg, ''); 
    39273883      this.name_input.onkeypress = function(e){ rcmail.name_input_keypress(e); }; 
    3928        
     3884 
    39293885      row.cells[0].replaceChild(this.name_input, row.cells[0].firstChild); 
    39303886      this.edit_folder = id; 
    39313887      this.name_input.select(); 
    3932        
     3888 
    39333889      if (form = this.gui_objects.editform) 
    39343890        form.onsubmit = function(){ return false; }; 
    3935       } 
    3936     }; 
     3891    } 
     3892  }; 
    39373893 
    39383894  // remove the input field and write the current mailbox name to the table cell 
    39393895  this.reset_folder_rename = function() 
    3940     { 
     3896  { 
    39413897    var cell = this.name_input ? this.name_input.parentNode : null; 
    39423898 
    39433899    if (cell && this.edit_folder && this.env.subscriptionrows[this.edit_folder]) 
    39443900      $(cell).html(this.env.subscriptionrows[this.edit_folder][1]); 
    3945        
     3901 
    39463902    this.edit_folder = null; 
    3947     }; 
     3903  }; 
    39483904 
    39493905  // handler for keyboard events on the input field 
    39503906  this.name_input_keypress = function(e) 
    3951     { 
     3907  { 
    39523908    var key = rcube_event.get_keycode(e); 
    39533909 
    39543910    // enter 
    3955     if (key==13) 
    3956       { 
     3911    if (key==13) { 
    39573912      var newname = this.name_input ? this.name_input.value : null; 
    3958       if (this.edit_folder && newname) 
    3959         { 
    3960         if (newname.indexOf(this.env.delimiter)>=0) 
    3961           { 
     3913      if (this.edit_folder && newname) { 
     3914        if (newname.indexOf(this.env.delimiter)>=0) { 
    39623915          alert(this.get_label('forbiddencharacter')+' ('+this.env.delimiter+')'); 
    39633916          return false; 
    3964           } 
     3917        } 
    39653918 
    39663919        if (this.name_input.__parent) 
     
    39693922        this.set_busy(true, 'folderrenaming'); 
    39703923        this.http_post('rename-folder', '_folder_oldname='+urlencode(this.env.subscriptionrows[this.edit_folder][0])+'&_folder_newname='+urlencode(newname), true); 
    3971         } 
    3972       } 
     3924      } 
     3925    } 
    39733926    // escape 
    39743927    else if (key==27) 
    39753928      this.reset_folder_rename(); 
    3976     }; 
     3929  }; 
    39773930 
    39783931  // delete a specific mailbox with all its messages 
    39793932  this.delete_folder = function(id) 
    3980     { 
     3933  { 
    39813934    var folder = this.env.subscriptionrows[id][0]; 
    39823935 
     
    39843937      this.reset_folder_rename(); 
    39853938 
    3986     if (folder && confirm(this.get_label('deletefolderconfirm'))) 
    3987       { 
     3939    if (folder && confirm(this.get_label('deletefolderconfirm'))) { 
    39883940      this.set_busy(true, 'folderdeleting'); 
    39893941      this.http_post('delete-folder', '_mboxes='+urlencode(folder), true); 
     
    39913943 
    39923944      $(this.gui_objects.createfolderhint).html(''); 
    3993       } 
    3994     }; 
     3945    } 
     3946  }; 
    39953947 
    39963948  // add a new folder to the subscription list by cloning a folder row 
    39973949  this.add_folder_row = function(name, display_name, replace, before) 
    3998     { 
     3950  { 
    39993951    if (!this.gui_objects.subscriptionlist) 
    40003952      return false; 
     
    40023954    // find not protected folder 
    40033955    var refid; 
    4004     for (var rid in this.env.subscriptionrows) 
     3956    for (var rid in this.env.subscriptionrows) { 
    40053957      if (this.env.subscriptionrows[rid]!=null && !this.env.subscriptionrows[rid][2]) { 
    40063958        refid = rid; 
    40073959        break; 
    40083960      } 
    4009  
    4010     var refrow, form; 
    4011     var tbody = this.gui_objects.subscriptionlist.tBodies[0]; 
    4012     var id = 'rcmrow'+(tbody.childNodes.length+1); 
    4013     var selection = this.subscription_list.get_single_selection(); 
    4014      
    4015     if (replace && replace.id) 
    4016     { 
     3961    } 
     3962 
     3963    var refrow, form, 
     3964      tbody = this.gui_objects.subscriptionlist.tBodies[0], 
     3965      id = 'rcmrow'+(tbody.childNodes.length+1), 
     3966      selection = this.subscription_list.get_single_selection(); 
     3967 
     3968    if (replace && replace.id) { 
    40173969      id = replace.id; 
    40183970      refid = replace.id; 
    40193971    } 
    40203972 
    4021     if (!id || !refid || !(refrow = document.getElementById(refid))) 
    4022       { 
     3973    if (!id || !refid || !(refrow = document.getElementById(refid))) { 
    40233974      // Refresh page if we don't have a table row to clone 
    40243975      this.goto_url('folders'); 
    40253976      return false; 
    4026       } 
    4027     else 
    4028       { 
     3977    } 
     3978    else { 
    40293979      // clone a table row if there are existing rows 
    40303980      var row = this.clone_table_row(refrow); 
     
    40353985      else 
    40363986        tbody.appendChild(row); 
    4037        
     3987 
    40383988      if (replace) 
    40393989        tbody.removeChild(replace); 
    4040       } 
     3990    } 
    40413991 
    40423992    // add to folder/row-ID map 
     
    40453995    // set folder name 
    40463996    row.cells[0].innerHTML = display_name; 
    4047      
     3997 
    40483998    // set messages count to zero 
    40493999    if (!replace) 
    40504000      row.cells[1].innerHTML = '*'; 
    40514001 
    4052     if (!replace && row.cells[2] && row.cells[2].firstChild.tagName.toLowerCase()=='input') 
    4053       { 
     4002    if (!replace && row.cells[2] && row.cells[2].firstChild.tagName.toLowerCase()=='input') { 
    40544003      row.cells[2].firstChild.value = name; 
    40554004      row.cells[2].firstChild.checked = true; 
    4056       } 
    4057      
     4005    } 
     4006 
    40584007    // add new folder to rename-folder list and clear input field 
    4059     if (!replace && (form = this.gui_objects.editform)) 
    4060       { 
     4008    if (!replace && (form = this.gui_objects.editform)) { 
    40614009      if (form.elements['_folder_oldname']) 
    40624010        form.elements['_folder_oldname'].options[form.elements['_folder_oldname'].options.length] = new Option(name,name); 
    40634011      if (form.elements['_folder_name']) 
    40644012        form.elements['_folder_name'].value = '';  
    4065       } 
     4013    } 
    40664014 
    40674015    this.init_subscription_list(); 
     
    40714019    if (document.getElementById(id).scrollIntoView) 
    40724020      document.getElementById(id).scrollIntoView(); 
    4073     }; 
     4021  }; 
    40744022 
    40754023  // replace an existing table row with a new folder line 
    40764024  this.replace_folder_row = function(oldfolder, newfolder, display_name, before) 
    4077     { 
    4078     var id = this.get_folder_row_id(oldfolder); 
    4079     var row = document.getElementById(id); 
    4080      
     4025  { 
     4026    var form, elm, 
     4027      id = this.get_folder_row_id(oldfolder), 
     4028      row = document.getElementById(id); 
     4029 
    40814030    // replace an existing table row (if found) 
    40824031    this.add_folder_row(newfolder, display_name, row, before); 
    4083      
     4032 
    40844033    // rename folder in rename-folder dropdown 
    4085     var form, elm; 
    4086     if ((form = this.gui_objects.editform) && (elm = form.elements['_folder_oldname'])) 
    4087       { 
    4088       for (var i=0;i<elm.options.length;i++) 
    4089         { 
    4090         if (elm.options[i].value == oldfolder) 
    4091           { 
     4034    if ((form = this.gui_objects.editform) && (elm = form.elements['_folder_oldname'])) { 
     4035      for (var i=0; i<elm.options.length; i++) { 
     4036        if (elm.options[i].value == oldfolder) { 
    40924037          elm.options[i].text = display_name; 
    40934038          elm.options[i].value = newfolder; 
    40944039          break; 
    4095           } 
    4096         } 
     4040        } 
     4041      } 
    40974042 
    40984043      form.elements['_folder_newname'].value = ''; 
    4099       } 
    4100     }; 
     4044    } 
     4045  }; 
    41014046 
    41024047  // remove the table row of a specific mailbox from the table 
    41034048  // (the row will not be removed, just hidden) 
    41044049  this.remove_folder_row = function(folder) 
    4105     { 
    4106     var row; 
    4107     var id = this.get_folder_row_id(folder); 
     4050  { 
     4051    var form, elm, row, id = this.get_folder_row_id(folder); 
     4052 
    41084053    if (id && (row = document.getElementById(id))) 
    41094054      row.style.display = 'none'; 
    41104055 
    41114056    // remove folder from rename-folder list 
    4112     var form; 
    4113     if ((form = this.gui_objects.editform) && form.elements['_folder_oldname']) 
    4114       { 
    4115       for (var i=0;i<form.elements['_folder_oldname'].options.length;i++) 
    4116         { 
    4117         if (form.elements['_folder_oldname'].options[i].value == folder)  
    4118           { 
    4119           form.elements['_folder_oldname'].options[i] = null; 
     4057    if ((form = this.gui_objects.editform) && (elm = form.elements['_folder_oldname'])) { 
     4058      for (var i=0; i<elm.options.length; i++) { 
     4059        if (elm.options[i].value == folder) { 
     4060          elm.options[i] = null; 
    41204061          break; 
    4121           } 
    4122         } 
    4123       } 
    4124      
     4062        } 
     4063      } 
     4064    } 
     4065 
    41254066    if (form && form.elements['_folder_newname']) 
    41264067      form.elements['_folder_newname'].value = ''; 
    4127     }; 
     4068  }; 
    41284069 
    41294070  this.subscribe_folder = function(folder) 
    4130     { 
     4071  { 
    41314072    if (folder) 
    41324073      this.http_post('subscribe', '_mbox='+urlencode(folder)); 
    4133     }; 
     4074  }; 
    41344075 
    41354076  this.unsubscribe_folder = function(folder) 
    4136     { 
     4077  { 
    41374078    if (folder) 
    41384079      this.http_post('unsubscribe', '_mbox='+urlencode(folder)); 
    4139     }; 
     4080  }; 
    41404081 
    41414082  this.enable_threading = function(folder) 
    4142     { 
     4083  { 
    41434084    if (folder) 
    41444085      this.http_post('enable-threading', '_mbox='+urlencode(folder)); 
    4145     }; 
     4086  }; 
    41464087 
    41474088  this.disable_threading = function(folder) 
    4148     { 
     4089  { 
    41494090    if (folder) 
    41504091      this.http_post('disable-threading', '_mbox='+urlencode(folder)); 
    4151     }; 
    4152      
     4092  }; 
    41534093 
    41544094  // helper method to find a specific mailbox row ID 
    41554095  this.get_folder_row_id = function(folder) 
    4156     { 
     4096  { 
    41574097    for (var id in this.env.subscriptionrows) 
    41584098      if (this.env.subscriptionrows[id] && this.env.subscriptionrows[id][0] == folder) 
    41594099        break; 
    4160          
     4100 
    41614101    return id; 
    4162     }; 
     4102  }; 
    41634103 
    41644104  // duplicate a specific table row 
    41654105  this.clone_table_row = function(row) 
    4166     { 
    4167     var cell, td; 
    4168     var new_row = document.createElement('tr'); 
    4169     for(var n=0; n<row.cells.length; n++) 
    4170       { 
     4106  { 
     4107    var cell, td, 
     4108      new_row = document.createElement('tr'); 
     4109 
     4110    for(var n=0; n<row.cells.length; n++) { 
    41714111      cell = row.cells[n]; 
    41724112      td = document.createElement('td'); 
     
    41764116      if (cell.align) 
    41774117        td.setAttribute('align', cell.align); 
    4178          
     4118 
    41794119      td.innerHTML = cell.innerHTML; 
    41804120      new_row.appendChild(td); 
    4181       } 
    4182      
     4121    } 
     4122 
    41834123    return new_row; 
    4184     }; 
     4124  }; 
    41854125 
    41864126 
     
    41974137    this.enable_command('firstpage', (this.env.current_page > 1)); 
    41984138  }; 
    4199    
     4139 
    42004140  // set event handlers on registered buttons 
    42014141  this.init_buttons = function() 
     
    42044144      if (typeof cmd != 'string') 
    42054145        continue; 
    4206        
     4146 
    42074147      for (var i=0; i< this.buttons[cmd].length; i++) { 
    42084148        var prop = this.buttons[cmd][i]; 
     
    42164156          preload = true; 
    42174157        } 
    4218          
     4158 
    42194159        elm._command = cmd; 
    42204160        elm._id = prop.id; 
     
    42374177  // set button to a specific state 
    42384178  this.set_button = function(command, state) 
    4239     { 
    4240     var a_buttons = this.buttons[command]; 
    4241     var button, obj; 
    4242  
    4243     if(!a_buttons || !a_buttons.length) 
     4179  { 
     4180    var button, obj, a_buttons = this.buttons[command]; 
     4181 
     4182    if (!a_buttons || !a_buttons.length) 
    42444183      return false; 
    42454184 
    4246     for(var n=0; n<a_buttons.length; n++) 
    4247       { 
     4185    for (var n=0; n<a_buttons.length; n++) { 
    42484186      button = a_buttons[n]; 
    42494187      obj = document.getElementById(button.id); 
     
    42604198 
    42614199      // set image according to button state 
    4262       if (obj && button.type=='image' && button[state]) 
    4263         { 
     4200      if (obj && button.type=='image' && button[state]) { 
    42644201        button.status = state;         
    42654202        obj.src = button[state]; 
    4266         } 
     4203      } 
    42674204      // set class name according to button state 
    4268       else if (obj && typeof(button[state])!='undefined') 
    4269         { 
     4205      else if (obj && typeof(button[state])!='undefined') { 
    42704206        button.status = state;         
    42714207        obj.className = button[state];         
    4272         } 
     4208      } 
    42734209      // disable/enable input buttons 
    4274       if (obj && button.type=='input') 
    4275         { 
     4210      if (obj && button.type=='input') { 
    42764211        button.status = state; 
    42774212        obj.disabled = !state; 
    4278         } 
    4279       } 
    4280     }; 
     4213      } 
     4214    } 
     4215  }; 
    42814216 
    42824217  // display a specific alttext 
    42834218  this.set_alttext = function(command, label) 
    4284     { 
    4285       if (!this.buttons[command] || !this.buttons[command].length) 
    4286         return; 
    4287        
    4288       var button, obj, link; 
    4289       for (var n=0; n<this.buttons[command].length; n++) 
    4290       { 
    4291         button = this.buttons[command][n]; 
    4292         obj = document.getElementById(button.id); 
    4293          
    4294         if (button.type=='image' && obj) 
    4295         { 
    4296           obj.setAttribute('alt', this.get_label(label)); 
    4297           if ((link = obj.parentNode) && link.tagName.toLowerCase() == 'a') 
    4298             link.setAttribute('title', this.get_label(label)); 
    4299         } 
    4300         else if (obj) 
    4301           obj.setAttribute('title', this.get_label(label)); 
    4302       } 
    4303     }; 
     4219  { 
     4220    if (!this.buttons[command] || !this.buttons[command].length) 
     4221      return; 
     4222 
     4223    var button, obj, link; 
     4224    for (var n=0; n<this.buttons[command].length; n++) { 
     4225      button = this.buttons[command][n]; 
     4226      obj = document.getElementById(button.id); 
     4227 
     4228      if (button.type=='image' && obj) { 
     4229        obj.setAttribute('alt', this.get_label(label)); 
     4230        if ((link = obj.parentNode) && link.tagName.toLowerCase() == 'a') 
     4231          link.setAttribute('title', this.get_label(label)); 
     4232      } 
     4233      else if (obj) 
     4234        obj.setAttribute('title', this.get_label(label)); 
     4235    } 
     4236  }; 
    43044237 
    43054238  // mouse over button 
    43064239  this.button_over = function(command, id) 
    43074240  { 
    4308     var a_buttons = this.buttons[command]; 
    4309     var button, elm; 
    4310  
    4311     if(!a_buttons || !a_buttons.length) 
     4241    var button, elm, a_buttons = this.buttons[command]; 
     4242 
     4243    if (!a_buttons || !a_buttons.length) 
    43124244      return false; 
    43134245 
    4314     for(var n=0; n<a_buttons.length; n++) 
    4315     { 
     4246    for (var n=0; n<a_buttons.length; n++) { 
    43164247      button = a_buttons[n]; 
    4317       if(button.id==id && button.status=='act') 
    4318       { 
     4248      if (button.id == id && button.status == 'act') { 
    43194249        elm = document.getElementById(button.id); 
    43204250        if (elm && button.over) { 
     
    43314261  this.button_sel = function(command, id) 
    43324262  { 
    4333     var a_buttons = this.buttons[command]; 
    4334     var button, elm; 
    4335  
    4336     if(!a_buttons || !a_buttons.length) 
     4263    var button, elm, a_buttons = this.buttons[command]; 
     4264 
     4265    if (!a_buttons || !a_buttons.length) 
    43374266      return; 
    43384267 
    4339     for(var n=0; n<a_buttons.length; n++) 
    4340     { 
     4268    for (var n=0; n<a_buttons.length; n++) { 
    43414269      button = a_buttons[n]; 
    4342       if(button.id==id && button.status=='act') 
    4343       { 
     4270      if (button.id == id && button.status == 'act') { 
    43444271        elm = document.getElementById(button.id); 
    43454272        if (elm && button.sel) { 
     
    43574284  this.button_out = function(command, id) 
    43584285  { 
    4359     var a_buttons = this.buttons[command]; 
    4360     var button, elm; 
    4361  
    4362     if(!a_buttons || !a_buttons.length) 
     4286    var button, elm, a_buttons = this.buttons[command]; 
     4287 
     4288    if (!a_buttons || !a_buttons.length) 
    43634289      return; 
    43644290 
    4365     for(var n=0; n<a_buttons.length; n++) 
    4366     { 
     4291    for (var n=0; n<a_buttons.length; n++) { 
    43674292      button = a_buttons[n]; 
    4368       if(button.id==id && button.status=='act') 
    4369       { 
     4293      if (button.id == id && button.status == 'act') { 
    43704294        elm = document.getElementById(button.id); 
    43714295        if (elm && button.act) { 
     
    43844308    if (title && document.title) 
    43854309      document.title = title; 
    4386   } 
     4310  }; 
    43874311 
    43884312  // display a system message 
    43894313  this.display_message = function(msg, type, hold) 
    4390     { 
    4391     if (!this.loaded)  // save message in order to display after page loaded 
    4392       { 
     4314  { 
     4315    if (!this.loaded) { 
     4316      // save message in order to display after page loaded 
    43934317      this.pending_message = new Array(msg, type); 
    43944318      return true; 
    4395       } 
     4319    } 
    43964320 
    43974321    // pass command to parent window 
     
    44044328    if (this.message_timer) 
    44054329      clearTimeout(this.message_timer); 
    4406      
     4330 
    44074331    var cont = msg; 
    44084332    if (type) 
     
    44104334 
    44114335    var obj = $(this.gui_objects.message).html(cont).show(); 
    4412      
     4336 
    44134337    if (type!='loading') 
    44144338      obj.bind('mousedown', function(){ ref.hide_message(); return true; }); 
    4415      
     4339 
    44164340    if (!hold) 
    44174341      this.message_timer = window.setTimeout(function(){ ref.hide_message(true); }, this.message_time); 
    4418     }; 
     4342  }; 
    44194343 
    44204344  // make a message row disapear 
    44214345  this.hide_message = function(fade) 
    4422     { 
     4346  { 
    44234347    if (this.gui_objects.message) 
    44244348      $(this.gui_objects.message).unbind()[(fade?'fadeOut':'hide')](); 
    4425     }; 
     4349  }; 
    44264350 
    44274351  // mark a mailbox as selected and set environment variable 
    44284352  this.select_folder = function(name, old, prefix) 
    44294353  { 
    4430     if (this.gui_objects.folderlist) 
    4431     { 
     4354    if (this.gui_objects.folderlist) { 
    44324355      var current_li, target_li; 
    4433        
     4356 
    44344357      if ((current_li = this.get_folder_li(old, prefix))) { 
    44354358        $(current_li).removeClass('selected').removeClass('unfocused'); 
     
    44384361        $(target_li).removeClass('unfocused').addClass('selected'); 
    44394362      } 
    4440        
     4363 
    44414364      // trigger event hook 
    44424365      this.triggerEvent('selectfolder', { folder:name, old:old, prefix:prefix }); 
     
    44494372    if (!prefix) 
    44504373      prefix = 'rcmli'; 
    4451     if (this.gui_objects.folderlist) 
    4452     { 
     4374 
     4375    if (this.gui_objects.folderlist) { 
    44534376      name = String(name).replace(this.identifier_expr, '_'); 
    44544377      return document.getElementById(prefix+name); 
     
    44634386  {  
    44644387    this.env.coltypes = coltypes; 
    4465      
     4388 
    44664389    // set correct list titles 
    44674390    var thead = this.gui_objects.messagelist ? this.gui_objects.messagelist.tHead : null; 
     
    44824405 
    44834406    var cell, col, n; 
    4484     for (n=0; thead && n<this.env.coltypes.length; n++) 
    4485       { 
     4407    for (n=0; thead && n<this.env.coltypes.length; n++) { 
    44864408      col = this.env.coltypes[n]; 
    4487       if ((cell = thead.rows[0].cells[n+1]) && (col=='from' || col=='to')) 
    4488         { 
     4409      if ((cell = thead.rows[0].cells[n+1]) && (col=='from' || col=='to')) { 
    44894410        // if we have links for sorting, it's a bit more complicated... 
    4490         if (cell.firstChild && cell.firstChild.tagName.toLowerCase()=='a') 
    4491           { 
     4411        if (cell.firstChild && cell.firstChild.tagName.toLowerCase()=='a') { 
    44924412          cell.firstChild.innerHTML = this.get_label(this.env.coltypes[n]); 
    44934413          cell.firstChild.onclick = function(){ return rcmail.command('sort', this.__col, this); }; 
    44944414          cell.firstChild.__col = col; 
    4495           } 
     4415        } 
    44964416        else 
    44974417          cell.innerHTML = this.get_label(this.env.coltypes[n]); 
    44984418 
    44994419        cell.id = 'rcm'+col; 
    4500         } 
    4501       } 
     4420      } 
     4421    } 
    45024422 
    45034423    // remove excessive columns 
     
    45094429 
    45104430    var found; 
    4511     if((found = jQuery.inArray('subject', this.env.coltypes)) >= 0) { 
     4431    if((found = $.inArray('subject', this.env.coltypes)) >= 0) { 
    45124432      this.set_env('subject_col', found); 
    45134433      if (this.message_list) 
    45144434        this.message_list.subject_col = found+1; 
    4515       } 
    4516     if((found = jQuery.inArray('flag', this.env.coltypes)) >= 0) 
     4435    } 
     4436    if((found = $.inArray('flag', this.env.coltypes)) >= 0) 
    45174437      this.set_env('flagged_col', found); 
    45184438  }; 
     
    45204440  // replace content of row count display 
    45214441  this.set_rowcount = function(text) 
    4522     { 
     4442  { 
    45234443    $(this.gui_objects.countdisplay).html(text); 
    45244444 
    45254445    // update page navigation buttons 
    45264446    this.set_page_buttons(); 
    4527     }; 
     4447  }; 
    45284448 
    45294449  // replace content of mailboxname display 
    45304450  this.set_mailboxname = function(content) 
    4531     { 
     4451  { 
    45324452    if (this.gui_objects.mailboxname && content) 
    45334453      this.gui_objects.mailboxname.innerHTML = content; 
    4534     }; 
     4454  }; 
    45354455 
    45364456  // replace content of quota display 
    45374457  this.set_quota = function(content) 
    4538     { 
     4458  { 
    45394459    if (content && this.gui_objects.quotadisplay) { 
    45404460      if (typeof(content) == 'object') 
     
    45424462      else 
    45434463        $(this.gui_objects.quotadisplay).html(content); 
    4544       } 
    4545     }; 
     4464    } 
     4465  }; 
    45464466 
    45474467  // update the mailboxlist 
    45484468  this.set_unread_count = function(mbox, count, set_title) 
    4549     { 
     4469  { 
    45504470    if (!this.gui_objects.mailboxlist) 
    45514471      return false; 
     
    45534473    this.env.unread_counts[mbox] = count; 
    45544474    this.set_unread_count_display(mbox, set_title); 
    4555     } 
     4475  }; 
    45564476 
    45574477  // update the mailbox count display 
    45584478  this.set_unread_count_display = function(mbox, set_title) 
    4559     { 
     4479  { 
    45604480    var reg, text_obj, item, mycount, childcount, div; 
    4561     if (item = this.get_folder_li(mbox)) 
    4562       { 
     4481    if (item = this.get_folder_li(mbox)) { 
    45634482      mycount = this.env.unread_counts[mbox] ? this.env.unread_counts[mbox] : 0; 
    45644483      text_obj = item.getElementsByTagName('a')[0]; 
     
    45674486      childcount = 0; 
    45684487      if ((div = item.getElementsByTagName('div')[0]) && 
    4569           div.className.match(/collapsed/)) 
    4570         { 
     4488          div.className.match(/collapsed/)) { 
    45714489        // add children's counters 
    45724490        for (var k in this.env.unread_counts)  
    45734491          if (k.indexOf(mbox + this.env.delimiter) == 0) 
    45744492            childcount += this.env.unread_counts[k]; 
    4575         } 
     4493      } 
    45764494 
    45774495      if (mycount && text_obj.innerHTML.match(reg)) 
     
    45924510      else 
    45934511        $(item).removeClass('unread'); 
    4594       } 
     4512    } 
    45954513 
    45964514    // set unread count to window title 
    45974515    reg = /^\([0-9]+\)\s+/i; 
    4598     if (set_title && document.title) 
    4599       { 
     4516    if (set_title && document.title) { 
    46004517      var doc_title = String(document.title); 
    46014518      var new_title = ""; 
     
    46074524      else 
    46084525        new_title = doc_title.replace(reg, ''); 
    4609          
     4526 
    46104527      this.set_pagetitle(new_title); 
    4611       } 
    4612     }; 
     4528    } 
     4529  }; 
    46134530 
    46144531  // notifies that a new message(s) has hit the mailbox 
    46154532  this.new_message_focus = function() 
    4616     { 
     4533  { 
    46174534    // focus main window 
    46184535    if (this.env.framed && window.parent) 
     
    46204537    else 
    46214538      window.focus(); 
    4622     } 
     4539  }; 
    46234540 
    46244541  this.toggle_prefer_html = function(checkbox) 
    4625     { 
     4542  { 
    46264543    var addrbook_show_images; 
    46274544    if (addrbook_show_images = document.getElementById('rcmfd_addrbook_show_images')) 
    46284545      addrbook_show_images.disabled = !checkbox.checked; 
    4629     } 
     4546  }; 
    46304547 
    46314548  this.toggle_preview_pane = function(checkbox) 
    4632     { 
     4549  { 
    46334550    var preview_pane_mark_read; 
    46344551    if (preview_pane_mark_read = document.getElementById('rcmfd_preview_pane_mark_read')) 
    46354552      preview_pane_mark_read.disabled = !checkbox.checked; 
    4636     } 
     4553  }; 
    46374554 
    46384555  // display fetched raw headers 
     
    46514568  // display all-headers row and fetch raw message headers 
    46524569  this.load_headers = function(elem) 
    4653     { 
     4570  { 
    46544571    if (!this.gui_objects.all_headers_row || !this.gui_objects.all_headers_box || !this.env.uid) 
    46554572      return; 
    4656      
     4573 
    46574574    $(elem).removeClass('show-headers').addClass('hide-headers'); 
    46584575    $(this.gui_objects.all_headers_row).show(); 
    4659     elem.onclick = function() { rcmail.hide_headers(elem); } 
     4576    elem.onclick = function() { rcmail.hide_headers(elem); }; 
    46604577 
    46614578    // fetch headers only once 
    4662     if (!this.gui_objects.all_headers_box.innerHTML) 
    4663       { 
     4579    if (!this.gui_objects.all_headers_box.innerHTML) { 
    46644580      this.display_message(this.get_label('loading'), 'loading', true); 
    46654581      this.http_post('headers', '_uid='+this.env.uid); 
    4666       } 
    4667     } 
     4582    } 
     4583  }; 
    46684584 
    46694585  // hide all-headers row 
    46704586  this.hide_headers = function(elem) 
    4671     { 
     4587  { 
    46724588    if (!this.gui_objects.all_headers_row || !this.gui_objects.all_headers_box) 
    46734589      return; 
     
    46754591    $(elem).removeClass('hide-headers').addClass('show-headers'); 
    46764592    $(this.gui_objects.all_headers_row).hide(); 
    4677     elem.onclick = function() { rcmail.load_headers(elem); } 
    4678     } 
     4593    elem.onclick = function() { rcmail.load_headers(elem); }; 
     4594  }; 
    46794595 
    46804596  // percent (quota) indicator 
    46814597  this.percent_indicator = function(obj, data) 
    4682     { 
     4598  { 
    46834599    if (!data || !obj) 
    46844600      return false; 
     
    46944610    this.env.indicator_width = width; 
    46954611    this.env.indicator_height = height; 
    4696      
     4612 
    46974613    // overlimit 
    46984614    if (quota_width > width) { 
    46994615      quota_width = width; 
    47004616      quota = 100;  
    4701       } 
    4702    
     4617    } 
     4618 
    47034619    // main div 
    47044620    var main = $('<div>'); 
    47054621    main.css({position: 'absolute', top: pos.top, left: pos.left, 
    4706         width: width + 'px', height: height + 'px', zIndex: 100, lineHeight: height + 'px'}) 
    4707         .attr('title', data.title).addClass('quota_text').html(quota + '%'); 
     4622            width: width + 'px', height: height + 'px', zIndex: 100, lineHeight: height + 'px'}) 
     4623          .attr('title', data.title).addClass('quota_text').html(quota + '%'); 
    47084624    // used bar 
    47094625    var bar1 = $('<div>'); 
    47104626    bar1.css({position: 'absolute', top: pos.top + 1, left: pos.left + 1, 
    4711         width: quota_width + 'px', height: height + 'px', zIndex: 99}); 
     4627            width: quota_width + 'px', height: height + 'px', zIndex: 99}); 
    47124628    // background 
    47134629    var bar2 = $('<div>'); 
    47144630    bar2.css({position: 'absolute', top: pos.top + 1, left: pos.left + 1, 
    4715         width: width + 'px', height: height + 'px', zIndex: 98}) 
    4716         .addClass('quota_bg'); 
     4631            width: width + 'px', height: height + 'px', zIndex: 98}) 
     4632          .addClass('quota_bg'); 
    47174633 
    47184634    if (quota >= limit_high) { 
    47194635      main.addClass(' quota_text_high'); 
    47204636      bar1.addClass('quota_high'); 
    4721       } 
     4637    } 
    47224638    else if(quota >= limit_mid) { 
    47234639      main.addClass(' quota_text_mid'); 
    47244640      bar1.addClass('quota_mid'); 
    4725       } 
     4641    } 
    47264642    else { 
    47274643      main.addClass(' quota_text_normal'); 
    47284644      bar1.addClass('quota_low'); 
    4729       } 
     4645    } 
    47304646 
    47314647    // replace quota image 
    47324648    obj.innerHTML = ''; 
    47334649    $(obj).append(bar1).append(bar2).append(main); 
    4734     } 
     4650  }; 
    47354651 
    47364652  /********************************************************/ 
     
    47394655 
    47404656  this.html2plain = function(htmlText, id) 
    4741     { 
     4657  { 
    47424658    var url = this.env.bin_path+'html2text.php'; 
    47434659    var rcmail = this; 
     
    47494665      error: function(o) { rcmail.http_error(o); }, 
    47504666      success: function(data) { rcmail.set_busy(false); $(document.getElementById(id)).val(data); console.log(data); } 
    4751       }); 
    4752     } 
     4667    }); 
     4668  }; 
    47534669 
    47544670  this.plain2html = function(plainText, id) 
    4755     { 
     4671  { 
    47564672    this.set_busy(true, 'converting'); 
    47574673    $(document.getElementById(id)).val('<pre>'+plainText+'</pre>'); 
    47584674    this.set_busy(false); 
    4759     } 
     4675  }; 
    47604676 
    47614677 
     
    47654681 
    47664682  this.redirect = function(url, lock) 
    4767     { 
     4683  { 
    47684684    if (lock || lock === null) 
    47694685      this.set_busy(true); 
     
    47734689    else 
    47744690      location.href = url; 
    4775     }; 
     4691  }; 
    47764692 
    47774693  this.goto_url = function(action, query, lock) 
    4778     { 
     4694  { 
    47794695    var querystring = query ? '&'+query : ''; 
    47804696    this.redirect(this.env.comm_path+'&_action='+action+querystring, lock); 
    4781     }; 
     4697  }; 
    47824698 
    47834699  // send a http request to the server 
     
    47864702    querystring += (querystring ? '&' : '') + '_remote=1'; 
    47874703    var url = this.env.comm_path + '&_action=' + action + '&' + querystring 
    4788      
     4704 
    47894705    // send request 
    47904706    console.log('HTTP GET: ' + url); 
    4791     jQuery.get(url, { _unlock:(lock?1:0) }, function(data){ ref.http_response(data); }, 'json'); 
     4707    $.get(url, { _unlock:(lock?1:0) }, function(data){ ref.http_response(data); }, 'json'); 
    47924708  }; 
    47934709 
     
    47964712  { 
    47974713    var url = this.env.comm_path+'&_action=' + action; 
    4798      
     4714 
    47994715    if (postdata && typeof(postdata) == 'object') { 
    48004716      postdata._remote = 1; 
     
    48064722    // send request 
    48074723    console.log('HTTP POST: ' + url); 
    4808     jQuery.post(url, postdata, function(data){ ref.http_response(data); }, 'json'); 
     4724    $.post(url, postdata, function(data){ ref.http_response(data); }, 'json'); 
    48094725  }; 
    48104726 
     
    48134729  { 
    48144730    var console_msg = ''; 
    4815      
     4731 
    48164732    if (response.unlock) 
    48174733      this.set_busy(false); 
     
    48334749      eval(response.exec); 
    48344750    } 
    4835      
     4751 
    48364752    // execute callback functions of plugins 
    48374753    if (response.callbacks && response.callbacks.length) { 
     
    48494765          this.enable_command('export', (this.contact_list && this.contact_list.rowcount > 0)); 
    48504766        } 
    4851        
     4767 
    48524768      case 'moveto': 
    48534769        if (this.env.action == 'show') { 
     
    48574773          this.message_list.init(); 
    48584774        break; 
    4859          
     4775 
    48604776      case 'purge': 
    48614777      case 'expunge': 
     
    48834799          this.enable_command('show', 'expunge', 'select-all', 'select-none', 'sort', (this.env.messagecount > 0)); 
    48844800          this.enable_command('purge', this.purge_mailbox_test()); 
    4885           
     4801 
    48864802          this.enable_command('expand-all', 'expand-unread', 'collapse-all', this.env.threading && this.env.messagecount); 
    48874803 
     
    48914807        else if (this.task == 'addressbook') { 
    48924808          this.enable_command('export', (this.contact_list && this.contact_list.rowcount > 0)); 
    4893            
     4809 
    48944810          if (response.action == 'list') { 
    48954811            this.enable_command('group-create', this.env.address_sources[this.env.source].groups); 
     
    49044820  // handle HTTP request errors 
    49054821  this.http_error = function(request, status, err) 
    4906     { 
     4822  { 
    49074823    var errmsg = request.statusText; 
    49084824 
    49094825    this.set_busy(false); 
    49104826    request.abort(); 
    4911      
     4827 
    49124828    if (errmsg) 
    49134829      this.display_message(this.get_label('servererror') + ' (' + errmsg + ')', 'error'); 
    4914     }; 
     4830  }; 
    49154831 
    49164832  // use an image to send a keep-alive siganl to the server 
    49174833  this.send_keep_alive = function() 
    4918     { 
     4834  { 
    49194835    var d = new Date(); 
    49204836    this.http_request('keep-alive', '_t='+d.getTime()); 
    4921     }; 
     4837  }; 
    49224838 
    49234839  // start interval for keep-alive/recent_check signal 
    49244840  this.start_keepalive = function() 
    4925     { 
     4841  { 
    49264842    if (this.env.keep_alive && !this.env.framed && this.task=='mail' && this.gui_objects.mailboxlist) 
    49274843      this._int = setInterval(function(){ ref.check_for_recent(false); }, this.env.keep_alive * 1000); 
    49284844    else if (this.env.keep_alive && !this.env.framed && this.task!='login') 
    49294845      this._int = setInterval(function(){ ref.send_keep_alive(); }, this.env.keep_alive * 1000); 
    4930     } 
     4846  }; 
    49314847 
    49324848  // send periodic request to check for recent messages 
    49334849  this.check_for_recent = function(refresh) 
    4934     { 
     4850  { 
    49354851    if (this.busy) 
    49364852      return; 
     
    49514867 
    49524868    this.http_request('check-recent', addurl, true); 
    4953     }; 
     4869  }; 
    49544870 
    49554871 
     
    49574873  /*********            helper methods            *********/ 
    49584874  /********************************************************/ 
    4959    
     4875 
    49604876  // check if we're in show mode or if we have a unique selection 
    49614877  // and return the message uid 
    49624878  this.get_single_uid = function() 
    4963     { 
     4879  { 
    49644880    return this.env.uid ? this.env.uid : (this.message_list ? this.message_list.get_single_selection() : null); 
    4965     }; 
     4881  }; 
    49664882 
    49674883  // same as above but for contacts 
    49684884  this.get_single_cid = function() 
    4969     { 
     4885  { 
    49704886    return this.env.cid ? this.env.cid : (this.contact_list ? this.contact_list.get_single_selection() : null); 
    4971     }; 
    4972  
    4973  
     4887  }; 
     4888 
     4889  // gets cursor position 
    49744890  this.get_caret_pos = function(obj) 
    4975     { 
     4891  { 
    49764892    if (typeof(obj.selectionEnd)!='undefined') 
    49774893      return obj.selectionEnd; 
    4978     else if (document.selection && document.selection.createRange) 
    4979       { 
     4894    else if (document.selection && document.selection.createRange) { 
    49804895      var range = document.selection.createRange(); 
    49814896      if (range.parentElement()!=obj) 
     
    49834898 
    49844899      var gm = range.duplicate(); 
    4985       if (obj.tagName=='TEXTAREA') 
     4900      if (obj.tagName == 'TEXTAREA') 
    49864901        gm.moveToElementText(obj); 
    49874902      else 
    49884903        gm.expand('textedit'); 
    4989        
     4904 
    49904905      gm.setEndPoint('EndToStart', range); 
    49914906      var p = gm.text.length; 
    49924907 
    49934908      return p<=obj.value.length ? p : -1; 
    4994       } 
     4909    } 
    49954910    else 
    49964911      return obj.value.length; 
    4997     }; 
    4998  
     4912  }; 
     4913 
     4914  // moves cursor to specified position 
    49994915  this.set_caret_pos = function(obj, pos) 
    5000     { 
     4916  { 
    50014917    if (obj.setSelectionRange) 
    50024918      obj.setSelectionRange(pos, pos); 
    5003     else if (obj.createTextRange) 
    5004       { 
     4919    else if (obj.createTextRange) { 
    50054920      var range = obj.createTextRange(); 
    50064921      range.collapse(true); 
     
    50084923      range.moveStart('character', pos); 
    50094924      range.select(); 
    5010       } 
    5011     } 
     4925    } 
     4926  }; 
    50124927 
    50134928  // set all fields of a form disabled 
    50144929  this.lock_form = function(form, lock) 
    5015     { 
     4930  { 
    50164931    if (!form || !form.elements) 
    50174932      return; 
    5018      
     4933 
    50194934    var type; 
    5020     for (var n=0; n<form.elements.length; n++) 
    5021       { 
     4935    for (var n=0; n<form.elements.length; n++) { 
    50224936      type = form.elements[n]; 
    50234937      if (type=='hidden') 
    50244938        continue; 
    5025          
     4939 
    50264940      form.elements[n].disabled = lock; 
    5027       } 
    5028     }; 
    5029      
     4941    } 
     4942  }; 
     4943 
    50304944}  // end object rcube_webmail 
    50314945 
  • program/js/common.js

    r186537b r8fa9229  
    2525 */ 
    2626function roundcube_browser() 
    27   { 
     27{ 
    2828  this.ver = parseFloat(navigator.appVersion); 
    2929  this.appver = navigator.appVersion; 
     
    7373    this.vendver = (/khtml\/([0-9\.]+)/i.test(this.agent)) ? parseFloat(RegExp.$1) : 0; 
    7474 
    75  
    7675  // get real language out of safari's user agent 
    7776  if(this.safari && (/;\s+([a-z]{2})-[a-z]{2}\)/i.test(this.agent))) 
     
    8685   
    8786  // test for XMLHTTP support 
    88   this.xmlhttp_test = function() 
    89     { 
     87  this.xmlhttp_test = function() { 
    9088    var activeX_test = new Function("try{var o=new ActiveXObject('Microsoft.XMLHTTP');return true;}catch(err){return false;}"); 
    9189    this.xmlhttp = (window.XMLHttpRequest || (window.ActiveXObject && activeX_test())) ? true : false; 
    9290    return this.xmlhttp; 
    93     } 
    94   } 
     91  } 
     92}; 
    9593 
    9694 
     
    133131  e = e || window.event; 
    134132 
    135   if (bw.mac && e) 
    136     { 
     133  if (bw.mac && e) { 
    137134    opcode += (e.metaKey && CONTROL_KEY) + (e.shiftKey && SHIFT_KEY); 
    138135    return opcode;     
    139     } 
    140   if (e) 
    141     { 
     136  } 
     137  if (e) { 
    142138    opcode += (e.ctrlKey && CONTROL_KEY) + (e.shiftKey && SHIFT_KEY); 
    143139    return opcode; 
    144     } 
     140  } 
    145141}, 
    146142 
     
    154150  var mY = (e.pageY) ? e.pageY : e.clientY; 
    155151 
    156   if (document.body && document.all) 
    157   { 
     152  if (document.body && document.all) { 
    158153    mX += document.body.scrollLeft; 
    159154    mY += document.body.scrollTop; 
     
    187182  if (p.element.addEventListener) 
    188183    p.element.addEventListener(p.event, p.object._rc_events[key], false); 
    189   else if (p.element.attachEvent) 
    190     { 
     184  else if (p.element.attachEvent) { 
    191185    // IE allows multiple events with the same function to be applied to the same object 
    192186    // forcibly detach the event, then attach 
    193187    p.element.detachEvent('on'+p.event, p.object._rc_events[key]); 
    194188    p.element.attachEvent('on'+p.event, p.object._rc_events[key]); 
    195     } 
     189  } 
    196190  else 
    197191    p.element['on'+p.event] = p.object._rc_events[key]; 
     
    242236{ 
    243237  this._events = {}; 
    244 } 
     238}; 
    245239 
    246240rcube_event_engine.prototype = { 
     
    314308} 
    315309 
    316 }  // end rcube_event_engine.prototype 
     310};  // end rcube_event_engine.prototype 
    317311 
    318312 
     
    329323  // create a new layer in the current document 
    330324  this.create = function(arg) 
    331     { 
     325  { 
    332326    var l = (arg.x) ? arg.x : 0; 
    333327    var t = (arg.y) ? arg.y : 0; 
     
    341335    obj = document.createElement('DIV'); 
    342336 
    343     with(obj) 
    344       { 
     337    with(obj) { 
    345338      id = this.name; 
    346       with(style) 
    347         { 
    348         position = 'absolute'; 
     339      with(style) { 
     340            position = 'absolute'; 
    349341        visibility = (vis) ? (vis==2) ? 'inherit' : 'visible' : 'hidden'; 
    350342        left = l+'px'; 
    351343        top = t+'px'; 
    352344        if (w) 
    353           width = w.toString().match(/\%$/) ? w : w+'px'; 
     345              width = w.toString().match(/\%$/) ? w : w+'px'; 
    354346        if (h) 
    355           height = h.toString().match(/\%$/) ? h : h+'px'; 
     347              height = h.toString().match(/\%$/) ? h : h+'px'; 
    356348        if(z) zIndex = z; 
    357         } 
    358       } 
     349          } 
     350    } 
    359351 
    360352    if (parent) 
     
    364356 
    365357    this.elm = obj; 
    366     }; 
    367  
     358  }; 
    368359 
    369360  // create new layer 
    370   if(attributes!=null) 
    371     { 
     361  if(attributes != null) { 
    372362    this.create(attributes); 
    373363    this.name = this.elm.id; 
    374     } 
     364  } 
    375365  else  // just refer to the object 
    376366    this.elm = document.getElementById(id); 
    377  
    378367 
    379368  if(!this.elm) 
     
    394383  // ********* layer object methods ********* 
    395384 
    396  
    397385  // move the layer to a specific position 
    398386  this.move = function(x, y) 
    399     { 
     387  { 
    400388    this.x = x; 
    401389    this.y = y; 
    402390    this.css.left = Math.round(this.x)+'px'; 
    403391    this.css.top = Math.round(this.y)+'px'; 
    404     } 
     392  }; 
    405393 
    406394  // change the layers width and height 
    407395  this.resize = function(w,h) 
    408     { 
     396  { 
    409397    this.css.width  = w+'px'; 
    410398    this.css.height = h+'px'; 
    411399    this.width = w; 
    412400    this.height = h; 
    413     } 
    414  
     401  }; 
    415402 
    416403  // show or hide the layer 
    417404  this.show = function(a) 
    418     { 
    419     if(a==1) 
    420       { 
     405  { 
     406    if(a == 1) { 
    421407      this.css.visibility = 'visible'; 
    422408      this.visible = true; 
    423       } 
    424     else if(a==2) 
    425       { 
     409    } 
     410    else if(a == 2) { 
    426411      this.css.visibility = 'inherit'; 
    427412      this.visible = true; 
    428       } 
    429     else 
    430       { 
     413    } 
     414    else { 
    431415      this.css.visibility = 'hidden'; 
    432416      this.visible = false; 
    433       } 
    434417    } 
    435  
     418  }; 
    436419 
    437420  // write new content into a Layer 
    438421  this.write = function(cont) 
    439     { 
     422  { 
    440423    this.elm.innerHTML = cont; 
    441     } 
    442  
    443 } 
     424  }; 
     425 
     426}; 
    444427 
    445428 
     
    448431// http://code.iamcal.com/php/rfc822/ 
    449432function rcube_check_email(input, inline) 
    450   { 
    451   if (input && window.RegExp) 
    452     { 
     433{ 
     434  if (input && window.RegExp) { 
    453435    var qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; 
    454436    var dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; 
     
    465447    var reg1 = inline ? new RegExp('(^|<|'+delim+')'+addr_spec+'($|>|'+delim+')', 'i') : new RegExp('^'+addr_spec+'$', 'i'); 
    466448    return reg1.test(input) ? true : false; 
    467     } 
     449  } 
    468450  return false; 
    469   } 
    470    
     451}; 
     452 
    471453 
    472454// recursively copy an object 
     
    483465   
    484466  return out; 
    485 } 
     467}; 
    486468 
    487469// make a string URL safe 
     
    489471{ 
    490472  return window.encodeURIComponent ? encodeURIComponent(str) : escape(str); 
    491 } 
     473}; 
    492474 
    493475 
     
    524506 
    525507  return obj; 
    526 } 
     508}; 
    527509 
    528510// determine whether the mouse is over the given object or not 
     
    534516  return ((mouse.x >= pos.left) && (mouse.x < (pos.left + obj.offsetWidth)) && 
    535517    (mouse.y >= pos.top) && (mouse.y < (pos.top + obj.offsetHeight))); 
    536 } 
     518}; 
    537519 
    538520 
    539521// cookie functions by GoogieSpell 
    540522function setCookie(name, value, expires, path, domain, secure) 
    541   { 
     523{ 
    542524  var curCookie = name + "=" + escape(value) + 
    543525      (expires ? "; expires=" + expires.toGMTString() : "") + 
     
    546528      (secure ? "; secure" : ""); 
    547529  document.cookie = curCookie; 
    548   } 
    549  
    550 roundcube_browser.prototype.set_cookie = setCookie; 
     530}; 
    551531 
    552532function getCookie(name) 
    553   { 
     533{ 
    554534  var dc = document.cookie; 
    555535  var prefix = name + "="; 
    556536  var begin = dc.indexOf("; " + prefix); 
    557   if (begin == -1) 
    558     { 
     537  if (begin == -1) { 
    559538    begin = dc.indexOf(prefix); 
    560539    if (begin != 0) return null; 
    561     } 
     540  } 
    562541  else 
    563542    begin += 2;   
     
    566545    end = dc.length; 
    567546  return unescape(dc.substring(begin + prefix.length, end)); 
    568   } 
    569  
     547}; 
     548 
     549roundcube_browser.prototype.set_cookie = setCookie; 
    570550roundcube_browser.prototype.get_cookie = getCookie; 
    571551 
     
    598578      box.innerText = box.value = ''; 
    599579  }; 
    600 } 
     580}; 
    601581 
    602582var bw = new roundcube_browser(); 
     
    608588// http://dev.rubyonrails.org/changeset/7271 
    609589RegExp.escape = function(str) 
    610   { 
     590{ 
    611591  return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); 
    612   } 
     592}; 
    613593 
    614594 
    615595// Make getElementById() case-sensitive on IE 
    616596if (bw.ie) 
    617   { 
     597{ 
    618598  document._getElementById = document.getElementById; 
    619599  document.getElementById = function(id) 
    620     { 
     600  { 
    621601    var i = 0; 
    622602    var o = document._getElementById(id); 
     
    627607 
    628608    return o; 
    629     } 
    630   } 
     609  } 
     610}; 
  • program/js/list.js

    rda8f11c r8fa9229  
    2323 */ 
    2424function rcube_list_widget(list, p) 
    25   { 
     25{ 
    2626  // static contants 
    2727  this.ENTER_KEY = 13; 
    2828  this.DELETE_KEY = 46; 
    2929  this.BACKSPACE_KEY = 8; 
    30    
     30 
    3131  this.list = list ? list : null; 
    3232  this.frame = null; 
     
    3434  this.selection = []; 
    3535  this.rowcount = 0; 
    36    
     36 
    3737  this.subject_col = -1; 
    3838  this.shiftkey = false; 
     
    4343  this.keyboard = false; 
    4444  this.toggleselect = false; 
    45    
     45 
    4646  this.dont_select = false; 
    4747  this.drag_active = false; 
     
    5353  this.dblclick_time = 600; 
    5454  this.row_init = function(){}; 
    55    
     55 
    5656  // overwrite default paramaters 
    57   if (p && typeof(p)=='object') 
     57  if (p && typeof(p) == 'object') 
    5858    for (var n in p) 
    5959      this[n] = p[n]; 
    60   } 
     60}; 
    6161 
    6262 
     
    6969init: function() 
    7070{ 
    71   if (this.list && this.list.tBodies[0]) 
    72   { 
    73     this.rows = new Array(); 
     71  if (this.list && this.list.tBodies[0]) { 
     72    this.rows = []; 
    7473    this.rowcount = 0; 
    7574 
    7675    var row; 
    77     for(var r=0; r<this.list.tBodies[0].childNodes.length; r++) 
    78     { 
     76    for(var r=0; r<this.list.tBodies[0].childNodes.length; r++) { 
    7977      row = this.list.tBodies[0].childNodes[r]; 
    80       while (row && row.nodeType != 1) 
    81       { 
     78      while (row && row.nodeType != 1) { 
    8279        row = row.nextSibling; 
    8380        r++; 
     
    105102{ 
    106103  // make references in internal array and set event handlers 
    107   if (row && String(row.id).match(/rcmrow([a-z0-9\-_=\+\/]+)/i)) 
    108   { 
     104  if (row && String(row.id).match(/rcmrow([a-z0-9\-_=\+\/]+)/i)) { 
    109105    var p = this; 
    110106    var uid = RegExp.$1; 
     
    132128  this.list.insertBefore(tbody, this.list.tBodies[0]); 
    133129  this.list.removeChild(this.list.tBodies[1]); 
    134   this.rows = new Array(); 
     130  this.rows = []; 
    135131  this.rowcount = 0; 
    136    
    137   if (sel) this.clear_selection(); 
     132 
     133  if (sel) 
     134    this.clear_selection(); 
    138135}, 
    139136 
     
    182179{ 
    183180  this.focused = true; 
    184   for (var n=0; n<this.selection.length; n++) 
    185   { 
     181  for (var n=0; n<this.selection.length; n++) { 
    186182    id = this.selection[n]; 
    187183    if (this.rows[id] && this.rows[id].obj) { 
     
    202198  var id; 
    203199  this.focused = false; 
    204   for (var n=0; n<this.selection.length; n++) 
    205   { 
     200  for (var n=0; n<this.selection.length; n++) { 
    206201    id = this.selection[n]; 
    207202    if (this.rows[id] && this.rows[id].obj) { 
     
    222217  if (this.dont_select || (evtarget && (tagname == 'input' || tagname == 'img'))) 
    223218    return true; 
    224      
     219 
    225220  // accept right-clicks 
    226221  if (rcube_event.get_button(e) == 2) 
    227222    return true; 
    228    
     223 
    229224  this.in_selection_before = this.in_selection(id) ? id : false; 
    230225 
    231226  // selects currently unselected row 
    232   if (!this.in_selection_before) 
    233   { 
     227  if (!this.in_selection_before) { 
    234228    var mod_key = rcube_event.get_modifier(e); 
    235229    this.select_row(id, mod_key, false); 
    236230  } 
    237231 
    238   if (this.draggable && this.selection.length) 
    239   { 
     232  if (this.draggable && this.selection.length) { 
    240233    this.drag_start = true; 
    241234    this.drag_mouse_start = rcube_event.get_mouse_pos(e); 
     
    273266 
    274267  // don't do anything (another action processed before) 
    275   if (this.dont_select) 
    276     { 
     268  if (this.dont_select) { 
    277269    this.dont_select = false; 
    278270    return false; 
    279271    } 
    280      
     272 
    281273  var dblclicked = now - this.rows[id].clicked < this.dblclick_time; 
    282274 
     
    426418    this.update_expando(row.uid); 
    427419    this.triggerEvent('expandcollapse', { uid:row.uid, expanded:row.expanded }); 
    428      
     420 
    429421    // don't collapse sub-root tree in multiexpand mode  
    430422    if (depth && this.multiexpand) 
     
    536528get_first_row: function() 
    537529{ 
    538   if (this.rowcount) 
    539     { 
     530  if (this.rowcount) { 
    540531    var rows = this.list.tBodies[0].rows; 
    541532 
    542533    for(var i=0; i<rows.length-1; i++) 
    543534      if(rows[i].id && String(rows[i].id).match(/rcmrow([a-z0-9\-_=\+\/]+)/i) && this.rows[RegExp.$1] != null) 
     535 
    544536        return RegExp.$1; 
    545     } 
     537  } 
    546538 
    547539  return null; 
     
    550542get_last_row: function() 
    551543{ 
    552   if (this.rowcount) 
    553     { 
     544  if (this.rowcount) { 
    554545    var rows = this.list.tBodies[0].rows; 
    555546 
    556547    for(var i=rows.length-1; i>=0; i--) 
    557548      if(rows[i].id && String(rows[i].id).match(/rcmrow([a-z0-9\-_=\+\/]+)/i) && this.rows[RegExp.$1] != null) 
     549 
    558550        return RegExp.$1; 
    559     } 
     551  } 
    560552 
    561553  return null; 
     
    571563  if (!this.multiselect) 
    572564    mod_key = 0; 
    573      
     565 
    574566  if (!this.shift_start) 
    575567    this.shift_start = id 
    576568 
    577   if (!mod_key) 
    578   { 
     569  if (!mod_key) { 
    579570    this.shift_start = id; 
    580571    this.highlight_row(id, false); 
    581572    this.multi_selecting = false; 
    582573  } 
    583   else 
    584   { 
    585     switch (mod_key) 
    586     { 
     574  else { 
     575    switch (mod_key) { 
    587576      case SHIFT_KEY: 
    588577        this.shift_select(id, false); 
     
    613602 
    614603  // unselect if toggleselect is active and the same row was clicked again 
    615   if (this.toggleselect && this.last_selected == id) 
    616   { 
     604  if (this.toggleselect && this.last_selected == id) { 
    617605    this.clear_selection(); 
    618606    id = null; 
     
    691679  if (!this.rows[uid] || !this.rows[uid].has_children) 
    692680    return; 
    693    
     681 
    694682  var depth = this.rows[uid].depth; 
    695683  var row = this.rows[uid].obj.nextSibling; 
     
    723711 
    724712  // iterate through the entire message list 
    725   for (var n in this.rows) 
    726   { 
    727     if ((this.rows[n].obj.rowIndex >= i) && (this.rows[n].obj.rowIndex <= j)) 
    728     { 
     713  for (var n in this.rows) { 
     714    if ((this.rows[n].obj.rowIndex >= i) && (this.rows[n].obj.rowIndex <= j)) { 
    729715      if (!this.in_selection(n)) { 
    730716        this.highlight_row(n, true); 
    731717      } 
    732718    } 
    733     else 
    734     { 
     719    else { 
    735720      if  (this.in_selection(n) && !control) { 
    736721        this.highlight_row(n, true); 
     
    764749  // reset but remember selection first 
    765750  var select_before = this.selection.join(','); 
    766   this.selection = new Array(); 
    767    
    768   for (var n in this.rows) 
    769   { 
    770     if (!filter || (this.rows[n] && this.rows[n][filter] == true)) 
    771     { 
     751  this.selection = []; 
     752 
     753  for (var n in this.rows) { 
     754    if (!filter || (this.rows[n] && this.rows[n][filter] == true)) { 
    772755      this.last_selected = n; 
    773756      this.highlight_row(n, true); 
    774757    } 
    775     else if (this.rows[n]) 
    776     { 
     758    else if (this.rows[n]) { 
    777759      $(this.rows[n].obj).removeClass('selected').removeClass('unfocused'); 
    778760    } 
     
    799781  // remember old selection 
    800782  var select_before = this.selection.join(','); 
    801    
     783 
    802784  for (var n in this.rows) 
    803785    this.highlight_row(n, true); 
     
    821803 
    822804  // one row 
    823   if (id) 
    824     { 
     805  if (id) { 
    825806    for (var n=0; n<this.selection.length; n++) 
    826807      if (this.selection[n] == id) { 
     
    828809        break; 
    829810      } 
    830     } 
     811  } 
    831812  // all rows 
    832   else 
    833     { 
     813  else { 
    834814    for (var n=0; n<this.selection.length; n++) 
    835815      if (this.rows[this.selection[n]]) { 
    836816        $(this.rows[this.selection[n]].obj).removeClass('selected').removeClass('unfocused'); 
    837         } 
    838      
    839     this.selection = new Array(); 
    840     } 
     817      } 
     818 
     819    this.selection = []; 
     820  } 
    841821 
    842822  if (num_select && !this.selection.length) 
     
    871851highlight_row: function(id, multiple) 
    872852{ 
    873   if (this.rows[id] && !multiple) 
    874   { 
    875     if (this.selection.length > 1 || !this.in_selection(id)) 
    876     { 
     853  if (this.rows[id] && !multiple) { 
     854    if (this.selection.length > 1 || !this.in_selection(id)) { 
    877855      this.clear_selection(); 
    878856      this.selection[0] = id; 
     
    880858    } 
    881859  } 
    882   else if (this.rows[id]) 
    883   { 
    884     if (!this.in_selection(id))  // select row 
    885     { 
     860  else if (this.rows[id]) { 
     861    if (!this.in_selection(id)) { // select row 
    886862      this.selection[this.selection.length] = id; 
    887863      $(this.rows[id].obj).addClass('selected'); 
    888864    } 
    889     else  // unselect row 
    890     { 
    891       var p = jQuery.inArray(id, this.selection); 
     865    else { // unselect row 
     866      var p = $.inArray(id, this.selection); 
    892867      var a_pre = this.selection.slice(0, p); 
    893868      var a_post = this.selection.slice(p+1, this.selection.length); 
     
    910885  var mod_key = rcube_event.get_modifier(e); 
    911886 
    912   switch (keyCode) 
    913   { 
     887  switch (keyCode) { 
    914888    case 40: 
    915889    case 38:  
     
    939913      this.key_pressed = keyCode; 
    940914      this.triggerEvent('keypress'); 
    941        
     915 
    942916      if (this.key_pressed == this.BACKSPACE_KEY) 
    943917        return rcube_event.cancel(e); 
    944918  } 
    945    
     919 
    946920  return true; 
    947921}, 
     
    952926key_down: function(e) 
    953927{ 
    954   switch (rcube_event.get_keycode(e)) 
    955   { 
     928  switch (rcube_event.get_keycode(e)) { 
    956929    case 27: 
    957930      if (this.drag_active) 
    958931        return this.drag_mouse_up(e); 
    959          
     932 
    960933    case 40: 
    961934    case 38:  
     
    968941      if (!rcube_event.get_modifier(e) && this.focused) 
    969942        return rcube_event.cancel(e); 
    970          
     943 
    971944    default: 
    972945  } 
    973    
     946 
    974947  return true; 
    975948}, 
     
    989962    new_row = this.get_prev_row(); 
    990963 
    991   if (new_row) 
    992   { 
     964  if (new_row) { 
    993965    this.select_row(new_row.uid, mod_key, true); 
    994966    this.scrollto(new_row.uid); 
     
    10351007{ 
    10361008  var row = this.rows[id].obj; 
    1037   if (row && this.frame) 
    1038   { 
     1009  if (row && this.frame) { 
    10391010    var scroll_to = Number(row.offsetTop); 
    10401011 
     
    10591030drag_mouse_move: function(e) 
    10601031{ 
    1061   if (this.drag_start) 
    1062   { 
     1032  if (this.drag_start) { 
    10631033    // check mouse movement, of less than 3 pixels, don't start dragging 
    10641034    var m = rcube_event.get_mouse_pos(e); 
     
    10661036    if (!this.drag_mouse_start || (Math.abs(m.x - this.drag_mouse_start.x) < 3 && Math.abs(m.y - this.drag_mouse_start.y) < 3)) 
    10671037      return false; 
    1068    
     1038 
    10691039    if (!this.draglayer) 
    10701040      this.draglayer = $('<div>').attr('id', 'rcmdraglayer').css({ position:'absolute', display:'none', 'z-index':2000 }).appendTo(document.body); 
    1071        
     1041 
    10721042    // also select childs of (collapsed) threads for dragging 
    10731043    var selection = $.merge([], this.selection); 
     
    10821052    var names = ''; 
    10831053    var c, i, subject, obj; 
    1084     for(var n=0; n<this.selection.length; n++) 
    1085     { 
    1086       if (n>12)  // only show 12 lines 
    1087       { 
     1054    for(var n=0; n<this.selection.length; n++) { 
     1055      // only show 12 lines 
     1056      if (n>12) { 
    10881057        names += '...'; 
    10891058        break; 
    10901059      } 
    10911060 
    1092       if (obj = this.rows[this.selection[n]].obj) 
    1093       { 
     1061      if (obj = this.rows[this.selection[n]].obj) { 
    10941062        subject = ''; 
    10951063 
    1096         for (c=0, i=0; i<obj.childNodes.length; i++) 
    1097         { 
    1098           if (obj.childNodes[i].nodeName == 'TD') 
    1099           { 
     1064        for (c=0, i=0; i<obj.childNodes.length; i++) { 
     1065              if (obj.childNodes[i].nodeName == 'TD') { 
    11001066            if (n == 0) 
    1101               this.drag_start_pos = $(obj.childNodes[i]).offset(); 
    1102  
    1103             if (this.subject_col < 0 || (this.subject_col >= 0 && this.subject_col == c)) 
    1104             { 
    1105               var node, tmp_node, nodes = obj.childNodes[i].childNodes; 
    1106               // find text node 
    1107               for (m=0; m<nodes.length; m++) { 
    1108                 if ((tmp_node = obj.childNodes[i].childNodes[m]) && (tmp_node.nodeType==3 || tmp_node.nodeName=='A')) 
    1109                   node = tmp_node; 
    1110               } 
    1111                
    1112               if (!node) 
    1113                 break; 
     1067                  this.drag_start_pos = $(obj.childNodes[i]).offset(); 
     1068 
     1069                if (this.subject_col < 0 || (this.subject_col >= 0 && this.subject_col == c)) { 
     1070                  var node, tmp_node, nodes = obj.childNodes[i].childNodes; 
     1071                  // find text node 
     1072                  for (m=0; m<nodes.length; m++) { 
     1073                    if ((tmp_node = obj.childNodes[i].childNodes[m]) && (tmp_node.nodeType==3 || tmp_node.nodeName=='A')) 
     1074                      node = tmp_node; 
     1075                  } 
     1076 
     1077                  if (!node) 
     1078                    break; 
    11141079 
    11151080              subject = node.nodeType==3 ? node.data : node.innerHTML; 
    1116               // remove leading spaces 
    1117               subject = subject.replace(/^\s+/i, ''); 
     1081                  // remove leading spaces 
     1082                  subject = subject.replace(/^\s+/i, ''); 
    11181083              // truncate line to 50 characters 
    1119               names += (subject.length > 50 ? subject.substring(0, 50)+'...' : subject) + '<br />'; 
     1084                  names += (subject.length > 50 ? subject.substring(0, 50)+'...' : subject) + '<br />'; 
    11201085              break; 
    11211086            } 
     
    11331098  } 
    11341099 
    1135   if (this.drag_active && this.draglayer) 
    1136   { 
     1100  if (this.drag_active && this.draglayer) { 
    11371101    var pos = rcube_event.get_mouse_pos(e); 
    11381102    this.draglayer.css({ left:(pos.x+20)+'px', top:(pos.y-5 + (bw.ie ? document.documentElement.scrollTop : 0))+'px' }); 
Note: See TracChangeset for help on using the changeset viewer.