Changeset 887 in subversion


Ignore:
Timestamp:
Oct 19, 2007 8:24:04 AM (6 years ago)
Author:
robin
Message:
  • Enable single-selection toggling in JS list object
  • Use row id's instead of folder names in folder renaming/moving
  • Fix some smaller errors in folder renaming/moving
Location:
trunk/roundcubemail/program
Files:
3 edited

Legend:

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

    r881 r887  
    942942 
    943943      case 'delete-folder': 
    944         if (confirm(this.get_label('deletefolderconfirm'))) 
    945           this.delete_folder(props); 
     944        this.delete_folder(props); 
    946945        break; 
    947946 
     
    24102409    { 
    24112410    var p = this; 
    2412     this.subscription_list = new rcube_list_widget(this.gui_objects.subscriptionlist, {multiselect:false, draggable:true, keyboard:false}); 
     2411    this.subscription_list = new rcube_list_widget(this.gui_objects.subscriptionlist, {multiselect:false, draggable:true, keyboard:false, toggleselect:true}); 
    24132412    this.subscription_list.addEventListener('select', function(o){ p.subscription_select(o); }); 
    24142413    this.subscription_list.addEventListener('dragstart', function(o){ p.drag_active = true; }); 
    24152414    this.subscription_list.addEventListener('dragend', function(o){ p.subscription_move_folder(o); }); 
     2415    this.subscription_list.row_init = function (row) 
     2416      { 
     2417      var anchors = row.obj.getElementsByTagName('A'); 
     2418      if (anchors[0]) 
     2419        anchors[0].onclick = function() { p.rename_folder(row.id); }; 
     2420      if (anchors[1]) 
     2421        anchors[1].onclick = function() { p.delete_folder(row.id); }; 
     2422      row.obj.onmouseover = function() { p.focus_subscription(row.id); }; 
     2423      row.obj.onmouseout = function() { p.unfocus_subscription(row.id); }; 
     2424      } 
    24162425    this.subscription_list.init(); 
    24172426    } 
     
    24662475  this.focus_subscription = function(id) 
    24672476    { 
    2468     var row; 
     2477    var row, folder; 
    24692478    var reg = RegExp('['+RegExp.escape(this.env.delimiter)+']?[^'+RegExp.escape(this.env.delimiter)+']+$'); 
    2470     if (this.drag_active && this.check_droptarget(id) && 
    2471         (id != this.env.folder.replace(reg, '')) && 
    2472         (!id.match(new RegExp('^'+RegExp.escape(this.env.folder+this.env.delimiter)))) && 
    2473         (row = document.getElementById(this.get_folder_row_id(id)))) 
    2474       if (find_in_array(this.env.defaultfolders, id)>=0) 
     2479    if (this.env.subscriptionrows[id] && 
     2480        (folder = this.env.subscriptionrows[id][0]) && 
     2481        this.drag_active && this.check_droptarget(folder) && 
     2482        (folder != this.env.folder.replace(reg, '')) && 
     2483        (!folder.match(new RegExp('^'+RegExp.escape(this.env.folder+this.env.delimiter)))) && 
     2484        (row = document.getElementById(id))) 
     2485      if (find_in_array(this.env.defaultfolders, folder)>=0) 
    24752486        { 
    24762487        if (this.env.folder.replace(reg, '')!='') 
     
    24822493      else 
    24832494        { 
    2484         this.set_env('dstfolder', id); 
     2495        this.set_env('dstfolder', folder); 
    24852496        this.set_classname(row, 'droptarget', true); 
    24862497        } 
     
    24902501  this.unfocus_subscription = function(id) 
    24912502    { 
    2492     var row; 
    2493     if (row = document.getElementById(this.get_folder_row_id(id))) 
     2503    var row, folder; 
     2504    if (this.env.subscriptionrows[id] && 
     2505        (folder = this.env.subscriptionrows[id][0]) && 
     2506        (row = document.getElementById(id))) 
    24942507      { 
    24952508      this.set_env('dstfolder', null); 
    2496       if (find_in_array(this.env.defaultfolders, id)>=0) 
     2509      if (find_in_array(this.env.defaultfolders, folder)>=0) 
    24972510        this.set_classname(this.subscription_list.frame, 'droptarget', false); 
    24982511      else 
     
    25042517  this.subscription_select = function(list) 
    25052518    { 
    2506     var id; 
    2507     if (id = list.get_single_selection()) 
    2508       { 
    2509       if (this.env.subscriptionrows['rcmrow'+id]) 
    2510         { 
    2511         var folder = this.env.subscriptionrows['rcmrow'+id][0]; 
    2512         if (find_in_array(this.env.defaultfolders, folder)!=0) 
    2513           this.set_env('folder', folder); 
    2514         } 
    2515       else 
    2516         { 
    2517         list.clear_selection(); 
    2518         this.set_env('folder', null); 
    2519         } 
    2520       } 
     2519    var id, folder; 
     2520    if ((id = list.get_single_selection()) && 
     2521        this.env.subscriptionrows['rcmrow'+id] && 
     2522        (folder = this.env.subscriptionrows['rcmrow'+id][0]) && 
     2523        (find_in_array(this.env.defaultfolders, folder)!=0)) 
     2524      this.set_env('folder', folder); 
     2525    else 
     2526      this.set_env('folder', null); 
    25212527    }; 
    25222528 
     
    25342540      } 
    25352541    this.drag_active = false; 
    2536     this.unfocus_subscription(this.env.dstfolder); 
     2542    this.unfocus_subscription(this.get_folder_row_id(this.env.dstfolder)); 
    25372543    }; 
    25382544 
     
    25592565  // start renaming the mailbox name. 
    25602566  // this will replace the name string with an input field 
    2561   this.rename_folder = function(folder) 
     2567  this.rename_folder = function(id) 
    25622568    { 
    25632569    var temp, row, form; 
    2564     var id = this.get_folder_row_id(folder); 
     2570    var folder = this.env.subscriptionrows[id][0]; 
    25652571 
    25662572    // reset current renaming 
     
    26292635 
    26302636  // delete a specific mailbox with all its messages 
    2631   this.delete_folder = function(folder) 
    2632     { 
     2637  this.delete_folder = function(id) 
     2638    { 
     2639    var folder = this.env.subscriptionrows[id][0]; 
     2640 
    26332641    if (this.edit_folder) 
    26342642      this.reset_folder_rename(); 
    2635      
    2636     if (folder) 
     2643 
     2644    if (folder && confirm(this.get_label('deletefolderconfirm'))) 
     2645      { 
    26372646      this.http_post('delete-folder', '_mboxes='+urlencode(folder)); 
    2638  
    2639     this.set_env('folder', null); 
     2647      this.set_env('folder', null); 
     2648      } 
    26402649    }; 
    26412650 
     
    26542663    var refrow, form; 
    26552664    var tbody = this.gui_objects.subscriptionlist.tBodies[0]; 
    2656     var id = replace && replace.id ? replace.id : tbody.childNodes.length+1; 
     2665    var id = replace && replace.id ? replace.id : 'rcmrow'+(tbody.childNodes.length+1); 
    26572666    var selection = this.subscription_list.get_single_selection(); 
    26582667 
     
    26662675      // clone a table row if there are existing rows 
    26672676      var row = this.clone_table_row(refrow); 
    2668       row.id = 'rcmrow'+id; 
     2677      row.id = id; 
    26692678      if (replace) 
    26702679        tbody.replaceChild(row, replace); 
     
    26842693      } 
    26852694        
    2686     if (row.cells[2] && row.cells[2].firstChild.tagName=='A') 
    2687       row.cells[2].firstChild.onclick = new Function(this.ref+".command('rename-folder','"+name.replace('\'','\\\'')+"')"); 
    2688     if (row.cells[3] && row.cells[3].firstChild.tagName=='A') 
    2689       row.cells[3].firstChild.onclick = new Function(this.ref+".command('delete-folder','"+name.replace('\'','\\\'')+"')"); 
    2690  
    26912695    // add new folder to rename-folder list and clear input field 
    26922696    if (!replace && (form = this.gui_objects.editform)) 
     
    27032707      this.subscription_list.select_row(selection); 
    27042708 
    2705     if (document.getElementById('rcmrow'+id).scrollIntoView) 
    2706       document.getElementById('rcmrow'+id).scrollIntoView(); 
     2709    if (document.getElementById(id).scrollIntoView) 
     2710      document.getElementById(id).scrollIntoView(); 
    27072711    }; 
    27082712 
     
    27162720    // replace an existing table row (if found) 
    27172721    this.add_folder_row(newfolder, display_name, row); 
    2718     this.env.subscriptionrows[id] = null; 
    27192722     
    27202723    // rename folder in rename-folder dropdown 
  • trunk/roundcubemail/program/js/list.js

    r828 r887  
    3838  this.draggable = false; 
    3939  this.keyboard = false; 
     40  this.toggleselect = false; 
    4041   
    4142  this.dont_select = false; 
     
    348349    this.shift_start = null; 
    349350 
     351  if (this.toggleselect && this.last_selected==id) 
     352    this.highlight_row(id, true); 
     353 
    350354  this.last_selected = id; 
    351   this.set_classname(this.rows[id].obj, 'focused', true);         
     355  this.set_classname(this.rows[id].obj, 'focused', true); 
    352356}, 
    353357 
  • trunk/roundcubemail/program/steps/settings/manage_folders.inc

    r868 r887  
    7272else if ($_action=='rename-folder') 
    7373  { 
    74   $a_mboxes = array_merge($IMAP->list_mailboxes(), $IMAP->list_unsubscribed()); 
     74  $a_mboxes = array_unique(array_merge($IMAP->list_mailboxes(), $IMAP->list_unsubscribed())); 
    7575  $delimiter = $IMAP->get_hierarchy_delimiter(); 
    7676 
     
    196196      $a_js_folders['rcmrow'.($i+1)] = array($folder, rcube_charset_convert($folder, 'UTF-7')); 
    197197 
    198     $out .= sprintf('<tr id="rcmrow%d" class="%s"' . 
    199                     ' onmouseover="return %s.focus_subscription(\'%s\')"' . 
    200                     ' onmouseout="return %s.unfocus_subscription(\'%s\')"><td>%s</td>', 
     198    $out .= sprintf('<tr id="rcmrow%d" class="%s"><td>%s</td>', 
    201199                    $i+1, 
    202200                    $zebra_class, 
    203                     JS_OBJECT_NAME, 
    204                     $folder_js, 
    205                     JS_OBJECT_NAME, 
    206                     $folder_js, 
    207201                    Q($folder_html)); 
    208202                     
     
    214208    // add rename and delete buttons 
    215209    if (!$protected) 
    216       $out .= sprintf('<td><a href="#rename" onclick="%s.command(\'rename-folder\',\'%s\')" title="%s">%s</a>'. 
    217                       '<td><a href="#delete" onclick="%s.command(\'delete-folder\',\'%s\')" title="%s">%s</a></td>', 
    218                       JS_OBJECT_NAME, 
    219                       $folder_js, 
     210      $out .= sprintf('<td><a href="#rename" title="%s">%s</a>'. 
     211                      '<td><a href="#delete" title="%s">%s</a></td>', 
    220212                      rcube_label('renamefolder'), 
    221213                      $edit_button, 
    222                       JS_OBJECT_NAME, 
    223                       $folder_js, 
    224214                      rcube_label('deletefolder'), 
    225215                      $del_button); 
Note: See TracChangeset for help on using the changeset viewer.