Streamerpedia
SBEyes (talk | contribs)
No edit summary
(nearly-blank page (moved to common))
 
Line 1: Line 1:
  +
/* Any JavaScript here will be loaded for users using the Hydra skin */
/*****************************************
 
/* Front Page column height equalization *
 
/*****************************************/
 
// Author: Shawn Bruckner
 
// Date: 2015-Feb-12
 
// License: CC-BY 3.0
 
// Version: beta
 
 
var fp = fp || {
 
equalizeColumns : function() {
 
$( '.fpcontent' ).each( function () {
 
fp.resetSectionBoxHeights( $( this ).find( '#fptopsection, #fpflexsection, #fpbottomsection' ) );
 
} );
 
if ( $( window ).width() > 1471 ) {
 
fp.equalizeColumnsOfBlock( '.fpcontent',
 
'#fptopsection, #fpbottomsection',
 
'#fpbottomsection',
 
'#fpflexsection',
 
'#fpflexsection',
 
''
 
);
 
}
 
},
 
 
equalizeColumnsOfBlock : function( blockSel, leftSel, leftBottomSel, rightSel, rightBottomSel, excludeSel ) {
 
$( blockSel ).each( function ( index ) {
 
var tryCount = 0;
 
do {
 
var leftBottom = $( this ).find( leftBottomSel ).offset().top + $( this ).find( leftBottomSel ).height();
 
var rightBottom = $( this ).find( rightBottomSel ).offset().top + $( this ).find( rightBottomSel ).height();
 
 
var difference = Math.round( Math.abs( rightBottom - leftBottom ) );
 
 
if ( leftBottom < rightBottom ) {
 
fp.adjustSectionBoxHeights( difference, $( this ).find( leftSel ).not( excludeSel ) );
 
} else if ( rightBottom < leftBottom ) {
 
fp.adjustSectionBoxHeights( difference, $( this ).find( rightSel ).not( excludeSel ) );
 
}
 
++tryCount;
 
} while ( Math.round( leftBottom ) != Math.round( rightBottom ) && tryCount < 4 );
 
} );
 
},
 
 
resetSectionBoxHeights : function ( sections ) {
 
sections.each( function () {
 
$( this ).find( '.fpboxes, .fpbox' ).not( '.fpboxes .fpbox' ).not( '.noresize' ).each( function () {
 
$( this ).height( 'auto' );
 
} );
 
} );
 
},
 
 
adjustSectionBoxHeights : function ( heightToAdd, sections ) {
 
var boxCount = 0;
 
sections.each( function() {
 
boxCount += $( this ).find( '.fpboxes, .fpbox' ).not( '.fpboxes .fpbox' ).not( '.noresize' ).length;
 
} );
 
 
var avgHeightToAdd = heightToAdd / boxCount;
 
var decimalPortion = 0.0;
 
var boxes, heightToAdd;
 
sections.each( function() {
 
boxes = $( this ).find( '.fpboxes, .fpbox' ).not( '.fpboxes .fpbox' ).not( '.noresize' );
 
 
boxes.each( function() {
 
heightToAdd = Math.round( decimalPortion + avgHeightToAdd ); /* should iron out rounding error */
 
decimalPortion += avgHeightToAdd - heightToAdd;
 
$( this ).height( $( this ).height() + heightToAdd );
 
} );
 
} );
 
}
 
};
 
 
$( window ).load( fp.equalizeColumns );
 
$( window ).resize( fp.equalizeColumns );
 
/*********************************************
 
/* End Front Page column height equalization *
 
/*********************************************/
 

Latest revision as of 19:57, 15 February 2018

/* Any JavaScript here will be loaded for users using the Hydra skin */