Location: PHPKode > projects > phlyMail Lite > phlymail/frontend/templates/listfolder.general.tpl
<script type="text/javascript">
openlist = [];
FormOpen = 0;
TextClosed = 0;
CurrentId = 0;
blockedmenu = 0;
nocollapses = 0<!-- START nocollapses -->+1<!-- END nocollapses -->;
idToHandlerId = [];<!-- START add_handler_array -->
idToHandlerId['txt_{Rfolder_path}'] = {'handler' : '{handler}', 'fid' : '{fid}', 'ctx' : <!-- START ctx -->1+<!-- END ctx -->0 ,'props' : <!-- START props -->1+<!-- END props -->0,'move' : <!-- START move -->1+<!-- END move -->0, 'rename' : <!-- START rename -->1+<!-- END rename -->0, 'dele' : <!-- START dele -->1+<!-- END dele -->0, 'resync' : <!-- START resync -->1+<!-- END resync -->0,'subfolder' : <!-- START subfolder -->1+<!-- END subfolder -->0,'is_trash' : <!-- START trash -->1+<!-- END trash -->0, 'is_junk' : <!-- START junk -->1+<!-- END junk -->0, 'is_collapsed' : <!-- START is_collapsed -->1+<!-- END is_collapsed -->0};<!-- END add_handler_array -->
ctxmen =
        {0 : { 'status' : 1, 'link': 'blockedmenu = 0; open_folderprops()', 'name' : '{msg_properties} ...', 'icon' : '{theme_path}/icons/folderprops_ctx.gif'}
        ,1 : { 'status' : 1, 'link': 'blockedmenu = 1; context_resync()', 'name' : '{msg_resync}', 'icon' : '{theme_path}/icons/resyncfolder_ctx.gif'}
        ,2 : { 'status' : 1, 'link': 'blockedmenu = 1; context_move()', 'name' : '{msg_move} ...', 'icon' : '{theme_path}/icons/movefolder_ctx.gif'}
        ,3 : { 'status' : 1, 'link': 'blockedmenu = 1; context_rename()', 'name' : '{msg_rename} ...', 'icon' : '{theme_path}/icons/renamefolder_ctx.gif'}
        ,4 : { 'status' : 1, 'link': 'blockedmenu = 1; context_delete(e)', 'name' : '{msg_dele}', 'icon' : '{theme_path}/icons/deletefolder_ctx.gif'}
        ,5 : { 'status' : 1, 'link': 'blockedmenu = 1; context_createsubfolder()', 'name' : '{msg_subfolder} ...', 'icon' : '{theme_path}/icons/createfolder_ctx.gif'}
        ,6 : { 'status' : 1, 'link': 'blockedmenu = 1; context_expungefolder()', 'name' : '{msg_emptytrash}', 'icon' : '{theme_path}/icons/emptytrash_ctx.gif'}
        ,7 : { 'status' : 1, 'link': 'blockedmenu = 1; context_expungefolder()', 'name' : '{msg_emptyjunk}', 'icon' : '{theme_path}/icons/emptytrash_ctx.gif'}
        };

function foldermenu(fname)
{
    if (blockedmenu) return;
    active_folder = fname;
    ctx_handler = idToHandlerId[fname]['handler']
    if (idToHandlerId[fname] && idToHandlerId[fname]['ctx']) ctxmen_activate_sensor(ctxmen);
    ctxmen[0]['status'] = (idToHandlerId[fname]['props'] == 1) ? 1 : 3;
    ctxmen[1]['status'] = (idToHandlerId[fname]['resync'] == 1) ? 1 : 3;
    ctxmen[2]['status'] = (idToHandlerId[fname]['move'] == 1) ? 1 : 3;
    ctxmen[3]['status'] = (idToHandlerId[fname]['rename'] == 1) ? 1 : 3;
    ctxmen[4]['status'] = (idToHandlerId[fname]['dele'] == 1) ? 1 : 3;
    ctxmen[5]['status'] = (idToHandlerId[fname]['subfolder'] == 1) ? 1 : 3;
    ctxmen[6]['status'] = (idToHandlerId[fname]['is_trash'] == 1) ? 1 : 3;
    ctxmen[7]['status'] = (idToHandlerId[fname]['is_junk'] == 1) ? 1 : 3;
}

function disable_foldermenu()
{
    ctxmen_disable_sensor();
}

function context_rename()
{
    var txt = active_folder;
    var frm = txt.replace(/^txt_/, 'form_');
    create_input(txt, frm);
}

function context_delete(e)
{
    alternate = 0;
    // Shift held -> throw them away, no dustbin at all
    if (!e && window.event) e = window.event;
    if (e.shiftKey) {
        alternate = 1;
        drop_screen_selection();
    }
    if (confirm('{msg_really_dele_folder}')) {
        sendAJAX('{PHP_SELF}?{passthrough}&load=worker&handler=' + ctx_handler + '&what=folder_delete&directly=' + alternate + '&remove_folder=' + idToHandlerId[active_folder]['fid']);
    }
    blockedmenu = 0;
}

function context_resync()
{
    sendAJAX('{PHP_SELF}?{passthrough}&load=worker&handler=' + ctx_handler + '&what=folder_resync&resync_folder=' + idToHandlerId[active_folder]['fid']);
    blockedmenu = 0;
}

function context_expungefolder()
{
    if (confirm('{msg_really_empty_folder}')) {
        sendAJAX('{PHP_SELF}?{passthrough}&load=worker&handler=' + ctx_handler + '&what=folder_empty&empty_folder=' + idToHandlerId[active_folder]['fid']);
    }
    blockedmenu = 0;
}

function context_createsubfolder()
{
    keyfetch_off();
    newname = prompt('{msg_foldername}');
    keyfetch_on();
    if (!newname || newname.length == 0) {
        alert('{etooshort}');
        blockedmenu = 0;
        return false;
    }
    if (newname.length > 32) {
        alert('{etoolong}');
        blockedmenu = 0;
        return false;
    }
    newname = encodeURIComponent(newname);
    sendAJAX('{PHP_SELF}?{passthrough}&load=worker&handler=' + ctx_handler + '&what=folder_create&childof=' + idToHandlerId[active_folder]['fid'] + '&new_folder=' + newname);
    blockedmenu = 0;
}

function context_move()
{
    browserwin = window.open
            ('{PHP_SELF}?load=browse&handler=' + ctx_handler + '&mode=move&{passthrough}'
            ,'browser_movefolder'
            ,'width=450,height=400,left=200,top=200,scrollbars=no,resizable=yes,location=no,menubar=no,status=no,toolbar=no'
            );
}

function submit_folder_browser(folder, handler, ops)
{
    opsfolder = folder;
    browserwin.close();
    url = '{PHP_SELF}?{passthrough}&load=worker&handler=' + handler + '&what=folder_' + ops
            + '&move_folder=' + idToHandlerId[active_folder]['fid'] + '&move_to=' + opsfolder;
    sendAJAX(url);
    blockedmenu = 0;
}

function rename_folder(formname)
{
    myform = document.getElementById(formname);
    if (myform.rename_to.value.length == 0) {
        alert('{etooshort}');
        blockedmenu = 0;
        return false;
    }
    close_input();
    sendAJAX(myform.action + '&rename_to=' + encodeURIComponent(myform.rename_to.value));
    blockedmenu = 0;
    return false;
}

function sendAJAX(url)
{
    if (opener) {
        window.setTimeout('opener.parent.email_AJAX("' + url + '")', 0);
    } else {
        window.setTimeout('parent.email_AJAX("' + url + '")', 0);
    }
}

function collapse_folders()
{
    for (var i in idToHandlerId) {
        if (idToHandlerId[i]['is_collapsed']) {
            aufzu(i.replace(/^txt_/, '').replace(/_.+$/, ''), true);
        }
    }
}

function aufzu(id, internal)
{
    var i, img, span, level, Durchlauf, sublevel, currlevel, newstyle, mode;

    img = document.getElementById(id);
    if (!img) return;
    span = img.parentNode;
    level = span.getAttribute('name');
    Durchlauf = 1;
    sublevel = 0;
    if (openlist[id] == 1) {
        img.src = '{theme_path}/icons/minus.png';
        openlist[id] = 0;
        newstyle = 'inline';
        mode = 'auf';
    } else {
        img.src = '{theme_path}/icons/plus.png';
        openlist[id] = 1;
        newstyle = 'none';
        mode = 'zu';
    }
    do {
        span = span.nextSibling;
        if (span == null) Durchlauf = 0;
        else if (span.nodeName == 'DIV') {
            currlevel = span.getAttribute('name');
            if (currlevel < sublevel) {
                sublevel = 0;
            } else if (sublevel > 0) {
                continue;
            }
            if (currlevel <= level) Durchlauf = 0;
            else {
                // Find possible subnodes, which are not affected on reopening
                if (mode == 'auf') {
                    for (i = 0; i < span.childNodes.length; ++i) {
                        if (span.childNodes[i].nodeName == 'IMG') {
                            var ifid = span.childNodes[i].getAttribute('id');
                            if (openlist[ifid] == 1) {
                                sublevel = currlevel + 1;
                                continue;
                            }
                        }
                    }
                }
                span.style.display = newstyle;
            }
        }
    } while (1 == Durchlauf)
    blockedmenu = 0;
    if (internal) return;
    var realfolder = 'txt_' + id + img.nextSibling.getAttribute('id').replace(/^img/, '');
    if (!nocollapses) sendAJAX('{fordercollapseurl}' + idToHandlerId[realfolder]['handler'] + '_' + idToHandlerId[realfolder]['fid'] + '&aufzu=' + mode);
}

function open_folder(id, link, name, icon, handler)
{
    parent.PHM_tr.location.href = link;
    parent.update_headings(name, icon);
    mark_folder(id);
    parent.OpenFolder = id;
    blockedmenu = 0;
}

function mark_folder(id)
{
    if (parent.FLMarkedItem != 0) {
        document.getElementById(parent.FLMarkedItem).className = 'foldername';
    }
    document.getElementById(id).className = 'marked foldername';
    parent.FLMarkedItem = id;
    blockedmenu = 0;
}

function folder_mark_unseen(id)
{
    // document.getElementById(id).className = 'unseen_foldername';
}

function select_folder(id, fid)
{
    mark_folder(id);
    CurrentId = fid;
    document.getElementById('browse_submit').disabled = false;
    blockedmenu = 0;
}

function submit_folder(fid)
{
    if (!fid && CurrentId) fid = CurrentId;
    opener.submit_folder_browser(fid, '{handler}', '{mode}');
    blockedmenu = 0;
}

function folder_set_unread_items(fid, count)
{
    var node = document.getElementById('unread_' + fid);
    if (!node) return;
    if (node.childNodes.length) {
        node.removeChild(node.firstChild);
    }
    if (!count || count < 1) return;
    node.appendChild(document.createTextNode('(' + count + ')'));
}

function open_folderprops()
{
    if (active_folder == 0) return false;
    if (!idToHandlerId[active_folder]) return false;
    var handler = idToHandlerId[active_folder]['handler'];
    var fid     = idToHandlerId[active_folder]['fid'];
    browserwin = window.open
            ('{PHP_SELF}?load=folderprops&handler=' + handler + '&fid=' + fid + '&{passthrough}'
            ,'folderprops_' + active_folder
            ,'width=450,height=' + parent.FolderPropsHeight + ',left=200,top=200,scrollbars=no,resizable=yes,location=no,menubar=no,status=yes,toolbar=no'
            );
}

function create_input(textfield, formular)
{
    close_input();
    if (FormOpen == 0) {
        keyfetch_off();
        FormOpen = textfield;
        TextClosed = formular;
        var textfield = document.getElementById(textfield);
        var formular = document.getElementById(formular);
        formular.style.display = "inline";
        textfield.style.display = "none";
        formular.firstChild.focus();
        formular.firstChild.select();
        formular.firstChild.onblur = close_input;
    }
    blockedmenu = 0;
}

function close_input()
{
    if (FormOpen != 0) {
        keyfetch_on();
        var otextfield = document.getElementById(FormOpen);
        var oformular = document.getElementById(TextClosed);
        FormOpen = 0;
        oformular.style.display = "none";
        otextfield.style.display = "inline";
    }
    blockedmenu = 0;
}

function drop_screen_selection()
{
    try { document.selection.empty(); } catch (e) {
        try { window.getSelection().collapseToStart(); } catch (e) {
            try { document.getSelection().collapseToStart(); } catch (e) { }
        }
    }
}

