Home > CRM > CRM Form Collapsible Sections

CRM Form Collapsible Sections

//Add collapsible functionality to sections.
/*********************************************************************/

function attachCollapsableToSections() {
    var sections = getElementsByCondition(function(elm)
    { if (elm.className.indexOf("ms-crm-Form-Section") != -1) return true; }, null);
    for (var i = 0; i < sections.length; i++) {
        sections[i].innerHTML = ‘<img  alt="Expanded, click to collapse" src="/_imgs/navup.gif" style="cursor:hand;"/>’ + sections[i].innerHTML; sections[i].childNodes[0].attachEvent(‘onclick’, toggleVisibility);
    }
}
function attachCollapsableToSections() {
    var sections = getElementsByCondition(function (elm) { if (elm.className.indexOf("ms-crm-Form-Section") != -1) return true; }, null);

    for (var i = 0; i < sections.length; i++) {

        sections[i].innerHTML = ‘<img  alt="Expanded, click to collapse" src="/_imgs/navup.gif" style="cursor:hand;"/>’ + sections[i].innerHTML;
        sections[i].childNodes[0].attachEvent(‘onclick’, toggleVisibility);
    }

}

function toggleVisibility(e) {
    var sectionContainer = e.srcElement.parentNode.parentNode.parentNode;

    var elements = getElementsByCondition(function (elm) { if (elm.vAlign == "top") return true; }, sectionContainer);

    for (var i = 0; i < elements.length; i++) {
        if (elements[i].style.display == "none") {
            elements[i].style.display = "";           
            e.srcElement.src = e.srcElement.src.replace("navdown", "navup");
        }
        else {
            elements[i].style.display = "none";           
            e.srcElement.src = e.srcElement.src.replace("navup", "navdown");
        }
    }
}

function getElementsByCondition(condition, container) {
    container = container || document;
    var all = container.all || container.getElementsByTagName(‘*’);
    var arr = [];
    for (var k = 0; k < all.length; k++) {
        var elm = all[k];
        if (condition(elm, k))
            arr[arr.length] = elm;
    }
    return arr;
}
/*********************************************************************/

Categories: CRM Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: