From de53cfb93012612e90fdb7c48431e06f1a690b3f Mon Sep 17 00:00:00 2001 From: scottjehl Date: Thu, 7 Oct 2010 15:15:59 -0400 Subject: [PATCH] Made all css and JS rely upon media query support. ("only all"). We can go back to the previous system, but so far, this seems to create a better divide than our previous support tests provided. 1-person discussion here: https://github.com/jquery/jquery-mobile/issues/#issue/29 --- _containers-states.html | 2 +- _dialog.html | 2 +- _events.html | 2 +- _filter.html | 2 +- _fixed-variation1.html | 2 +- _fixed-variation2.html | 2 +- _fixed.html | 2 +- _footer-persist-result.html | 2 +- _footer-persist.html | 2 +- _form-controls.html | 2 +- _listview.html | 2 +- _navlist.html | 2 +- _progressbar-static.html | 2 +- _search-results.html | 2 +- _search.html | 2 +- _transitions-destination.html | 2 +- _transitions.html | 2 +- experiments/api-viewer/index.html | 2 +- experiments/converter/index.html | 2 +- experiments/navlist-glyphish/index.html | 2 +- experiments/photos/_photo1.html | 4 +-- experiments/photos/_photo2.html | 4 +-- experiments/photos/_photo3.html | 4 +-- experiments/photos/_photo4.html | 4 +-- experiments/photos/_photo5.html | 4 +-- experiments/photos/_photo6.html | 4 +-- experiments/ui-datepicker/index.html | 4 +-- index.html | 2 +- js/jquery.mobile.js | 4 +-- js/jquery.mobile.support.js | 45 +++++++++++++------------ 30 files changed, 60 insertions(+), 59 deletions(-) diff --git a/_containers-states.html b/_containers-states.html index 67ea29fc..0eba81d4 100644 --- a/_containers-states.html +++ b/_containers-states.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Static Containers, States - + diff --git a/_dialog.html b/_dialog.html index 0f041d01..e514d567 100644 --- a/_dialog.html +++ b/_dialog.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Dialog Example - + diff --git a/_events.html b/_events.html index 6f6b7633..cc2e998f 100644 --- a/_events.html +++ b/_events.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Event tests - + diff --git a/_filter.html b/_filter.html index 2a324de0..42827f58 100644 --- a/_filter.html +++ b/_filter.html @@ -3,7 +3,7 @@ jQuery Mobile Framework - Filtered List View - + diff --git a/_fixed-variation1.html b/_fixed-variation1.html index 3f972f13..ad1d8ead 100644 --- a/_fixed-variation1.html +++ b/_fixed-variation1.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Fixed toolbars variation - + diff --git a/_fixed-variation2.html b/_fixed-variation2.html index e7d0358a..44bd78c1 100644 --- a/_fixed-variation2.html +++ b/_fixed-variation2.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Fixed Overlay Style Toolbars - + diff --git a/_fixed.html b/_fixed.html index 457efb95..b0e3866b 100644 --- a/_fixed.html +++ b/_fixed.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Toolbars demo - + diff --git a/_footer-persist-result.html b/_footer-persist-result.html index f4a3e286..26655286 100644 --- a/_footer-persist-result.html +++ b/_footer-persist-result.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Persistent footer demo - + diff --git a/_footer-persist.html b/_footer-persist.html index 77c9168d..f9d5f893 100644 --- a/_footer-persist.html +++ b/_footer-persist.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Persistent footer demo - + diff --git a/_form-controls.html b/_form-controls.html index dddac4bf..dc40ab64 100644 --- a/_form-controls.html +++ b/_form-controls.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Form Controls - + diff --git a/_listview.html b/_listview.html index 5d270e42..68af624f 100644 --- a/_listview.html +++ b/_listview.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Listview Examples - + diff --git a/_navlist.html b/_navlist.html index 2dd1e68f..76485134 100644 --- a/_navlist.html +++ b/_navlist.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - navlist Example - + diff --git a/_progressbar-static.html b/_progressbar-static.html index c9561bec..3a9630f9 100644 --- a/_progressbar-static.html +++ b/_progressbar-static.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Static Progressbar Example - + diff --git a/_search-results.html b/_search-results.html index 2d3b3824..98ca5430 100644 --- a/_search-results.html +++ b/_search-results.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Search Results - + diff --git a/_search.html b/_search.html index f07d5889..86354237 100644 --- a/_search.html +++ b/_search.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Search Example - + diff --git a/_transitions-destination.html b/_transitions-destination.html index af22b26f..75f8382a 100644 --- a/_transitions-destination.html +++ b/_transitions-destination.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Transition Completed! - + diff --git a/_transitions.html b/_transitions.html index a2cb941f..0ad3fdbe 100644 --- a/_transitions.html +++ b/_transitions.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Static Containers, States - + diff --git a/experiments/api-viewer/index.html b/experiments/api-viewer/index.html index 0fc5e641..10df76f1 100644 --- a/experiments/api-viewer/index.html +++ b/experiments/api-viewer/index.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - Listview Examples - + diff --git a/experiments/converter/index.html b/experiments/converter/index.html index 144ec7f0..05b42ab1 100644 --- a/experiments/converter/index.html +++ b/experiments/converter/index.html @@ -3,7 +3,7 @@ jQuery Mobile Framework - Converter Demo Application - + diff --git a/experiments/navlist-glyphish/index.html b/experiments/navlist-glyphish/index.html index 55b780b8..91092015 100644 --- a/experiments/navlist-glyphish/index.html +++ b/experiments/navlist-glyphish/index.html @@ -2,7 +2,7 @@ jQuery Mobile Framework - navlist Example - + diff --git a/experiments/photos/_photo1.html b/experiments/photos/_photo1.html index 5dd5d015..cbffd001 100644 --- a/experiments/photos/_photo1.html +++ b/experiments/photos/_photo1.html @@ -2,13 +2,13 @@ jQuery Mobile Framework - Photo 1 - +
- +
diff --git a/experiments/photos/_photo2.html b/experiments/photos/_photo2.html index 1fd74697..19bc6d01 100644 --- a/experiments/photos/_photo2.html +++ b/experiments/photos/_photo2.html @@ -2,13 +2,13 @@ jQuery Mobile Framework - Photo 1 - +
- +
diff --git a/experiments/photos/_photo3.html b/experiments/photos/_photo3.html index ee339369..a4cd6baf 100644 --- a/experiments/photos/_photo3.html +++ b/experiments/photos/_photo3.html @@ -2,13 +2,13 @@ jQuery Mobile Framework - Photo 1 - +
- +
diff --git a/experiments/photos/_photo4.html b/experiments/photos/_photo4.html index 070ad3b8..6e7f9c48 100644 --- a/experiments/photos/_photo4.html +++ b/experiments/photos/_photo4.html @@ -2,13 +2,13 @@ jQuery Mobile Framework - Photo 1 - +
- +
diff --git a/experiments/photos/_photo5.html b/experiments/photos/_photo5.html index ae9e3e51..bbfabbbc 100644 --- a/experiments/photos/_photo5.html +++ b/experiments/photos/_photo5.html @@ -2,13 +2,13 @@ jQuery Mobile Framework - Photo 1 - +
- +

