Created
January 5, 2015 13:17
-
-
Save donnywals/ec8a18d30ba0e188538b to your computer and use it in GitHub Desktop.
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
/* | |
* see http://krijnhoetmer.nl/stuff/javascript/media-queries/ | |
*/ | |
var App = App || {}; | |
(function(){ | |
var screenSizeTest = function(mediaQuery){ | |
return window.matchMedia(mediaQuery).matches; | |
} | |
var readSize = function() { | |
var pseudo = window.getComputedStyle(document.documentElement, ':before').getPropertyValue('content'); | |
return pseudo ? pseudo.replace(/['"]/g, '') : false; | |
} | |
App.isSmallScreen = function() { | |
return parseInt(readSize()) === 1; | |
} | |
App.isMediumScreen = function() { | |
return parseInt(readSize()) === 2; | |
} | |
App.isLargeScreen = function() { | |
return parseInt(readSize()) === 3; | |
} | |
App.isXLargeScreen = function() { | |
return parseInt(readSize()) === 4; | |
} | |
/* | |
* Unfortunatly... | |
*/ | |
App.isSmallerThanPortraitIpad = function() { | |
return screenSizeTest("(max-width: 768px)"); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment