jquery-mobile/js/jquery.mobile.support.js

40 lines
1.1 KiB
JavaScript

/*
Possible additions:
scollTop
CSS Matrix
*/
// test whether a CSS media type or query applies
$.media = (function() {
// TODO: use window.matchMedia once at least one UA implements it
var cache = {},
$html = $( "html" ),
testDiv = $( "<div id='jquery-mediatest'>" ),
fakeBody = $( "<body>" ).append( testDiv );
return function( query ) {
if ( !( query in cache ) ) {
var styleBlock = $( "<style type='text/css'>" +
"@media " + query + "{#jquery-mediatest{position:absolute;}}" +
"</style>" );
$html.prepend( fakeBody ).prepend( styleBlock );
cache[ query ] = testDiv.css( "position" ) === "absolute";
fakeBody.add( styleBlock ).remove();
}
return cache[ query ];
};
})();
var fakeBody = $( "<body>" ).prependTo( "html" );
$.extend( $.support, {
orientation: "orientation" in window,
touch: "ontouchend" in document,
WebKitAnimationEvent: typeof WebKitTransitionEvent === "object",
pushState: !!history.pushState,
mediaquery: $.media('only all'),
cssPseudoElement: fakeBody[0].style.content !== undefined
});
fakeBody.remove();