Created
August 28, 2011 14:21
-
-
Save emjayess/1176723 to your computer and use it in GitHub Desktop.
scripted layout techniques
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @file: unlayout.js | |
*/ | |
jQuery(function(){ | |
(function($,w) { | |
var unlayout = {} | |
, $w = $(w) | |
, $pagehdr = $('#page-header') | |
, $sidebar = $('#sidebar') | |
, shrinkage = 12; // very arbitrary amount of default shrinkage | |
unlayout.respond = function() { | |
unlayout.contentHxW(); | |
}; | |
unlayout.contentHxW = function() { | |
$main | |
.height( | |
$w.height() - $pagehdr.height() - shrinkage | |
//Math.max($w.height(), unlayout.calcHeight()) - $pagehdr.height() - shrinkage | |
) | |
.width( | |
$w.width() - $sidebar.width() - shrinkage | |
); | |
}; | |
$w | |
// draw on load: | |
.bind('load', unlayout.respond) | |
// re-draw on resize: todo: debounce on $w.resize! | |
.bind('resize', unlayout.respond); | |
unlayout.calcHeight = function() { // ~= $.innerHeight() | |
return Math.max( | |
Math.max( | |
d.body.scrollHeight, | |
d.documentElement.scrollHeight | |
), | |
Math.max( | |
d.body.offsetHeight, | |
d.documentElement.offsetHeight | |
), | |
Math.max( | |
d.body.clientHeight, | |
d.documentElement.clientHeight | |
) | |
); | |
}; | |
unlayout.calcWidth = function() { // ~= $.innerWidth() | |
return Math.max( | |
Math.max( | |
d.body.scrollWidth, | |
d.documentElement.scrollWidth | |
), | |
Math.max( | |
d.body.offsetWidth, | |
d.documentElement.offsetWidth | |
), | |
Math.max( | |
d.body.clientWidth, | |
d.documentElement.clientWidth | |
) | |
); | |
}; | |
}(jQuery,window)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment