Created
December 1, 2017 14:22
-
-
Save pagemashine/2ed1a5b83fe2787d886ed6a2f23dc3f2 to your computer and use it in GitHub Desktop.
media query on js
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
window.adaptive = (function(){ | |
var jqAdaptiveParamsContainer = $(".js_adaptive_params"); | |
var oData = {}; | |
if ( jqAdaptiveParamsContainer.length ){ | |
oData = jqAdaptiveParamsContainer.data('adaptive_parameters'); | |
} | |
return { | |
getData: function(){ | |
return oData; | |
}, | |
getParam: function(sParamName, mDefValue){ | |
return oData[sParamName] !== undefined ? oData[sParamName] : mDefValue; | |
}, | |
setParam: function(sParamName, mVal){ | |
oData.sParamName = mVal; | |
}, | |
isMobile: function(){ | |
return $(window).width() <= Number.parseInt( adaptive.getParam('break_tablet', 768) ); | |
}, | |
isTablet: function(){ | |
var windowWidth = $(window).width(); | |
return ( windowWidth < Number.parseInt(adaptive.getParam('break_desktop', 980)) ) && ( windowWidth > Number.parseInt(adaptive.getParam('break_tablet', 768)) ); | |
}, | |
isDesktop: function(){ | |
return $(window).width() >= Number.parseInt(adaptive.getParam('break_desktop', 980)); | |
} | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment