Firstly...Hello! :) Secondly...A patch to highlight selected messages

Conor Kerr conor@dev.ceon.net
Wed, 23 Jan 2002 17:41:18 GMT


---------------------- multipart/mixed attachment
Hi everyone,

I decided to install webmail software last weekend and after a look
around all the options I found IMP to be the most suitable.

I was able to configure it reasonably quickly but can't say that I find
the systems used very intuitive.  Nevertheless I now have quite a decent
webmail system which is fairly clean and functional and after some
tweaking has an even nicer colour scheme. ;)

My thanks must go to those who wrote the software! :)

There are a few things that I think need fixing/adding and today I
decided to make some changes to make the table rows for the message
summaries change colour when they are selected.  I feel that this makes
the software slightly easier to use as it is now much clearer which
messages are selected.  Users familiar with recent versions of hotmail
will be familiar with this comparatively recent addition to that
company's webmail software.

Unfortunately adding this functionality has had to be done at the
expense of the "mouseover" highlighting of message summaries.  Although
this was an attractive feature I feel that the functionality gained by
being able to easily determine which messages have been selected results
in a much more worthwhile feature to have in the software.

I'd really appreciate feedback on these thoughts as I would like to see
my patches made part of the standard distribution.

I have tested this with several browsers and it works perfectly in M$IE
6 and Netscape 6.  It does not work in Netscape 4 so the necessary code
has been added to disable it for this old and poorly written browser.

Three files need to be modified for this feature to be implemented:

imp/config/html.php
imp/templates/mailbox/message_summaries.inc
imp/templates/mailbox/javascript.inc

Below follows a description of how to patch your files directly but most
will find it easier to simply copy over their current files with the
modified versions which I have attached to this e-mail.

I hope that you will find this modification useful, again please let me
know what your thoughts are on it!

All the best...

Conor



HOW TO PATCH IMP
----------------
Modifying the first file is very easy, all you have to do is to add the
following lines after the other css properties:

$css['.text-selected']['background-color'] = '#e5e5e5';
$css['.deleted-selected']['background-color'] = '#777777';
$css['.important-selected']['background-color'] = '#ffaaaa';
$css['.unseen-selected']['background-color'] = '#eeeeff';
$css['.answered-selected']['background-color'] = '#ccffcc';

All you are doing here is defining some new css properties which set the
colours to be used to show the various types of messages as selected. 
Some people may prefer to set all of the above colours to the same
colour, others may prefer to use different colours for each type of
flagged message so that they can see if they have accidentally selected
an unread (unseen) message etc.


The modifications to be made to the second file are also very simple:

1) The opening table row tag should become:

<tr class="<?= $bg ?>">

As you can see all that has been changed for this tag is that the
"mouseover" and "mouseout" attributes (and accompanying inline php code)
have been removed.

2) The input checkbox tag should have the following attribute added to
it:

<?php if ($browser->isBrowser('mozilla') && $browser->getMajor() > 4) : ?>onclick="javascript:SetMsgSummaryColour(this);"<?php endif; ?>

This is the event handler which calls the javascript function when the
input checkbox is checked/un-checked.  This event handler is not
included in the tag if Netscape version 4.0 is being used as its
javascript sucks. :)


The modifications to the third file are slightly more involved but still very
basic:

1) The selectFlagged function has to have a call to SetMsgSummaryColour
added to its main loop with the current input element as the sole
parameter.

The exact lines to be added to the for loop is as follows:

<?php if ($browser->isBrowser('mozilla') && $browser->getMajor() > 4) : ?>
SetMsgSummaryColour(document.messages.elements[i]);
<?php endif; ?>

As before if Netscape version 4 is being used this function is not
called.

2) The following three functions have to be added to the file.  These
are the functions which do the main work, finding the <tr> tag to which
the <input> checkbox belongs and modifying its class according to
whether or not the current message is selected in the mailbox:

function SetMsgSummaryColour(obj)
{
    // Has the checkbox been checked?
    if(obj.checked)
        MsgSummarySelected(obj);  // Yes, so set class to selected version of class
    else
        MsgSummaryUnselected(obj);  // No, so restore class to class specified for the message's flag
}

function MsgSummarySelected(obj)
{
    // Find row tag for message summary
    while(obj.tagName != "TR")
    {
        <?php if ($browser->isBrowser('msie')) : ?>
        obj = obj.parentElement;
        <?php else : ?>
        obj = obj.parentNode;
        <?php endif; ?>
    }

    // Set class for row to selected version of class if not already set as such
    if(obj.className.length <= 9 || obj.className.substring(obj.className.length - 9, obj.className.length) != "-selected")
        obj.className = obj.className + "-selected";
}

function MsgSummaryUnselected(obj)
{
    // Find row tag for message summary
    while(obj.tagName != "TR")
    {
        <?php if ($browser->isBrowser('msie')) : ?>
        obj = obj.parentElement;
        <?php else : ?>
        obj = obj.parentNode;
        <?php endif; ?>
    }
    
    // Restore class for row
    if(obj.className.length > 9 && obj.className.substring(obj.className.length - 9, obj.className.length) == "-selected")
        obj.className = obj.className.substring(0, obj.className.length - 9); // Remove "-selected" from end of class
}
---------------------- multipart/mixed attachment--