rice-framework/krad-web/src/main/webapp/krad/scripts/krad.focusJump.js
/**
 * Performs a focus on an the element with the id preset
 *
 * @param focusId - id of the dom element to focus on
 * @param autoFocus - boolean that indicates where focus to top should happen if focus to not set
 */
Performs a focus on an the element with the id preset

@param focusId - id of the dom element to focus on
@param autoFocus - boolean that indicates where focus to top should happen if focus to not set
Performs a focus on an the element with the id preset @param focusId - id of the dom element to focus on @param autoFocus - boolean that indicates where focus to top should happen if focus to not set
function performFocus(focusId) {
    var errorMessageItem = jQuery(".uif-errorMessageItem").first().find("a");
    if(errorMessageItem.length > 0) {
        errorMessageItem.focus();
        return;
    }
    if (!focusId) {
        return;
    }
    if (focusId == "FIRST") {
        var id = jQuery("div[data-role='InputField']:first [data-role='Control']:input:first", "#kualiForm").attr("id");
        focus(id);
        return;
    }
    if (focusId.match("^" + kradVariables.NEXT_INPUT.toString())) {
        focusId = focusId.substr(kradVariables.NEXT_INPUT.length, focusId.length);
        var original = jQuery("#" + focusId);
        var inputs = jQuery(":input:visible, a:visible:not(\"a[data-role='disclosureLink']\")");
        var index = jQuery(inputs).index(original);
        if (index && jQuery(inputs).length > index + 1) {
            var id = jQuery(inputs).eq(index + 1).attr("id");
            focus(id);
        }
    } else {
        var focusElement = jQuery("#" + focusId);
        if (focusElement.length) {
            focus(focusId);
        }
        else {
            focusId = focusId.replace(/_control\S*/, "");
            focusElement = jQuery("#" + focusId).find(":input:visible, a:visible").first();
            if (focusElement.length) {
                focus(jQuery(focusElement).attr("id"));
            }
        }
    }
}
function performFocus ( focusId ) { var errorMessageItem = jQuery ( ".uif-errorMessageItem" ) . first ( ) . find ( "a" ) ; if ( errorMessageItem . length > 0 ) { errorMessageItem . focus ( ) ; return ; } if ( ! focusId ) { return ; } if ( focusId == "FIRST" ) { var id = jQuery ( "div[data-role='InputField']:first [data-role='Control']:input:first" , "#kualiForm" ) . attr ( "id" ) ; focus ( id ) ; return ; } if ( focusId . match ( "^" + kradVariables . NEXT_INPUT . toString ( ) ) ) { focusId = focusId . substr ( kradVariables . NEXT_INPUT . length , focusId . length ) ; var original = jQuery ( "#" + focusId ) ; var inputs = jQuery ( ":input:visible, a:visible:not(\"a[data-role='disclosureLink']\")" ) ; var index = jQuery ( inputs ) . index ( original ) ; if ( index && jQuery ( inputs ) . length > index + 1 ) { var id = jQuery ( inputs ) . eq ( index + 1 ) . attr ( "id" ) ; focus ( id ) ; } } else { var focusElement = jQuery ( "#" + focusId ) ; if ( focusElement . length ) { focus ( focusId ) ; } else { focusId = focusId . replace ( / _control\S* / , "" ) ; focusElement = jQuery ( "#" + focusId ) . find ( ":input:visible, a:visible" ) . first ( ) ; if ( focusElement . length ) { focus ( jQuery ( focusElement ) . attr ( "id" ) ) ; } } } }
Performs a focus on an the element with the id preset
Performs a focus on an the element with the id preset
// Check to see if there are errors on the view. If error messages present use the first link of
 // validation messages as the focusId
