mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-22 17:00:24 +00:00
40 lines
1.1 KiB
JavaScript
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();
|
|
|