2010-09-08 16:00:29 +00:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
jQuery.support = (function() {
|
|
|
|
|
2011-11-17 19:48:27 +00:00
|
|
|
var support,
|
2011-04-07 04:51:37 +00:00
|
|
|
all,
|
|
|
|
a,
|
|
|
|
select,
|
|
|
|
opt,
|
|
|
|
input,
|
|
|
|
fragment,
|
|
|
|
tds,
|
|
|
|
events,
|
|
|
|
eventName,
|
|
|
|
i,
|
2011-11-17 19:48:27 +00:00
|
|
|
isSupported,
|
|
|
|
div = document.createElement( "div" ),
|
|
|
|
documentElement = document.documentElement;
|
2011-04-07 04:51:37 +00:00
|
|
|
|
|
|
|
// Preliminary tests
|
2011-04-10 21:08:18 +00:00
|
|
|
div.setAttribute("className", "t");
|
2011-11-08 05:05:33 +00:00
|
|
|
div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
|
2011-09-01 15:16:38 +00:00
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
all = div.getElementsByTagName( "*" );
|
|
|
|
a = div.getElementsByTagName( "a" )[ 0 ];
|
2008-12-21 23:06:42 +00:00
|
|
|
|
|
|
|
// Can't get basic test support
|
|
|
|
if ( !all || !all.length || !a ) {
|
2011-04-07 04:51:37 +00:00
|
|
|
return {};
|
2008-12-21 23:06:42 +00:00
|
|
|
}
|
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
// First batch of supports tests
|
|
|
|
select = document.createElement( "select" );
|
|
|
|
opt = select.appendChild( document.createElement("option") );
|
|
|
|
input = div.getElementsByTagName( "input" )[ 0 ];
|
|
|
|
|
|
|
|
support = {
|
2008-12-21 23:06:42 +00:00
|
|
|
// IE strips leading whitespace when .innerHTML is used
|
2011-04-07 04:51:37 +00:00
|
|
|
leadingWhitespace: ( div.firstChild.nodeType === 3 ),
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
// Make sure that tbody elements aren't automatically inserted
|
|
|
|
// IE will insert them into empty tables
|
2011-11-17 19:48:27 +00:00
|
|
|
tbody: !div.getElementsByTagName("tbody").length,
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
// Make sure that link elements get serialized correctly by innerHTML
|
|
|
|
// This requires a wrapper element in IE
|
2011-11-17 19:48:27 +00:00
|
|
|
htmlSerialize: !!div.getElementsByTagName("link").length,
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
// Get the style information from getAttribute
|
2011-04-07 04:51:37 +00:00
|
|
|
// (IE uses .cssText instead)
|
2011-04-10 21:08:18 +00:00
|
|
|
style: /top/.test( a.getAttribute("style") ),
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
// Make sure that URLs aren't manipulated
|
|
|
|
// (IE normalizes it by default)
|
2011-11-17 19:48:27 +00:00
|
|
|
hrefNormalized: ( a.getAttribute("href") === "/a" ),
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
// Make sure that element opacity exists
|
|
|
|
// (IE uses filter instead)
|
2009-12-10 04:37:14 +00:00
|
|
|
// Use a regex to work around a WebKit issue. See #5145
|
2011-10-12 02:37:52 +00:00
|
|
|
opacity: /^0.55/.test( a.style.opacity ),
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
// Verify style float existence
|
|
|
|
// (IE uses styleFloat instead of cssFloat)
|
|
|
|
cssFloat: !!a.style.cssFloat,
|
|
|
|
|
2009-12-22 07:00:46 +00:00
|
|
|
// Make sure that if no value is specified for a checkbox
|
|
|
|
// that it defaults to "on".
|
|
|
|
// (WebKit defaults to "" instead)
|
2011-04-08 16:24:25 +00:00
|
|
|
checkOn: ( input.value === "on" ),
|
2009-12-22 07:00:46 +00:00
|
|
|
|
2009-12-22 20:46:54 +00:00
|
|
|
// Make sure that a selected-by-default option has a working selected property.
|
|
|
|
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
|
2010-09-27 14:19:55 +00:00
|
|
|
optSelected: opt.selected,
|
2011-04-13 16:35:38 +00:00
|
|
|
|
2011-03-13 19:44:51 +00:00
|
|
|
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
|
2011-03-12 02:28:42 +00:00
|
|
|
getSetAttribute: div.className !== "t",
|
2009-12-22 20:46:54 +00:00
|
|
|
|
2011-10-22 20:03:57 +00:00
|
|
|
// Tests for enctype support on a form(#6743)
|
|
|
|
enctype: !!document.createElement("form").enctype,
|
|
|
|
|
2011-11-08 05:05:33 +00:00
|
|
|
// Makes sure cloning an html5 element does not cause problems
|
|
|
|
// Where outerHTML is undefined, this still works
|
|
|
|
html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
|
|
|
|
|
2008-12-21 23:06:42 +00:00
|
|
|
// Will be defined later
|
2011-04-07 04:51:37 +00:00
|
|
|
submitBubbles: true,
|
|
|
|
changeBubbles: true,
|
2011-04-08 16:24:25 +00:00
|
|
|
focusinBubbles: false,
|
2010-10-17 14:56:01 +00:00
|
|
|
deleteExpando: true,
|
2009-01-11 16:17:20 +00:00
|
|
|
noCloneEvent: true,
|
2010-10-05 18:28:43 +00:00
|
|
|
inlineBlockNeedsLayout: false,
|
2010-10-05 19:53:35 +00:00
|
|
|
shrinkWrapBlocks: false,
|
2011-12-07 01:32:26 +00:00
|
|
|
reliableMarginRight: true,
|
|
|
|
pixelMargin: true
|
2008-12-21 23:06:42 +00:00
|
|
|
};
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
// Make sure checked status is properly cloned
|
2011-02-23 18:18:44 +00:00
|
|
|
input.checked = true;
|
2011-04-07 04:51:37 +00:00
|
|
|
support.noCloneChecked = input.cloneNode( true ).checked;
|
2011-02-23 18:18:44 +00:00
|
|
|
|
2010-09-27 14:19:55 +00:00
|
|
|
// Make sure that the options inside disabled selects aren't marked as disabled
|
2011-04-07 04:51:37 +00:00
|
|
|
// (WebKit marks them as disabled)
|
2010-09-27 14:19:55 +00:00
|
|
|
select.disabled = true;
|
2011-04-07 04:51:37 +00:00
|
|
|
support.optDisabled = !opt.disabled;
|
2008-12-21 23:06:42 +00:00
|
|
|
|
2010-10-17 14:56:01 +00:00
|
|
|
// Test to see if it's possible to delete an expando from an element
|
|
|
|
// Fails in Internet Explorer
|
|
|
|
try {
|
2011-01-17 21:31:12 +00:00
|
|
|
delete div.test;
|
2011-04-07 04:51:37 +00:00
|
|
|
} catch( e ) {
|
|
|
|
support.deleteExpando = false;
|
2010-10-17 14:56:01 +00:00
|
|
|
}
|
|
|
|
|
2011-02-07 16:56:48 +00:00
|
|
|
if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
|
2011-05-25 19:08:37 +00:00
|
|
|
div.attachEvent( "onclick", function() {
|
2008-12-21 23:06:42 +00:00
|
|
|
// Cloning a node shouldn't copy over any
|
|
|
|
// bound event handlers (IE does this)
|
2011-04-07 04:51:37 +00:00
|
|
|
support.noCloneEvent = false;
|
2011-04-08 15:41:14 +00:00
|
|
|
});
|
2011-04-07 04:51:37 +00:00
|
|
|
div.cloneNode( true ).fireEvent( "onclick" );
|
2008-12-21 23:06:42 +00:00
|
|
|
}
|
|
|
|
|
2011-09-20 15:23:01 +00:00
|
|
|
// Check if a radio maintains its value
|
2011-04-22 04:27:52 +00:00
|
|
|
// after being appended to the DOM
|
2011-04-22 01:33:09 +00:00
|
|
|
input = document.createElement("input");
|
|
|
|
input.value = "t";
|
|
|
|
input.setAttribute("type", "radio");
|
|
|
|
support.radioValue = input.value === "t";
|
|
|
|
|
2011-04-22 04:27:52 +00:00
|
|
|
input.setAttribute("checked", "checked");
|
|
|
|
div.appendChild( input );
|
2011-04-07 04:51:37 +00:00
|
|
|
fragment = document.createDocumentFragment();
|
2011-10-24 15:33:09 +00:00
|
|
|
fragment.appendChild( div.lastChild );
|
2010-01-25 23:43:33 +00:00
|
|
|
|
|
|
|
// WebKit doesn't clone checked state correctly in fragments
|
2011-04-07 04:51:37 +00:00
|
|
|
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
|
2010-01-25 23:43:33 +00:00
|
|
|
|
2011-04-22 04:27:52 +00:00
|
|
|
// Check if a disconnected checkbox will retain its checked
|
|
|
|
// value of true after appended to the DOM (IE6/7)
|
|
|
|
support.appendChecked = input.checked;
|
|
|
|
|
2011-11-17 19:48:27 +00:00
|
|
|
fragment.removeChild( input );
|
|
|
|
fragment.appendChild( div );
|
2011-04-07 04:51:37 +00:00
|
|
|
|
2009-12-04 16:28:50 +00:00
|
|
|
// Technique from Juriy Zaytsev
|
2011-10-04 15:09:12 +00:00
|
|
|
// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
|
2011-04-07 04:51:37 +00:00
|
|
|
// We only care about the case where non-standard event systems
|
|
|
|
// are used, namely in IE. Short-circuiting here helps us to
|
|
|
|
// avoid an eval call (in setAttribute) which can cause CSP
|
|
|
|
// to go haywire. See: https://developer.mozilla.org/en/Security/CSP
|
|
|
|
if ( div.attachEvent ) {
|
2012-01-20 19:17:02 +00:00
|
|
|
for ( i in {
|
2011-04-07 04:51:37 +00:00
|
|
|
submit: 1,
|
|
|
|
change: 1,
|
|
|
|
focusin: 1
|
2011-11-17 19:48:27 +00:00
|
|
|
}) {
|
2011-04-07 04:51:37 +00:00
|
|
|
eventName = "on" + i;
|
|
|
|
isSupported = ( eventName in div );
|
|
|
|
if ( !isSupported ) {
|
|
|
|
div.setAttribute( eventName, "return;" );
|
|
|
|
isSupported = ( typeof div[ eventName ] === "function" );
|
|
|
|
}
|
|
|
|
support[ i + "Bubbles" ] = isSupported;
|
2010-10-05 19:53:35 +00:00
|
|
|
}
|
2011-04-07 04:51:37 +00:00
|
|
|
}
|
2009-12-04 16:28:50 +00:00
|
|
|
|
2011-11-17 19:48:27 +00:00
|
|
|
fragment.removeChild( div );
|
2011-11-10 15:30:10 +00:00
|
|
|
|
2011-11-17 19:48:27 +00:00
|
|
|
// Null elements to avoid leaks in IE
|
2012-02-13 14:52:43 +00:00
|
|
|
fragment = select = opt = div = input = null;
|
2011-11-10 15:30:10 +00:00
|
|
|
|
2011-11-18 14:28:54 +00:00
|
|
|
// Run tests that need a body at doc ready
|
2011-10-31 13:50:21 +00:00
|
|
|
jQuery(function() {
|
2011-10-31 16:07:19 +00:00
|
|
|
var container, outer, inner, table, td, offsetSupport,
|
2012-02-13 14:52:43 +00:00
|
|
|
marginDiv, conMarginTop, ptlm, vb, style, html,
|
2011-11-18 14:28:54 +00:00
|
|
|
body = document.getElementsByTagName("body")[0];
|
|
|
|
|
2011-11-01 16:02:22 +00:00
|
|
|
if ( !body ) {
|
|
|
|
// Return for frameset docs that don't have a body
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-18 14:28:54 +00:00
|
|
|
conMarginTop = 1;
|
|
|
|
ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;";
|
|
|
|
vb = "visibility:hidden;border:0;";
|
|
|
|
style = "style='" + ptlm + "border:5px solid #000;padding:0;'";
|
|
|
|
html = "<div " + style + "><div></div></div>" +
|
|
|
|
"<table " + style + " cellpadding='0' cellspacing='0'>" +
|
|
|
|
"<tr><td></td></tr></table>";
|
|
|
|
|
2011-10-31 14:50:19 +00:00
|
|
|
container = document.createElement("div");
|
2011-11-02 18:03:08 +00:00
|
|
|
container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
|
2011-10-31 14:50:19 +00:00
|
|
|
body.insertBefore( container, body.firstChild );
|
|
|
|
|
2011-11-17 19:48:27 +00:00
|
|
|
// Construct the test element
|
|
|
|
div = document.createElement("div");
|
|
|
|
container.appendChild( div );
|
|
|
|
|
|
|
|
// Check if table cells still have offsetWidth/Height when they are set
|
|
|
|
// to display:none and there are still other visible table cells in a
|
|
|
|
// table row; if so, offsetWidth/Height are not reliable for use when
|
|
|
|
// determining if an element has been hidden directly using
|
|
|
|
// display:none (it is still safe to use offsets if a parent element is
|
|
|
|
// hidden; don safety goggles and see bug #4512 for more information).
|
|
|
|
// (only IE 8 fails this test)
|
|
|
|
div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
|
2012-01-20 19:17:02 +00:00
|
|
|
|
2011-11-17 19:48:27 +00:00
|
|
|
tds = div.getElementsByTagName( "td" );
|
|
|
|
isSupported = ( tds[ 0 ].offsetHeight === 0 );
|
|
|
|
|
|
|
|
tds[ 0 ].style.display = "";
|
|
|
|
tds[ 1 ].style.display = "none";
|
|
|
|
|
|
|
|
// Check if empty table cells still have offsetWidth/Height
|
|
|
|
// (IE <= 8 fail this test)
|
|
|
|
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
|
|
|
|
|
2012-02-13 14:52:43 +00:00
|
|
|
// Check if div with explicit width and no margin-right incorrectly
|
|
|
|
// gets computed margin-right based on width of container. For more
|
|
|
|
// info see bug #3333
|
|
|
|
// Fails in WebKit before Feb 2011 nightlies
|
|
|
|
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
|
|
|
|
if ( window.getComputedStyle ) {
|
|
|
|
div.innerHTML = "";
|
|
|
|
marginDiv = document.createElement( "div" );
|
|
|
|
marginDiv.style.width = "0";
|
|
|
|
marginDiv.style.marginRight = "0";
|
|
|
|
div.style.width = "2px";
|
|
|
|
div.appendChild( marginDiv );
|
|
|
|
support.reliableMarginRight =
|
|
|
|
( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
|
|
|
|
}
|
|
|
|
|
2011-11-17 19:48:27 +00:00
|
|
|
// Figure out if the W3C box model works as expected
|
|
|
|
div.innerHTML = "";
|
|
|
|
div.style.width = div.style.paddingLeft = "1px";
|
|
|
|
jQuery.boxModel = support.boxModel = div.offsetWidth === 2;
|
|
|
|
|
|
|
|
if ( typeof div.style.zoom !== "undefined" ) {
|
|
|
|
// Check if natively block-level elements act like inline-block
|
|
|
|
// elements when setting their display to 'inline' and giving
|
|
|
|
// them layout
|
|
|
|
// (IE < 8 does this)
|
|
|
|
div.style.display = "inline";
|
|
|
|
div.style.zoom = 1;
|
|
|
|
support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
|
|
|
|
|
|
|
|
// Check if elements with layout shrink-wrap their children
|
|
|
|
// (IE 6 does this)
|
|
|
|
div.style.display = "";
|
|
|
|
div.innerHTML = "<div style='width:4px;'></div>";
|
|
|
|
support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
|
|
|
|
}
|
|
|
|
|
|
|
|
div.style.cssText = ptlm + vb;
|
|
|
|
div.innerHTML = html;
|
2011-10-31 13:50:21 +00:00
|
|
|
|
2011-11-17 19:48:27 +00:00
|
|
|
outer = div.firstChild;
|
2011-09-20 01:03:41 +00:00
|
|
|
inner = outer.firstChild;
|
2011-10-31 16:07:19 +00:00
|
|
|
td = outer.nextSibling.firstChild.firstChild;
|
2011-09-20 01:03:41 +00:00
|
|
|
|
2011-10-31 13:50:21 +00:00
|
|
|
offsetSupport = {
|
2011-10-27 19:34:42 +00:00
|
|
|
doesNotAddBorder: ( inner.offsetTop !== 5 ),
|
|
|
|
doesAddBorderForTableAndCells: ( td.offsetTop === 5 )
|
2011-09-20 03:25:02 +00:00
|
|
|
};
|
2011-09-20 01:03:41 +00:00
|
|
|
|
|
|
|
inner.style.position = "fixed";
|
|
|
|
inner.style.top = "20px";
|
|
|
|
|
|
|
|
// safari subtracts parent border width here which is 5px
|
2011-10-31 16:33:55 +00:00
|
|
|
offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 );
|
2011-09-20 01:03:41 +00:00
|
|
|
inner.style.position = inner.style.top = "";
|
|
|
|
|
|
|
|
outer.style.overflow = "hidden";
|
|
|
|
outer.style.position = "relative";
|
|
|
|
|
2011-10-31 13:50:21 +00:00
|
|
|
offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
|
2011-10-31 14:50:19 +00:00
|
|
|
offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
|
|
|
|
|
2012-01-20 19:17:02 +00:00
|
|
|
if ( window.getComputedStyle ) {
|
2011-12-07 01:32:26 +00:00
|
|
|
div.style.marginTop = "1%";
|
|
|
|
support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%";
|
|
|
|
}
|
|
|
|
|
2011-12-26 20:22:29 +00:00
|
|
|
if ( typeof container.style.zoom !== "undefined" ) {
|
|
|
|
container.style.zoom = 1;
|
|
|
|
}
|
|
|
|
|
2011-10-31 14:50:19 +00:00
|
|
|
body.removeChild( container );
|
2012-02-13 14:52:43 +00:00
|
|
|
marginDiv = div = container = null;
|
2011-09-20 01:03:41 +00:00
|
|
|
|
2011-10-31 13:50:21 +00:00
|
|
|
jQuery.extend( support, offsetSupport );
|
|
|
|
});
|
2011-09-20 01:03:41 +00:00
|
|
|
|
2011-04-07 04:51:37 +00:00
|
|
|
return support;
|
2010-09-17 18:58:50 +00:00
|
|
|
})();
|
2011-04-07 04:51:37 +00:00
|
|
|
|
2010-09-08 16:00:29 +00:00
|
|
|
})( jQuery );
|