From b62c4869f7c43804601b7786809e7e7a2508566d Mon Sep 17 00:00:00 2001 From: alecpl Date: Sun, 2 May 2010 15:09:36 +0000 Subject: - Allow columns order change per user - drag&drop (#1485795) --- program/js/app.js | 54 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 7 deletions(-) (limited to 'program/js/app.js') diff --git a/program/js/app.js b/program/js/app.js index b2888d028..dd3feeeca 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -166,7 +166,8 @@ function rcube_webmail() if (this.gui_objects.messagelist) { this.message_list = new rcube_list_widget(this.gui_objects.messagelist, - {multiselect:true, multiexpand:true, draggable:true, keyboard:true, dblclick_time:this.dblclick_time}); + {multiselect:true, multiexpand:true, draggable:true, keyboard:true, + column_movable:this.env.col_movable, column_fixed:0, dblclick_time:this.dblclick_time}); this.message_list.row_init = function(o){ p.init_message_row(o); }; this.message_list.addEventListener('dblclick', function(o){ p.msglist_dbl_click(o); }); this.message_list.addEventListener('click', function(o){ p.msglist_click(o); }); @@ -176,11 +177,11 @@ function rcube_webmail() this.message_list.addEventListener('dragmove', function(e){ p.drag_move(e); }); this.message_list.addEventListener('dragend', function(e){ p.drag_end(e); }); this.message_list.addEventListener('expandcollapse', function(e){ p.msglist_expand(e); }); + this.message_list.addEventListener('column_replace', function(e){ p.msglist_set_coltypes(e); }); document.onmouseup = function(e){ return p.doc_mouse_up(e); }; this.gui_objects.messagelist.parentNode.onmousedown = function(e){ return p.click_on_list(e); }; - this.set_message_coltypes(this.env.coltypes); this.message_list.init(); this.enable_command('toggle_status', 'toggle_flag', 'menu-open', 'menu-save', true); @@ -1487,6 +1488,24 @@ function rcube_webmail() if (this.env.messages[row.uid]) this.env.messages[row.uid].expanded = row.expanded; }; + + this.msglist_set_coltypes = function(list) + { + var i, found, name, cols = list.list.tHead.rows[0].cells; + + this.env.coltypes = []; + + for (i=0; i= 0) + this.set_env('flagged_col', found); + + this.http_post('save-pref', { '_name':'list_cols', '_value':this.env.coltypes }); + }; this.check_droptarget = function(id) { @@ -1692,6 +1711,9 @@ function rcube_webmail() { var update, add_url = ''; + if (!sort_col) sort_col = this.env.sort_col; + if (!sort_order) sort_order = this.env.sort_order; + if (this.env.sort_col != sort_col || this.env.sort_order != sort_order) { update = 1; this.set_list_sorting(sort_col, sort_order); @@ -1702,9 +1724,25 @@ function rcube_webmail() add_url += '&_threads=' + threads; } - if (cols.join() != this.env.coltypes.join()) { - update = 1; - add_url += '&_cols=' + cols.join(','); + if (cols && cols.length) { + // make sure new columns are added at the end of the list + var i, idx, name, newcols = [], oldcols = this.env.coltypes; + for (i=0; i= 0) { + if ((found = $.inArray('subject', this.env.coltypes)) >= 0) { this.set_env('subject_col', found); if (this.message_list) this.message_list.subject_col = found+1; } - if((found = $.inArray('flag', this.env.coltypes)) >= 0) + if ((found = $.inArray('flag', this.env.coltypes)) >= 0) this.set_env('flagged_col', found); + + this.message_list.init_header(); }; // replace content of row count display -- cgit v1.2.3