rice-framework/krad-web/src/main/webapp/krad/scripts/krad.validate.js
/**
 * Generates a summary link for the section specified by id, this link describes how many messages of each type can
 * be found in a particular section.  The link links, the 'header' of that section.
 * @param sectionId - the id of the section to create a summary link for
 */
Generates a summary link for the section specified by id, this link describes how many messages of each type can
be found in a particular section.  The link links, the 'header' of that section.
@param sectionId - the id of the section to create a summary link for
Generates a summary link for the section specified by id this link describes how many messages of each type can be found in a particular section . The link links the ' header ' of that section . @param sectionId - the id of the section to create a summary link for
function generateSummaryLink(sectionId) {
    var sectionTitle = getGroupHeaderElement(sectionId).find(".uif-headerText-span").text();
    if (sectionTitle == null || sectionTitle == "") {
        sectionTitle = jQuery("#" + sectionId).data("label");
        sectionId = jQuery("#" + sectionId).data("group");
    }
    if (sectionTitle == null || sectionTitle == undefined) {
        sectionTitle = "";
    }
    var sectionData = getValidationData(jQuery("#" + sectionId), true);
    var summaryLink = null;
    var summaryMessage = "";
    var image = "";
    var linkType = "";
    var highlight = "";
    var sectionHasCorrectedErrors = jQuery("[data-messages_for='" + sectionId + "']").find("span.uif-correctedError").length;
    if (sectionData && (sectionData.messageTotal || sectionHasCorrectedErrors)) {
        var countMessage = generateCountString(sectionData.errorTotal, sectionData.warningTotal, sectionData.infoTotal);
        sectionTitle = sectionTitle.replace(/\r?\n/g, "");
        if (sectionTitle && countMessage != "") {
            summaryMessage = sectionTitle + ": " + countMessage;
        }
        else {
            summaryMessage = countMessage;
        }
    }
    if (summaryMessage != "") {
        if (sectionData.errorTotal) {
            image = errorImage;
            linkType = "uif-errorMessageItem";
            highlight = kradVariables.ERROR_HIGHLIGHT_SECTION_CLASS;
        }
        else if (sectionData.warningTotal) {
            image = warningImage;
            linkType = "uif-warningMessageItem";
            highlight = kradVariables.WARNING_HIGHLIGHT_SECTION_CLASS;
        }
        else if (sectionData.infoTotal) {
            image = infoImage;
            linkType = "uif-infoMessageItem";
            highlight = kradVariables.INFO_HIGHLIGHT_SECTION_CLASS;
        }
        summaryLink = jQuery("<li data-messageItemFor='" + sectionId + "' class='" + linkType + "'><a "
                + "class='alert-link' href='#'>"
                + summaryMessage + "</a></li>");
        summaryLink.find("a").click(function (event) {
            event.preventDefault();
            jumpToElementById(sectionId);
            var firstItem = jQuery("[data-messages_for='" + sectionId + "'] > ul > li:first");
            if (firstItem.length) {
                if (jQuery(firstItem).find("> a").length) {
                    jQuery(firstItem).find("> a").focus();
                }
                else {
                    jQuery(firstItem).focus();
                }
            }
        });
        summaryLink.find("a").focus(function () {
            jQuery("#" + sectionId).addClass(highlight);
        });
        summaryLink.find("a").blur(function () {
            jQuery("#" + sectionId).removeClass(highlight);
        });
        summaryLink.find("a").hover(
                function () {
                    jQuery("#" + sectionId).addClass(highlight);
                },
                function () {
                    jQuery("#" + sectionId).removeClass(highlight);
                });
        if (!sectionData.displayMessages) {
            var sectionLinks = jQuery("[data-messages_for='" + sectionId + "']");
            sectionLinks.removeAttr("class");
            sectionLinks.removeAttr("style");
            jQuery(sectionLinks).show();
            return sectionLinks;
        }
    }
    return summaryLink;
}
function generateSummaryLink ( sectionId ) { var sectionTitle = getGroupHeaderElement ( sectionId ) . find ( ".uif-headerText-span" ) . text ( ) ; if ( sectionTitle == null || sectionTitle == "" ) { sectionTitle = jQuery ( "#" + sectionId ) . data ( "label" ) ; sectionId = jQuery ( "#" + sectionId ) . data ( "group" ) ; } if ( sectionTitle == null || sectionTitle == undefined ) { sectionTitle = "" ; } var sectionData = getValidationData ( jQuery ( "#" + sectionId ) , true ) ; var summaryLink = null ; var summaryMessage = "" ; var image = "" ; var linkType = "" ; var highlight = "" ; var sectionHasCorrectedErrors = jQuery ( "[data-messages_for='" + sectionId + "']" ) . find ( "span.uif-correctedError" ) . length ; if ( sectionData && ( sectionData . messageTotal || sectionHasCorrectedErrors ) ) { var countMessage = generateCountString ( sectionData . errorTotal , sectionData . warningTotal , sectionData . infoTotal ) ; sectionTitle = sectionTitle . replace ( / \r?\n / g , "" ) ; if ( sectionTitle && countMessage != "" ) { summaryMessage = sectionTitle + ": " + countMessage ; } else { summaryMessage = countMessage ; } } if ( summaryMessage != "" ) { if ( sectionData . errorTotal ) { image = errorImage ; linkType = "uif-errorMessageItem" ; highlight = kradVariables . ERROR_HIGHLIGHT_SECTION_CLASS ; } else if ( sectionData . warningTotal ) { image = warningImage ; linkType = "uif-warningMessageItem" ; highlight = kradVariables . WARNING_HIGHLIGHT_SECTION_CLASS ; } else if ( sectionData . infoTotal ) { image = infoImage ; linkType = "uif-infoMessageItem" ; highlight = kradVariables . INFO_HIGHLIGHT_SECTION_CLASS ; } summaryLink = jQuery ( "<li data-messageItemFor='" + sectionId + "' class='" + linkType + "'><a " + "class='alert-link' href='#'>" + summaryMessage + "</a></li>" ) ; summaryLink . find ( "a" ) . click ( function ( event ) { event . preventDefault ( ) ; jumpToElementById ( sectionId ) ; var firstItem = jQuery ( "[data-messages_for='" + sectionId + "'] > ul > li:first" ) ; if ( firstItem . length ) { if ( jQuery ( firstItem ) . find ( "> a" ) . length ) { jQuery ( firstItem ) . find ( "> a" ) . focus ( ) ; } else { jQuery ( firstItem ) . focus ( ) ; } } } ) ; summaryLink . find ( "a" ) . focus ( function ( ) { jQuery ( "#" + sectionId ) . addClass ( highlight ) ; } ) ; summaryLink . find ( "a" ) . blur ( function ( ) { jQuery ( "#" + sectionId ) . removeClass ( highlight ) ; } ) ; summaryLink . find ( "a" ) . hover ( function ( ) { jQuery ( "#" + sectionId ) . addClass ( highlight ) ; } , function ( ) { jQuery ( "#" + sectionId ) . removeClass ( highlight ) ; } ) ; if ( ! sectionData . displayMessages ) { var sectionLinks = jQuery ( "[data-messages_for='" + sectionId + "']" ) ; sectionLinks . removeAttr ( "class" ) ; sectionLinks . removeAttr ( "style" ) ; jQuery ( sectionLinks ) . show ( ) ; return sectionLinks ; } } return summaryLink ; }
Generates a summary link for the section specified by id, this link describes how many messages of each type can
 be found in a particular section.
Generates a summary link for the section specified by id this link describes how many messages of each type can be found in a particular section .
//determine section title and section type
 //field group case
 // for empty section titles (should not happen in unless we force it to)
 //remove newline characters
 //case where this section is not showing its own messages show them here
 //summaryLink.append(sectionLinks); (incase we want to go back to previous impl)
