2011-12-16 02:09:25 +00:00
|
|
|
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
|
2012-01-07 00:28:54 +00:00
|
|
|
//>>description: Assorted support tests.
|
|
|
|
|
//>>label: Support Tests
|
2012-01-17 17:22:07 +00:00
|
|
|
//>>group: core
|
|
|
|
|
//>>required: true
|
2012-01-07 00:28:54 +00:00
|
|
|
|
2012-01-24 22:43:24 +00:00
|
|
|
define( [ "jquery", "./jquery.mobile.media" ], function( $ ) {
|
2011-12-16 02:09:25 +00:00
|
|
|
//>>excludeEnd("jqmBuildExclude");
|
|
|
|
|
(function( $, undefined ) {
|
2010-09-14 01:46:20 +00:00
|
|
|
|
2011-08-03 17:19:53 +00:00
|
|
|
var fakeBody = $( "<body>" ).prependTo( "html" ),
|
2011-05-12 00:47:37 +00:00
|
|
|
fbCSS = fakeBody[ 0 ].style,
|
2011-08-18 23:40:08 +00:00
|
|
|
vendors = [ "Webkit", "Moz", "O" ],
|
2011-06-29 13:33:19 +00:00
|
|
|
webos = "palmGetResource" in window, //only used to rule out scrollTop
|
2011-11-16 22:13:13 +00:00
|
|
|
operamini = window.operamini && ({}).toString.call( window.operamini ) === "[object OperaMini]",
|
2010-10-13 21:25:14 +00:00
|
|
|
bb = window.blackberry; //only used to rule out box shadow, as it's filled opaque on BB
|
|
|
|
|
|
2011-05-12 00:47:37 +00:00
|
|
|
// thx Modernizr
|
2011-08-03 17:19:53 +00:00
|
|
|
function propExists( prop ) {
|
2011-05-12 00:47:37 +00:00
|
|
|
var uc_prop = prop.charAt( 0 ).toUpperCase() + prop.substr( 1 ),
|
2011-08-03 17:19:53 +00:00
|
|
|
props = ( prop + " " + vendors.join( uc_prop + " " ) + uc_prop ).split( " " );
|
2011-06-29 13:33:19 +00:00
|
|
|
|
|
|
|
|
for ( var v in props ){
|
2011-08-07 17:19:20 +00:00
|
|
|
if ( fbCSS[ props[ v ] ] !== undefined ) {
|
2010-10-13 21:25:14 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-05-12 00:47:37 +00:00
|
|
|
}
|
2010-10-07 19:46:46 +00:00
|
|
|
|
2012-01-13 20:33:30 +00:00
|
|
|
function validStyle( prop, value, check_vend ) {
|
|
|
|
|
var div = document.createElement('div'),
|
|
|
|
|
uc = function( txt ) {
|
|
|
|
|
return txt.charAt( 0 ).toUpperCase() + txt.substr( 1 )
|
|
|
|
|
},
|
|
|
|
|
vend_pref = function( vend ) {
|
|
|
|
|
return "-" + vend.charAt( 0 ).toLowerCase() + vend.substr( 1 ) + "-";
|
|
|
|
|
},
|
|
|
|
|
check_style = function( vend ) {
|
|
|
|
|
var vend_prop = vend_pref( vend ) + prop + ": " + value + ";",
|
|
|
|
|
uc_vend = uc( vend ),
|
|
|
|
|
propStyle = uc_vend + uc( prop );
|
|
|
|
|
|
|
|
|
|
div.setAttribute( "style", vend_prop );
|
|
|
|
|
|
|
|
|
|
if( !!div.style[ propStyle ] ) {
|
|
|
|
|
ret = true;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
check_vends = check_vend ? [ check_vend ] : vendors,
|
|
|
|
|
ret;
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < check_vends.length; i++ ) {
|
|
|
|
|
check_style( check_vends[i] );
|
|
|
|
|
}
|
|
|
|
|
return !!ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Thanks to Modernizr src for this test idea. `perspective` check is limited to Moz to prevent a false positive for 3D transforms on Android.
|
2012-01-04 09:23:26 +00:00
|
|
|
function transform3dTest() {
|
2012-01-13 07:46:35 +00:00
|
|
|
var prop = "transform-3d";
|
2012-01-13 20:33:30 +00:00
|
|
|
return validStyle( 'perspective', '10px', 'moz' ) || $.mobile.media( "(-" + vendors.join( "-" + prop + "),(-" ) + "-" + prop + "),(" + prop + ")" );
|
2012-01-04 09:23:26 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 13:33:19 +00:00
|
|
|
// Test for dynamic-updating base tag support ( allows us to avoid href,src attr rewriting )
|
|
|
|
|
function baseTagTest() {
|
2011-05-12 00:47:37 +00:00
|
|
|
var fauxBase = location.protocol + "//" + location.host + location.pathname + "ui-dir/",
|
|
|
|
|
base = $( "head base" ),
|
2011-01-18 17:18:22 +00:00
|
|
|
fauxEle = null,
|
2011-06-29 13:33:19 +00:00
|
|
|
href = "",
|
|
|
|
|
link, rebase;
|
|
|
|
|
|
2011-05-12 00:47:37 +00:00
|
|
|
if ( !base.length ) {
|
2011-08-03 17:19:53 +00:00
|
|
|
base = fauxEle = $( "<base>", { "href": fauxBase }).appendTo( "head" );
|
2011-06-29 13:33:19 +00:00
|
|
|
} else {
|
2011-05-12 00:47:37 +00:00
|
|
|
href = base.attr( "href" );
|
2011-01-18 17:18:22 +00:00
|
|
|
}
|
2011-06-29 13:33:19 +00:00
|
|
|
|
2011-10-17 23:39:05 +00:00
|
|
|
link = $( "<a href='testurl' />" ).prependTo( fakeBody );
|
2011-06-29 13:33:19 +00:00
|
|
|
rebase = link[ 0 ].href;
|
2011-10-17 23:39:05 +00:00
|
|
|
base[ 0 ].href = href || location.pathname;
|
2011-06-29 13:33:19 +00:00
|
|
|
|
2011-05-12 00:47:37 +00:00
|
|
|
if ( fauxEle ) {
|
2011-01-18 17:18:22 +00:00
|
|
|
fauxEle.remove();
|
|
|
|
|
}
|
2011-05-12 00:47:37 +00:00
|
|
|
return rebase.indexOf( fauxBase ) === 0;
|
|
|
|
|
}
|
Added a support test $.support.dynamicBaseTag and workaround for browsers that don't support dynamically updating BASE tag (Firefox is the only one I've seen so far. In those browsers, when a new page is fetched, any elements with href and src attributes will have their attribute prefixed with a proper base url (if they don't already start with an external site http address, "/", "#", or any protocol such as "mailto:, etc).
In the process, the BASE element and related functions are only implemented if that support is true, and BASE urls now use a full URL path when set, to avoid issues with browsers that may need that.
Fixes #263, Fixes #221
2010-10-22 16:31:00 +00:00
|
|
|
|
2011-03-13 21:01:51 +00:00
|
|
|
|
2011-05-12 00:47:37 +00:00
|
|
|
// non-UA-based IE version check by James Padolsey, modified by jdalton - from http://gist.github.com/527683
|
|
|
|
|
// allows for inclusion of IE 6+, including Windows Mobile 7
|
2011-12-07 23:42:08 +00:00
|
|
|
$.extend( $.mobile, { browser: {} } );
|
2011-06-29 13:33:19 +00:00
|
|
|
$.mobile.browser.ie = (function() {
|
|
|
|
|
var v = 3,
|
|
|
|
|
div = document.createElement( "div" ),
|
2011-05-12 00:47:37 +00:00
|
|
|
a = div.all || [];
|
2011-06-29 13:33:19 +00:00
|
|
|
|
2011-12-06 23:56:16 +00:00
|
|
|
// added {} to silence closure compiler warnings. registering my dislike of all things
|
|
|
|
|
// overly clever here for future reference
|
|
|
|
|
while ( div.innerHTML = "<!--[if gt IE " + ( ++v ) + "]><br><![endif]-->", a[ 0 ] ){};
|
2011-06-29 13:33:19 +00:00
|
|
|
|
|
|
|
|
return v > 4 ? v : !v;
|
|
|
|
|
})();
|
2011-03-13 21:01:51 +00:00
|
|
|
|
2011-05-24 21:08:29 +00:00
|
|
|
|
2010-09-14 01:46:20 +00:00
|
|
|
$.extend( $.support, {
|
2011-09-27 16:05:37 +00:00
|
|
|
orientation: "orientation" in window && "onorientationchange" in window,
|
2010-09-23 14:13:20 +00:00
|
|
|
touch: "ontouchend" in document,
|
2012-01-13 20:33:30 +00:00
|
|
|
cssTransitions: "WebKitTransitionEvent" in window || validStyle( 'transition', 'height 100ms linear' ),
|
2011-08-14 17:44:40 +00:00
|
|
|
pushState: "pushState" in history && "replaceState" in history,
|
2011-12-07 23:42:08 +00:00
|
|
|
mediaquery: $.mobile.media( "only all" ),
|
2011-05-12 00:47:37 +00:00
|
|
|
cssPseudoElement: !!propExists( "content" ),
|
2011-09-07 13:24:36 +00:00
|
|
|
touchOverflow: !!propExists( "overflowScrolling" ),
|
2012-01-04 09:23:26 +00:00
|
|
|
cssTransform3d: transform3dTest(),
|
2011-05-12 00:47:37 +00:00
|
|
|
boxShadow: !!propExists( "boxShadow" ) && !bb,
|
2011-11-16 22:13:13 +00:00
|
|
|
scrollTop: ( "pageXOffset" in window || "scrollTop" in document.documentElement || "scrollTop" in fakeBody[ 0 ] ) && !webos && !operamini,
|
2011-09-20 21:26:36 +00:00
|
|
|
dynamicBaseTag: baseTagTest()
|
2011-06-29 13:33:19 +00:00
|
|
|
});
|
2010-09-14 01:46:20 +00:00
|
|
|
|
2010-10-07 19:46:46 +00:00
|
|
|
fakeBody.remove();
|
|
|
|
|
|
2011-08-02 21:11:00 +00:00
|
|
|
|
|
|
|
|
// $.mobile.ajaxBlacklist is used to override ajaxEnabled on platforms that have known conflicts with hash history updates (BB5, Symbian)
|
|
|
|
|
// or that generally work better browsing in regular http for full page refreshes (Opera Mini)
|
2011-08-03 17:19:53 +00:00
|
|
|
// Note: This detection below is used as a last resort.
|
2011-08-02 21:11:00 +00:00
|
|
|
// We recommend only using these detection methods when all other more reliable/forward-looking approaches are not possible
|
2011-08-03 15:54:44 +00:00
|
|
|
var nokiaLTE7_3 = (function(){
|
2011-08-03 17:19:53 +00:00
|
|
|
|
2011-08-02 21:11:00 +00:00
|
|
|
var ua = window.navigator.userAgent;
|
|
|
|
|
|
|
|
|
|
//The following is an attempt to match Nokia browsers that are running Symbian/s60, with webkit, version 7.3 or older
|
2011-08-03 17:19:53 +00:00
|
|
|
return ua.indexOf( "Nokia" ) > -1 &&
|
|
|
|
|
( ua.indexOf( "Symbian/3" ) > -1 || ua.indexOf( "Series60/5" ) > -1 ) &&
|
|
|
|
|
ua.indexOf( "AppleWebKit" ) > -1 &&
|
|
|
|
|
ua.match( /(BrowserNG|NokiaBrowser)\/7\.[0-3]/ );
|
2011-08-03 15:54:44 +00:00
|
|
|
})();
|
2011-08-02 21:11:00 +00:00
|
|
|
|
|
|
|
|
$.mobile.ajaxBlacklist =
|
2011-08-03 17:19:53 +00:00
|
|
|
// BlackBerry browsers, pre-webkit
|
|
|
|
|
window.blackberry && !window.WebKitPoint ||
|
|
|
|
|
// Opera Mini
|
2011-11-16 22:13:13 +00:00
|
|
|
operamini ||
|
2011-08-03 17:19:53 +00:00
|
|
|
// Symbian webkits pre 7.3
|
|
|
|
|
nokiaLTE7_3;
|
2011-08-02 21:11:00 +00:00
|
|
|
|
|
|
|
|
// Lastly, this workaround is the only way we've found so far to get pre 7.3 Symbian webkit devices
|
|
|
|
|
// to render the stylesheets when they're referenced before this script, as we'd recommend doing.
|
|
|
|
|
// This simply reappends the CSS in place, which for some reason makes it apply
|
2011-08-03 17:19:53 +00:00
|
|
|
if ( nokiaLTE7_3 ) {
|
|
|
|
|
$(function() {
|
2011-10-17 23:39:05 +00:00
|
|
|
$( "head link[rel='stylesheet']" ).attr( "rel", "alternate stylesheet" ).attr( "rel", "stylesheet" );
|
2011-08-03 17:19:53 +00:00
|
|
|
});
|
2011-08-02 21:11:00 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 13:33:19 +00:00
|
|
|
// For ruling out shadows via css
|
2011-08-03 17:19:53 +00:00
|
|
|
if ( !$.support.boxShadow ) {
|
2011-06-29 13:33:19 +00:00
|
|
|
$( "html" ).addClass( "ui-mobile-nosupport-boxshadow" );
|
|
|
|
|
}
|
2010-11-01 18:33:54 +00:00
|
|
|
|
2011-12-16 02:09:25 +00:00
|
|
|
})( jQuery );
|
|
|
|
|
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
|
2011-10-31 05:03:56 +00:00
|
|
|
});
|
2011-12-16 02:09:25 +00:00
|
|
|
//>>excludeEnd("jqmBuildExclude");
|