Created
September 17, 2012 21:49
-
-
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)
This file contains 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
// 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