function fetchkey(e)
{
    var evt =  e || window.event;
    var key = (evt.which) ? evt.which : evt.keyCode;
    var fetched = false; // Pass on keycodes we did not fetch
    var exec = false; // First return from the keypress, then execute the command
    // React on pressed key
    switch (key) {
    case 46: // Entf (Del)
        foldermenu(parent.FLMarkedItem);
        context_delete(e);
        fetched = true;
        break;
    case 69: // E
        if (evt.shiftKey) {
            exec = 'context_expungefolder();';
            fetched = true;
        }
        break;
    case 78: // N
        if (evt.ctrlKey) {
            exec = 'context_createsubfolder();';
            fetched = true;
        }
        break;
    case 80: // P
        if (evt.ctrlKey) {
            exec = 'open_folderprops();';
            fetched = true;
        }
        break;
    case 82: // R
        if (evt.ctrlKey) {
            exec = 'context_rename();';
            fetched = true;
        }
        break;
    case 83: // S
        if (evt.shiftKey) {
            exec = 'context_resync();';
            fetched = true;
        }
        break;
    case 86: // V
        if (evt.ctrlKey && evt.shiftKey) {
            exec = 'context_move();';
            fetched = true;
        }
        break;
    }
    if (fetched) {
        if (window.event) {
            evt.cancelBubble = true;
        } else if (evt.preventDefault) {
            evt.preventDefault();
        } else {
            evt.stopPropagation();
        }
        evt.returnValue = false;
        if (exec) window.setTimeout('foldermenu(parent.FLMarkedItem); ' + exec, 1);
        return false;
    }
}

function init_folderlist()
{
    if (parent.FLMarkedItem && idToHandlerId[parent.FLMarkedItem]) {
        mark_folder(parent.FLMarkedItem);
    } else {
        parent.FLMarkedItem = 0;
    }
    collapse_folders();
    parent.FolderListLoaded = 1;
    try { parent.empty_statustext(); } catch (e) { }
}

function keyfetch_on()
{
    if (window.captureEvenets) {
        window.onkeydown = fetchkey;
    } else {
        document.onkeydown = fetchkey;
    }
}

function keyfetch_off()
{
    if (window.captureEvenets) {
        window.onkeydown = null;
    } else {
        document.onkeydown = null;
    }
}

if (window.addEventListener) {
    window.addEventListener('load', init_folderlist, false);
} else if (window.attachEvent) {
    window.attachEvent('onload', init_folderlist);
}
window.onunload = function (e) {
    parent.FolderListLoaded = 0;
}
keyfetch_on();
</script>
<div style="text-align:left; vertical-align:top;background:white;color:black;" onmouseout="disable_foldermenu();">
<!-- START line --><div class="listfolderline" name="{level}" onmouseover="foldermenu('txt_{Rfolder_path}');"><!-- START bars --><!-- START vbar --><img src="{theme_path}/icons/corn2.png" alt="" align="middle" /><!-- END vbar --><!-- START novbar --><img src="{theme_path}/icons/corn3.png" alt="" align="middle" /><!-- END novbar --><!-- END bars --><!-- START aufzu --><img src="{theme_path}/icons/minus.png" alt="" align="middle" onclick="aufzu({id});" id="{id}" /><!-- END aufzu --><!-- START cornplus --><img src="{theme_path}/icons/corn1.png" alt="" align="middle" /><!-- END cornplus --><!-- START corn --><img src="{theme_path}/icons/corn0.png" alt="" align="middle" /><!-- END corn --><!-- START rootline --><img src="{theme_path}/icons/root.png" alt="" align="middle" /><!-- END rootline --><!-- START default --><img id="img_{folder_path}" style="cursor:pointer"<!-- START renamable --> ondblclick="create_input('txt_{Rfolder_path}','form_{Rfolder_path}');"<!-- END renamable -->  src="{icon}" alt="" title="{foldername}" align="middle" />&nbsp;<span class="foldername" id="txt_{Rfolder_path}" title="{foldername}" onclick="open_folder('txt_{Rfolder_path}', '{link_target}','{foldername}','{big_icon}', '{handler}');">{foldername} <span class="folder_unread" id="unread_{fid}">{unread}</span></span><form action="{rename_target}" id="form_{Rfolder_path}" style="display:none; vertical-align:middle;" onsubmit="return rename_folder('form_{Rfolder_path}');" method="get"><input type="text" name="rename_to" value="{foldername}" size="{namelength}" class="renamebox" /></form><!-- END default --><!-- START browse --><img id="img_{folder_path}" style="cursor:pointer" src="{icon}" alt="" title="{foldername}" align="middle" />&nbsp;<span class="foldername" id="txt_{Rfolder_path}" title="{foldername}" onclick="select_folder('txt_{Rfolder_path}', '{fid}');" ondblclick="submit_folder('{fid}');">{foldername}</span><!-- END browse --><br /></div>
<!-- END line -->
</div>
Return current item: phlyMail Lite