Cireson Partners, Customers and Community members share your customizations and examples here to help benefit the community as a whole to earn Kudos and badges.

DISCLAIMER

All files and projects located here are provided and come "as-is" and without any warranty or support. Use at your own risk. Your use of Community Uploads is subject to our Terms of Use.

Cireson does not and will not support or maintain these enhancements, extensions, and scripts.

For Team Cireson uploads click here.

Sorting the Task Menu

Jerry_VeldhuisJerry_Veldhuis Customer Advanced IT Monkey ✭✭✭
A bit of helpful code that sorts the Task Menu. It uses a MutationObserver to monitor the page and when the menu is present it sorts it once. Its best to add this at the bottom of your custom.js (or load is using getScript).

Tested in v4.0.10 as well as v7.3.2012.1 and 7.4.2012.1

Would be nice if the the portal did this automatically.
/* ------------------------------ */
/* ------ Sort Task Menu -------- */
/* ------------------------------ */
// Tested with v4.0.10 and v7.3.2012.1 and v7.4.2012.1
// Author: Jerry Veldhuis
// Description: Sort Task Menu
// Notes: add to the bottom of the custom.js file
// Credit: http://stackoverflow.com/questions/1134976/how-may-i-sort-a-list-alphabetically-using-jquery

(function() {
    var browseByCategoryObserver = new MutationObserver(function (mutations) {
	var mylist = $('ul[class=taskmenu]')
        if ( mylist ) {
            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); });
	    browseByCategoryObserver.disconnect();
        }
    });
    
    // Notify me of these!
    var observerConfig = { attributes: false, childList: true, characterData: false, subtree: true };
    
    // Node, config
    $(document).ready(function () {
	var targetNode = document.getElementById('main_wrapper');
	browseByCategoryObserver.observe(targetNode, observerConfig);
    });
})();

/* ------------------------------------------- */
/* ----------------- End  -------------------- */
/* ------------------------------------------- */

Sign In or Register to comment.