mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-13 19:01:02 +00:00
- boxShadow (tests that the property is defined and window.blackberry is false, as BB's shadows have no feathering) - scrollTop (tests that the property is defined and that a webos property or two isn't defined, as Palm always reports 0) Added an existence test for CSS properties, which is used for cssPseudoElement and boxShadow).
57 lines
1.7 KiB
JavaScript
57 lines
1.7 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();
|
|
|