mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-21 00:10:24 +00:00
59 lines
No EOL
1.8 KiB
JavaScript
59 lines
No EOL
1.8 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" ),
|
|
fbCSS = fakeBody[0].style,
|
|
vendors = ['webkit','moz','o'],
|
|
webos = window.palmGetResource || window.PalmServiceBridge, //only used to rule out scrollTop
|
|
bb = window.blackberry; //only used to rule out box shadow, as it's filled opaque on BB
|
|
|
|
//thx Modernizr
|
|
function propExists( prop ){
|
|
var uc_prop = prop.charAt(0).toUpperCase() + prop.substr(1),
|
|
props = (prop + ' ' + vendors.join(uc_prop + ' ') + uc_prop).split(' ');
|
|
for(var v in props){
|
|
if( fbCSS[ v ] !== undefined ){
|
|
return true;
|
|
}
|
|
}
|
|
};
|
|
|
|
$.extend( $.support, {
|
|
orientation: "orientation" in window,
|
|
touch: "ontouchend" in document,
|
|
WebKitAnimationEvent: typeof WebKitTransitionEvent === "object",
|
|
pushState: !!history.pushState,
|
|
mediaquery: $.media('only all'),
|
|
cssPseudoElement: !!propExists('content'),
|
|
boxShadow: !!propExists('boxShadow') && !bb,
|
|
scrollTop: ("pageXOffset" in window || "scrollTop" in document.documentElement || "scrollTop" in fakeBody[0]) && !webos
|
|
});
|
|
|
|
fakeBody.remove();
|
|
|
|
//for ruling out shadows via css
|
|
if( !$.support.boxShadow ){ $('html').addClass('ui-mobile-nosupport-boxshadow'); } |