Nathan running

diff --git a/experiments/photos/_photo6.html b/experiments/photos/_photo6.html index 199197bc..1271cba1 100644 --- a/experiments/photos/_photo6.html +++ b/experiments/photos/_photo6.html @@ -2,13 +2,13 @@ jQuery Mobile Framework - Photo 1 - +
- +

Sandy beach

diff --git a/experiments/ui-datepicker/index.html b/experiments/ui-datepicker/index.html index df132df6..5ef5e3e1 100644 --- a/experiments/ui-datepicker/index.html +++ b/experiments/ui-datepicker/index.html @@ -2,14 +2,14 @@ jQuery Mobile Framework - Datepicker - +
- + diff --git a/js/jquery.mobile.js b/js/jquery.mobile.js index f096bb35..e1ed9344 100644 --- a/js/jquery.mobile.js +++ b/js/jquery.mobile.js @@ -8,7 +8,7 @@ */ (function( jQuery, window, undefined ) { // if we're missing support for any of these, then we're a C-grade browser - if ( !jQuery.support.display || !jQuery.support.position || !jQuery.support.overflow || !jQuery.support.floatclear ) { + if ( !jQuery.support.mediaquery ) { return; } @@ -255,7 +255,7 @@ $html.addClass('ui-mobile'); //insert mobile meta - these will need to be configurable somehow. - $head.append(''+ + $head.append(''+ ''+ ''+ '' + diff --git a/js/jquery.mobile.support.js b/js/jquery.mobile.support.js index ffa9398d..e570421a 100644 --- a/js/jquery.mobile.support.js +++ b/js/jquery.mobile.support.js @@ -4,11 +4,33 @@ Possible additions: 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 = $( "
" ), + fakeBody = $( "" ).append( testDiv ); + + return function( query ) { + if ( !( query in cache ) ) { + var styleBlock = $( "" ); + $html.prepend( fakeBody ).prepend( styleBlock ); + cache[ query ] = testDiv.css( "position" ) === "absolute"; + fakeBody.add( styleBlock ).remove(); + } + return cache[ query ]; + }; +})(); + $.extend( $.support, { orientation: "orientation" in window, touch: "ontouchend" in document, WebKitAnimationEvent: typeof WebKitTransitionEvent === "object", - pushState: !!history.pushState + pushState: !!history.pushState, + mediaquery: $.media('only all') }); (function() { @@ -43,24 +65,3 @@ $.extend( $.support, { fakeBody.remove(); })(); - -// 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 = $( "
" ), - fakeBody = $( "" ).append( testDiv ); - - return function( query ) { - if ( !( query in cache ) ) { - var styleBlock = $( "" ); - $html.prepend( fakeBody ).prepend( styleBlock ); - cache[ query ] = testDiv.css( "position" ) === "absolute"; - fakeBody.add( styleBlock ).remove(); - } - return cache[ query ]; - }; -})();