Skip to content

Instantly share code, notes, and snippets.

@dorey
Created September 17, 2012 21:49
Show Gist options
  • Save dorey/3740001 to your computer and use it in GitHub Desktop.
Save dorey/3740001 to your computer and use it in GitHub Desktop.
a basic test of logging # of inches of a given element (using a dpi method)
// dpi.get() code is from stackoverflow:
// http://stackoverflow.com/questions/2252030/how-can-i-find-out-a-web-page-viewers-pixels-per-inch#answer-2312609
var dpi = {
v: 0,
get: function (noCache) {
if (noCache || dpi.v == 0) {
e = document.body.appendChild(document.createElement('DIV'));
e.style.width = '1in';
e.style.padding = '0';
dpi.v = e.offsetWidth;
e.parentNode.removeChild(e);
}
return dpi.v;
}
};
$(function(){
$('fieldset')
.filter(function(){return $(this).find('fieldset').length == 0})
.each(function(){
console.log("OuterHeight: ",
Math.floor(($(this).outerHeight() / dpi.get())*10)/10,
" inches ...->", $(this));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment