From e189a6ca18fe43def249c78a0e89405012981de5 Mon Sep 17 00:00:00 2001 From: alecpl Date: Mon, 30 Jun 2008 09:36:18 +0000 Subject: - Added flag column on messages list (#1484623) --- program/js/app.js | 103 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 93 insertions(+), 10 deletions(-) (limited to 'program/js/app.js') diff --git a/program/js/app.js b/program/js/app.js index 74e027403..657a45d19 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -136,7 +136,7 @@ function rcube_webmail() this.message_list.addEventListener('dragend', function(o){ p.drag_active = false; }); this.message_list.init(); - this.enable_command('toggle_status', true); + this.enable_command('toggle_status', 'toggle_flag', true); if (this.gui_objects.mailcontframe) { @@ -373,6 +373,7 @@ function rcube_webmail() row.deleted = this.env.messages[uid].deleted ? true : false; row.unread = this.env.messages[uid].unread ? true : false; row.replied = this.env.messages[uid].replied ? true : false; + row.flagged = this.env.messages[uid].flagged ? true : false; } // set eventhandler to message icon @@ -383,6 +384,24 @@ function rcube_webmail() row.icon._row = row.obj; row.icon.onmousedown = function(e) { p.command('toggle_status', this); }; } + + // global variable 'flagged_col' may be not defined yet + if (!this.env.flagged_col && this.env.coltypes) + { + var found; + if((found = find_in_array('flag', this.env.coltypes)) >= 0) + this.set_env('flagged_col', found+1); + } + + // set eventhandler to flag icon, if icon found + if (this.env.flagged_col && (row.flagged_icon = row.obj.cells[this.env.flagged_col].childNodes[0]) + && row.flagged_icon.nodeName=='IMG') + { + var p = this; + row.flagged_icon.id = 'flaggedicn_'+row.uid; + row.flagged_icon._row = row.obj; + row.flagged_icon.onmousedown = function(e) { p.command('toggle_flag', this); }; + } }; @@ -708,6 +727,24 @@ function rcube_webmail() this.mark_message(flag, uid); break; + case 'toggle_flag': + if (props && !props._row) + break; + + var uid; + var flag = 'flagged'; + + if (props._row.uid) + { + uid = props._row.uid; + this.message_list.dont_select = true; + // toggle flagged/unflagged + if (this.message_list.rows[uid].flagged) + flag = 'unflagged'; + } + this.mark_message(flag, uid); + break; + case 'always-load': if (this.env.uid && this.env.sender) { this.add_contact(urlencode(this.env.sender)); @@ -1526,7 +1563,7 @@ function rcube_webmail() { for (var n=0; n'; + } } }; @@ -3261,7 +3333,8 @@ function rcube_webmail() this.env.messages[uid] = {deleted:flags.deleted?1:0, replied:flags.replied?1:0, - unread:flags.unread?1:0}; + unread:flags.unread?1:0, + flagged:flags.flagged?1:0}; var row = document.createElement('TR'); row.id = 'rcmrow'+uid; @@ -3276,7 +3349,7 @@ function rcube_webmail() var col = document.createElement('TD'); col.className = 'icon'; - col.innerHTML = icon ? '' : ''; + col.innerHTML = icon ? '' : ''; row.appendChild(col); // add each submitted col @@ -3285,13 +3358,23 @@ function rcube_webmail() var c = this.coltypes[n]; col = document.createElement('TD'); col.className = String(c).toLowerCase(); - col.innerHTML = cols[c]; + + if (c=='flag') + { + if (flags.flagged && this.env.flaggedicon) + col.innerHTML = ''; + else if(this.env.unflaggedicon) + col.innerHTML = ''; + } + else + col.innerHTML = cols[c]; + row.appendChild(col); } col = document.createElement('TD'); col.className = 'icon'; - col.innerHTML = attachment && this.env.attachmenticon ? '' : ''; + col.innerHTML = attachment && this.env.attachmenticon ? '' : ''; row.appendChild(col); this.message_list.insert_row(row, attop); -- cgit v1.2.3