[TemporaryStorage] add files required for SDK build
[samples/web/TemporaryStorage.git] / tizen-web-ui-fw / latest / js / src / jquery.mobile.media.js
1 (function( $, undefined ) {
2
3 var $window = $.mobile.$window,
4         $html = $( "html" );
5
6 /* $.mobile.media method: pass a CSS media type or query and get a bool return
7         note: this feature relies on actual media query support for media queries, though types will work most anywhere
8         examples:
9                 $.mobile.media('screen') // tests for screen media type
10                 $.mobile.media('screen and (min-width: 480px)') // tests for screen media type with window width > 480px
11                 $.mobile.media('@media screen and (-webkit-min-device-pixel-ratio: 2)') // tests for webkit 2x pixel ratio (iPhone 4)
12 */
13 $.mobile.media = (function() {
14         // TODO: use window.matchMedia once at least one UA implements it
15         var cache = {},
16                 testDiv = $( "<div id='jquery-mediatest'></div>" ),
17                 fakeBody = $( "<body>" ).append( testDiv );
18
19         return function( query ) {
20                 if ( !( query in cache ) ) {
21                         var styleBlock = document.createElement( "style" ),
22                                 cssrule = "@media " + query + " { #jquery-mediatest { position:absolute; } }";
23
24                         //must set type for IE!
25                         styleBlock.type = "text/css";
26
27                         if ( styleBlock.styleSheet ) {
28                                 styleBlock.styleSheet.cssText = cssrule;
29                         } else {
30                                 styleBlock.appendChild( document.createTextNode(cssrule) );
31                         }
32
33                         $html.prepend( fakeBody ).prepend( styleBlock );
34                         cache[ query ] = testDiv.css( "position" ) === "absolute";
35                         fakeBody.add( styleBlock ).remove();
36                 }
37                 return cache[ query ];
38         };
39 })();
40
41 })(jQuery);