'use strict'; (function(){ window.NIJS = window.NIJS || {}; NIJS.detection = NIJS.detection || {}; var html = document.getElementsByTagName('html')[0], removeClass = function(str, className){ var classArr = str.split(' '), index = -1; for(var i = classArr.length; i--; ) { if(classArr[i] == className){ index = i; break; } } if(index > -1) { classArr.splice(index, 1); } return classArr.join(' '); }; function detectOrientation(){ html.className = removeClass(html.className, 'is-landscape'); html.className = removeClass(html.className, 'is-portrait'); if(window.innerHeight > window.innerWidth){ // is portrait html.className += ' is-portrait'; NIJS.detection.orientation = 'portrait'; }else { // is landscape html.className += ' is-landscape'; NIJS.detection.orientation = 'landscape'; } } window.addEventListener('resize', detectOrientation); // set initial value detectOrientation(); })();