Skip to content

Instantly share code, notes, and snippets.

@jessebeach
Created July 19, 2012 19:34
Show Gist options
  • Select an option

  • Save jessebeach/3146242 to your computer and use it in GitHub Desktop.

Select an option

Save jessebeach/3146242 to your computer and use it in GitHub Desktop.
Acquia Responsivizer plugin
(function ($) {
var plugin = 'responsiviser';
// Local copy of jQuery.
var Drupal = window.Drupal;
Drupal.behaviors[plugin] = {
attach: function (context, settings) {
$('body').once(plugin, function (index) {
var $pageWidth = $('.page-width');
var $stackWidth = $('.stack-width');
var $content = $('#content');
var $sidebars = $content.find('.sidebar');
var $main = $content.find('#main');
var $box = $main.parent('.box');
var $menus = $('.horizontal.stack');
// Breakpoint step functions.
function mobileBreak() {
// Make the page 100% width.
$pageWidth.addClass('responsive-flex');
$stackWidth.addClass('responsive-flex');
$sidebars.addClass('responsive-sidebar');
// Move the main content to the top of the content box.
$main.prependTo($box);
// Show any hidden sidebars.
$('.sidebar:hidden').not('.tb-hidden').show();
// Remove the main menu event handlers added by the superfish plugin.
$('.pulldown-processed li').unbind('mouseover mouseout');
}
function tabletBreak() {
// Make the page 100% width.
$pageWidth.addClass('responsive-flex');
$stackWidth.addClass('responsive-flex');
$sidebars.addClass('responsive-sidebar');
// Move the main content to the top of the content box.
$main.prependTo($box);
}
function flexiBreak() {
// Make the page max-width 960px.
$pageWidth.addClass('responsive-flex');
$stackWidth.addClass('responsive-flex');
$sidebars.removeClass('responsive-sidebar');
// Move the main content below the sidebars.
$main.appendTo($box);
}
function desktopBreak() {
// Make the page fixed width.
$pageWidth.removeClass('responsive-flex');
$stackWidth.removeClass('responsive-flex');
$sidebars.removeClass('responsive-sidebar');
// Move the main content below the sidebars.
$main.appendTo($box);
}
// Turn off automatic column resizing.
if (Drupal.behaviors.acquia && Drupal.behaviors.acquia.equalCols) {
Drupal.behaviors.acquia.equalCols = false;
}
// Remove the min height on columns if the resizing already ran.
$('.tb-height-balance').css({
'min-height': 0
});
// Don't responsivize the theme is the viewport tag isn't present.
if (!$('[name="viewport"]', 'head').length > 0) {
return;
}
// Pass the step handlers to the BreakUp plugin.
var responder = new $.BreakUp({
'0': mobileBreak,
'480': tabletBreak,
'768': flexiBreak,
'960': desktopBreak
}, {'namespace': 'gardens_features'}, $(document));
});
}
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment