rice-framework/krad-web/src/main/webapp/krad/scripts/krad.utility.js
/**
 * Initialize or reinitialize the sticky header positions based on the current scroll value
 *
 * @param currentScroll the current scroll
 */
Initialize or reinitialize the sticky header positions based on the current scroll value

@param currentScroll the current scroll
Initialize or reinitialize the sticky header positions based on the current scroll value @param currentScroll the current scroll
function initStickyContent(currentScroll) {
    if (stickyContent == undefined || stickyContent.length == 0) {
        return;
    }
    if (!currentScroll) {
        currentScroll = jQuery(window).scrollTop();
    }
    var topOffset = Math.floor(stickyContentOffset.top);
    var totalHeight = 0;
    var margin = 0;
    var prevHeight = 0;
    var automateMargin = false;
    var innerNonStickyCount = 0;
    var lastStickyContent;
    stickyContent.each(function () {
        var height = jQuery(this).outerHeight();
        var thisOffset = jQuery(this).data("offset");
        var thisOffsetTop = Math.floor(thisOffset.top);
        jQuery(this).addClass(kradVariables.STICKY_CLASS);
        if (thisOffsetTop < 1) {
            automateMargin = true;
        }
        if (currentScroll > 0) {
            jQuery(this).attr("style", "position:fixed; left: 0; top: " + (thisOffsetTop - currentScroll) + "px;");
        }
        else {
            jQuery(this).attr("style", "position:fixed; left: 0; top: " + thisOffsetTop + "px;");
        }
        if (thisOffsetTop > topOffset + 1) {
            margin = margin + totalHeight;
            innerNonStickyCount++;
            topOffset = thisOffsetTop;
        }
        totalHeight = totalHeight + height;
        topOffset = topOffset + height;
        prevHeight = height;
        lastStickyContent = jQuery(this);
    });
    if (automateMargin && innerNonStickyCount == 1) {
        jQuery("#" + kradVariables.APP_ID).css("marginTop", (margin) + "px");
    }
    var navigation = jQuery("#" + kradVariables.NAVIGATION_ID);
    var navigationHeightAdjust = 0;
    if (navigation.length && navigation.has(".nav-tabs").length === 0) {
        navigation.attr("style", "position:absolute;");
    }
    var applyMarginToContent = jQuery("[data-role='View'] > .uif-sticky:last").next();
    if (applyMarginToContent.length == 0) {
        applyMarginToContent = jQuery("[data-role='View']");
    }
    jQuery(applyMarginToContent).css("marginTop",
        (totalHeight + navigationHeightAdjust - margin) + "px");
    currentHeaderHeight = (topOffset - currentScroll);
}
function initStickyContent ( currentScroll ) { if ( stickyContent == undefined || stickyContent . length == 0 ) { return ; } if ( ! currentScroll ) { currentScroll = jQuery ( window ) . scrollTop ( ) ; } var topOffset = Math . floor ( stickyContentOffset . top ) ; var totalHeight = 0 ; var margin = 0 ; var prevHeight = 0 ; var automateMargin = false ; var innerNonStickyCount = 0 ; var lastStickyContent ; stickyContent . each ( function ( ) { var height = jQuery ( this ) . outerHeight ( ) ; var thisOffset = jQuery ( this ) . data ( "offset" ) ; var thisOffsetTop = Math . floor ( thisOffset . top ) ; jQuery ( this ) . addClass ( kradVariables . STICKY_CLASS ) ; if ( thisOffsetTop < 1 ) { automateMargin = true ; } if ( currentScroll > 0 ) { jQuery ( this ) . attr ( "style" , "position:fixed; left: 0; top: " + ( thisOffsetTop - currentScroll ) + "px;" ) ; } else { jQuery ( this ) . attr ( "style" , "position:fixed; left: 0; top: " + thisOffsetTop + "px;" ) ; } if ( thisOffsetTop > topOffset + 1 ) { margin = margin + totalHeight ; innerNonStickyCount ++ ; topOffset = thisOffsetTop ; } totalHeight = totalHeight + height ; topOffset = topOffset + height ; prevHeight = height ; lastStickyContent = jQuery ( this ) ; } ) ; if ( automateMargin && innerNonStickyCount == 1 ) { jQuery ( "#" + kradVariables . APP_ID ) . css ( "marginTop" , ( margin ) + "px" ) ; } var navigation = jQuery ( "#" + kradVariables . NAVIGATION_ID ) ; var navigationHeightAdjust = 0 ; if ( navigation . length && navigation . has ( ".nav-tabs" ) . length === 0 ) { navigation . attr ( "style" , "position:absolute;" ) ; } var applyMarginToContent = jQuery ( "[data-role='View'] > .uif-sticky:last" ) . next ( ) ; if ( applyMarginToContent . length == 0 ) { applyMarginToContent = jQuery ( "[data-role='View']" ) ; } jQuery ( applyMarginToContent ) . css ( "marginTop" , ( totalHeight + navigationHeightAdjust - margin ) + "px" ) ; currentHeaderHeight = ( topOffset - currentScroll ) ; }
Initialize or reinitialize the sticky header positions based on the current scroll value
Initialize or reinitialize the sticky header positions based on the current scroll value
//early return if no sticky content
 //fix each sticky piece of content
 //scroll content with the scroll
 //this means there is inner non-sticky content in the header
 //set totalHeight of sticky elements, topOffset, and prevHeight
 //Only adjust the margin if a sticky area exists in the top most area, and there is inner-non-sticky content
 // this allows for customization of
 //non-sticky, sticky, non-sticky, sticky pattern through explicit css setting (non-calculated, complex)
 //change the margin to account for content in the header that collapses (scrolls away)
 //move the navigation with total height of the header pieces - the scroll
 // TODO support both absolute and fixed
 //navigation.attr("style", "position:fixed; top: " + (topOffset - currentScroll) + "px;");
 // Determine which div to apply the margin to by figuring out the first applicable div that exists after all
 // the sticky content, in order to push down that content and content below it correctly
 //make the ViewContentWrapper margin-top reflect the visible header content pixel height
 //set header height global
