mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-24 01:40:25 +00:00
56 lines
No EOL
1.8 KiB
JavaScript
56 lines
No EOL
1.8 KiB
JavaScript
/*
|
|
* jQuery Mobile Framework : support tests
|
|
* Copyright (c) jQuery Project
|
|
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
|
|
* Note: Code is in draft form and is subject to change
|
|
*/
|
|
(function($, undefined ) {
|
|
|
|
|
|
|
|
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;
|
|
}
|
|
}
|
|
};
|
|
|
|
//test for dynamic-updating base tag support (allows us to avoid href,src attr rewriting)
|
|
function baseTagTest(){
|
|
var fauxBase = location.protocol + '//' + location.host + location.pathname + "ui-dir/",
|
|
base = $("<base>", {"href": fauxBase}).appendTo("head"),
|
|
link = $( "<a href='testurl'></a>" ).prependTo( fakeBody ),
|
|
rebase = link[0].href;
|
|
base[0].href = location.pathname;
|
|
base.remove();
|
|
return rebase.indexOf(fauxBase) === 0;
|
|
};
|
|
|
|
$.extend( $.support, {
|
|
orientation: "orientation" in window,
|
|
touch: "ontouchend" in document,
|
|
cssTransitions: "WebKitTransitionEvent" in window,
|
|
pushState: !!history.pushState,
|
|
mediaquery: $.mobile.media('only all'),
|
|
cssPseudoElement: !!propExists('content'),
|
|
boxShadow: !!propExists('boxShadow') && !bb,
|
|
scrollTop: ("pageXOffset" in window || "scrollTop" in document.documentElement || "scrollTop" in fakeBody[0]) && !webos,
|
|
dynamicBaseTag: baseTagTest()
|
|
});
|
|
|
|
fakeBody.remove();
|
|
|
|
//for ruling out shadows via css
|
|
if( !$.support.boxShadow ){ $('html').addClass('ui-mobile-nosupport-boxshadow'); }
|
|
|
|
})( jQuery ); |