Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // refresh roundcube to get the latest mail
- rcmail.command("checkmail","",this,"");
- // tag all the folders that have unread messages in them or in their subfolders
- // with the class "has_unread"
- $("ul.folderlist").children("li").filter(function() {
- if( $(this).hasClass("unread") || $(this).find(".unread").length !== 0 ) {
- $(this).addClass("has_unread");
- }
- });
- // order the folder list alphabetically
- var mylist = $(".folderlist");
- var listitems = mylist.children("li").get();
- listitems.sort(function(a, b) {
- return $(a).text().toUpperCase().localeCompare($(b).text().toUpperCase());
- });
- $.each(listitems, function(idx, itm) { mylist.append(itm); });
- // order_of_list is the order the mailboxes should appear in the folder list,
- // for ease of reading we put this in the order we want and then reverse it
- var order_of_list = ["inbox", "drafts", "sent", "junk", "trash", "archive", "has_unread"].reverse();
- // order the list
- $.each(order_of_list , function(index, value) {
- // in the folderlist select the children who have a li element with the
- // class equal to the value of the each loop and put them to the top
- // of the folderlist
- $("ul.folderlist").children("li." + value).prependTo(".folderlist");
- });
- // remove the "has_unread" tag
- $("ul.folderlist li").removeClass("has_unread");
Add Comment
Please, Sign In to add comment