Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Created November 13, 2012 15:58
Show Gist options
  • Select an option

  • Save wpsmith/4066550 to your computer and use it in GitHub Desktop.

Select an option

Save wpsmith/4066550 to your computer and use it in GitHub Desktop.
JS: Resizes Genesis Content-Sidebar to Equal Heights (responsively)
// Responsive: Get Width
jQuery(window).resize(function() {
// Set size of sidebar/content
selectorSizing( jQuery(this).width() );
});
/*
* Resizes the selector to the designated size
*
* @param int size Browser Size to do nothing
* @param string selector Selector, defaults to '#footer-widgets .widget-area'
*/
function selectorSizing( size ) {
'use strict';
// size is required
if ( !size)
return false;
// Responsive Code
// Widgets move to 100% width if width of the browser window is < 960px
// Done via @media only screen and (max-width: 960px) { } in style.css
if( 960 < size ) {
var contentH = jQuery('#content').height();
var sidebarH = jQuery('#sidebar').height();
if ( sidebarH > contentH ) {
jQuery('#content').height(sidebarH);
}
}
else {
// Remove max height to the selectors
jQuery('#content').height('auto');
}
}
<?php
add_action( 'wp_enqueue_scripts', 'wps_enqueue_refooterwidgets' , 15 );
/*
* Enqueue reFooterWidgets to the footer
*
*/
function wps_enqueue_refooterwidgets() {
wp_enqueue_script( 'wps-content-sidebar-size' , get_stylesheet_directory() . '/js/content-sidebar-size.js' , array( 'jquery' ), '1.0.0' , true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment