1 (function( $, undefined ) {
4 function propExists( prop ) {
5 var uc_prop = prop.charAt( 0 ).toUpperCase() + prop.substr( 1 ),
6 props = ( prop + " " + vendors.join( uc_prop + " " ) + uc_prop ).split( " " );
8 for ( var v in props ) {
9 if ( fbCSS[ props[ v ] ] !== undefined ) {
15 var fakeBody = $( "<body>" ).prependTo( "html" ),
16 fbCSS = fakeBody[ 0 ].style,
17 vendors = [ "Webkit", "Moz", "O" ],
18 webos = "palmGetResource" in window, //only used to rule out scrollTop
20 operamini = window.operamini && ({}).toString.call( window.operamini ) === "[object OperaMini]",
21 bb = window.blackberry && !propExists( "-webkit-transform" ); //only used to rule out box shadow, as it's filled opaque on BB 5 and lower
24 function validStyle( prop, value, check_vend ) {
25 var div = document.createElement( 'div' ),
26 uc = function( txt ) {
27 return txt.charAt( 0 ).toUpperCase() + txt.substr( 1 );
29 vend_pref = function( vend ) {
30 return "-" + vend.charAt( 0 ).toLowerCase() + vend.substr( 1 ) + "-";
32 check_style = function( vend ) {
33 var vend_prop = vend_pref( vend ) + prop + ": " + value + ";",
35 propStyle = uc_vend + uc( prop );
37 div.setAttribute( "style", vend_prop );
39 if ( !!div.style[ propStyle ] ) {
43 check_vends = check_vend ? [ check_vend ] : vendors,
46 for( var i = 0; i < check_vends.length; i++ ) {
47 check_style( check_vends[i] );
52 // Thanks to Modernizr src for this test idea. `perspective` check is limited to Moz to prevent a false positive for 3D transforms on Android.
53 function transform3dTest() {
54 var prop = "transform-3d";
55 return validStyle( 'perspective', '10px', 'moz' ) || $.mobile.media( "(-" + vendors.join( "-" + prop + "),(-" ) + "-" + prop + "),(" + prop + ")" );
58 // Test for dynamic-updating base tag support ( allows us to avoid href,src attr rewriting )
59 function baseTagTest() {
60 var fauxBase = location.protocol + "//" + location.host + location.pathname + "ui-dir/",
61 base = $( "head base" ),
67 base = fauxEle = $( "<base>", { "href": fauxBase }).appendTo( "head" );
69 href = base.attr( "href" );
72 link = $( "<a href='testurl' />" ).prependTo( fakeBody );
73 rebase = link[ 0 ].href;
74 base[ 0 ].href = href || location.pathname;
79 return rebase.indexOf( fauxBase ) === 0;
83 function cssPointerEventsTest() {
84 var element = document.createElement( 'x' ),
85 documentElement = document.documentElement,
86 getComputedStyle = window.getComputedStyle,
89 if ( !( 'pointerEvents' in element.style ) ) {
93 element.style.pointerEvents = 'auto';
94 element.style.pointerEvents = 'x';
95 documentElement.appendChild( element );
96 supports = getComputedStyle &&
97 getComputedStyle( element, '' ).pointerEvents === 'auto';
98 documentElement.removeChild( element );
102 function boundingRect() {
103 var div = document.createElement( "div" );
104 return typeof div.getBoundingClientRect !== "undefined";
107 // non-UA-based IE version check by James Padolsey, modified by jdalton - from http://gist.github.com/527683
108 // allows for inclusion of IE 6+, including Windows Mobile 7
109 $.extend( $.mobile, { browser: {} } );
110 $.mobile.browser.ie = (function() {
112 div = document.createElement( "div" ),
116 div.innerHTML = "<!--[if gt IE " + ( ++v ) + "]><br><![endif]-->";
119 return v > 4 ? v : !v;
123 $.extend( $.support, {
124 cssTransitions: "WebKitTransitionEvent" in window || validStyle( 'transition', 'height 100ms linear' ) && !opera,
125 pushState: "pushState" in history && "replaceState" in history,
126 mediaquery: $.mobile.media( "only all" ),
127 cssPseudoElement: !!propExists( "content" ),
128 touchOverflow: !!propExists( "overflowScrolling" ),
129 cssTransform3d: transform3dTest(),
130 boxShadow: !!propExists( "boxShadow" ) && !bb,
131 scrollTop: ( "pageXOffset" in window || "scrollTop" in document.documentElement || "scrollTop" in fakeBody[ 0 ] ) && !webos && !operamini,
132 dynamicBaseTag: baseTagTest(),
133 cssPointerEvents: cssPointerEventsTest(),
134 boundingRect: boundingRect()
140 // $.mobile.ajaxBlacklist is used to override ajaxEnabled on platforms that have known conflicts with hash history updates (BB5, Symbian)
141 // or that generally work better browsing in regular http for full page refreshes (Opera Mini)
142 // Note: This detection below is used as a last resort.
143 // We recommend only using these detection methods when all other more reliable/forward-looking approaches are not possible
144 var nokiaLTE7_3 = (function() {
146 var ua = window.navigator.userAgent;
148 //The following is an attempt to match Nokia browsers that are running Symbian/s60, with webkit, version 7.3 or older
149 return ua.indexOf( "Nokia" ) > -1 &&
150 ( ua.indexOf( "Symbian/3" ) > -1 || ua.indexOf( "Series60/5" ) > -1 ) &&
151 ua.indexOf( "AppleWebKit" ) > -1 &&
152 ua.match( /(BrowserNG|NokiaBrowser)\/7\.[0-3]/ );
155 // Support conditions that must be met in order to proceed
156 // default enhanced qualifications are media query support OR IE 7+
158 $.mobile.gradeA = function() {
159 return ( $.support.mediaquery || $.mobile.browser.ie && $.mobile.browser.ie >= 7 ) && ( $.support.boundingRect || $.fn.jquery.match(/1\.[0-7+]\.[0-9+]?/) !== null );
162 $.mobile.ajaxBlacklist =
163 // BlackBerry browsers, pre-webkit
164 window.blackberry && !window.WebKitPoint ||
167 // Symbian webkits pre 7.3
170 // Lastly, this workaround is the only way we've found so far to get pre 7.3 Symbian webkit devices
171 // to render the stylesheets when they're referenced before this script, as we'd recommend doing.
172 // This simply reappends the CSS in place, which for some reason makes it apply
175 $( "head link[rel='stylesheet']" ).attr( "rel", "alternate stylesheet" ).attr( "rel", "stylesheet" );
179 // For ruling out shadows via css
180 if ( !$.support.boxShadow ) {
181 $( "html" ).addClass( "ui-mobile-nosupport-boxshadow" );