diff --git a/js/jQuery.mobile.js b/js/jQuery.mobile.js index f84c0afe..1cb3da8e 100644 --- a/js/jQuery.mobile.js +++ b/js/jQuery.mobile.js @@ -33,71 +33,6 @@ maxSwipeTime = 1000, minSwipeXDistance = 180, maxSwipeYtolerance = 80; - - /* - add some properties to $.support - - Notes: - - add $.support.scrollTop ? - - CSS matrix support needed? - */ - $.support.orientation = !!window.orientation; - - /* Some CSS capability tests from EnhanceJS -- in the vein of $.support.boxmodel -- almost certainly needed for widgets to work - */ - //test CSS display none - $.support.display = (function(){ - var fakeBody = $('').prependTo($html), - testDiv = $('
').prependTo(fakeBody), - divHeight = testDiv[0].offsetHeight; //note: jQuery .height() returned "5" - fakeBody.remove(); - return divHeight === 0; - })(); - - //test CSS absolute positioning - $.support.position = (function(){ - var fakeBody = $('').prependTo($html), - testDiv = $('
').prependTo(fakeBody), - divLeft = testDiv[0].offsetLeft; - fakeBody.remove(); - return divLeft === 10; - })(); - - //test CSS overflow (used in widgets for clearfix, hiding, etc) - $.support.overflow = (function(){ - var fakeBody = $('').prependTo($html), - testDiv = $('
').prependTo(fakeBody), - divHeight = testDiv[0].offsetHeight; - fakeBody.remove(); - return divHeight === 0; - })(); - - //test CSS float,clear - $.support.floatclear = (function(){ - var fakeBody = $('').prependTo($html), - pass = false, - innerStyle = 'style="width: 5px; height: 5px; float: left;"', - testDiv = $('
').prependTo(fakeBody), - kids = testDiv[0].childNodes, - topA = kids[0].offsetTop, - divB = kids[1], - topB = divB.offsetTop; - if (topA === topB) { - divB.style.clear = 'left'; - topB = divB.offsetTop; - if (topA !== topB) { - pass = true; - } - } - fakeBody.remove(); - return pass; - })(); - - //right about here, we *could* make sure all of the above css support props are true, if not, return and leave the page usable fercryin'outloud - if(!$.support.display || !$.support.position || !$.support.overflow || !$.support.floatclear ) { return; } - - //support properties from jQtouch - $.support.touch = (typeof Touch == "object"); - $.support.WebKitAnimationEvent = (typeof WebKitTransitionEvent == "object"); /* add some core behavior,events diff --git a/js/jQuery.mobile.support.js b/js/jQuery.mobile.support.js new file mode 100644 index 00000000..2d493fd7 --- /dev/null +++ b/js/jQuery.mobile.support.js @@ -0,0 +1,53 @@ +/* +Possible additions: + scollTop + CSS Matrix +*/ + +$.extend( $.support, { + orientation: !!window.orientation, + // to use bbq-style navigation with external pages + // we will need to first test for ajax support (and fall back to normal urls) + ajax: !!$.ajaxSettings.xhr(), + touch: typeof Touch === "object", + WebKitAnimationEvent: typeof WebKitTransitionEvent === "object" +}); + +(function() { + var fakeBody = $( "" ).prependTo( "html" ), + displayDiv = $( "
" ) + .prependTo( fakeBody ), + positionDiv = $( "
" ) + .prependTo( fakeBody ), + overflowDiv = $( "
" + + "
" ).prependTo( fakeBody ), + floatClearHtml = "
", + floatClearWrap = $( "
" ) + .append( floatClearHtml + floatClearHtml ) + .prependTo( fakeBody ), + floatClearDivs = floatClearWrap.children(), + floatClearDiv1Top = floatClearDivs[ 0 ].offsetTop, + floatClearDiv2 = floatClearDivs[ 1 ], + supportFloatClear = false; + + if ( floatClearDiv1Top === floatClearDiv2.offsetTop ) { + floatClearDiv2.style.clear = "left"; + if ( floatClearDiv1Top !== floatClearDiv2.offsetTop ) { + supportFloatClear = true; + } + } + + $.extend( $.support, { + display: displayDiv[ 0 ].offsetHeight === 0, + position: positionDiv[ 0 ].offsetLeft === 10, + overflow: overflowDiv[ 0 ].offsetHeight === 0, + floatclear: supportFloatClear + }); + + fakeBody.remove(); +})(); + +// if we're missing support for any of these, then we're a C-grade browser +if ( !$.support.display || !$.support.position || !$.support.overflow || !$.support.floatclear ) { + return; +} diff --git a/js/manifest.php b/js/manifest.php index d8d7e25a..9375486e 100644 --- a/js/manifest.php +++ b/js/manifest.php @@ -16,6 +16,7 @@ $elements = array( 'jQuery.tabs.js', 'jQuery.tree.js', 'jQuery.globalnav.js', + 'jQuery.mobile.support.js', 'jQuery.mobile.js' );