mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-23 17:30:31 +00:00
- Internally, each plugin self-initializes by binding to the pagecreate event. - Unit tests have been added and adjusted to support some internal changes involved in this commit. - In the process, the portions of the page plugin that were used to enhance the header,content,and footer sections of a native-app style page layout are now located in jquery.mobile.page.sections.js. - No public API options have changed, except that the page plugin no longer has options for keepNative, and degradeInputs, as plugins now handle these internally (keepNative was never documented, and degradeInputs only affected slider, so it lives there now. Page options related to the page sections are now located in the page.sections script, but they are still configurable via the page plugin's options api. - Make, Ant, and index files are updated with a new load order for all JS files.
47 lines
No EOL
1.6 KiB
JavaScript
47 lines
No EOL
1.6 KiB
JavaScript
/*
|
|
* jQuery Mobile Framework : resolution and CSS media query related helpers and behavior
|
|
* Copyright (c) jQuery Project
|
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
* http://jquery.org/license
|
|
*/
|
|
(function( $, undefined ) {
|
|
|
|
var $window = $( window ),
|
|
$html = $( "html" );
|
|
|
|
/* $.mobile.media method: pass a CSS media type or query and get a bool return
|
|
note: this feature relies on actual media query support for media queries, though types will work most anywhere
|
|
examples:
|
|
$.mobile.media('screen') //>> tests for screen media type
|
|
$.mobile.media('screen and (min-width: 480px)') //>> tests for screen media type with window width > 480px
|
|
$.mobile.media('@media screen and (-webkit-min-device-pixel-ratio: 2)') //>> tests for webkit 2x pixel ratio (iPhone 4)
|
|
*/
|
|
$.mobile.media = (function() {
|
|
// TODO: use window.matchMedia once at least one UA implements it
|
|
var cache = {},
|
|
testDiv = $( "<div id='jquery-mediatest'>" ),
|
|
fakeBody = $( "<body>" ).append( testDiv );
|
|
|
|
return function( query ) {
|
|
if ( !( query in cache ) ) {
|
|
var styleBlock = document.createElement( "style" ),
|
|
cssrule = "@media " + query + " { #jquery-mediatest { position:absolute; } }";
|
|
|
|
//must set type for IE!
|
|
styleBlock.type = "text/css";
|
|
|
|
if ( styleBlock.styleSheet ){
|
|
styleBlock.styleSheet.cssText = cssrule;
|
|
} else {
|
|
styleBlock.appendChild( document.createTextNode(cssrule) );
|
|
}
|
|
|
|
$html.prepend( fakeBody ).prepend( styleBlock );
|
|
cache[ query ] = testDiv.css( "position" ) === "absolute";
|
|
fakeBody.add( styleBlock ).remove();
|
|
}
|
|
return cache[ query ];
|
|
};
|
|
})();
|
|
|
|
})(jQuery); |