Created
September 23, 2011 23:00
-
-
Save brianswisher/1238678 to your computer and use it in GitHub Desktop.
A mobile web dev script to toggle through portrait & landscape classes on a document's body element.
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
/*global document */ | |
var orientation; | |
(function () { | |
"use strict"; | |
orientation = function () { | |
var isPortrait, isLandscape; | |
isPortrait = document.body.className.indexOf('portrait') !== -1; | |
isLandscape = document.body.className.indexOf('landscape') !== -1; | |
document.body.className = document.body.className.split(' portrait ').join(''); | |
document.body.className = document.body.className.split(' landscape ').join(''); | |
if (!isPortrait && !isLandscape) { | |
document.body.className += ' portrait '; | |
} else if (!isLandscape) { | |
document.body.className += ' landscape '; | |
} | |
}; | |
orientation(); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment