Final attachment for highlighting patch: imp/templates/mailbox/javascript.inc

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


<?php // $Horde: imp/templates/mailbox/javascript.inc,v 2.24.2.1 2001/11/16 00:50:58 chuck Exp $ ?>
<script language="JavaScript" type="text/javascript">
<!--

function AnySelected()
{
    for (i = 0; i < document.messages.elements.length; i++) {
        if (document.messages.elements[i].checked) return true;
    }
    return false;
}

function Submit(actID)
{
<?php if (strstr($imp['protocol'], 'pop3')): ?>
    if (window.confirm('<?= _("Are you sure you wish to PERMANENTLY delete these messages?") ?>')) {
<?php endif; ?>
    if (AnySelected()) {
        document.messages.actionID.value = actID;
        document.messages.submit();
    } else {
        window.alert('<?= _("You must select at least one message first.") ?>');
    }
<?php if (strstr($imp['protocol'], 'pop3')): ?>
    }
<?php endif; ?>
}
    
function toggle(isChecked)
{
    for (i = 0; i < document.messages.elements.length; i++) {
        document.messages.elements[i].checked = isChecked;
    }
}

function makeSelection(whichForm)
{
    if (whichForm == 1) {
        flag = document.select1.filter.options[document.select1.filter.selectedIndex].value;
    } else {
        flag = document.select2.filter.options[document.select2.filter.selectedIndex].value;
    }
    
    if (flag.substring(0, 1) == "!") {
        selectFlagged(parseInt(flag.substring(1)), false);
    } else {
        selectFlagged(parseInt(flag), true);
    }
    
    // reset the form
    if (whichForm == 1) {
        document.select1.reset();
    } else {
        document.select2.reset();
    }
}

<?php if ($conf['user']['allow_folders']): ?>
function updateFolders(whichForm)
{
    if ((whichForm == 1 && document.copymove1.targetMailbox.options[document.copymove1.targetMailbox.selectedIndex].value != "") ||
        (whichForm == 2 && document.copymove2.targetMailbox.options[document.copymove2.targetMailbox.selectedIndex].value != "")) {
        if (whichForm == 1) {
            document.copymove2.targetMailbox.selectedIndex = document.copymove1.targetMailbox.selectedIndex;
        } else {
            document.copymove1.targetMailbox.selectedIndex = document.copymove2.targetMailbox.selectedIndex;
        }
    }
} // updateFolders()

function Transfer(actID, whichForm)
{
    if (AnySelected()) {
        if (whichForm == 1) {
            document.messages.targetMbox.value = document.copymove1.targetMailbox.options[document.copymove1.targetMailbox.selectedIndex].value;
        } else {
            document.messages.targetMbox.value = document.copymove2.targetMailbox.options[document.copymove2.targetMailbox.selectedIndex].value;
        }
    
        // check for a mailbox actually being selected
        if (document.messages.targetMbox.value == '') {
            window.alert('<?= _("You must select a target mailbox first.") ?>');
        } else {
            document.messages.actionID.value = actID;
            document.messages.submit();
        }
    } else {
        window.alert('<?= _("You must select at least one message first.") ?>');
    }
}
<?php endif; ?>
<?php if (!$prefs->isLocked('filters')): ?>
function BlackList()
{
    if (AnySelected()) {
        document.messages.actionID.value = <?= IMP_BLACKLIST ?>;
        document.messages.submit();
    } else {
        window.alert('<?= _("You must select at least one message first.") ?>');
    }
}
<?php endif; ?>

// Put everything reliant on IMAP flags in this section.
var Flags;

function selectFlagged(flag, val)
{
    for (var i = 0; i < Flags.length; i++) {
        if (flag & Flags[i]) {
            document.messages.elements[i].checked = val;
        } else {
            document.messages.elements[i].checked = !val;
        }

        // Set colour for row according to whether the message has been selected or not
		<?php if ($browser->isBrowser('mozilla') && $browser->getMajor() > 4) : ?>
        SetMsgSummaryColour(document.messages.elements[i]);
		<?php endif; ?>
    }
}

<?php if (!strstr($imp['protocol'], 'pop3')): ?>
function flagMessages(whichForm)
{
    if ((whichForm == 1 && document.select1.flag.options[document.select1.flag.selectedIndex].value != "") ||
        (whichForm == 2 && document.select2.flag.options[document.select2.flag.selectedIndex].value != "")) {
        if (AnySelected()) {
            if (whichForm == 1) {
                document.messages.flag.value = document.select1.flag.options[document.select1.flag.selectedIndex].value;
            } else {
                document.messages.flag.value = document.select2.flag.options[document.select2.flag.selectedIndex].value;
            }
            
            document.messages.actionID.value = <?= FLAG_MESSAGES ?>;
            document.messages.submit();
        } else {
            if (whichForm == 1) {
                document.select1.flag.selectedIndex = 0;
            } else {
                document.select2.flag.selectedIndex = 0;
            }
            window.alert('<?= _("You must select at least one message first.") ?>');
        }
    }
}
<?php endif; ?>

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
}

//-->
</script>