Last active
December 10, 2015 00:28
-
-
Save mauryaratan/4350979 to your computer and use it in GitHub Desktop.
Add body classes for browser, OS and retina display support.
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
$(function() { | |
var browser, classList, os, platform, retina; | |
retina = window.devicePixelRatio > 1 ? "retina" : "no-retina"; | |
platform = window.navigator.userAgent; | |
if (/Chrome/.test(platform)) { | |
browser = "chrome"; | |
} else if (/Firefox/.test(platform)) { | |
browser = "firefox"; | |
} else { | |
browser = "unknown-browser"; | |
} | |
if (/Mac/.test(platform)) { | |
os = "mac"; | |
} else if (/Windows/.test(plaform)) { | |
os = "windows"; | |
} else { | |
os = "unknown-os"; | |
} | |
classList = os + " " + browser + " " + retina; | |
$("body").addClass(classList); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment